Node
Node represents a transformable object that can be placed within a scene graph hierarchy. Nodes support local and world transforms, parent-child relationships, and can respond to events and updates. All renderable, light-emitting, and camera entities in the engine inherit from this class.
Nodes can be organized in a tree structure, and transformations will propagate through the hierarchy. When attached to a scene, nodes gain access to the shared context and may perform initialization in OnAttached.
To define behavior, override virtual methods such as OnUpdate, OnKeyboardEvent, or OnMouseEvent.
Construction
Constructors
Node()
Constructs an Node instance.
Node::Node();Factories preferred
Node::Create() auto
Creates a shared pointer to a Node object.
static auto Node::Create();Types
Node::Type enum
Enumerates all node types.
Each node subclass identifies its type through Node::GetNodeType, allowing runtime checks and scene traversal logic to distinguish between different kinds of nodes. The engine uses these identifiers internally for tasks such as culling, rendering, and event dispatch.
| Value | Description |
|---|---|
| Camera | Perspective or orthographic camera. |
| Default | Generic node without special behavior. |
| InstancedMesh | Node containing instanced geometry. |
| Light | Light source (directional, point, or spot). |
| Mesh | Single mesh with an associated material. |
| Renderable | Any node that can be rendered to the screen. |
| Scene | Root of a scene hierarchy. |
| Sprite | Billboarded sprite. |
Properties
frustum_culled bool
If true, the node is subject to frustum culling during rendering.
bool frustum_culled {true};transform Transform3
Local transformation.
Transform3 transform {};transform_auto_update bool
If true, the local transform is automatically updated before rendering.
bool transform_auto_update {true};Functions
LookAt() void virtual
Rotates the node to face a given target position in world space.
virtual void Node::LookAt(const Vector3& target);| Parameter | Description |
|---|---|
| target | Target world-space position to look at. |
TranslateX() auto
Translates the node along the X axis in local space.
auto Node::TranslateX(float value);| Parameter | Description |
|---|---|
| value | Translation distance. |
TranslateY() auto
Translates the node along the Y axis in local space.
auto Node::TranslateY(float value);| Parameter | Description |
|---|---|
| value | Translation distance. |
TranslateZ() auto
Translates the node along the Z axis in local space.
auto Node::TranslateZ(float value);| Parameter | Description |
|---|---|
| value | Translation distance. |
RotateX() auto
Rotates the node along the X axis in local space.
auto Node::RotateX(float angle);| Parameter | Description |
|---|---|
| angle | Rotation angle in radians. |
RotateY() auto
Rotates the node along the Y axis in local space.
auto Node::RotateY(float angle);| Parameter | Description |
|---|---|
| angle | Rotation angle in radians. |
RotateZ() auto
Rotates the node along the Z axis in local space.
auto Node::RotateZ(float angle);| Parameter | Description |
|---|---|
| angle | Rotation angle in radians. |
SetScale() auto
Scales the node non-uniformly in local space.
auto Node::SetScale(const Vector3& value);| Parameter | Description |
|---|---|
| value | Scale vector applied to the X, Y, and Z axes. |
OnUpdate() void virtual
Called every frame.
Override this method to implement per-frame logic or animation.
virtual void Node::OnUpdate(float delta);| Parameter | Description |
|---|---|
| delta | Time in seconds since the last frame. |
OnAttached() void virtual
Called when the node becomes part of an attached scene.
This method is invoked when the node is added to a scene that is currently attached to the application context. The shared context is guaranteed to be initialized and available. Use this hook to perform resource loading or event registration that depends on application state.
virtual void Node::OnAttached(SharedContextPointer context);| Parameter | Description |
|---|---|
| context | Pointer to the shared context. |
OnKeyboardEvent() void virtual
Called when a keyboard event is dispatched to this node.
Override to handle key presses or releases.
virtual void Node::OnKeyboardEvent(KeyboardEvent* event);| Parameter | Description |
|---|---|
| event | Pointer to the dispatched keyboard event. |
OnMouseEvent() void virtual
Called when a mouse event is dispatched to this node.
Override to handle mouse movement, clicks, or scrolling.
virtual void Node::OnMouseEvent(MouseEvent* event);| Parameter | Description |
|---|---|
| event | Pointer to the dispatched mouse event. |
Add() void
Adds a child node to this node.
void Node::Add(const std::shared_ptr<Node> & node);| Parameter | Description |
|---|---|
| node | Child node to add. |
Returns the list of child nodes.
const std::vector<std::shared_ptr< Node> > & Node::Children() const;GetNodeType() Node::Type virtual
Returns node type.
virtual Type vglx::Node::GetNodeType() const;Returns the world-space position of this node.
Vector3 Node::GetWorldPosition();Returns the world transformation matrix of this node.
Matrix4 Node::GetWorldTransform();IsChild() bool
Checks whether the given node is a direct child of this node.
bool Node::IsChild(const Node* node) const;| Parameter | Description |
|---|---|
| node | Pointer to the node to check. |
IsRenderable() bool virtual
Returns true if the node is renderable.
virtual bool Node::IsRenderable() const;Remove() void
Removes a child node from this node.
void Node::Remove(const std::shared_ptr<Node> & node);| Parameter | Description |
|---|---|
| node | Child node to remove. |
RemoveAllChildren() void
Removes all children from this node.
void Node::RemoveAllChildren();ShouldUpdateWorldTransform() bool
Determines whether the world transform should be recalculated.
bool Node::ShouldUpdateWorldTransform() const;UpdateTransformHierarchy() void
Recursively updates this node and all child world transforms.
This updates the transformation matrix of the current node first, then propagates the update recursively through all children.
void Node::UpdateTransformHierarchy();UpdateWorldTransform() void
Updates this node’s world transform, ensuring parent transforms are current.
This ensures that the world transform of all ancestors is updated before updating the current node. Required for correct world positioning.
void Node::UpdateWorldTransform();