Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Light Class Referenceabstract

A general light with adjustable color intensity, that can cast shadows. More...

#include <Light.hpp>

Public Member Functions

 Light ()
 
 Light (const glm::vec3 &color)
 
void addAnimation (const std::shared_ptr< Animation > &anim)
 
virtual void draw (LightRenderer &renderer)=0
 
virtual void update (double fullTime, double frameTime)=0
 
virtual void setScene (const BoundingBox &sceneBox)=0
 
virtual glm::vec3 sample (const glm::vec3 &position, float &dist, float &attenuation) const =0
 
virtual KeyValues encode () const
 
bool castsShadow () const
 
void setCastShadow (bool shouldCast)
 
const glm::vec3 & intensity () const
 
void setIntensity (const glm::vec3 &color)
 
const glm::mat4 & vp () const
 
const glm::mat4 & model () const
 
const ShadowMap::RegionshadowMap () const
 
void 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))
 
bool animated () const
 
virtual ~Light ()=default
 
 Light (const Light &)=delete
 
Lightoperator= (const Light &)=delete
 
 Light (Light &&)=default
 
Lightoperator= (Light &&)=delete
 

Static Public Member Functions

static std::shared_ptr< Lightdecode (const KeyValues &params)
 

Protected Member Functions

bool decodeBase (const KeyValues &params)
 

Protected Attributes

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

Detailed Description

A general light with adjustable color intensity, that can cast shadows.

Inherited by DirectionalLight, PointLight, and SpotLight.

Constructor & Destructor Documentation

◆ Light() [1/4]

Light::Light ( )

Default constructor.

◆ Light() [2/4]

Light::Light ( const glm::vec3 &  color)
explicit

Constructor

Parameters
colorthe light color intensity

◆ ~Light()

virtual Light::~Light ( )
virtualdefault

Destructor.

◆ Light() [3/4]

Light::Light ( const Light )
delete

Copy constructor.

◆ Light() [4/4]

Light::Light ( Light &&  )
default

Move constructor.

Member Function Documentation

◆ addAnimation()

void Light::addAnimation ( const std::shared_ptr< Animation > &  anim)

Add an animation to the light.

Parameters
animthe 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()

std::shared_ptr< Light > Light::decode ( const KeyValues params)
static

Helper that can instantiate a light of any type from the passed keywords and parameters.

Parameters
paramsa 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
paramsthe parameters tuple list
Returns
decoding status

◆ draw()

virtual void Light::draw ( LightRenderer renderer)
pure virtual

Process the light using a specific renderer.

See also
LightRenderer for the expected interface details.
Parameters
rendererthe light-specific renderer

Implemented in DirectionalLight, PointLight, and SpotLight.

◆ encode()

KeyValues Light::encode ( ) const
virtual

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]

Light & Light::operator= ( const Light )
delete

Copy assignment.

Returns
a reference to the object assigned to

◆ operator=() [2/2]

Light & Light::operator= ( Light &&  )
delete

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
mapthe shadow map texture
modethe type of shadow map
layerthe texture layer containing the map
minUVbottom-left corner of map region in the texture
maxUVupper-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
positionthe 3D point
distwill contain the distance from the light to the point
attenuationwill 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
shouldCasta boolean denoting if the light is a shadowcaster

◆ setIntensity()

void Light::setIntensity ( const glm::vec3 &  color)
inline

Set the light colored intensity.

Parameters
colorthe light intensity

◆ setScene()

virtual void Light::setScene ( const BoundingBox sceneBox)
pure virtual

Update the scene bounding box used for internal setup (shadow map,...).

Parameters
sceneBoxthe new bounding box

Implemented in DirectionalLight, PointLight, and SpotLight.

◆ shadowMap()

const ShadowMap::Region & Light::shadowMap ( ) const
inline

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
fullTimethe time since the launch of the application
frameTimethe 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: