KiCad PCB EDA Suite
CPOINTLIGHT Class Reference

Point light based on: http://ogldev.atspace.co.uk/www/tutorial20/tutorial20.html. More...

#include <clight.h>

Inheritance diagram for CPOINTLIGHT:
CLIGHT

Public Member Functions

 CPOINTLIGHT (const SFVEC3F &aPos, const SFVEC3F &aColor)
 
void GetLightParameters (const SFVEC3F &aHitPoint, SFVEC3F &aOutVectorToLight, SFVEC3F &aOutLightColor, float &aOutDistance) const override
 GetLightParameters - Get parameters from this light. More...
 
void SetCastShadows (bool aCastShadow)
 
bool GetCastShadows () const
 

Protected Attributes

bool m_castShadow
 

Private Attributes

SFVEC3F m_position
 
SFVEC3F m_color
 
float m_att_constant
 
float m_att_linear
 
float m_att_exp
 

Detailed Description

Point light based on: http://ogldev.atspace.co.uk/www/tutorial20/tutorial20.html.

Definition at line 67 of file clight.h.

Constructor & Destructor Documentation

◆ CPOINTLIGHT()

CPOINTLIGHT::CPOINTLIGHT ( const SFVEC3F aPos,
const SFVEC3F aColor 
)
inline

Definition at line 71 of file clight.h.

72  {
73  m_position = aPos;
74  m_color = aColor;
75  m_att_constant = 0.9f;
76  m_att_linear = 0.0005f;
77  m_att_exp = 0.001f;
78  m_castShadow = true;
79  }
bool m_castShadow
Definition: clight.h:61
float m_att_constant
Definition: clight.h:107
float m_att_exp
Definition: clight.h:109
SFVEC3F m_position
Definition: clight.h:104
SFVEC3F m_color
Definition: clight.h:105
float m_att_linear
Definition: clight.h:108

References m_att_constant, m_att_exp, m_att_linear, CLIGHT::m_castShadow, m_color, and m_position.

Member Function Documentation

◆ GetCastShadows()

bool CLIGHT::GetCastShadows ( ) const
inlineinherited

Definition at line 58 of file clight.h.

58 { return m_castShadow; }
bool m_castShadow
Definition: clight.h:61

References CLIGHT::m_castShadow.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

◆ GetLightParameters()

void CPOINTLIGHT::GetLightParameters ( const SFVEC3F aHitPoint,
SFVEC3F aOutVectorToLight,
SFVEC3F aOutLightColor,
float &  aOutDistance 
) const
inlineoverridevirtual

GetLightParameters - Get parameters from this light.

Parameters
aHitPointinput hit position
aOutVectorToLighta vector that points from the hit position in direction to the light
aOutLightColorthe color of this light
aOutDistancethe distance from the point to the light

Implements CLIGHT.

Definition at line 83 of file clight.h.

87  {
88  const SFVEC3F vectorLight = m_position - aHitPoint;
89 
90  aOutDistance = glm::length( vectorLight );
91  aOutVectorToLight = vectorLight / aOutDistance; // normalize
92 
93  const float att = 1.0f / ( m_att_constant +
94  m_att_linear * aOutDistance +
95  m_att_exp * aOutDistance * aOutDistance );
96 
97  if( att <= 0.0f )
98  aOutLightColor = SFVEC3F( 0.0f, 0.0f, 0.0f );
99  else
100  aOutLightColor = m_color * att;
101  }
float m_att_constant
Definition: clight.h:107
float m_att_exp
Definition: clight.h:109
SFVEC3F m_position
Definition: clight.h:104
glm::vec3 SFVEC3F
Definition: xv3d_types.h:47
SFVEC3F m_color
Definition: clight.h:105
float m_att_linear
Definition: clight.h:108

References m_att_constant, m_att_exp, m_att_linear, m_color, and m_position.

◆ SetCastShadows()

void CLIGHT::SetCastShadows ( bool  aCastShadow)
inlineinherited

Definition at line 57 of file clight.h.

57 { m_castShadow = aCastShadow; }
bool m_castShadow
Definition: clight.h:61

References CLIGHT::m_castShadow.

Referenced by C3D_RENDER_RAYTRACING::reload().

Member Data Documentation

◆ m_att_constant

float CPOINTLIGHT::m_att_constant
private

Definition at line 107 of file clight.h.

Referenced by CPOINTLIGHT(), and GetLightParameters().

◆ m_att_exp

float CPOINTLIGHT::m_att_exp
private

Definition at line 109 of file clight.h.

Referenced by CPOINTLIGHT(), and GetLightParameters().

◆ m_att_linear

float CPOINTLIGHT::m_att_linear
private

Definition at line 108 of file clight.h.

Referenced by CPOINTLIGHT(), and GetLightParameters().

◆ m_castShadow

bool CLIGHT::m_castShadow
protectedinherited

◆ m_color

SFVEC3F CPOINTLIGHT::m_color
private

Definition at line 105 of file clight.h.

Referenced by CPOINTLIGHT(), and GetLightParameters().

◆ m_position

SFVEC3F CPOINTLIGHT::m_position
private

Definition at line 104 of file clight.h.

Referenced by CPOINTLIGHT(), and GetLightParameters().


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