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
Factories preferred
Types
Node::Type scoped enum
Enumerates all node types.
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
bool frustum_culled { true }
If true, the node is subject to frustum culling during rendering.
transform Transform3
Transform3 transform
Local transformation.
transform_auto_update bool
bool transform_auto_update { true }
If true, the local transform is automatically updated before rendering.
Functions
LookAt() void virtual
virtual void vglx::Node::LookAt(const Vector3 &target)
Parameter | Description |
---|---|
target | Target world-space position to look at. |
Rotates the node to face a given target position in world space.
TranslateX() auto
auto vglx::Node::TranslateX(float value)
Parameter | Description |
---|---|
value | Translation distance. |
Translates the node along the X axis in local space.
TranslateY() auto
auto vglx::Node::TranslateY(float value)
Parameter | Description |
---|---|
value | Translation distance. |
Translates the node along the Y axis in local space.
TranslateZ() auto
auto vglx::Node::TranslateZ(float value)
Parameter | Description |
---|---|
value | Translation distance. |
Translates the node along the Z axis in local space.
RotateX() auto
auto vglx::Node::RotateX(float angle)
Parameter | Description |
---|---|
angle | Rotation angle in radians. |
Rotates the node along the X axis in local space.
RotateY() auto
auto vglx::Node::RotateY(float angle)
Parameter | Description |
---|---|
angle | Rotation angle in radians. |
Rotates the node along the Y axis in local space.
RotateZ() auto
auto vglx::Node::RotateZ(float angle)
Parameter | Description |
---|---|
angle | Rotation angle in radians. |
Rotates the node along the Z axis in local space.
SetScale() auto
auto vglx::Node::SetScale(const Vector3 &value)
Parameter | Description |
---|---|
value | Scale vector applied to the X, Y, and Z axes. |
Scales the node non-uniformly in local space.
OnUpdate() void virtual
virtual void vglx::Node::OnUpdate(float delta)
Parameter | Description |
---|---|
delta | Time in seconds since the last frame. |
Called every frame. Override this method to implement per-frame logic or animation.
OnAttached() void virtual
virtual void vglx::Node::OnAttached(SharedContextPointer context)
Parameter | Description |
---|---|
context | Pointer to the shared context (const). |
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.
OnKeyboardEvent() void virtual
virtual void vglx::Node::OnKeyboardEvent(KeyboardEvent *event)
Parameter | Description |
---|---|
event | Pointer to the dispatched keyboard event. |
Called when a keyboard event is dispatched to this node. Override to handle key presses or releases.
OnMouseEvent() void virtual
virtual void vglx::Node::OnMouseEvent(MouseEvent *event)
Parameter | Description |
---|---|
event | Pointer to the dispatched mouse event. |
Called when a mouse event is dispatched to this node. Override to handle mouse movement, clicks, or scrolling.
Add() void
void vglx::Node::Add(const std::shared_ptr< Node > &node)
Parameter | Description |
---|---|
node | Child node to add. |
Adds a child node to this node.
const std::vector< std::shared_ptr< Node > > & vglx::Node::Children() const
Returns the list of child nodes.
GetNodeType() Node::Type virtual
virtual Node::Type vglx::Node::GetNodeType() const
Returns node type.
Vector3 vglx::Node::GetWorldPosition()
Returns the world-space position of this node.
Matrix4 vglx::Node::GetWorldTransform()
Returns the world transformation matrix of this node.
IsChild() bool
bool vglx::Node::IsChild(const Node *node) const
Parameter | Description |
---|---|
node | Pointer to the node to check. |
Checks whether the given node is a direct child of this node.
IsRenderable() bool virtual
virtual bool vglx::Node::IsRenderable() const
Returns true if the node is renderable.
Remove() void
void vglx::Node::Remove(const std::shared_ptr< Node > &node)
Parameter | Description |
---|---|
node | Child node to remove. |
Removes a child node from this node.
RemoveAllChildren() void
void vglx::Node::RemoveAllChildren()
Removes all children from this node.
ShouldUpdateWorldTransform() bool
bool vglx::Node::ShouldUpdateWorldTransform() const
Determines whether the world transform should be recalculated.
UpdateTransformHierarchy() void
void vglx::Node::UpdateTransformHierarchy()
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.
UpdateWorldTransform() void
void vglx::Node::UpdateWorldTransform()
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.