Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
PointLight.hpp
1#pragma once
2
3#include "scene/lights/Light.hpp"
4#include "scene/Animated.hpp"
5#include "scene/Object.hpp"
6
7#include <array>
8
15class PointLight final : public Light {
16
17public:
19 PointLight() = default;
20
26 PointLight(const glm::vec3 & worldPosition, const glm::vec3 & color, float radius);
27
31 void draw(LightRenderer & renderer) override;
32
36 void update(double fullTime, double frameTime) override;
37
41 void setScene(const BoundingBox & sceneBox) override;
42
46 glm::vec3 sample(const glm::vec3 & position, float & dist, float & attenuation) const override;
47
61 bool decode(const KeyValues & params);
62
66 KeyValues encode() const override;
67
71 const glm::vec3 & position() const { return _lightPosition; }
72
76 float radius() const { return _radius; }
77
81 float farPlane() const { return _farPlane; }
82
86 const std::array<glm::mat4, 6> & vpFaces(){ return _vps; }
87
88private:
89
90 std::array<glm::mat4, 6> _vps;
91 Animated<glm::vec3> _lightPosition { glm::vec3(0.0f) };
92 float _radius = 1.0f;
93 float _farPlane = 1.0f;
94
95};
Wraps an animated property so that the initial value is preserved.
Definition: Animated.hpp:11
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
Base structure of a per-light specialized renderer.
Definition: LightRenderer.hpp:13
An omnidirectional punctual light, where light is radiating in all directions from a single point in ...
Definition: PointLight.hpp:15
std::array< glm::mat4, 6 > _vps
Light VP matrices for each face.
Definition: PointLight.hpp:90
void draw(LightRenderer &renderer) override
Definition: PointLight.cpp:12
float _radius
The attenuation radius.
Definition: PointLight.hpp:92
Animated< glm::vec3 > _lightPosition
Light position.
Definition: PointLight.hpp:91
const glm::vec3 & position() const
Definition: PointLight.hpp:71
const std::array< glm::mat4, 6 > & vpFaces()
Definition: PointLight.hpp:86
bool decode(const KeyValues &params)
Definition: PointLight.cpp:89
float farPlane() const
Definition: PointLight.hpp:81
float radius() const
Definition: PointLight.hpp:76
KeyValues encode() const override
Definition: PointLight.cpp:101
void setScene(const BoundingBox &sceneBox) override
Definition: PointLight.cpp:25
void update(double fullTime, double frameTime) override
Definition: PointLight.cpp:16
PointLight()=default
glm::vec3 sample(const glm::vec3 &position, float &dist, float &attenuation) const override
Definition: PointLight.cpp:68
float _farPlane
The projection matrices far plane.
Definition: PointLight.hpp:93
Represent a key-values tuple.
Definition: Config.hpp:9