SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
AreaLight.hpp
Go to the documentation of this file.
1#ifndef _AREA_LIGHT_HPP_
2#define _AREA_LIGHT_HPP_
3
4#include <Lighting/Light.hpp>
5
6namespace Sleak {
7
8 /// Emitting surface shape for an AreaLight.
9 /// @ingroup lighting
10 enum class AreaLightShape : uint8_t {
12 Disc = 1
13 };
14
15 /// Light emitted from a rectangular or disc surface rather than a point.
16 /// @ingroup lighting
17 class ENGINE_API AreaLight : public Light {
18 public:
19 explicit AreaLight(const std::string& name = "AreaLight");
20 ~AreaLight() override = default;
21
23
24 void SetPosition(const Math::Vector3D& pos) {
25 m_position = pos;
26 }
27 Math::Vector3D GetPosition() const { return m_position; }
28
29 void SetDirection(const Math::Vector3D& dir) {
30 m_direction = dir;
31 m_direction.Normalize();
32 }
33 Math::Vector3D GetDirection() const { return m_direction; }
34
35 void SetRange(float range) { m_range = range; }
36 float GetRange() const { return m_range; }
37
38 void SetWidth(float width) { m_width = width; }
39 float GetWidth() const { return m_width; }
40
41 void SetHeight(float height) { m_height = height; }
42 float GetHeight() const { return m_height; }
43
44 void SetShape(AreaLightShape shape) { m_shape = shape; }
45 AreaLightShape GetShape() const { return m_shape; }
46
47 void SetTwoSided(bool twoSided) { m_twoSided = twoSided; }
48 bool IsTwoSided() const { return m_twoSided; }
49
50 private:
51 Math::Vector3D m_position{0.0f, 0.0f, 0.0f};
52 Math::Vector3D m_direction{0.0f, -1.0f, 0.0f};
53 float m_range = 10.0f;
54 float m_width = 1.0f;
55 float m_height = 1.0f;
56 AreaLightShape m_shape = AreaLightShape::Rectangle;
57 bool m_twoSided = false;
58 };
59
60} // namespace Sleak
61
62#endif // _AREA_LIGHT_HPP_
int width
int height
void SetShape(AreaLightShape shape)
Definition AreaLight.hpp:44
float GetRange() const
Definition AreaLight.hpp:36
AreaLight(const std::string &name="AreaLight")
Definition AreaLight.cpp:6
bool IsTwoSided() const
Definition AreaLight.hpp:48
void SetDirection(const Math::Vector3D &dir)
Definition AreaLight.hpp:29
void SetRange(float range)
Definition AreaLight.hpp:35
RenderEngine::LightGPUEntry BuildGPUData() const override
Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.
Definition AreaLight.cpp:8
void SetWidth(float width)
Definition AreaLight.hpp:38
~AreaLight() override=default
void SetPosition(const Math::Vector3D &pos)
Definition AreaLight.hpp:24
AreaLightShape GetShape() const
Definition AreaLight.hpp:45
float GetHeight() const
Definition AreaLight.hpp:42
void SetTwoSided(bool twoSided)
Definition AreaLight.hpp:47
void SetHeight(float height)
Definition AreaLight.hpp:41
Math::Vector3D GetPosition() const
Definition AreaLight.hpp:27
Math::Vector3D GetDirection() const
Definition AreaLight.hpp:33
float GetWidth() const
Definition AreaLight.hpp:39
Light(const std::string &name="Light")
Definition Light.cpp:5
Vector3D & Normalize()
Definition Vector.hpp:435
AreaLightShape
Definition AreaLight.hpp:10
Root namespace for everything the engine exposes.
Definition Camera.hpp:10
One light's packed GPU representation, laid out for std140/cbuffer alignment.