Skip to content

Scene

Root node of a renderable scene graph.

Scene is the top-level container for all nodes that participate in rendering and updates. It owns the scene graph hierarchy and optional global fog settings. Construct a scene directly with Scene::Create or by subclassing, attach nodes to it, and call Advance once per frame to drive its updates.

cpp
auto scene = vglx::Scene::Create();
scene->fog = vglx::Fog::CreateExponential({.color = 0x444444u, .density = 0.3f});

scene->Add(vglx::Mesh::Create(
  vglx::BoxGeometry::Create(),
  vglx::PhongMaterial::Create({.color = 0x049EF4u})
));

// Inside the main loop:
scene->Advance(delta);
renderer.Render(scene.get(), camera.get());

INFO

Derives from Node and inherits all public properties and methods.

Construction

Constructors


Scene()

Constructs a scene object.

cpp
Scene::Scene();

Factories preferred


Scene::Create() std::unique_ptr<Scene>

Creates an instance of Scene.

cpp
static std::unique_ptr<Scene> Scene::Create();

Properties

background std::shared_ptr<Texture>

Optional for defining a flat texture background.

cpp
std::shared_ptr<Texture> background {nullptr};

environment std::shared_ptr<Texture>

Optional environment map used as the image-based lighting source.

cpp
std::shared_ptr<Texture> environment {nullptr};

environment_intensity float

Scalar multiplier applied to the environment lighting contribution.

cpp
float environment_intensity {1.0f};

fog std::optional<Fog>

Optional global fog settings applied during rendering.

cpp
std::optional<Fog> fog {};

Functions

Advance() void

Advances the scene by one frame.

Propagates per-frame updates through the scene graph, calling OnUpdate on the scene and all attached nodes in depth-first order. Call this once per frame from your main loop.

cpp
void Scene::Advance(float delta);
ParameterDescription
deltaElapsed time in seconds since the last frame.

GetNodeType() Node::Type virtual

Identifies this node as Node::Type::Scene.

cpp
Type vglx::Scene::GetNodeType() const override;

Released under the MIT License.