KiCad PCB EDA Suite
CDIRECTIONALLIGHT Class Reference

Directional light - a light based only on a direction vector. More...

#include <clight.h>

Inheritance diagram for CDIRECTIONALLIGHT:
CLIGHT

Public Member Functions

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

Detailed Description

Directional light - a light based only on a direction vector.

Definition at line 114 of file clight.h.

Constructor & Destructor Documentation

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

Definition at line 117 of file clight.h.

References CLIGHT::m_castShadow, m_color, and m_inv_direction.

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

Member Function Documentation

bool CLIGHT::GetCastShadows ( ) const
inlineinherited

Definition at line 58 of file clight.h.

References CLIGHT::m_castShadow.

Referenced by C3D_RENDER_RAYTRACING::shadeHit().

58 { return m_castShadow; }
bool m_castShadow
Definition: clight.h:61
void CDIRECTIONALLIGHT::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 133 of file clight.h.

References m_color, and m_inv_direction.

137  {
138  (void)aHitPoint; // unused
139 
140  aOutVectorToLight = m_inv_direction;
141  aOutDistance = std::numeric_limits<float>::infinity();
142  aOutLightColor = m_color;
143  }
SFVEC3F m_inv_direction
oposite direction of the light
Definition: clight.h:146
SFVEC3F m_color
light color
Definition: clight.h:147
void CLIGHT::SetCastShadows ( bool  aCastShadow)
inlineinherited

Definition at line 57 of file clight.h.

References CLIGHT::m_castShadow.

Referenced by C3D_RENDER_RAYTRACING::reload().

57 { m_castShadow = aCastShadow; }
bool m_castShadow
Definition: clight.h:61
void CDIRECTIONALLIGHT::SetDirection ( const SFVEC3F aDir)
inline

SetDirection - Set directional light orientation.

Parameters
aDirvector from the light

Definition at line 129 of file clight.h.

References m_inv_direction.

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

129 { m_inv_direction = -aDir; }
SFVEC3F m_inv_direction
oposite direction of the light
Definition: clight.h:146

Member Data Documentation

bool CLIGHT::m_castShadow
protectedinherited
SFVEC3F CDIRECTIONALLIGHT::m_color
private

light color

Definition at line 147 of file clight.h.

Referenced by CDIRECTIONALLIGHT(), and GetLightParameters().

SFVEC3F CDIRECTIONALLIGHT::m_inv_direction
private

oposite direction of the light

Definition at line 146 of file clight.h.

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


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