KiCad PCB EDA Suite
MATERIAL Class Referenceabstract

Base material class that can be used to derive other material implementations. More...

#include <material.h>

Inheritance diagram for MATERIAL:
BLINN_PHONG_MATERIAL

Public Member Functions

 MATERIAL ()
 
 MATERIAL (const SFVEC3F &aAmbient, const SFVEC3F &aEmissive, const SFVEC3F &aSpecular, float aShinness, float aTransparency, float aReflection)
 
virtual ~MATERIAL ()
 
const SFVEC3FGetAmbientColor () const
 
const SFVEC3FGetEmissiveColor () const
 
const SFVEC3FGetSpecularColor () const
 
float GetReflectivity () const
 
float GetTransparency () const
 
float GetReflection () const
 
float GetAbsorvance () const
 
unsigned int GetRefractionRayCount () const
 
unsigned int GetReflectionRayCount () const
 
unsigned int GetReflectionRecursionCount () const
 
unsigned int GetRefractionRecursionCount () const
 
void SetAbsorvance (float aAbsorvanceFactor)
 
void SetRefractionRayCount (unsigned int aCount)
 
void SetReflectionRayCount (unsigned int aCount)
 
void SetReflectionRecursionCount (unsigned int aCount)
 
void SetRefractionRecursionCount (unsigned int aCount)
 
void SetCastShadows (bool aCastShadows)
 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 an intersection point. More...
 
void SetGenerator (const MATERIAL_GENERATOR *aGenerator)
 
const MATERIAL_GENERATORGetGenerator () const
 
void Generate (SFVEC3F &aNormal, const RAY &aRay, const HITINFO &aHitInfo) const
 

Static Public Member Functions

static void SetDefaultRefractionRayCount (unsigned int aCount)
 
static void SetDefaultReflectionRayCount (unsigned int aCount)
 
static void SetDefaultRefractionRecursionCount (unsigned int aCount)
 
static void SetDefaultReflectionRecursionCount (unsigned int aCount)
 

Protected Attributes

SFVEC3F m_ambientColor
 
SFVEC3F m_emissiveColor
 
SFVEC3F m_specularColor
 
float m_reflectivity
 1.0 is completely transparent, 0.0 completely opaque. More...
 
float m_transparency
 
float m_absorbance
 absorbance factor for the transparent material. More...
 
float m_reflection
 1.0 completely reflective, 0.0 no reflective. More...
 
bool m_castShadows
 true if this object will block the light. More...
 
unsigned int m_refractionRayCount
 Number of rays that will be interpolated for this material if it is reflective. More...
 
unsigned int m_reflectionRayCount
 Number of levels it allows for refraction recursiveness. More...
 
unsigned int m_refractionRecursionCount
 Number of levels it allows for reflection recursiveness. More...
 
unsigned int m_reflectionRecursionCount
 
const MATERIAL_GENERATORm_generator
 

Static Private Attributes

static int m_defaultRefractionRayCount = 4
 
static int m_defaultReflectionRayCount = 3
 
static int m_defaultRefractionRecursionCount = 2
 
static int m_defaultFeflectionRecursionCount = 3
 

Detailed Description

Base material class that can be used to derive other material implementations.

Definition at line 239 of file material.h.

Constructor & Destructor Documentation

◆ MATERIAL() [1/2]

MATERIAL::MATERIAL ( )

Definition at line 40 of file material.cpp.

41 {
42  m_ambientColor = SFVEC3F( 0.2f, 0.2f, 0.2f );
43  m_emissiveColor = SFVEC3F( 0.0f, 0.0f, 0.0f );
44  m_specularColor = SFVEC3F( 1.0f, 1.0f, 1.0f );
45  m_reflectivity = 50.2f;
46  m_transparency = 0.0f; // completely opaque
47  m_castShadows = true;
48  m_reflection = 0.0f;
49  m_absorbance = 1.0f;
54 
55  m_generator = nullptr;
56 }
float m_reflection
1.0 completely reflective, 0.0 no reflective.
Definition: material.h:351
bool m_castShadows
true if this object will block the light.
Definition: material.h:352
static int m_defaultReflectionRayCount
Definition: material.h:370
SFVEC3F m_emissiveColor
Definition: material.h:344
SFVEC3F m_ambientColor
Definition: material.h:338
float m_transparency
Definition: material.h:349
static int m_defaultFeflectionRecursionCount
Definition: material.h:372
unsigned int m_reflectionRecursionCount
Definition: material.h:364
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
Definition: material.h:355
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
Definition: material.h:358
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
Definition: material.h:361
const MATERIAL_GENERATOR * m_generator
Definition: material.h:366
static int m_defaultRefractionRecursionCount
Definition: material.h:371
SFVEC3F m_specularColor
Definition: material.h:345
static int m_defaultRefractionRayCount
Definition: material.h:369
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float m_absorbance
absorbance factor for the transparent material.
Definition: material.h:350
float m_reflectivity
1.0 is completely transparent, 0.0 completely opaque.
Definition: material.h:346

References m_absorbance, m_ambientColor, m_castShadows, m_defaultFeflectionRecursionCount, m_defaultReflectionRayCount, m_defaultRefractionRayCount, m_defaultRefractionRecursionCount, m_emissiveColor, m_generator, m_reflection, m_reflectionRayCount, m_reflectionRecursionCount, m_reflectivity, m_refractionRayCount, m_refractionRecursionCount, m_specularColor, and m_transparency.

◆ MATERIAL() [2/2]

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

Definition at line 59 of file material.cpp.

61 {
62  wxASSERT( aReflection >= 0.0f );
63  wxASSERT( aReflection <= 1.0f );
64 
65  wxASSERT( aTransparency >= 0.0f );
66  wxASSERT( aTransparency <= 1.0f );
67 
68  wxASSERT( aShinness >= 0.0f );
69  wxASSERT( aShinness <= 180.0f );
70 
72 
73  m_emissiveColor = aEmissive;
74  m_specularColor = aSpecular;
75  m_reflectivity = aShinness;
76  m_transparency = glm::clamp( aTransparency, 0.0f, 1.0f );
77  m_absorbance = 1.0f;
78  m_reflection = aReflection;
79  m_castShadows = true;
84 
85  m_generator = nullptr;
86 }
float m_reflection
1.0 completely reflective, 0.0 no reflective.
Definition: material.h:351
bool m_castShadows
true if this object will block the light.
Definition: material.h:352
static int m_defaultReflectionRayCount
Definition: material.h:370
SFVEC3F m_emissiveColor
Definition: material.h:344
SFVEC3F m_ambientColor
Definition: material.h:338
float m_transparency
Definition: material.h:349
static int m_defaultFeflectionRecursionCount
Definition: material.h:372
unsigned int m_reflectionRecursionCount
Definition: material.h:364
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
Definition: material.h:355
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
Definition: material.h:358
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
Definition: material.h:361
const MATERIAL_GENERATOR * m_generator
Definition: material.h:366
static int m_defaultRefractionRecursionCount
Definition: material.h:371
SFVEC3F m_specularColor
Definition: material.h:345
static int m_defaultRefractionRayCount
Definition: material.h:369
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float m_absorbance
absorbance factor for the transparent material.
Definition: material.h:350
float m_reflectivity
1.0 is completely transparent, 0.0 completely opaque.
Definition: material.h:346
#define AMBIENT_FACTOR
Definition: material.cpp:36

References AMBIENT_FACTOR, m_absorbance, m_ambientColor, m_castShadows, m_defaultFeflectionRecursionCount, m_defaultReflectionRayCount, m_defaultRefractionRayCount, m_defaultRefractionRecursionCount, m_emissiveColor, m_generator, m_reflection, m_reflectionRayCount, m_reflectionRecursionCount, m_reflectivity, m_refractionRayCount, m_refractionRecursionCount, m_specularColor, and m_transparency.

◆ ~MATERIAL()

virtual MATERIAL::~MATERIAL ( )
inlinevirtual

Definition at line 266 of file material.h.

266 {}

Member Function Documentation

◆ Generate()

void MATERIAL::Generate ( SFVEC3F aNormal,
const RAY aRay,
const HITINFO aHitInfo 
) const

Definition at line 89 of file material.cpp.

90 {
91  if( m_generator )
92  {
93  aNormal = aNormal + m_generator->Generate( aRay, aHitInfo );
94  aNormal = glm::normalize( aNormal );
95  }
96 }
const MATERIAL_GENERATOR * m_generator
Definition: material.h:366
virtual SFVEC3F Generate(const RAY &aRay, const HITINFO &aHitInfo) const =0
Generate a 3D vector based on the ray and hit information depending on the implementation.

References MATERIAL_GENERATOR::Generate(), and m_generator.

Referenced by LAYER_ITEM::Intersect(), ROUND_SEGMENT::Intersect(), DUMMY_BLOCK::Intersect(), CYLINDER::Intersect(), XY_PLANE::Intersect(), and TRIANGLE::Intersect().

◆ GetAbsorvance()

float MATERIAL::GetAbsorvance ( ) const
inline

Definition at line 275 of file material.h.

275 { return m_absorbance; }
float m_absorbance
absorbance factor for the transparent material.
Definition: material.h:350

References m_absorbance.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetAmbientColor()

const SFVEC3F& MATERIAL::GetAmbientColor ( ) const
inline

Definition at line 268 of file material.h.

268 { return m_ambientColor; }
SFVEC3F m_ambientColor
Definition: material.h:338

References m_ambientColor.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetCastShadows()

bool MATERIAL::GetCastShadows ( ) const
inline

Definition at line 309 of file material.h.

309 { return m_castShadows; }
bool m_castShadows
true if this object will block the light.
Definition: material.h:352

References m_castShadows.

Referenced by BVH_PBRT::IntersectP().

◆ GetEmissiveColor()

const SFVEC3F& MATERIAL::GetEmissiveColor ( ) const
inline

Definition at line 269 of file material.h.

269 { return m_emissiveColor; }
SFVEC3F m_emissiveColor
Definition: material.h:344

References m_emissiveColor.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetGenerator()

const MATERIAL_GENERATOR* MATERIAL::GetGenerator ( ) const
inline

Definition at line 333 of file material.h.

333 { return m_generator; }
const MATERIAL_GENERATOR * m_generator
Definition: material.h:366

References m_generator.

◆ GetReflection()

float MATERIAL::GetReflection ( ) const
inline

Definition at line 274 of file material.h.

274 { return m_reflection; }
float m_reflection
1.0 completely reflective, 0.0 no reflective.
Definition: material.h:351

References m_reflection.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetReflectionRayCount()

unsigned int MATERIAL::GetReflectionRayCount ( ) const
inline

Definition at line 277 of file material.h.

277 { return m_reflectionRayCount; }
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
Definition: material.h:358

References m_reflectionRayCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetReflectionRecursionCount()

unsigned int MATERIAL::GetReflectionRecursionCount ( ) const
inline

Definition at line 278 of file material.h.

278 { return m_reflectionRecursionCount; }
unsigned int m_reflectionRecursionCount
Definition: material.h:364

References m_reflectionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetReflectivity()

float MATERIAL::GetReflectivity ( ) const
inline

Definition at line 272 of file material.h.

272 { return m_reflectivity; }
float m_reflectivity
1.0 is completely transparent, 0.0 completely opaque.
Definition: material.h:346

References m_reflectivity.

◆ GetRefractionRayCount()

unsigned int MATERIAL::GetRefractionRayCount ( ) const
inline

Definition at line 276 of file material.h.

276 { return m_refractionRayCount; }
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
Definition: material.h:355

References m_refractionRayCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetRefractionRecursionCount()

unsigned int MATERIAL::GetRefractionRecursionCount ( ) const
inline

Definition at line 279 of file material.h.

279 { return m_refractionRecursionCount; }
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
Definition: material.h:361

References m_refractionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetSpecularColor()

const SFVEC3F& MATERIAL::GetSpecularColor ( ) const
inline

Definition at line 270 of file material.h.

270 { return m_specularColor; }
SFVEC3F m_specularColor
Definition: material.h:345

References m_specularColor.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetTransparency()

float MATERIAL::GetTransparency ( ) const
inline

Definition at line 273 of file material.h.

273 { return m_transparency; }
float m_transparency
Definition: material.h:349

References m_transparency.

Referenced by RENDER_3D_RAYTRACE::addModels(), and OBJECT_3D::SetMaterial().

◆ SetAbsorvance()

void MATERIAL::SetAbsorvance ( float  aAbsorvanceFactor)
inline

Definition at line 281 of file material.h.

281 { m_absorbance = aAbsorvanceFactor; }
float m_absorbance
absorbance factor for the transparent material.
Definition: material.h:350

References m_absorbance.

◆ SetCastShadows()

void MATERIAL::SetCastShadows ( bool  aCastShadows)
inline

Set if the material can receive shadows.

Parameters
aCastShadowstrue yes it can, false not it cannot

Definition at line 307 of file material.h.

307 { m_castShadows = aCastShadows; }
bool m_castShadows
true if this object will block the light.
Definition: material.h:352

References m_castShadows.

◆ SetDefaultReflectionRayCount()

static void MATERIAL::SetDefaultReflectionRayCount ( unsigned int  aCount)
inlinestatic

Definition at line 247 of file material.h.

248  {
250  }
static int m_defaultReflectionRayCount
Definition: material.h:370

References m_defaultReflectionRayCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetDefaultReflectionRecursionCount()

static void MATERIAL::SetDefaultReflectionRecursionCount ( unsigned int  aCount)
inlinestatic

Definition at line 257 of file material.h.

258  {
260  }
static int m_defaultFeflectionRecursionCount
Definition: material.h:372

References m_defaultFeflectionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetDefaultRefractionRayCount()

static void MATERIAL::SetDefaultRefractionRayCount ( unsigned int  aCount)
inlinestatic

Definition at line 242 of file material.h.

243  {
245  }
static int m_defaultRefractionRayCount
Definition: material.h:369

References m_defaultRefractionRayCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetDefaultRefractionRecursionCount()

static void MATERIAL::SetDefaultRefractionRecursionCount ( unsigned int  aCount)
inlinestatic

Definition at line 252 of file material.h.

253  {
255  }
static int m_defaultRefractionRecursionCount
Definition: material.h:371

References m_defaultRefractionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetGenerator()

void MATERIAL::SetGenerator ( const MATERIAL_GENERATOR aGenerator)
inline

Definition at line 328 of file material.h.

329  {
330  m_generator = aGenerator;
331  }
const MATERIAL_GENERATOR * m_generator
Definition: material.h:366

References m_generator.

Referenced by RENDER_3D_RAYTRACE::getModelMaterial().

◆ SetReflectionRayCount()

void MATERIAL::SetReflectionRayCount ( unsigned int  aCount)
inline

Definition at line 287 of file material.h.

288  {
289  m_reflectionRayCount = aCount;
290  }
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
Definition: material.h:358

References m_reflectionRayCount.

◆ SetReflectionRecursionCount()

void MATERIAL::SetReflectionRecursionCount ( unsigned int  aCount)
inline

Definition at line 292 of file material.h.

293  {
295  }
unsigned int m_reflectionRecursionCount
Definition: material.h:364

References m_reflectionRecursionCount.

◆ SetRefractionRayCount()

void MATERIAL::SetRefractionRayCount ( unsigned int  aCount)
inline

Definition at line 282 of file material.h.

283  {
284  m_refractionRayCount = aCount;
285  }
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
Definition: material.h:355

References m_refractionRayCount.

◆ SetRefractionRecursionCount()

void MATERIAL::SetRefractionRecursionCount ( unsigned int  aCount)
inline

Definition at line 297 of file material.h.

298  {
300  }
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
Definition: material.h:361

References m_refractionRecursionCount.

◆ Shade()

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

Shade 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 BLINN_PHONG_MATERIAL.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

Member Data Documentation

◆ m_absorbance

float MATERIAL::m_absorbance
protected

absorbance factor for the transparent material.

Definition at line 350 of file material.h.

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

◆ m_ambientColor

SFVEC3F MATERIAL::m_ambientColor
protected

Definition at line 338 of file material.h.

Referenced by GetAmbientColor(), MATERIAL(), and BLINN_PHONG_MATERIAL::Shade().

◆ m_castShadows

bool MATERIAL::m_castShadows
protected

true if this object will block the light.

Number of rays that will be interpolated for this material if it is transparent.

Definition at line 352 of file material.h.

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

◆ m_defaultFeflectionRecursionCount

int MATERIAL::m_defaultFeflectionRecursionCount = 3
staticprivate

Definition at line 372 of file material.h.

Referenced by MATERIAL(), and SetDefaultReflectionRecursionCount().

◆ m_defaultReflectionRayCount

int MATERIAL::m_defaultReflectionRayCount = 3
staticprivate

Definition at line 370 of file material.h.

Referenced by MATERIAL(), and SetDefaultReflectionRayCount().

◆ m_defaultRefractionRayCount

int MATERIAL::m_defaultRefractionRayCount = 4
staticprivate

Definition at line 369 of file material.h.

Referenced by MATERIAL(), and SetDefaultRefractionRayCount().

◆ m_defaultRefractionRecursionCount

int MATERIAL::m_defaultRefractionRecursionCount = 2
staticprivate

Definition at line 371 of file material.h.

Referenced by MATERIAL(), and SetDefaultRefractionRecursionCount().

◆ m_emissiveColor

SFVEC3F MATERIAL::m_emissiveColor
protected

Definition at line 344 of file material.h.

Referenced by GetEmissiveColor(), and MATERIAL().

◆ m_generator

const MATERIAL_GENERATOR* MATERIAL::m_generator
protected

Definition at line 366 of file material.h.

Referenced by Generate(), GetGenerator(), MATERIAL(), and SetGenerator().

◆ m_reflection

float MATERIAL::m_reflection
protected

1.0 completely reflective, 0.0 no reflective.

Definition at line 351 of file material.h.

Referenced by GetReflection(), and MATERIAL().

◆ m_reflectionRayCount

unsigned int MATERIAL::m_reflectionRayCount
protected

Number of levels it allows for refraction recursiveness.

Definition at line 358 of file material.h.

Referenced by GetReflectionRayCount(), MATERIAL(), and SetReflectionRayCount().

◆ m_reflectionRecursionCount

unsigned int MATERIAL::m_reflectionRecursionCount
protected

Definition at line 364 of file material.h.

Referenced by GetReflectionRecursionCount(), MATERIAL(), and SetReflectionRecursionCount().

◆ m_reflectivity

float MATERIAL::m_reflectivity
protected

1.0 is completely transparent, 0.0 completely opaque.

Definition at line 346 of file material.h.

Referenced by GetReflectivity(), MATERIAL(), and BLINN_PHONG_MATERIAL::Shade().

◆ m_refractionRayCount

unsigned int MATERIAL::m_refractionRayCount
protected

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

Definition at line 355 of file material.h.

Referenced by GetRefractionRayCount(), MATERIAL(), and SetRefractionRayCount().

◆ m_refractionRecursionCount

unsigned int MATERIAL::m_refractionRecursionCount
protected

Number of levels it allows for reflection recursiveness.

Definition at line 361 of file material.h.

Referenced by GetRefractionRecursionCount(), MATERIAL(), and SetRefractionRecursionCount().

◆ m_specularColor

SFVEC3F MATERIAL::m_specularColor
protected

Definition at line 345 of file material.h.

Referenced by GetSpecularColor(), MATERIAL(), and BLINN_PHONG_MATERIAL::Shade().

◆ m_transparency

float MATERIAL::m_transparency
protected

Definition at line 349 of file material.h.

Referenced by GetTransparency(), and MATERIAL().


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