8#ifndef MODELVIEWER_MATERIAL_HPP
9#define MODELVIEWER_MATERIAL_HPP
124 std::unordered_map<std::
string, QColor>
_colors;
127 std::unordered_map<std::
string, QUrl>
_maps;
130 std::unordered_map<std::
string, std::function<
void(const std::
string &,
131 const std::
string &)>>
148 void parseMTL(const std::
string &filepath);
270 void parseScalar(
const std::string &line,
const std::string &key);
277 void parseColor(
const std::string &line,
const std::string &key);
284 void parseMap(
const std::string &line,
const std::string &key);
Class representing a material parsed from an MTL file.
Definition Material.hpp:29
QColor _Kd
Diffuse Color.
Definition Material.hpp:58
qreal _d
Opacity.
Definition Material.hpp:73
QUrl _ambientMap
Path to the Ambient Map.
Definition Material.hpp:94
QUrl _specularMap
Path to the Specular Map.
Definition Material.hpp:103
QUrl _dispersionMap
Path to the Dispersion Map.
Definition Material.hpp:118
qreal _bumpStrength
Bump/Normal Strength.
Definition Material.hpp:91
std::unordered_map< std::string, std::function< void(const std::string &, const std::string &)> > _parseFunctions
Map of parsing functions for different MTL line prefixes.
Definition Material.hpp:132
const QUrl & getDispersionMap() const
Get the Dispersion Map URL.
Definition Material.hpp:207
std::unordered_map< std::string, QUrl > _maps
Maps to store parsed texture maps before applying them.
Definition Material.hpp:127
const QUrl & getAmbientMap() const
Get the Ambient Map URL.
Definition Material.hpp:157
qreal illumination
Definition Material.hpp:34
void dChanged()
Signal emitted when the opacity changes.
const QUrl & getBumpMap() const
Get the Bump/Normal Map URL.
Definition Material.hpp:195
QUrl _decalMap
Path to the Decal Map.
Definition Material.hpp:115
const QUrl & getDiffuseMap() const
Get the Diffuse Map URL.
Definition Material.hpp:163
const QUrl & getDissolveMap() const
Get the Dissolve Map URL.
Definition Material.hpp:189
QUrl dissolveMap
Definition Material.hpp:47
void NsChanged()
Signal emitted when the specular roughness changes.
QUrl diffuseMap
Definition Material.hpp:42
qreal indexOfRefraction
Definition Material.hpp:40
qreal bumpStrength
Definition Material.hpp:38
qreal _sharpness
Sharpness.
Definition Material.hpp:79
qreal roughness
Definition Material.hpp:36
void KdChanged()
Signal emitted when the diffuse color changes.
QUrl specularReflectionMap
Definition Material.hpp:44
void metalnessChanged()
Signal emitted when the metalness changes.
qreal opacity
Definition Material.hpp:39
QColor _Ke
Emissive Color.
Definition Material.hpp:64
void bumpStrengthChanged()
Signal emitted when the bump strength changes.
std::unordered_map< std::string, qreal > _scalars
Maps to store parsed values before applying them.
Definition Material.hpp:121
void dissolveMapChanged()
Signal emitted when the dissolve map changes.
QUrl _emissiveMap
Path to the Emissive Map.
Definition Material.hpp:106
const QUrl & getEmissiveMap() const
Get the Emissive Map URL.
Definition Material.hpp:183
void parseMaterial(std::ifstream &file)
Parse the MTL file line by line.
Definition Material.cpp:63
QUrl _specularReflectionMap
Path to the Specular Reflection Map.
Definition Material.hpp:100
QUrl emissiveMap
Definition Material.hpp:46
QUrl _bumpMap
Path to the Bump/Normal Map.
Definition Material.hpp:112
QUrl _dissolveMap
Path to the Dissolve Map.
Definition Material.hpp:109
void parseMap(const std::string &line, const std::string &key)
Parse a texture map from an MTL line.
Definition Material.cpp:133
QColor _Tf
Transmission Filter.
Definition Material.hpp:67
std::filesystem::path _parentPath
Parent path of the MTL file.
Definition Material.hpp:52
std::unordered_map< std::string, QColor > _colors
Maps to store parsed colors before applying them.
Definition Material.hpp:124
qreal _illumination
Illumination Model.
Definition Material.hpp:70
qreal _roughness
Roughness.
Definition Material.hpp:88
QColor _Ks
Specular Color.
Definition Material.hpp:61
void diffuseMapChanged()
Signal emitted when the diffuse map changes.
void emissiveMapChanged()
Signal emitted when the emissive map changes.
void specularReflectionMapChanged()
Signal emitted when the specular reflection map changes.
void parseMTL(const std::string &filepath)
Parse an MTL file and set the material properties.
Definition Material.cpp:51
void specularMapChanged()
Signal emitted when the specular map changes.
const QUrl & getSpecularMap() const
Get the Specular Map URL.
Definition Material.hpp:177
void parseColor(const std::string &line, const std::string &key)
Parse a color value from an MTL line.
Definition Material.cpp:122
void parseScalar(const std::string &line, const std::string &key)
Parse a scalar value from an MTL line.
Definition Material.cpp:112
const QUrl & getDecalMap() const
Get the Decal Map URL.
Definition Material.hpp:201
void bumpMapChanged()
Signal emitted when the bump map changes.
const QUrl & getSpecularReflectionMap() const
Get the Specular Reflection Map URL.
Definition Material.hpp:169
QUrl _diffuseMap
Path to the Diffuse Map.
Definition Material.hpp:97
void NiChanged()
Signal emitted when the index of refraction changes.
QUrl bumpMap
Definition Material.hpp:48
void setMaterialValues()
Apply parsed values to the material properties.
Definition Material.cpp:84
qreal _Ni
Index of Refraction.
Definition Material.hpp:82
QColor diffuseColor
Definition Material.hpp:32
QColor _Ka
Ambient Color.
Definition Material.hpp:55
qreal _Ns
Specular Roughness.
Definition Material.hpp:76
void roughnessChanged()
Signal emitted when the roughness changes.
void resetMaterial()
Reset the material to default values.
Definition Material.cpp:74
qreal _metalness
Metalness.
Definition Material.hpp:85
qreal metalness
Definition Material.hpp:35
void sharpnessChanged()
Signal emitted when the sharpness changes.
void illuminationChanged()
Signal emitted when the illumination model changes.
QUrl specularMap
Definition Material.hpp:45
Definition Material.cpp:10