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)
 
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 167 of file cmaterial.h.

Constructor & Destructor Documentation

CMATERIAL::CMATERIAL ( )

Definition at line 39 of file cmaterial.cpp.

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, and m_transparency.

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 
52  m_normal_perturbator = NULL;
53 }
float m_reflection
1.0 completely reflective, 0.0 no reflective
Definition: cmaterial.h:237
float m_transparency
1.0 is completely transparent, 0.0 completely opaque
Definition: cmaterial.h:235
SFVEC3F m_ambientColor
Definition: cmaterial.h:226
unsigned int m_reflections_nr_samples
nr of rays that will be interpolated for this material if it is reflective
Definition: cmaterial.h:240
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:242
float m_shinness
Definition: cmaterial.h:234
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:238
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F m_emissiveColor
Definition: cmaterial.h:232
SFVEC3F m_specularColor
Definition: cmaterial.h:233
unsigned int m_refraction_nr_samples
nr of rays that will be interpolated for this material if it is a transparent
Definition: cmaterial.h:239
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:236
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.

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, and m_transparency.

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 = aTransparency;
78  m_absorbance = 1.0f;
79  m_reflection = aReflection;
80  m_cast_shadows = true;
83 
84  m_normal_perturbator = NULL;
85 }
float m_reflection
1.0 completely reflective, 0.0 no reflective
Definition: cmaterial.h:237
float m_transparency
1.0 is completely transparent, 0.0 completely opaque
Definition: cmaterial.h:235
SFVEC3F m_ambientColor
Definition: cmaterial.h:226
unsigned int m_reflections_nr_samples
nr of rays that will be interpolated for this material if it is reflective
Definition: cmaterial.h:240
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:242
float m_shinness
Definition: cmaterial.h:234
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:238
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
#define AMBIENT_FACTOR
Definition: cmaterial.cpp:36
SFVEC3F m_emissiveColor
Definition: cmaterial.h:232
SFVEC3F m_specularColor
Definition: cmaterial.h:233
unsigned int m_refraction_nr_samples
nr of rays that will be interpolated for this material if it is a transparent
Definition: cmaterial.h:239
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:236

Member Function Documentation

float CMATERIAL::GetAbsorvance ( ) const
inline

Definition at line 185 of file cmaterial.h.

References m_absorbance.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

185 { return m_absorbance; }
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:236
const SFVEC3F& CMATERIAL::GetAmbientColor ( ) const
inline

Definition at line 178 of file cmaterial.h.

References m_ambientColor.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

178 { return m_ambientColor; }
SFVEC3F m_ambientColor
Definition: cmaterial.h:226
bool CMATERIAL::GetCastShadows ( ) const
inline

Definition at line 199 of file cmaterial.h.

References m_cast_shadows.

Referenced by CBVH_PBRT::IntersectP().

199 { return m_cast_shadows; }
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:238
const SFVEC3F& CMATERIAL::GetEmissiveColor ( ) const
inline

Definition at line 179 of file cmaterial.h.

References m_emissiveColor.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

179 { return m_emissiveColor; }
SFVEC3F m_emissiveColor
Definition: cmaterial.h:232
const CPROCEDURALGENERATOR* CMATERIAL::GetNormalPerturbator ( ) const
inline

Definition at line 221 of file cmaterial.h.

References m_normal_perturbator.

221 { return m_normal_perturbator; }
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:242
unsigned int CMATERIAL::GetNrReflectionsSamples ( ) const
inline

Definition at line 187 of file cmaterial.h.

References m_reflections_nr_samples.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

187 { 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:240
unsigned int CMATERIAL::GetNrRefractionsSamples ( ) const
inline

Definition at line 186 of file cmaterial.h.

References m_refraction_nr_samples.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

186 { 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:239
float CMATERIAL::GetReflection ( ) const
inline

Definition at line 184 of file cmaterial.h.

References m_reflection.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

184 { return m_reflection; }
float m_reflection
1.0 completely reflective, 0.0 no reflective
Definition: cmaterial.h:237
float CMATERIAL::GetShinness ( ) const
inline

Definition at line 182 of file cmaterial.h.

References m_shinness.

182 { return m_shinness; }
float m_shinness
Definition: cmaterial.h:234
const SFVEC3F& CMATERIAL::GetSpecularColor ( ) const
inline

Definition at line 180 of file cmaterial.h.

References m_specularColor.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

180 { return m_specularColor; }
SFVEC3F m_specularColor
Definition: cmaterial.h:233
float CMATERIAL::GetTransparency ( ) const
inline

Definition at line 183 of file cmaterial.h.

References m_transparency.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

183 { return m_transparency; }
float m_transparency
1.0 is completely transparent, 0.0 completely opaque
Definition: cmaterial.h:235
void CMATERIAL::PerturbeNormal ( SFVEC3F aNormal,
const RAY aRay,
const HITINFO aHitInfo 
) const

Definition at line 88 of file cmaterial.cpp.

References CPROCEDURALGENERATOR::Generate(), and m_normal_perturbator.

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

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:242
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...
void CMATERIAL::SetAbsorvance ( float  aAbsorvanceFactor)
inline

Definition at line 189 of file cmaterial.h.

References m_absorbance.

189 { m_absorbance = aAbsorvanceFactor; }
float m_absorbance
absorvance factor for the transparent material
Definition: cmaterial.h:236
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 197 of file cmaterial.h.

References m_cast_shadows.

197 { m_cast_shadows = aCastShadows; }
bool m_cast_shadows
true if this object will block the light
Definition: cmaterial.h:238
void CMATERIAL::SetNormalPerturbator ( const CPROCEDURALGENERATOR aPerturbator)
inline

Definition at line 220 of file cmaterial.h.

References m_normal_perturbator.

Referenced by C3D_RENDER_RAYTRACING::add_3D_models().

220 { m_normal_perturbator = aPerturbator; }
const CPROCEDURALGENERATOR * m_normal_perturbator
Definition: cmaterial.h:242
void CMATERIAL::SetNrReflectionsSamples ( unsigned int  aNrReflections)
inline

Definition at line 191 of file cmaterial.h.

References m_reflections_nr_samples.

191 { 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:240
void CMATERIAL::SetNrRefractionsSamples ( unsigned int  aNrRefractions)
inline

Definition at line 190 of file cmaterial.h.

References m_refraction_nr_samples.

190 { 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:239
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

float CMATERIAL::m_absorbance
protected

absorvance factor for the transparent material

Definition at line 236 of file cmaterial.h.

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

SFVEC3F CMATERIAL::m_ambientColor
protected

Definition at line 226 of file cmaterial.h.

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

bool CMATERIAL::m_cast_shadows
protected

true if this object will block the light

Definition at line 238 of file cmaterial.h.

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

SFVEC3F CMATERIAL::m_emissiveColor
protected

Definition at line 232 of file cmaterial.h.

Referenced by CMATERIAL(), and GetEmissiveColor().

const CPROCEDURALGENERATOR* CMATERIAL::m_normal_perturbator
protected

Definition at line 242 of file cmaterial.h.

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

float CMATERIAL::m_reflection
protected

1.0 completely reflective, 0.0 no reflective

Definition at line 237 of file cmaterial.h.

Referenced by CMATERIAL(), and GetReflection().

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 240 of file cmaterial.h.

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

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 239 of file cmaterial.h.

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

float CMATERIAL::m_shinness
protected

Definition at line 234 of file cmaterial.h.

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

SFVEC3F CMATERIAL::m_specularColor
protected

Definition at line 233 of file cmaterial.h.

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

float CMATERIAL::m_transparency
protected

1.0 is completely transparent, 0.0 completely opaque

Definition at line 235 of file cmaterial.h.

Referenced by CMATERIAL(), and GetTransparency().


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