Copperfield Engine 0.1
C++ Game Engine
Loading...
Searching...
No Matches
LightCmp Struct Reference

Component used to simulate different types of lights. More...

#include <default_components.hpp>

Public Member Functions

void calculateAttenuation ()
 After modifying max_distance_, this function should be called to update the rest of the parameters related to kPoint attenuation.
 
 LightCmp (const LightType type, const coma::Vec3 &color, const float intensity)
 Creates a LightCmp of the specified LightType. More...
 
 LightCmp (const coma::Vec3 &color, const float intensity, const float max_distance)
 Creates a kPoint. More...
 
 LightCmp (const coma::Vec3 &color, const float intensity, const float cutoff_angle, float falloff_start)
 Creates a kSpot. More...
 

Public Attributes

LightType type_ = LightType::kPoint
 Define the light type.
 
coma::Vec3 light_color_ = coma::Vec3(1.0f, 1.0f, 1.0f)
 Define the color of the light.
 
float intensity_ = 1.0f
 Define the power of the light.
 
float max_distance_ = 13.0f
 Distance at which the light intensity will become 0 due to attenuation.
 
float constant_value_ = 1.0f
 Can be handled with max_distance_.
 
float linear_value_ = 0.01f
 Can be handled with max_distance_.
 
float quadratic_value_ = 0.01f
 Can be handled with max_distance_.
 
float cutoff_angle_ = 50.0f
 Radius of the spot light.
 
float falloff_start_ = 0.8f
 Percentage of the cutoff_angle_ at which the light starts to attenuate.
 
bool show_shadows_ = true
 Define if the light shows shadows.
 

Detailed Description

Component used to simulate different types of lights.

Some of the member variables may not be used depending on the chosen LightType.

Constructor & Destructor Documentation

◆ LightCmp() [1/3]

LightCmp::LightCmp ( const LightType  type,
const coma::Vec3 color,
const float  intensity 
)
inline

Creates a LightCmp of the specified LightType.

Parameters
typetype_
colorlight_color_
intensityintensity_

Using this constructor will probably require you to set the desired parameters of the chosen LightType afterward.

◆ LightCmp() [2/3]

LightCmp::LightCmp ( const coma::Vec3 color,
const float  intensity,
const float  max_distance 
)
inline

Creates a kPoint.

Parameters
colorlight_color_
intensityintensity_
max_distancemax_distance_

◆ LightCmp() [3/3]

LightCmp::LightCmp ( const coma::Vec3 color,
const float  intensity,
const float  cutoff_angle,
float  falloff_start 
)
inline

Creates a kSpot.

Parameters
colorlight_color_
intensityintensity_
cutoff_anglecutoff_angle_
falloff_startfalloff_start_