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 243 of file material.h.

Constructor & Destructor Documentation

◆ MATERIAL() [1/2]

MATERIAL::MATERIAL ( )

Definition at line 44 of file material.cpp.

45 {
46  m_ambientColor = SFVEC3F( 0.2f, 0.2f, 0.2f );
47  m_emissiveColor = SFVEC3F( 0.0f, 0.0f, 0.0f );
48  m_specularColor = SFVEC3F( 1.0f, 1.0f, 1.0f );
49  m_reflectivity = 50.2f;
50  m_transparency = 0.0f; // completely opaque
51  m_castShadows = true;
52  m_reflection = 0.0f;
53  m_absorbance = 1.0f;
58 
59  m_generator = nullptr;
60 }
float m_reflection
1.0 completely reflective, 0.0 no reflective.
Definition: material.h:355
bool m_castShadows
true if this object will block the light.
Definition: material.h:356
static int m_defaultReflectionRayCount
Definition: material.h:374
SFVEC3F m_emissiveColor
Definition: material.h:348
SFVEC3F m_ambientColor
Definition: material.h:342
float m_transparency
Definition: material.h:353
static int m_defaultFeflectionRecursionCount
Definition: material.h:376
unsigned int m_reflectionRecursionCount
Definition: material.h:368
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
Definition: material.h:359
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
Definition: material.h:362
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
Definition: material.h:365
const MATERIAL_GENERATOR * m_generator
Definition: material.h:370
static int m_defaultRefractionRecursionCount
Definition: material.h:375
SFVEC3F m_specularColor
Definition: material.h:349
static int m_defaultRefractionRayCount
Definition: material.h:373
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float m_absorbance
absorbance factor for the transparent material.
Definition: material.h:354
float m_reflectivity
1.0 is completely transparent, 0.0 completely opaque.
Definition: material.h:350

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 63 of file material.cpp.

65 {
66  wxASSERT( aReflection >= 0.0f );
67  wxASSERT( aReflection <= 1.0f );
68 
69  wxASSERT( aTransparency >= 0.0f );
70  wxASSERT( aTransparency <= 1.0f );
71 
72  wxASSERT( aShinness >= 0.0f );
73  wxASSERT( aShinness <= 180.0f );
74 
76 
77  m_emissiveColor = aEmissive;
78  m_specularColor = aSpecular;
79  m_reflectivity = aShinness;
80  m_transparency = glm::clamp( aTransparency, 0.0f, 1.0f );
81  m_absorbance = 1.0f;
82  m_reflection = aReflection;
83  m_castShadows = true;
88 
89  m_generator = nullptr;
90 }
float m_reflection
1.0 completely reflective, 0.0 no reflective.
Definition: material.h:355
bool m_castShadows
true if this object will block the light.
Definition: material.h:356
static int m_defaultReflectionRayCount
Definition: material.h:374
SFVEC3F m_emissiveColor
Definition: material.h:348
SFVEC3F m_ambientColor
Definition: material.h:342
float m_transparency
Definition: material.h:353
static int m_defaultFeflectionRecursionCount
Definition: material.h:376
unsigned int m_reflectionRecursionCount
Definition: material.h:368
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
Definition: material.h:359
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
Definition: material.h:362
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
Definition: material.h:365
const MATERIAL_GENERATOR * m_generator
Definition: material.h:370
static int m_defaultRefractionRecursionCount
Definition: material.h:375
SFVEC3F m_specularColor
Definition: material.h:349
static int m_defaultRefractionRayCount
Definition: material.h:373
glm::vec3 SFVEC3F
Definition: xv3d_types.h:44
float m_absorbance
absorbance factor for the transparent material.
Definition: material.h:354
float m_reflectivity
1.0 is completely transparent, 0.0 completely opaque.
Definition: material.h:350
#define AMBIENT_FACTOR
Definition: material.cpp:40

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 270 of file material.h.

270 {}

Member Function Documentation

◆ Generate()

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

Definition at line 93 of file material.cpp.

94 {
95  if( m_generator )
96  {
97  aNormal = aNormal + m_generator->Generate( aRay, aHitInfo );
98  aNormal = glm::normalize( aNormal );
99  }
100 }
const MATERIAL_GENERATOR * m_generator
Definition: material.h:370
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 279 of file material.h.

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

References m_absorbance.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetAmbientColor()

const SFVEC3F& MATERIAL::GetAmbientColor ( ) const
inline

Definition at line 272 of file material.h.

272 { return m_ambientColor; }
SFVEC3F m_ambientColor
Definition: material.h:342

References m_ambientColor.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetCastShadows()

bool MATERIAL::GetCastShadows ( ) const
inline

Definition at line 313 of file material.h.

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

References m_castShadows.

Referenced by BVH_PBRT::IntersectP().

◆ GetEmissiveColor()

const SFVEC3F& MATERIAL::GetEmissiveColor ( ) const
inline

Definition at line 273 of file material.h.

273 { return m_emissiveColor; }
SFVEC3F m_emissiveColor
Definition: material.h:348

References m_emissiveColor.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetGenerator()

const MATERIAL_GENERATOR* MATERIAL::GetGenerator ( ) const
inline

Definition at line 337 of file material.h.

337 { return m_generator; }
const MATERIAL_GENERATOR * m_generator
Definition: material.h:370

References m_generator.

◆ GetReflection()

float MATERIAL::GetReflection ( ) const
inline

Definition at line 278 of file material.h.

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

References m_reflection.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetReflectionRayCount()

unsigned int MATERIAL::GetReflectionRayCount ( ) const
inline

Definition at line 281 of file material.h.

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

References m_reflectionRayCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetReflectionRecursionCount()

unsigned int MATERIAL::GetReflectionRecursionCount ( ) const
inline

Definition at line 282 of file material.h.

282 { return m_reflectionRecursionCount; }
unsigned int m_reflectionRecursionCount
Definition: material.h:368

References m_reflectionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetReflectivity()

float MATERIAL::GetReflectivity ( ) const
inline

Definition at line 276 of file material.h.

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

References m_reflectivity.

◆ GetRefractionRayCount()

unsigned int MATERIAL::GetRefractionRayCount ( ) const
inline

Definition at line 280 of file material.h.

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

References m_refractionRayCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetRefractionRecursionCount()

unsigned int MATERIAL::GetRefractionRecursionCount ( ) const
inline

Definition at line 283 of file material.h.

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

References m_refractionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetSpecularColor()

const SFVEC3F& MATERIAL::GetSpecularColor ( ) const
inline

Definition at line 274 of file material.h.

274 { return m_specularColor; }
SFVEC3F m_specularColor
Definition: material.h:349

References m_specularColor.

Referenced by RENDER_3D_RAYTRACE::shadeHit().

◆ GetTransparency()

float MATERIAL::GetTransparency ( ) const
inline

Definition at line 277 of file material.h.

277 { return m_transparency; }
float m_transparency
Definition: material.h:353

References m_transparency.

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

◆ SetAbsorvance()

void MATERIAL::SetAbsorvance ( float  aAbsorvanceFactor)
inline

Definition at line 285 of file material.h.

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

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 311 of file material.h.

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

References m_castShadows.

◆ SetDefaultReflectionRayCount()

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

Definition at line 251 of file material.h.

252  {
254  }
static int m_defaultReflectionRayCount
Definition: material.h:374

References m_defaultReflectionRayCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetDefaultReflectionRecursionCount()

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

Definition at line 261 of file material.h.

262  {
264  }
static int m_defaultFeflectionRecursionCount
Definition: material.h:376

References m_defaultFeflectionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetDefaultRefractionRayCount()

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

Definition at line 246 of file material.h.

247  {
249  }
static int m_defaultRefractionRayCount
Definition: material.h:373

References m_defaultRefractionRayCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetDefaultRefractionRecursionCount()

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

Definition at line 256 of file material.h.

257  {
259  }
static int m_defaultRefractionRecursionCount
Definition: material.h:375

References m_defaultRefractionRecursionCount.

Referenced by RENDER_3D_RAYTRACE::setupMaterials().

◆ SetGenerator()

void MATERIAL::SetGenerator ( const MATERIAL_GENERATOR aGenerator)
inline

Definition at line 332 of file material.h.

333  {
334  m_generator = aGenerator;
335  }
const MATERIAL_GENERATOR * m_generator
Definition: material.h:370

References m_generator.

Referenced by RENDER_3D_RAYTRACE::getModelMaterial().

◆ SetReflectionRayCount()

void MATERIAL::SetReflectionRayCount ( unsigned int  aCount)
inline

Definition at line 291 of file material.h.

292  {
293  m_reflectionRayCount = aCount;
294  }
unsigned int m_reflectionRayCount
Number of levels it allows for refraction recursiveness.
Definition: material.h:362

References m_reflectionRayCount.

◆ SetReflectionRecursionCount()

void MATERIAL::SetReflectionRecursionCount ( unsigned int  aCount)
inline

Definition at line 296 of file material.h.

297  {
299  }
unsigned int m_reflectionRecursionCount
Definition: material.h:368

References m_reflectionRecursionCount.

◆ SetRefractionRayCount()

void MATERIAL::SetRefractionRayCount ( unsigned int  aCount)
inline

Definition at line 286 of file material.h.

287  {
288  m_refractionRayCount = aCount;
289  }
unsigned int m_refractionRayCount
Number of rays that will be interpolated for this material if it is reflective.
Definition: material.h:359

References m_refractionRayCount.

◆ SetRefractionRecursionCount()

void MATERIAL::SetRefractionRecursionCount ( unsigned int  aCount)
inline

Definition at line 301 of file material.h.

302  {
304  }
unsigned int m_refractionRecursionCount
Number of levels it allows for reflection recursiveness.
Definition: material.h:365

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 354 of file material.h.

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

◆ m_ambientColor

SFVEC3F MATERIAL::m_ambientColor
protected

Definition at line 342 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 356 of file material.h.

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

◆ m_defaultFeflectionRecursionCount

int MATERIAL::m_defaultFeflectionRecursionCount = 3
staticprivate

Definition at line 376 of file material.h.

Referenced by MATERIAL(), and SetDefaultReflectionRecursionCount().

◆ m_defaultReflectionRayCount

int MATERIAL::m_defaultReflectionRayCount = 3
staticprivate

Definition at line 374 of file material.h.

Referenced by MATERIAL(), and SetDefaultReflectionRayCount().

◆ m_defaultRefractionRayCount

int MATERIAL::m_defaultRefractionRayCount = 4
staticprivate

Definition at line 373 of file material.h.

Referenced by MATERIAL(), and SetDefaultRefractionRayCount().

◆ m_defaultRefractionRecursionCount

int MATERIAL::m_defaultRefractionRecursionCount = 2
staticprivate

Definition at line 375 of file material.h.

Referenced by MATERIAL(), and SetDefaultRefractionRecursionCount().

◆ m_emissiveColor

SFVEC3F MATERIAL::m_emissiveColor
protected

Definition at line 348 of file material.h.

Referenced by GetEmissiveColor(), and MATERIAL().

◆ m_generator

const MATERIAL_GENERATOR* MATERIAL::m_generator
protected

Definition at line 370 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 355 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 362 of file material.h.

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

◆ m_reflectionRecursionCount

unsigned int MATERIAL::m_reflectionRecursionCount
protected

Definition at line 368 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 350 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 359 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 365 of file material.h.

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

◆ m_specularColor

SFVEC3F MATERIAL::m_specularColor
protected

Definition at line 349 of file material.h.

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

◆ m_transparency

float MATERIAL::m_transparency
protected

Definition at line 353 of file material.h.

Referenced by GetTransparency(), and MATERIAL().


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