sculpto
Public Member Functions | Public Attributes | List of all members
scl::directional_light_component Struct Reference

#include <directional_light_component.h>

Public Member Functions

bool GetIsShadow () const
 
float GetBoxSize () const
 
float GetBoxDepth () const
 
const matr4GetProjection () const
 
int GetShadowMapWidth () const
 
int GetShadowMapHeight () const
 
const shared< frame_buffer > & GetShadowMap () const
 
void EnableShadows (float BoxSize=10, float BoxDepth=100, int ShadowMapWidth=1000, int ShadowMapHeight=1000)
 
void DisableShadows ()
 
void SetIsShadows (bool IsShadows)
 
void SetBoxSize (float BoxSize)
 
void SetBoxDepth (float BoxDepth)
 
void SetShadowMapWidth (int ShadowMapWidth)
 
void SetShadowMapHeight (int ShadowMapHeight)
 
 directional_light_component ()=default
 
 directional_light_component (const directional_light_component &Other)=default
 
 directional_light_component (const vec3 &Color, bool IsShadows=false, float BoxSize=10, float BoxDepth=0, int ShadowMapWidth=1000, int ShadowMapHeight=1000)
 
 ~directional_light_component ()=default
 

Public Attributes

vec3 Color {}
 
float Strength { 1 }
 

Detailed Description

Directional light component class.

Definition at line 17 of file directional_light_component.h.

Constructor & Destructor Documentation

◆ directional_light_component() [1/3]

scl::directional_light_component::directional_light_component ( )
default

Directional light methods.

◆ directional_light_component() [2/3]

scl::directional_light_component::directional_light_component ( const directional_light_component Other)
default

◆ directional_light_component() [3/3]

scl::directional_light_component::directional_light_component ( const vec3 Color,
bool  IsShadows = false,
float  BoxSize = 10,
float  BoxDepth = 0,
int  ShadowMapWidth = 1000,
int  ShadowMapHeight = 1000 
)
inline

Definition at line 124 of file directional_light_component.h.

125 : Color(Color)
126 {
127 if (IsShadows) EnableShadows(BoxSize, BoxDepth, ShadowMapWidth, ShadowMapHeight);
128 }
void EnableShadows(float BoxSize=10, float BoxDepth=100, int ShadowMapWidth=1000, int ShadowMapHeight=1000)

◆ ~directional_light_component()

scl::directional_light_component::~directional_light_component ( )
default

Member Function Documentation

◆ DisableShadows()

void scl::directional_light_component::DisableShadows ( )
inline
  • Disable directional light shadow casting function.
Parameters
None.
Returns
None.

Definition at line 72 of file directional_light_component.h.

73 {
74 this->IsShadows = false;
75 if (ShadowMap) ShadowMap->Free();
76 ShadowMap.reset();
77 }

◆ EnableShadows()

void scl::directional_light_component::EnableShadows ( float  BoxSize = 10,
float  BoxDepth = 100,
int  ShadowMapWidth = 1000,
int  ShadowMapHeight = 1000 
)
inline
  • Enable directiona light shadow casting function.
Parameters
BoxSize- ortho projection shadow caster box width.
BoxDepth- ortho projecction shadow caster box depth.
ShadowMapWidth- shadow map frame buffer width in pixels.
ShadowMapHeight- shadow map frame buffer height in pixels.

Definition at line 55 of file directional_light_component.h.

57 {
58 this->IsShadows = true;
59 this->BoxSize = BoxSize;
60 this->BoxDepth = BoxDepth;
61 this->ShadowMapWidth = ShadowMapWidth, this->ShadowMapHeight = ShadowMapHeight;
62 Projection = matr4::Ortho(-BoxSize, BoxSize, -BoxSize, BoxSize, 1, BoxDepth);
63 ShadowMap = frame_buffer::Create(frame_buffer_props { ShadowMapWidth, ShadowMapHeight, 1, false, 0, 1 });
64 }
static shared< frame_buffer > Create(const frame_buffer_props &Props)
static matr4 Ortho(float Left, float Right, float Bottom, float Top, float Near, float Far)
Definition: matr4.h:375

◆ GetBoxDepth()

float scl::directional_light_component::GetBoxDepth ( ) const
inline

Ortho projecction shadow caster box depth getter function.

Definition at line 38 of file directional_light_component.h.

38{ return BoxDepth; }

◆ GetBoxSize()

float scl::directional_light_component::GetBoxSize ( ) const
inline

Ortho projection shadow caster box width getter function.

Definition at line 36 of file directional_light_component.h.

36{ return BoxSize; }

◆ GetIsShadow()

bool scl::directional_light_component::GetIsShadow ( ) const
inline

Directiona light data getter/setter functions.

Flag, showing wheather directional light is shadow caster or not getter function.

Definition at line 34 of file directional_light_component.h.

34{ return IsShadows; }

◆ GetProjection()

const matr4 & scl::directional_light_component::GetProjection ( ) const
inline

Directiona light projection matrix getter function.

Definition at line 40 of file directional_light_component.h.

40{ return Projection; }

◆ GetShadowMap()

const shared< frame_buffer > & scl::directional_light_component::GetShadowMap ( ) const
inline

Definition at line 45 of file directional_light_component.h.

45{ return ShadowMap; }

◆ GetShadowMapHeight()

int scl::directional_light_component::GetShadowMapHeight ( ) const
inline

Shadow map frame buffer height in pixels getter function.

Definition at line 44 of file directional_light_component.h.

44{ return ShadowMapHeight; }

◆ GetShadowMapWidth()

int scl::directional_light_component::GetShadowMapWidth ( ) const
inline

Shadow map frame buffer width in pixels getter function.

Definition at line 42 of file directional_light_component.h.

42{ return ShadowMapWidth; }

◆ SetBoxDepth()

void scl::directional_light_component::SetBoxDepth ( float  BoxDepth)
inline

Ortho projecction shadow caster box depth getter function.

Definition at line 99 of file directional_light_component.h.

100 {
101 this->BoxDepth = BoxDepth;
102 Projection = matr4::Ortho(-BoxSize, BoxSize, -BoxSize, BoxSize, 1, BoxDepth);
103 }

◆ SetBoxSize()

void scl::directional_light_component::SetBoxSize ( float  BoxSize)
inline

Ortho projection shadow caster box width getter function.

Definition at line 92 of file directional_light_component.h.

93 {
94 this->BoxSize = BoxSize;
95 Projection = matr4::Ortho(-BoxSize, BoxSize, -BoxSize, BoxSize, 1, BoxDepth);
96 }

◆ SetIsShadows()

void scl::directional_light_component::SetIsShadows ( bool  IsShadows)
inline
  • Set flag, showing wheather directiona light casing shadows or not function.
Parameters
IsShadows- flag, showing wheather directiona light casing shadows or not function.
Returns
None.

Definition at line 85 of file directional_light_component.h.

86 {
87 if (IsShadows) EnableShadows();
88 else DisableShadows();
89 }

◆ SetShadowMapHeight()

void scl::directional_light_component::SetShadowMapHeight ( int  ShadowMapHeight)
inline

Shadow map frame buffer height in pixels getter function.

Definition at line 114 of file directional_light_component.h.

115 {
116 this->ShadowMapHeight = ShadowMapHeight;
117 if (!ShadowMap) return;
118 ShadowMap->Resize(ShadowMapWidth, ShadowMapHeight);
119 }

◆ SetShadowMapWidth()

void scl::directional_light_component::SetShadowMapWidth ( int  ShadowMapWidth)
inline

Shadow map frame buffer width in pixels getter function.

Definition at line 106 of file directional_light_component.h.

107 {
108 this->ShadowMapWidth = ShadowMapWidth;
109 if (!ShadowMap) return;
110 ShadowMap->Resize(ShadowMapWidth, ShadowMapHeight);
111 }

Member Data Documentation

◆ Color

vec3 scl::directional_light_component::Color {}

Light color.

Definition at line 29 of file directional_light_component.h.

◆ Strength

float scl::directional_light_component::Strength { 1 }

Definition at line 30 of file directional_light_component.h.


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