Lysa Nodes  0.0
Lysa Nodes — Scene Graph for the Lysa Engine
Node

lysa::nodes::Node

Node is the base class for every object in a Lysa Nodes scene. It provides the parent-child hierarchy, world/local transforms, visibility, processing mode, groups, and a set of virtual callbacks that the engine calls each frame.

Transform API

Every node stores two matrices:

Field Description
localTransform (getTransform()) Transform relative to the parent
globalTransform (getTransformGlobal()) World-space transform

setTransform(float4x4) replaces the local matrix and immediately propagates globalTransform to all descendants. Convenience helpers avoid building matrices by hand:

Method Effect
setPosition(x, y, z) Set the local translation
translate(x, y, z) Offset the local translation
setPositionGlobal(x, y, z) Set the world position
setRotation(quaternion) Replace the local rotation
setRotationY(angle) Set a single-axis rotation
rotateX/Y/Z(angle) Incrementally rotate in local space
rotateGlobalX/Y/Z(angle) Incrementally rotate in world space
setScale(float3) Set the local scale

getPosition() returns localTransform[3].xyz (the translation component). getRotation() extracts a quaternion from the upper 3×3 of the local matrix.

Lifecycle callbacks

The engine calls virtual methods on a node at key moments. Override any of these in a subclass:

Method When called
onReady() Once, after the scene tree is fully built
onEnterScene() Each time the node is attached to a scene
onExitScene() Each time the node is detached
onProcess(float alpha) Once per rendered frame (variable delta)
onPhysicsProcess(float delta) Once per physics tick (fixed delta)
onInput(InputEvent&) On keyboard, mouse, or gamepad input

onProcess and onPhysicsProcess receive the time elapsed since the previous call of the same type (seconds).

isProcessed() and ProcessMode

A node's onProcess and onPhysicsProcess are only called when isProcessed() returns true. The result depends on the node's ProcessMode and whether the scene tree is paused:

ProcessMode Paused scene Running scene
INHERIT Follows parent Follows parent
PAUSABLE Stops Processes
WHEN_PAUSED Processes Stops
ALWAYS Processes Processes
DISABLED Stops Stops

The root nodes of a scene tree inherit from the tree's own running state.

Child management

addChild(child) attaches a node to the tree. If the scene is already attached to a render target, the child is registered with the renderer immediately. If the scene is not yet attached, the child is registered when SceneTree::attach() is called later.

removeChild(child) detaches the node from the renderer and removes it from the children list. Whether the node is destroyed depends on whether any other shared_ptr holds a reference to it.

findFirstChild<T>(name) and findAllChildren<T>() provide typed tree traversal without raw casts.

In this tutorial

Three plain Node instances are used in this tutorial:

  • assetRoot : the root returned by Loader::load. Its local transform is replaced each frame to drive the Y-axis rotation.
  • cameraAttachment : an invisible pivot that holds the camera's world position and accumulates yaw rotations.
  • cameraPivot : a child of attachment that accumulates pitch rotations.

Neither cameraAttachment nor cameraPivot overrides any callback; they exist purely as transform containers. setTransform on either node automatically propagates to their children, including the Camera node, which updates the scene tree's active camera via its updateGlobalTransform override.

Next : Scene tree