SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
Sleak::Light Class Referenceabstract

#include <Light.hpp>

Inheritance diagram for Sleak::Light:

Public Member Functions

 Light (const std::string &name="Light")
 ~Light () override=default
virtual RenderEngine::LightGPUEntry BuildGPUData () const =0
 Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.
bool GetCastShadows () const
Math::Vector3D GetColor () const
float GetIntensity () const
float GetLightSize () const
float GetShadowBias () const
float GetShadowNormalBias () const
float GetShadowStrength () const
bool IsEnabled () const
bool IsLight () const override
void SetCastShadows (bool cast)
void SetColor (const Math::Color &color)
void SetColor (float r, float g, float b)
void SetEnabled (bool enabled)
void SetIntensity (float intensity)
void SetLightSize (float size)
void SetShadowBias (float bias)
void SetShadowNormalBias (float bias)
void SetShadowStrength (float strength)
Public Member Functions inherited from Sleak::GameObject
 GameObject (const std::string &name="GameObject")
 ~GameObject () override
void AddChild (GameObject *child)
template<typename T, typename... Args>
void AddComponent (Args &&... args)
 Constructs and attaches a component of type T. Warns and no-ops if one already exists.
virtual void FixedUpdate (float fixedDeltaTime)
const List< GameObject * > & GetChildren () const
template<typename T>
T * GetComponent ()
 Finds the first attached component of type T, or nullptr.
GameObjectGetParent () const
const std::string & GetTag () const
bool HasChildren () const
template<typename T>
bool HasComponent ()
 True if a component of type T is attached.
bool HasParent () const
virtual void Initialize ()
 Initializes the object and its components; called once before the first Update.
bool IsActive () const
bool IsPendingDestroy () const
virtual void LateUpdate (float deltaTime)
void MarkForDestroy ()
 Flags the object for deferred destruction on the next scene pass.
void RemoveChild (GameObject *child)
template<typename T>
void RemoveComponent ()
 Destroys and detaches the first component of type T, if present.
void SetActive (bool active)
 Enables or disables the object, firing OnEnable/OnDisable on its components.
void SetParent (GameObject *parent)
 Reparents this object, updating both the old and new parent's child lists.
void SetTag (const std::string &tag)
virtual void Update (float deltaTime)
Public Member Functions inherited from Sleak::Object
 Object (const std::string &name="Object")
virtual ~Object ()=default
const std::string & GetName () const
uint64_t GetUniqueID () const
void SetName (const std::string &value)

Protected Attributes

bool m_castShadows = false
Math::Vector3D m_color {1.0f, 1.0f, 1.0f}
float m_intensity = 1.0f
bool m_lightEnabled = true
float m_lightSize = 1.0f
float m_shadowBias = 0.005f
float m_shadowNormalBias = 0.02f
float m_shadowStrength = 1.0f
Protected Attributes inherited from Sleak::GameObject
bool bIsInitialized

Additional Inherited Members

Static Public Member Functions inherited from Sleak::GameObject
static GameObjectCreateCapsule (Math::Vector3D position, int segments=16, int rings=8, float height=1, float radius=0.5)
static GameObjectCreateCube (Math::Vector3D position)
static GameObjectCreateCylinder (Math::Vector3D position, int segments=16, float height=1, float radius=0.5)
static GameObjectCreatePlane (Math::Vector3D position, int width=100, int height=100)
 Built-in primitive factories, mainly for prototyping and debug scenes.
static GameObjectCreateSphere (Math::Vector3D position, int stack=16, int slices=16)
static GameObjectCreateTorus (Math::Vector3D position, int segments=16, int rings=8, float innerRadius=8, float outerRadius=9)

Detailed Description

Base class for every light type; owns the color/intensity/shadow parameters LightManager uploads to the GPU.

Definition at line 17 of file Light.hpp.

Constructor & Destructor Documentation

◆ Light()

Sleak::Light::Light ( const std::string & name = "Light")
explicit

Definition at line 5 of file Light.cpp.

◆ ~Light()

Sleak::Light::~Light ( )
overridedefault

Member Function Documentation

◆ BuildGPUData()

virtual RenderEngine::LightGPUEntry Sleak::Light::BuildGPUData ( ) const
pure virtual

Packs this light's parameters into the GPU-side entry used by the lighting constant buffer.

Implemented in Sleak::AreaLight, Sleak::DirectionalLight, Sleak::PointLight, and Sleak::SpotLight.

◆ GetCastShadows()

bool Sleak::Light::GetCastShadows ( ) const
inline

Definition at line 40 of file Light.hpp.

◆ GetColor()

Math::Vector3D Sleak::Light::GetColor ( ) const
inline

Definition at line 29 of file Light.hpp.

◆ GetIntensity()

float Sleak::Light::GetIntensity ( ) const
inline

Definition at line 34 of file Light.hpp.

◆ GetLightSize()

float Sleak::Light::GetLightSize ( ) const
inline

Definition at line 54 of file Light.hpp.

◆ GetShadowBias()

float Sleak::Light::GetShadowBias ( ) const
inline

Definition at line 43 of file Light.hpp.

◆ GetShadowNormalBias()

float Sleak::Light::GetShadowNormalBias ( ) const
inline

Definition at line 51 of file Light.hpp.

◆ GetShadowStrength()

float Sleak::Light::GetShadowStrength ( ) const
inline

Definition at line 48 of file Light.hpp.

◆ IsEnabled()

bool Sleak::Light::IsEnabled ( ) const
inline

Definition at line 37 of file Light.hpp.

◆ IsLight()

bool Sleak::Light::IsLight ( ) const
inlineoverridevirtual

Reimplemented from Sleak::GameObject.

Definition at line 22 of file Light.hpp.

◆ SetCastShadows()

void Sleak::Light::SetCastShadows ( bool cast)
inline

Definition at line 39 of file Light.hpp.

◆ SetColor() [1/2]

void Sleak::Light::SetColor ( const Math::Color & color)

Definition at line 11 of file Light.cpp.

◆ SetColor() [2/2]

void Sleak::Light::SetColor ( float r,
float g,
float b )

Definition at line 7 of file Light.cpp.

◆ SetEnabled()

void Sleak::Light::SetEnabled ( bool enabled)
inline

Definition at line 36 of file Light.hpp.

◆ SetIntensity()

void Sleak::Light::SetIntensity ( float intensity)
inline

Definition at line 31 of file Light.hpp.

◆ SetLightSize()

void Sleak::Light::SetLightSize ( float size)
inline

Definition at line 53 of file Light.hpp.

◆ SetShadowBias()

void Sleak::Light::SetShadowBias ( float bias)
inline

Definition at line 42 of file Light.hpp.

◆ SetShadowNormalBias()

void Sleak::Light::SetShadowNormalBias ( float bias)
inline

Definition at line 50 of file Light.hpp.

◆ SetShadowStrength()

void Sleak::Light::SetShadowStrength ( float strength)
inline

Definition at line 45 of file Light.hpp.

Member Data Documentation

◆ m_castShadows

bool Sleak::Light::m_castShadows = false
protected

Definition at line 60 of file Light.hpp.

◆ m_color

Math::Vector3D Sleak::Light::m_color {1.0f, 1.0f, 1.0f}
protected

Definition at line 57 of file Light.hpp.

◆ m_intensity

float Sleak::Light::m_intensity = 1.0f
protected

Definition at line 58 of file Light.hpp.

◆ m_lightEnabled

bool Sleak::Light::m_lightEnabled = true
protected

Definition at line 59 of file Light.hpp.

◆ m_lightSize

float Sleak::Light::m_lightSize = 1.0f
protected

Definition at line 64 of file Light.hpp.

◆ m_shadowBias

float Sleak::Light::m_shadowBias = 0.005f
protected

Definition at line 61 of file Light.hpp.

◆ m_shadowNormalBias

float Sleak::Light::m_shadowNormalBias = 0.02f
protected

Definition at line 63 of file Light.hpp.

◆ m_shadowStrength

float Sleak::Light::m_shadowStrength = 1.0f
protected

Definition at line 62 of file Light.hpp.