SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
SpotLight.cpp
Go to the documentation of this file.
3
4namespace Sleak {
5
6SpotLight::SpotLight(const std::string& name) : Light(name) {}
7
10
11 entry.PositionX = m_position.GetX();
12 entry.PositionY = m_position.GetY();
13 entry.PositionZ = m_position.GetZ();
14 entry.Type = 2; // Spot
15
16 entry.DirectionX = m_direction.GetX();
17 entry.DirectionY = m_direction.GetY();
18 entry.DirectionZ = m_direction.GetZ();
19 entry.Intensity = m_intensity;
20
21 entry.ColorR = m_color.GetX();
22 entry.ColorG = m_color.GetY();
23 entry.ColorB = m_color.GetZ();
24 entry.Range = m_range;
25
26 // Convert degrees to cosines for GPU
27 float innerRad =
28 m_innerAngleDeg * static_cast<float>(M_PI) / 180.0f;
29 float outerRad =
30 m_outerAngleDeg * static_cast<float>(M_PI) / 180.0f;
31 entry.SpotInnerCos = std::cos(innerRad);
32 entry.SpotOuterCos = std::cos(outerRad);
33 entry.AreaWidth = 0.0f;
34 entry.AreaHeight = 0.0f;
35
36 return entry;
37}
38
39} // namespace Sleak
#define M_PI
Definition SpotLight.hpp:8
Math::Vector3D m_color
Definition Light.hpp:57
Light(const std::string &name="Light")
Definition Light.cpp:5
float m_intensity
Definition Light.hpp:58
SpotLight(const std::string &name="SpotLight")
Definition SpotLight.cpp:6
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
Root namespace for everything the engine exposes.
Definition Camera.hpp:10
One light's packed GPU representation, laid out for std140/cbuffer alignment.