Skip to content

DirectionalLight

Represents a light that gets emitted in a specific direction.

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.

cpp
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()

cpp
vglx::DirectionalLight::DirectionalLight(const Parameters &params)
ParameterDescription
paramsDirectionalLight::Parameters

Constructs a DirectionalLight object.

Factories preferred


DirectionalLight::Create() auto

cpp
static auto vglx::DirectionalLight::Create(const Parameters &params)
ParameterDescription
paramsDirectionalLight::Parameters

Creates a shared pointer to an DirectionalLight object.

Types

DirectionalLight::Parameters struct

Parameters for constructing a DirectionalLight object.

NameTypeDescription
colorColorLight color.
intensityfloatLight intensity.
targetstd::shared_ptr<Node>Light target position.

Properties

target std::shared_ptr<Node>

cpp
std::shared_ptr<Node> target

Node that the light is directed towards.

Functions

Direction() Vector3

cpp
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

cpp
LightType vglx::DirectionalLight::GetType() const override

Returns light type.

OnUpdate() void virtual

cpp
void vglx::DirectionalLight::OnUpdate(float delta) override
ParameterDescription
deltaTime in seconds since the last update.

Updates the light each frame.

SetDebugMode() void virtual

cpp
void vglx::DirectionalLight::SetDebugMode(bool is_debug_mode) override
ParameterDescription
is_debug_modeTrue to enable debug mode, false to disable.

Sets debug mode.

Released under the MIT License.