7 #include "imstkRenderMaterial.h" 8 #include "imstkLogger.h" 12 RenderMaterial::RenderMaterial()
15 for (
int i = 0; i < static_cast<int>(Texture::Type::None); i++)
17 m_textures.emplace_back(std::make_shared<Texture>(
"", static_cast<Texture::Type>(i)));
22 RenderMaterial::setDisplayMode(
const DisplayMode displayMode)
24 if (displayMode != m_displayMode)
26 m_displayMode = displayMode;
32 RenderMaterial::setLineWidth(
const double width)
42 RenderMaterial::setPointSize(
const double size)
44 if (size != m_pointSize)
52 RenderMaterial::setBackFaceCulling(
const bool culling)
62 RenderMaterial::backfaceCullingOn()
64 this->setBackFaceCulling(
true);
68 RenderMaterial::backfaceCullingOff()
70 this->setBackFaceCulling(
false);
74 RenderMaterial::setDiffuseColor(
const Color& color)
76 if (m_diffuseColor != color)
78 m_diffuseColor = color;
84 RenderMaterial::setColor(
const Color& color)
86 this->setDiffuseColor(color);
90 RenderMaterial::setSpecularColor(
const Color& color)
92 if (m_specularColor != color)
94 m_specularColor = color;
100 RenderMaterial::setAmbientColor(
const Color& color)
102 if (m_ambientColor != color)
104 m_ambientColor = color;
110 RenderMaterial::setMetalness(
const double metalness)
120 RenderMaterial::setRoughness(
const double roughness)
130 RenderMaterial::setEmissivity(
const double emissivity)
140 RenderMaterial::setAnisotropy(
const double anisotropy)
150 RenderMaterial::setAnisotropyRotation(
const double anisotropyRotation)
152 if (m_anisotropyRotation != anisotropyRotation)
154 m_anisotropyRotation = anisotropyRotation;
160 RenderMaterial::setBaseIOR(
const double baseIOR)
162 if (m_baseIOR != baseIOR)
170 RenderMaterial::setCoatColor(
const Color& coatColor)
172 if (m_coatColor != coatColor)
174 m_coatColor = coatColor;
180 RenderMaterial::setCoatIOR(
const double coatIOR)
182 if (m_coatIOR != coatIOR)
190 RenderMaterial::setCoatNormalScale(
const double coatNormalScale)
192 if (m_coatNormalScale != coatNormalScale)
194 m_coatNormalScale = coatNormalScale;
200 RenderMaterial::setCoatRoughness(
const double coatRoughness)
202 if (m_coatRoughness != coatRoughness)
204 m_coatRoughness = coatRoughness;
210 RenderMaterial::setCoatStrength(
const double coatStrength)
212 if (m_coatStrength != coatStrength)
214 m_coatStrength = coatStrength;
220 RenderMaterial::setEdgeTint(
const Color& edgeTint)
222 if (m_edgeTint != edgeTint)
224 m_edgeTint = edgeTint;
229 std::shared_ptr<Texture>
232 if (type >= Texture::Type::None)
234 LOG(WARNING) <<
"error: Invalid texture format";
243 if (texture->getType() >= Texture::Type::None)
245 LOG(WARNING) <<
"Invalid texture format";
248 m_textures[
static_cast<size_t>(texture->getType())] = texture;
253 RenderMaterial::removeTexture(std::shared_ptr<Texture> texture)
259 const size_t type =
static_cast<size_t>(texture->getType());
269 const size_t typeInt =
static_cast<size_t>(type);
270 std::shared_ptr<Texture> prevTex =
m_textures[typeInt];
271 if (prevTex->getPath() !=
"")
273 m_textures[typeInt] = std::make_shared<Texture>(
"", type);
289 RenderMaterial::setShadingModel(
const ShadingModel& model)
291 if (model != m_shadingModel)
293 m_shadingModel = model;
299 RenderMaterial::setOcclusionStrength(
const double occlusionStrength)
301 if (occlusionStrength != m_occlusionStrength)
303 m_occlusionStrength = occlusionStrength;
309 RenderMaterial::setNormalStrength(
const double normalStrength)
311 if (normalStrength != m_normalStrength)
313 m_normalStrength = normalStrength;
319 RenderMaterial::setEdgeColor(
const Color& color)
321 if (color != m_edgeColor)
329 RenderMaterial::setVertexColor(
const Color& color)
331 if (color != m_vertexColor)
333 m_vertexColor = color;
339 RenderMaterial::setOpacity(
const double opacity)
341 if (m_opacity != opacity)
349 RenderMaterial::setBackfaceCulling(
const bool culling)
359 RenderMaterial::setColorLookupTable(std::shared_ptr<ColorFunction> lut)
361 if (m_lookupTable != lut)
369 RenderMaterial::setScalarVisibility(
const bool scalarVisibility)
371 if (m_scalarVisibility != scalarVisibility)
373 m_scalarVisibility = scalarVisibility;
void addTexture(std::shared_ptr< Texture > texture)
Add/Remove/Get texture.
Base class for events which contain a type, priority, and data priority defaults to 0 and uses a grea...
Type
Texture type - determines filtering.
ShadingModel
surface shading model. Defaults to Phong
double m_emissivity
-------------—PBR specific properties----------------—
DisplayMode
Display mode for the scene objects.
BlendMode
Volume rendering blend mode.
double m_roughness
Value for roughness with range: [0.0, 1.0].
BlendMode m_blendMode
-----------—Volume rendering properties-------------—
virtual void setBlendMode(const BlendMode blendMode)
Get/Set blend mode This function only works for volumes, particles and decals currently and the MAXIM...
double m_anisotropy
-------------—PBR Clearcoat properties----------------—
void postEvent(const T &e)
Emits the event Direct observers will be immediately called, in sync Queued observers will receive th...
double m_metalness
Value for metalness with range: [0.0, 1.0].
bool m_backfaceCulling
For performance, uncommon for this to be false.
std::vector< std::shared_ptr< Texture > > m_textures
Ordered by Texture::Type.
double m_lineWidth
----------—Wireframe specific properties-------------—