DirectionalLight
This light will behave as though it is infinitely far away and the rays produced from it are all parallel. The common use case for this is to simulate daylight; the sun is far enough away that its position can be considered to be infinite, and all light rays coming from it are parallel.
auto directional_light = vglx::DirectionalLight::Create({
.color = 0xFFFFFF,
.intensity = 1.0f,
.target = nullptr
});
When the target parameter is set to nullptr
the light points to (0, 0, 0).
INFO
Derives from Light and inherits all public properties and methods.
Construction
Constructors
DirectionalLight()
vglx::DirectionalLight::DirectionalLight(const Parameters ¶ms)
Parameter | Description |
---|---|
params | DirectionalLight::Parameters |
Constructs a DirectionalLight object.
Factories preferred
DirectionalLight::Create() auto
static auto vglx::DirectionalLight::Create(const Parameters ¶ms)
Parameter | Description |
---|---|
params | DirectionalLight::Parameters |
Creates a shared pointer to an DirectionalLight object.
Types
DirectionalLight::Parameters struct
Parameters for constructing a DirectionalLight object.
Name | Type | Description |
---|---|---|
color | Color | Light color. |
intensity | float | Light intensity. |
target | std::shared_ptr<Node> | Light target position. |
Properties
Node that the light is directed towards.
Functions
Vector3 vglx::DirectionalLight::Direction()
Returns the direction vector of the light. Calculates and returns the normalized direction in which the directional light is pointing. The direction is determined based on the light's position and its target node.
GetType() LightType virtual
LightType vglx::DirectionalLight::GetType() const override
Returns light type.
OnUpdate() void virtual
void vglx::DirectionalLight::OnUpdate(float delta) override
Parameter | Description |
---|---|
delta | Time in seconds since the last update. |
Updates the light each frame.
SetDebugMode() void virtual
void vglx::DirectionalLight::SetDebugMode(bool is_debug_mode) override
Parameter | Description |
---|---|
is_debug_mode | True to enable debug mode, false to disable. |
Sets debug mode.