Monad Engine da02fba2
> Undercity Codex_
Loading...
Searching...
No Matches
LightComponent.h
Go to the documentation of this file.
1/**
2 * @file LightComponent.h
3 * @ingroup mnd_components
4 * @brief Tags a GameObject as a point light source in the scene.
5 *
6 * When a GameObject has a LightComponent, Scene::CollectLight() picks it up
7 * during the per-frame traversal and adds a LightData entry (world position
8 * + RGB colour) to the list forwarded to RenderQueue::Draw(). The queue then
9 * uploads the light data as uniforms to every material that is drawn.
10 *
11 * ## Usage
12 * @code
13 * auto *lightObj = scene->CreateObject("SunLight");
14 * lightObj->SetPosition(vec3(10, 20, 5));
15 * auto *light = new LightComponent();
16 * light->SetColor(vec3(1.0f, 0.95f, 0.8f)); // warm white
17 * lightObj->AddComponent(light);
18 * @endcode
19 *
20 * @note Only the owner's world position is used — there is no direction,
21 * radius, or attenuation yet (point light model).
22 *
23 * @see LightData, Scene::CollectLight, RenderQueue::Draw
24 */
25
26#pragma once
27#include "scene/Component.h"
28
29namespace mnd
30{
31
32/**
33 * @brief Point light that contributes position + colour to the render pass.
34 *
35 * The world-space position is read from the owner GameObject's transform.
36 * Multiple LightComponents in the same scene are all collected and passed
37 * to every shader as a uniform array.
38 */
40{
42public:
43 /// No per-frame computation needed; position is queried from owner on demand.
44 void Update(f32 deltaTime) override;
45
46 /// Returns the linear RGB colour of this light (default: white {1,1,1}).
47 const vec3 &GetColor() const;
48
49 void LoadProperties(const nlohmann::json &json) override;
50 /**
51 * @brief Set the light's emission colour.
52 * @param color Linear RGB values in [0, 1] (HDR values > 1 are allowed).
53 */
54 void SetColor(const vec3 &color);
55
56private:
57 vec3 m_color = vec3(1.0F); ///< Emission colour; default is full-intensity white.
58};
59
60} // namespace mnd
Point light that contributes position + colour to the render pass.
void LoadProperties(const nlohmann::json &json) override
void SetColor(const vec3 &color)
Set the light's emission colour.
void Update(f32 deltaTime) override
No per-frame computation needed; position is queried from owner on demand.
const vec3 & GetColor() const
Returns the linear RGB colour of this light (default: white {1,1,1}).
#define COMPONENT(ComponentClass)
Definition Component.h:105
glm::vec3 vec3
3-component float vector (e.g. world position, RGB colour, normals).
Definition Types.h:51
float f32
32-bit IEEE float — the standard GL scalar type.
Definition Types.h:40