A general light with adjustable color intensity, that can cast shadows.
More...
#include <Light.hpp>
|
std::vector< std::shared_ptr< Animation > > | _animations |
| Animations list (will be applied in order).
|
|
ShadowMap::Region | _shadowMapInfos |
| Region of the (optional) shadow map containing this light information.
|
|
BoundingBox | _sceneBox |
| The scene bounding box, to fit the shadow map.
|
|
glm::mat4 | _vp |
| VP matrix for shadow casting.
|
|
glm::mat4 | _model |
| Model matrix of the mesh containing the light-covered region.
|
|
glm::vec3 | _color |
| Colored intensity.
|
|
bool | _castShadows |
| Is the light casting shadows (and thus use a shadow map)..
|
|
A general light with adjustable color intensity, that can cast shadows.
Inherited by DirectionalLight, PointLight, and SpotLight.
◆ Light() [1/4]
◆ Light() [2/4]
Light::Light |
( |
const glm::vec3 & |
color | ) |
|
|
explicit |
Constructor
- Parameters
-
color | the light color intensity |
◆ ~Light()
virtual Light::~Light |
( |
| ) |
|
|
virtualdefault |
◆ Light() [3/4]
Light::Light |
( |
const Light & |
| ) |
|
|
delete |
◆ Light() [4/4]
Light::Light |
( |
Light && |
| ) |
|
|
default |
◆ addAnimation()
void Light::addAnimation |
( |
const std::shared_ptr< Animation > & |
anim | ) |
|
Add an animation to the light.
- Parameters
-
anim | the animation to apply |
◆ animated()
bool Light::animated |
( |
| ) |
const |
|
inline |
Check if the light is evolving over time.
- Returns
- a boolean denoting if animations are applied to the light
◆ castsShadow()
bool Light::castsShadow |
( |
| ) |
const |
|
inline |
Is the light casting shadows.
- Returns
- a boolean denoting if the light is a shadowcaster
◆ decode()
Helper that can instantiate a light of any type from the passed keywords and parameters.
- Parameters
-
params | a key-value tuple containing light parameters |
- Returns
- a generic light pointer
◆ decodeBase()
bool Light::decodeBase |
( |
const KeyValues & |
params | ) |
|
|
protected |
Setup a light common parameters from a list of key-value tuples. The following keywords will be searched for:
intensity: R,G,B
shadows: bool
animations:
- animationtype: ...
- ...
...
- Parameters
-
params | the parameters tuple list |
- Returns
- decoding status
◆ draw()
◆ encode()
Generate a key-values representation of the light. See decode for the keywords and layout.
- Returns
- a tuple representing the light
Reimplemented in DirectionalLight, PointLight, and SpotLight.
◆ intensity()
const glm::vec3 & Light::intensity |
( |
| ) |
const |
|
inline |
Get the light colored intensity.
- Returns
- the light intensity
◆ model()
const glm::mat4 & Light::model |
( |
| ) |
const |
|
inline |
Get the light mesh model matrix.
- Returns
- the model matrix
◆ operator=() [1/2]
Copy assignment.
- Returns
- a reference to the object assigned to
◆ operator=() [2/2]
Move assignment.
- Returns
- a reference to the object assigned to
◆ registerShadowMap()
void Light::registerShadowMap |
( |
const Texture * |
map, |
|
|
ShadowMode |
mode, |
|
|
size_t |
layer = 0 , |
|
|
const glm::vec2 & |
minUV = glm::vec2(0.0f) , |
|
|
const glm::vec2 & |
maxUV = glm::vec2(1.0f) |
|
) |
| |
|
inline |
Set the light shadow map (either 2D or cube depending on the light type).
- Parameters
-
map | the shadow map texture |
mode | the type of shadow map |
layer | the texture layer containing the map |
minUV | bottom-left corner of map region in the texture |
maxUV | upper-right corner of map region in the texture |
- Warning
- No check on texture type is performed.
◆ sample()
virtual glm::vec3 Light::sample |
( |
const glm::vec3 & |
position, |
|
|
float & |
dist, |
|
|
float & |
attenuation |
|
) |
| const |
|
pure virtual |
Sample a direction from a reference point to the light.
- Parameters
-
position | the 3D point |
dist | will contain the distance from the light to the point |
attenuation | will contain the light attenuation factor |
- Returns
- a direction from the point to the light
Implemented in DirectionalLight, PointLight, and SpotLight.
◆ setCastShadow()
void Light::setCastShadow |
( |
bool |
shouldCast | ) |
|
|
inline |
Set if the light should cast shadows.
- Parameters
-
shouldCast | a boolean denoting if the light is a shadowcaster |
◆ setIntensity()
void Light::setIntensity |
( |
const glm::vec3 & |
color | ) |
|
|
inline |
Set the light colored intensity.
- Parameters
-
◆ setScene()
virtual void Light::setScene |
( |
const BoundingBox & |
sceneBox | ) |
|
|
pure virtual |
◆ shadowMap()
Get the light shadow map texture (either 2D or cube depending on the light type) and location.
- Returns
- the shadow map information
◆ update()
virtual void Light::update |
( |
double |
fullTime, |
|
|
double |
frameTime |
|
) |
| |
|
pure virtual |
Apply the animations for a frame duration.
- Parameters
-
fullTime | the time since the launch of the application |
frameTime | the time elapsed since the last frame |
Implemented in DirectionalLight, PointLight, and SpotLight.
◆ vp()
const glm::mat4 & Light::vp |
( |
| ) |
const |
|
inline |
Get the light viewproj matrix.
- Returns
- the VP matrix
The documentation for this class was generated from the following files:
- src/engine/scene/lights/Light.hpp
- src/engine/scene/lights/Light.cpp