KiCad PCB EDA Suite
POINT_LIGHT Class Reference

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

#include <light.h>

Inheritance diagram for POINT_LIGHT:
LIGHT

Public Member Functions

 POINT_LIGHT (const SFVEC3F &aPos, const SFVEC3F &aColor)
 
void GetLightParameters (const SFVEC3F &aHitPoint, SFVEC3F &aOutVectorToLight, SFVEC3F &aOutLightColor, float &aOutDistance) const override
 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 source based on http://ogldev.atspace.co.uk/www/tutorial20/tutorial20.html.

Definition at line 70 of file light.h.

Constructor & Destructor Documentation

◆ POINT_LIGHT()

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

Definition at line 73 of file light.h.

74  {
75  m_position = aPos;
76  m_color = aColor;
77  m_att_constant = 0.9f;
78  m_att_linear = 0.0005f;
79  m_att_exp = 0.001f;
80  m_castShadow = true;
81  }
float m_att_linear
Definition: light.h:107
bool m_castShadow
Definition: light.h:63
SFVEC3F m_color
Definition: light.h:104
SFVEC3F m_position
Definition: light.h:103
float m_att_exp
Definition: light.h:108
float m_att_constant
Definition: light.h:106

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

Member Function Documentation

◆ GetCastShadows()

bool LIGHT::GetCastShadows ( ) const
inlineinherited

Definition at line 60 of file light.h.

60 { return m_castShadow; }
bool m_castShadow
Definition: light.h:63

References LIGHT::m_castShadow.

◆ GetLightParameters()

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

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 LIGHT.

Definition at line 84 of file light.h.

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

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

◆ SetCastShadows()

void LIGHT::SetCastShadows ( bool  aCastShadow)
inlineinherited

Definition at line 59 of file light.h.

59 { m_castShadow = aCastShadow; }
bool m_castShadow
Definition: light.h:63

References LIGHT::m_castShadow.

Referenced by RENDER_3D_RAYTRACE::Reload().

Member Data Documentation

◆ m_att_constant

float POINT_LIGHT::m_att_constant
private

Definition at line 106 of file light.h.

Referenced by GetLightParameters(), and POINT_LIGHT().

◆ m_att_exp

float POINT_LIGHT::m_att_exp
private

Definition at line 108 of file light.h.

Referenced by GetLightParameters(), and POINT_LIGHT().

◆ m_att_linear

float POINT_LIGHT::m_att_linear
private

Definition at line 107 of file light.h.

Referenced by GetLightParameters(), and POINT_LIGHT().

◆ m_castShadow

bool LIGHT::m_castShadow
protectedinherited

◆ m_color

SFVEC3F POINT_LIGHT::m_color
private

Definition at line 104 of file light.h.

Referenced by GetLightParameters(), and POINT_LIGHT().

◆ m_position

SFVEC3F POINT_LIGHT::m_position
private

Definition at line 103 of file light.h.

Referenced by GetLightParameters(), and POINT_LIGHT().


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