KiCad PCB EDA Suite
DIRECTIONAL_LIGHT Class Reference

A light source based only on a directional vector. More...

#include <light.h>

Inheritance diagram for DIRECTIONAL_LIGHT:
LIGHT

Public Member Functions

 DIRECTIONAL_LIGHT (const SFVEC3F &aDir, const SFVEC3F &aColor)
 
void SetDirection (const SFVEC3F &aDir)
 Set directional light orientation. More...
 
void GetLightParameters (const SFVEC3F &, 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_inv_direction
 opposite direction of the light More...
 
SFVEC3F m_color
 light color More...
 

Detailed Description

A light source based only on a directional vector.

Definition at line 115 of file light.h.

Constructor & Destructor Documentation

◆ DIRECTIONAL_LIGHT()

DIRECTIONAL_LIGHT::DIRECTIONAL_LIGHT ( const SFVEC3F aDir,
const SFVEC3F aColor 
)
inline

Definition at line 118 of file light.h.

119  {
120  // Invert light direction and make sure it is normalized
121  m_inv_direction = glm::normalize( -aDir );
122  m_color = aColor;
123  m_castShadow = true; // Set as default to cast shadows
124  }
bool m_castShadow
Definition: light.h:63
SFVEC3F m_inv_direction
opposite direction of the light
Definition: light.h:143
SFVEC3F m_color
light color
Definition: light.h:144

References LIGHT::m_castShadow, m_color, and m_inv_direction.

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 DIRECTIONAL_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 134 of file light.h.

136  {
137  aOutVectorToLight = m_inv_direction;
138  aOutDistance = std::numeric_limits<float>::infinity();
139  aOutLightColor = m_color;
140  }
SFVEC3F m_inv_direction
opposite direction of the light
Definition: light.h:143
SFVEC3F m_color
light color
Definition: light.h:144

References m_color, and m_inv_direction.

◆ 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().

◆ SetDirection()

void DIRECTIONAL_LIGHT::SetDirection ( const SFVEC3F aDir)
inline

Set directional light orientation.

Parameters
aDiris the vector defining the direction of the light source.

Definition at line 131 of file light.h.

131 { m_inv_direction = -aDir; }
SFVEC3F m_inv_direction
opposite direction of the light
Definition: light.h:143

References m_inv_direction.

Referenced by RENDER_3D_RAYTRACE::Redraw(), and RENDER_3D_RAYTRACE::render().

Member Data Documentation

◆ m_castShadow

bool LIGHT::m_castShadow
protectedinherited

◆ m_color

SFVEC3F DIRECTIONAL_LIGHT::m_color
private

light color

Definition at line 144 of file light.h.

Referenced by DIRECTIONAL_LIGHT(), and GetLightParameters().

◆ m_inv_direction

SFVEC3F DIRECTIONAL_LIGHT::m_inv_direction
private

opposite direction of the light

Definition at line 143 of file light.h.

Referenced by DIRECTIONAL_LIGHT(), GetLightParameters(), and SetDirection().


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