KiCad PCB EDA Suite
CMATERIAL Class Referenceabstract

A base material class that can be used to derive a material implementation. More...

#include <cmaterial.h>

Inheritance diagram for CMATERIAL:
CBLINN_PHONG_MATERIAL

Public Member Functions

 CMATERIAL ()
 
 CMATERIAL (const SFVEC3F &aAmbient, const SFVEC3F &aEmissive, const SFVEC3F &aSpecular, float aShinness, float aTransparency, float aReflection)
 
virtual ~CMATERIAL ()
 
const SFVEC3FGetAmbientColor () const
 
const SFVEC3FGetEmissiveColor () const
 
const SFVEC3FGetSpecularColor () const
 
float GetShinness () const
 
float GetTransparency () const
 
float GetReflection () const
 
float GetAbsorvance () const
 
unsigned int GetNrRefractionsSamples () const
 
unsigned int GetNrReflectionsSamples () const
 
void SetAbsorvance (float aAbsorvanceFactor)
 
void SetNrRefractionsSamples (unsigned int aNrRefractions)
 
void SetNrReflectionsSamples (unsigned int aNrReflections)
 
void SetCastShadows (bool aCastShadows)
 SetCastShadows - Set if the material can receive shadows. More...
 
bool GetCastShadows () const
 
virtual SFVEC3F Shade (const RAY &aRay, const HITINFO &aHitInfo, float NdotL, const SFVEC3F &aDiffuseObjColor, const SFVEC3F &aDirToLight, const SFVEC3F &aLightColor, float aShadowAttenuationFactor) const =0
 Shade - Shades an intersection point. More...
 
void SetNormalPerturbator (const CPROCEDURALGENERATOR *aPerturbator)
 
const CPROCEDURALGENERATORGetNormalPerturbator () const
 
void PerturbeNormal (SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
 

Protected Attributes

SFVEC3F m_ambientColor
 
SFVEC3F m_emissiveColor
 
SFVEC3F m_specularColor
 
float m_shinness
 
float m_transparency
 1.0 is completely transparent, 0.0 completely opaque More...
 
float m_absorbance
 absorvance factor for the transparent material More...
 
float m_reflection
 1.0 completely reflective, 0.0 no reflective More...
 
bool m_cast_shadows
 true if this object will block the light More...
 
unsigned int m_refraction_nr_samples
 nr of rays that will be interpolated for this material if it is a transparent More...
 
unsigned int m_reflections_nr_samples
 nr of rays that will be interpolated for this material if it is reflective More...
 
const CPROCEDURALGENERATORm_normal_perturbator
 

Detailed Description

A base material class that can be used to derive a material implementation.

Definition at line 195 of file cmaterial.h.

Constructor & Destructor Documentation

◆ CMATERIAL() [1/2]

CMATERIAL::CMATERIAL ( )

Definition at line 39 of file cmaterial.cpp.

40 {
41  m_ambientColor = SFVEC3F( 0.2f, 0.2f, 0.2f );
42  m_emissiveColor = SFVEC3F( 0.0f, 0.0f, 0.0f );
43  m_specularColor = SFVEC3F( 1.0f, 1.0f, 1.0f );
44  m_shinness = 50.2f;
45  m_transparency = 0.0f; // completely opaque
46  m_cast_shadows = true;
47  m_reflection = 0.0f;
48  m_absorbance = 1.0f;
51 
53 }
float m_reflection
1.0 completely reflective, 0.0 no reflective
Definition: cmaterial.h:267
float m_transparency
1.0 is completely transparent, 0.0 completely opaque
Definition: cmaterial.h:265
SFVEC3F m_ambientColor
Definition: cmaterial.h:256
unsigned int m_reflections_nr_samples
nr of rays that will be interpolated for this material if it is reflective
Definition: cmaterial.h:270
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:272
float m_shinness
Definition: cmaterial.h:264
#define NULL
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:268
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F m_emissiveColor
Definition: cmaterial.h:262
SFVEC3F m_specularColor
Definition: cmaterial.h:263
unsigned int m_refraction_nr_samples
nr of rays that will be interpolated for this material if it is a transparent
Definition: cmaterial.h:269
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:266

References m_absorbance, m_ambientColor, m_cast_shadows, m_emissiveColor, m_normal_perturbator, m_reflection, m_reflections_nr_samples, m_refraction_nr_samples, m_shinness, m_specularColor, m_transparency, and NULL.

◆ CMATERIAL() [2/2]

CMATERIAL::CMATERIAL ( const SFVEC3F aAmbient,
const SFVEC3F aEmissive,
const SFVEC3F aSpecular,
float  aShinness,
float  aTransparency,
float  aReflection 
)

Definition at line 56 of file cmaterial.cpp.

62 {
63  wxASSERT( aReflection >= 0.0f );
64  wxASSERT( aReflection <= 1.0f );
65 
66  wxASSERT( aTransparency >= 0.0f );
67  wxASSERT( aTransparency <= 1.0f );
68 
69  wxASSERT( aShinness >= 0.0f );
70  wxASSERT( aShinness <= 180.0f );
71 
73 
74  m_emissiveColor = aEmissive;
75  m_specularColor = aSpecular;
76  m_shinness = aShinness;
77  m_transparency = glm::clamp( aTransparency, 0.0f, 1.0f );
78  m_absorbance = 1.0f;
79  m_reflection = aReflection;
80  m_cast_shadows = true;
83 
85 }
float m_reflection
1.0 completely reflective, 0.0 no reflective
Definition: cmaterial.h:267
float m_transparency
1.0 is completely transparent, 0.0 completely opaque
Definition: cmaterial.h:265
SFVEC3F m_ambientColor
Definition: cmaterial.h:256
unsigned int m_reflections_nr_samples
nr of rays that will be interpolated for this material if it is reflective
Definition: cmaterial.h:270
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:272
float m_shinness
Definition: cmaterial.h:264
#define NULL
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:268
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
#define AMBIENT_FACTOR
Definition: cmaterial.cpp:36
SFVEC3F m_emissiveColor
Definition: cmaterial.h:262
SFVEC3F m_specularColor
Definition: cmaterial.h:263
unsigned int m_refraction_nr_samples
nr of rays that will be interpolated for this material if it is a transparent
Definition: cmaterial.h:269
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:266

References AMBIENT_FACTOR, m_absorbance, m_ambientColor, m_cast_shadows, m_emissiveColor, m_normal_perturbator, m_reflection, m_reflections_nr_samples, m_refraction_nr_samples, m_shinness, m_specularColor, m_transparency, and NULL.

◆ ~CMATERIAL()

virtual CMATERIAL::~CMATERIAL ( )
inlinevirtual

Definition at line 206 of file cmaterial.h.

206 {}

Member Function Documentation

◆ GetAbsorvance()

float CMATERIAL::GetAbsorvance ( ) const
inline

Definition at line 215 of file cmaterial.h.

215 { return m_absorbance; }
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:266

References m_absorbance.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetAmbientColor()

const SFVEC3F& CMATERIAL::GetAmbientColor ( ) const
inline

Definition at line 208 of file cmaterial.h.

208 { return m_ambientColor; }
SFVEC3F m_ambientColor
Definition: cmaterial.h:256

References m_ambientColor.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetCastShadows()

bool CMATERIAL::GetCastShadows ( ) const
inline

Definition at line 229 of file cmaterial.h.

229 { return m_cast_shadows; }
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:268

References m_cast_shadows.

Referenced by CBVH_PBRT::IntersectP().

◆ GetEmissiveColor()

const SFVEC3F& CMATERIAL::GetEmissiveColor ( ) const
inline

Definition at line 209 of file cmaterial.h.

209 { return m_emissiveColor; }
SFVEC3F m_emissiveColor
Definition: cmaterial.h:262

References m_emissiveColor.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetNormalPerturbator()

const CPROCEDURALGENERATOR* CMATERIAL::GetNormalPerturbator ( ) const
inline

Definition at line 251 of file cmaterial.h.

251 { return m_normal_perturbator; }
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:272

References m_normal_perturbator.

◆ GetNrReflectionsSamples()

unsigned int CMATERIAL::GetNrReflectionsSamples ( ) const
inline

Definition at line 217 of file cmaterial.h.

217 { return m_reflections_nr_samples; }
unsigned int m_reflections_nr_samples
nr of rays that will be interpolated for this material if it is reflective
Definition: cmaterial.h:270

References m_reflections_nr_samples.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetNrRefractionsSamples()

unsigned int CMATERIAL::GetNrRefractionsSamples ( ) const
inline

Definition at line 216 of file cmaterial.h.

216 { return m_refraction_nr_samples; }
unsigned int m_refraction_nr_samples
nr of rays that will be interpolated for this material if it is a transparent
Definition: cmaterial.h:269

References m_refraction_nr_samples.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetReflection()

float CMATERIAL::GetReflection ( ) const
inline

Definition at line 214 of file cmaterial.h.

214 { return m_reflection; }
float m_reflection
1.0 completely reflective, 0.0 no reflective
Definition: cmaterial.h:267

References m_reflection.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetShinness()

float CMATERIAL::GetShinness ( ) const
inline

Definition at line 212 of file cmaterial.h.

212 { return m_shinness; }
float m_shinness
Definition: cmaterial.h:264

References m_shinness.

◆ GetSpecularColor()

const SFVEC3F& CMATERIAL::GetSpecularColor ( ) const
inline

Definition at line 210 of file cmaterial.h.

210 { return m_specularColor; }
SFVEC3F m_specularColor
Definition: cmaterial.h:263

References m_specularColor.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetTransparency()

float CMATERIAL::GetTransparency ( ) const
inline

Definition at line 213 of file cmaterial.h.

213 { return m_transparency; }
float m_transparency
1.0 is completely transparent, 0.0 completely opaque
Definition: cmaterial.h:265

References m_transparency.

Referenced by C3D_RENDER_RAYTRACING::add_3D_models(), and COBJECT::SetMaterial().

◆ PerturbeNormal()

void CMATERIAL::PerturbeNormal ( SFVEC3F aNormal,
const RAY aRay,
const HITINFO aHitInfo 
) const

Definition at line 88 of file cmaterial.cpp.

91 {
93  {
94  aNormal = aNormal + m_normal_perturbator->Generate( aRay, aHitInfo );
95  aNormal = glm::normalize( aNormal );
96  }
97 }
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:272
virtual SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const =0
Generate - Generates a 3D vector based on the ray and hit information depending on the implementation...

References CPROCEDURALGENERATOR::Generate(), and m_normal_perturbator.

Referenced by CDUMMYBLOCK::Intersect(), CLAYERITEM::Intersect(), CROUNDSEG::Intersect(), CVCYLINDER::Intersect(), CXYPLANE::Intersect(), and CTRIANGLE::Intersect().

◆ SetAbsorvance()

void CMATERIAL::SetAbsorvance ( float  aAbsorvanceFactor)
inline

Definition at line 219 of file cmaterial.h.

219 { m_absorbance = aAbsorvanceFactor; }
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:266

References m_absorbance.

◆ SetCastShadows()

void CMATERIAL::SetCastShadows ( bool  aCastShadows)
inline

SetCastShadows - Set if the material can receive shadows.

Parameters
aCastShadows- true yes it can, false not it cannot

Definition at line 227 of file cmaterial.h.

227 { m_cast_shadows = aCastShadows; }
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:268

References m_cast_shadows.

◆ SetNormalPerturbator()

void CMATERIAL::SetNormalPerturbator ( const CPROCEDURALGENERATOR aPerturbator)
inline

Definition at line 250 of file cmaterial.h.

250 { m_normal_perturbator = aPerturbator; }
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:272

References m_normal_perturbator.

Referenced by C3D_RENDER_RAYTRACING::add_3D_models().

◆ SetNrReflectionsSamples()

void CMATERIAL::SetNrReflectionsSamples ( unsigned int  aNrReflections)
inline

Definition at line 221 of file cmaterial.h.

221 { m_reflections_nr_samples = aNrReflections; }
unsigned int m_reflections_nr_samples
nr of rays that will be interpolated for this material if it is reflective
Definition: cmaterial.h:270

References m_reflections_nr_samples.

◆ SetNrRefractionsSamples()

void CMATERIAL::SetNrRefractionsSamples ( unsigned int  aNrRefractions)
inline

Definition at line 220 of file cmaterial.h.

220 { m_refraction_nr_samples = aNrRefractions; }
unsigned int m_refraction_nr_samples
nr of rays that will be interpolated for this material if it is a transparent
Definition: cmaterial.h:269

References m_refraction_nr_samples.

◆ Shade()

virtual SFVEC3F CMATERIAL::Shade ( const RAY aRay,
const HITINFO aHitInfo,
float  NdotL,
const SFVEC3F aDiffuseObjColor,
const SFVEC3F aDirToLight,
const SFVEC3F aLightColor,
float  aShadowAttenuationFactor 
) const
pure virtual

Shade - Shades an intersection point.

Parameters
aRaythe camera ray that hits the object
aHitInfothe hit information
NdotLthe dot product between Normal and Light
aDiffuseObjColordiffuse object color
aDirToLighta vector of the incident light direction
aLightColorthe light color
aShadowAttenuationFactor0.0f total in shadow, 1.0f completely not in shadow
Returns
the resultant color

Implemented in CBLINN_PHONG_MATERIAL.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

Member Data Documentation

◆ m_absorbance

float CMATERIAL::m_absorbance
protected

absorvance factor for the transparent material

Definition at line 266 of file cmaterial.h.

Referenced by CMATERIAL(), GetAbsorvance(), and SetAbsorvance().

◆ m_ambientColor

SFVEC3F CMATERIAL::m_ambientColor
protected

Definition at line 256 of file cmaterial.h.

Referenced by CMATERIAL(), GetAmbientColor(), and CBLINN_PHONG_MATERIAL::Shade().

◆ m_cast_shadows

bool CMATERIAL::m_cast_shadows
protected

true if this object will block the light

Definition at line 268 of file cmaterial.h.

Referenced by CMATERIAL(), GetCastShadows(), and SetCastShadows().

◆ m_emissiveColor

SFVEC3F CMATERIAL::m_emissiveColor
protected

Definition at line 262 of file cmaterial.h.

Referenced by CMATERIAL(), and GetEmissiveColor().

◆ m_normal_perturbator

const CPROCEDURALGENERATOR* CMATERIAL::m_normal_perturbator
protected

Definition at line 272 of file cmaterial.h.

Referenced by CMATERIAL(), GetNormalPerturbator(), PerturbeNormal(), and SetNormalPerturbator().

◆ m_reflection

float CMATERIAL::m_reflection
protected

1.0 completely reflective, 0.0 no reflective

Definition at line 267 of file cmaterial.h.

Referenced by CMATERIAL(), and GetReflection().

◆ m_reflections_nr_samples

unsigned int CMATERIAL::m_reflections_nr_samples
protected

nr of rays that will be interpolated for this material if it is reflective

Definition at line 270 of file cmaterial.h.

Referenced by CMATERIAL(), GetNrReflectionsSamples(), and SetNrReflectionsSamples().

◆ m_refraction_nr_samples

unsigned int CMATERIAL::m_refraction_nr_samples
protected

nr of rays that will be interpolated for this material if it is a transparent

Definition at line 269 of file cmaterial.h.

Referenced by CMATERIAL(), GetNrRefractionsSamples(), and SetNrRefractionsSamples().

◆ m_shinness

float CMATERIAL::m_shinness
protected

Definition at line 264 of file cmaterial.h.

Referenced by CMATERIAL(), GetShinness(), and CBLINN_PHONG_MATERIAL::Shade().

◆ m_specularColor

SFVEC3F CMATERIAL::m_specularColor
protected

Definition at line 263 of file cmaterial.h.

Referenced by CMATERIAL(), GetSpecularColor(), and CBLINN_PHONG_MATERIAL::Shade().

◆ m_transparency

float CMATERIAL::m_transparency
protected

1.0 is completely transparent, 0.0 completely opaque

Definition at line 265 of file cmaterial.h.

Referenced by CMATERIAL(), and GetTransparency().


The documentation for this class was generated from the following files: