3#include "scene/Animation.hpp"
4#include "scene/Object.hpp"
5#include "raycaster/Raycaster.hpp"
6#include "renderers/LightRenderer.hpp"
7#include "renderers/shadowmaps/ShadowMap.hpp"
10enum class LightType :
int {
29 explicit Light(
const glm::vec3 & color);
34 void addAnimation(
const std::shared_ptr<Animation> & anim);
45 virtual void update(
double fullTime,
double frameTime) = 0;
58 virtual glm::vec3
sample(
const glm::vec3 & position,
float & dist,
float & attenuation)
const = 0;
88 const glm::mat4 &
vp()
const {
return _vp; }
Represent the smallest axis-aligne box containing a given object or region of space.
Definition: Bounds.hpp:28
A general light with adjustable color intensity, that can cast shadows.
Definition: Light.hpp:20
const glm::mat4 & vp() const
Definition: Light.hpp:88
ShadowMap::Region _shadowMapInfos
Region of the (optional) shadow map containing this light information.
Definition: Light.hpp:164
static std::shared_ptr< Light > decode(const KeyValues ¶ms)
Definition: Light.cpp:45
Light & operator=(Light &&)=delete
const ShadowMap::Region & shadowMap() const
Definition: Light.hpp:98
bool castsShadow() const
Definition: Light.hpp:68
bool _castShadows
Is the light casting shadows (and thus use a shadow map)..
Definition: Light.hpp:169
virtual void setScene(const BoundingBox &sceneBox)=0
virtual void update(double fullTime, double frameTime)=0
bool animated() const
Definition: Light.hpp:119
BoundingBox _sceneBox
The scene bounding box, to fit the shadow map.
Definition: Light.hpp:165
Light & operator=(const Light &)=delete
void setIntensity(const glm::vec3 &color)
Definition: Light.hpp:83
glm::mat4 _vp
VP matrix for shadow casting.
Definition: Light.hpp:166
bool decodeBase(const KeyValues ¶ms)
Definition: Light.cpp:19
virtual glm::vec3 sample(const glm::vec3 &position, float &dist, float &attenuation) const =0
const glm::vec3 & intensity() const
Definition: Light.hpp:78
std::vector< std::shared_ptr< Animation > > _animations
Animations list (will be applied in order).
Definition: Light.hpp:163
void addAnimation(const std::shared_ptr< Animation > &anim)
Definition: Light.cpp:15
const glm::mat4 & model() const
Definition: Light.hpp:93
glm::mat4 _model
Model matrix of the mesh containing the light-covered region.
Definition: Light.hpp:167
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))
Definition: Light.hpp:108
virtual KeyValues encode() const
Definition: Light.cpp:34
Light()
Definition: Light.cpp:7
Light(const Light &)=delete
glm::vec3 _color
Colored intensity.
Definition: Light.hpp:168
void setCastShadow(bool shouldCast)
Definition: Light.hpp:73
virtual void draw(LightRenderer &renderer)=0
Base structure of a per-light specialized renderer.
Definition: LightRenderer.hpp:13
Represents a texture containing one or more images, stored on the CPU and/or GPU.
Definition: Texture.hpp:12
ShadowMode
Available shadow mapping techniques.
Definition: ShadowMap.hpp:14
Represent a key-values tuple.
Definition: Config.hpp:9
Definition: ShadowMap.hpp:55
size_t layer
The layer containing the shadow map.
Definition: ShadowMap.hpp:60
const Texture * map
The texture reference.
Definition: ShadowMap.hpp:56
glm::vec2 minUV
The bottom-left corner of the texture region.
Definition: ShadowMap.hpp:58
glm::vec2 maxUV
The upper-right corner of the texture region.
Definition: ShadowMap.hpp:59
ShadowMode mode
The shadow mode to use.
Definition: ShadowMap.hpp:57