SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
SpotLight.hpp
Go to the documentation of this file.
1#ifndef _SPOT_LIGHT_HPP_
2#define _SPOT_LIGHT_HPP_
3
4#include <Lighting/Light.hpp>
5#include <cmath>
6
7#ifndef M_PI
8#define M_PI 3.14159265358979323846
9#endif
10
11namespace Sleak {
12
13 /// Cone light with separate inner/outer cone angles for a soft penumbra edge.
14 /// @ingroup lighting
15 class ENGINE_API SpotLight : public Light {
16 public:
17 explicit SpotLight(const std::string& name = "SpotLight");
18 ~SpotLight() override = default;
19
21
22 void SetPosition(const Math::Vector3D& pos) {
23 m_position = pos;
24 }
25 Math::Vector3D GetPosition() const { return m_position; }
26
27 void SetDirection(const Math::Vector3D& dir) {
28 m_direction = dir;
29 m_direction.Normalize();
30 }
31 Math::Vector3D GetDirection() const { return m_direction; }
32
33 void SetRange(float range) { m_range = range; }
34 float GetRange() const { return m_range; }
35
36 // Angles in degrees
37 void SetInnerConeAngle(float degrees) {
38 m_innerAngleDeg = degrees;
39 }
40 float GetInnerConeAngle() const { return m_innerAngleDeg; }
41
42 void SetOuterConeAngle(float degrees) {
43 m_outerAngleDeg = degrees;
44 }
45 float GetOuterConeAngle() const { return m_outerAngleDeg; }
46
47 private:
48 Math::Vector3D m_position{0.0f, 0.0f, 0.0f};
49 Math::Vector3D m_direction{0.0f, -1.0f, 0.0f};
50 float m_range = 10.0f;
51 float m_innerAngleDeg = 20.0f;
52 float m_outerAngleDeg = 30.0f;
53 };
54
55} // namespace Sleak
56
57#endif // _SPOT_LIGHT_HPP_
Light(const std::string &name="Light")
Definition Light.cpp:5
Vector3D & Normalize()
Definition Vector.hpp:435
float GetRange() const
Definition SpotLight.hpp:34
~SpotLight() override=default
void SetInnerConeAngle(float degrees)
Definition SpotLight.hpp:37
void SetPosition(const Math::Vector3D &pos)
Definition SpotLight.hpp:22
void SetOuterConeAngle(float degrees)
Definition SpotLight.hpp:42
void SetRange(float range)
Definition SpotLight.hpp:33
Math::Vector3D GetDirection() const
Definition SpotLight.hpp:31
Math::Vector3D GetPosition() const
Definition SpotLight.hpp:25
SpotLight(const std::string &name="SpotLight")
Definition SpotLight.cpp:6
float GetOuterConeAngle() const
Definition SpotLight.hpp:45
RenderEngine::LightGPUEntry BuildGPUData() const override
Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.
Definition SpotLight.cpp:8
void SetDirection(const Math::Vector3D &dir)
Definition SpotLight.hpp:27
float GetInnerConeAngle() const
Definition SpotLight.hpp:40
Root namespace for everything the engine exposes.
Definition Camera.hpp:10
One light's packed GPU representation, laid out for std140/cbuffer alignment.