SceneNode Class
Represents a SceneNode within a SceneGraph. More...
Declaration
Derived Classes
| class | CameraSceneNode |
|
Represents an adapter for cameras, allowing spatial positioning and transformation within the scene graph. More... | |
Public Constructors Index
| SceneNode (const SceneNode &)=delete | |
|
Delete copy constructor. A SceneNode is not copyable. More... | |
| SceneNode () noexcept | |
|
Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes. More... | |
| SceneNode (const Transform &transform) noexcept | |
|
Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes. More... | |
| SceneNode (std::shared_ptr< helios::rendering::Renderable > renderable, const Transform &transform) noexcept | |
|
Constructs a new SceneNode representing a renderable object. More... | |
| SceneNode (std::shared_ptr< helios::rendering::Renderable > renderable) noexcept | |
|
Constructs a new SceneNode representing a renderable object. More... | |
Public Destructor Index
| ~SceneNode ()=default | |
Public Operators Index
| SceneNode & | operator= (const SceneNode &)=delete |
|
Delete copy assignment operator. More... | |
Public Member Functions Index
| const helios::util::Guid & | guid () const noexcept |
|
Returns the globally unique identifier for this SceneNode. More... | |
| SceneNode * | addNode (std::unique_ptr< SceneNode > sceneNode) |
|
Adds a new child node to this SceneNode. The node's parent is automatically set to **this** node. More... | |
| const std::vector< std::unique_ptr< SceneNode > > & | children () const noexcept |
|
Returns a const ref to the list of this node's children. More... | |
| helios::rendering::Renderable * | renderable () noexcept |
|
Returns a raw pointer to the Renderable of this SceneNode. More... | |
| bool | hasRenderable () const noexcept |
|
Returns true if this SceneNode was configured with a Renderable. More... | |
| const helios::rendering::Renderable * | renderable () const noexcept |
|
Returns a const pointer to the non-const Renderable of this SceneNode. More... | |
| std::shared_ptr< helios::rendering::Renderable > | shareRenderable () noexcept |
|
Returns a shared pointer to the non-const Renderable of this SceneNode. More... | |
| SceneNode & | setScale (const helios::math::vec3f &scale) noexcept |
|
Applies a scaling transformation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering. More... | |
| SceneNode & | setRotation (const helios::math::mat4f &rotation) noexcept |
|
Applies rotation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering. More... | |
| SceneNode & | setTranslation (const helios::math::vec3f &translation) noexcept |
|
Applies translation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering. More... | |
| const Transform & | localTransform () const noexcept |
| Transform & | localTransform () noexcept |
| SceneNode * | parent () const noexcept |
|
Returns a pointer to this node's parent node. More... | |
| bool | applyWorldTransform (const helios::math::mat4f &parentWorldTransform, helios::scene::SceneGraphKey sceneGraphKey) noexcept |
| void | setIsRoot (helios::scene::SceneGraphKey sceneGraphKey) noexcept |
|
Marks this node as the root of the scene graph. More... | |
| bool | isRoot () const noexcept |
|
Checks whether this node is the root of the scene graph. More... | |
| const helios::math::mat4f & | worldTransform () noexcept |
|
Computes and returns the world transform for this SceneNode. Will request the current world transform from the parent node to calculate this SceneNode's world transform. For efficiency, this method should cache the result and only trigger a recompute if this SceneNode is dirty (`needsUpdate_ == true`). More... | |
| const helios::math::mat4f & | cachedWorldTransform () const noexcept |
|
Returns the current worldTransform matrix of this SceneNode **without triggering any recomputation**. This method is efficient for access when the world transform is known to be up-to-date. More... | |
| bool | needsUpdate () const noexcept |
| helios::math::aabbf | aabb () noexcept |
|
Returns the axis-aligned bounding box for this SceneNode in world coordinates. More... | |
| void | update () noexcept |
|
Updates the world transform and axis-aligned bounding box of this SceneNode. More... | |
| void | onWorldTransformUpdate () noexcept |
|
Virtual callback invoked after the world transform has been updated. More... | |
| helios::math::mat4f | inheritWorldTransform (const helios::math::mat4f &parentWorldTransform) noexcept |
|
Filters a parent world transform based on the node's inheritance flags. More... | |
| void | setInheritance (const helios::math::TransformType inherit) noexcept |
|
Sets which transform components this node inherits from its parent. More... | |
| helios::math::TransformType | inheritance () const noexcept |
|
Returns the current transform inheritance flags for this node. More... | |
| bool | isActive () const noexcept |
|
Returns whether this SceneNode and its child nodes should be considered for rendering. More... | |
| void | setActive (const bool active) noexcept |
Protected Member Functions Index
| void | setParent (SceneNode *parentNode) |
|
Sets the parent of this SceneNode. Internally used once a child was added to this SceneNode. More... | |
Protected Member Attributes Index
| bool | needsUpdate_ = true |
|
Boolean flag to represent the dirty-state of this node. Should be set to false if the current `worldTransform_` for this node was computed, otherwise true, e.g. if the node's local transform has been changed. More... | |
| bool | isRoot_ = false |
|
True if this node is the root of the scene graph. More... | |
| std::shared_ptr< helios::rendering::Renderable > | renderable_ = nullptr |
|
A shared pointer to the Renderable this node represents in the SceneGraph. May be nullptr if this node does not represent a. More... | |
| SceneNode * | parent_ = nullptr |
|
The parent node of **this** node. This will be nullptr for any root node. Implementing APIs must take care of properly assigning parent nodes when adding child nodes. More... | |
| std::vector< std::unique_ptr< SceneNode > > | children_ |
|
A list of unique pointers to this node's children. Ensures ownership of the child nodes withing the graph hierarchy. More... | |
| math::mat4f | worldTransform_ = math::mat4f::identity() |
|
The 4x4 worldTransform-Matrix of this node. This matrix is initially set to the identity matrix. Implementing APIs MUST make sure to recompute the worldTransform before each rendering pass. More... | |
| Transform | localTransform_ |
|
A local transformation representing affine transformation information for this SceneNode. Encapsulates rotation, scaling and translation. More... | |
| bool | isActive_ = true |
|
Boolean flag indicating whether this SceneNode should be considered for rendering. More... | |
| helios::math::aabbf | aabb_ {} |
|
The axis-aligned-bounding-box for this SceneNode in world-coordinates. More... | |
| helios::math::TransformType | inheritance_ = helios::math::TransformType::All |
|
Flags controlling which transform components are inherited from the parent node. More... | |
Private Member Attributes Index
| const util::Guid | guid_ |
|
A unique identifier for this SceneNode, computed automatically during instantiation. More... | |
Description
Represents a SceneNode within a SceneGraph.
A SceneNode holds its local transformation and a (shared) pointer to a Renderable object (the representative of a visible element). Furthermore, a SceneNode can have multiple child nodes uniquely owned by **this** SceneNode.
A SceneNode holds a global unique identifier and tracks a dirty state (`needsUpdate_`) related to any transformations that occurred on the SceneNode. Ownership is managed by a collection of unique pointers of the child nodes. SceneNodes are designed to be not copyable and not assignable to prevent duplication and to enforce the hierarchical tree structure.
The `worldTransform_` is derived from a SceneNode's `localTransform_` and the SceneNode's parent's `worldTransform`s. A call to `worldTransform()` will update the particular subtree of the SceneNode bottom-up to make sure the actual values are available with the SceneNode's `worldTransform`. A Scene might also propagate changes top-bottom - see `Scene::updateNodes()`.
Definition at line 62 of file SceneNode.ixx.
Public Constructors
SceneNode()
| delete |
Delete copy constructor. A SceneNode is not copyable.
Definition at line 162 of file SceneNode.ixx.
Reference SceneNode.
Referenced by helios::scene::CameraSceneNode::addNode, addNode, operator=, parent, SceneNode, setParent, setRotation, setScale and setTranslation.
SceneNode()
| inline noexcept |
Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes.
- Todo
-
explicitly implement move (assignment) constructor if required, since we have deleted the copy constructors
Definition at line 181 of file SceneNode.ixx.
SceneNode()
| inline explicit noexcept |
Constructs a new SceneNode that represents no renderable object. Nodes constructed in this way should be treated as transformation nodes.
- Parameters
-
transform The initial transformation for this node.
Definition at line 192 of file SceneNode.ixx.
Reference helios::util::Guid::generate.
SceneNode()
| inline explicit noexcept |
Constructs a new SceneNode representing a renderable object.
- Parameters
-
renderable A shared_ptr to the Renderable this SceneNode represents in a Scene.
transform The initial local transform for this node.
Definition at line 204 of file SceneNode.ixx.
References helios::util::Guid::generate and renderable.
SceneNode()
| inline explicit noexcept |
Constructs a new SceneNode representing a renderable object.
Definition at line 219 of file SceneNode.ixx.
References helios::util::Guid::generate and renderable.
Public Destructor
~SceneNode()
| virtual default |
Definition at line 156 of file SceneNode.ixx.
Public Operators
operator=()
| delete |
Delete copy assignment operator.
A SceneNode is not intended to be copied.
Definition at line 169 of file SceneNode.ixx.
Reference SceneNode.
Public Member Functions
aabb()
| inline nodiscard noexcept |
Returns the axis-aligned bounding box for this SceneNode in world coordinates.
- Returns
The AABB transformed to world space.
Definition at line 465 of file SceneNode.ixx.
References aabb_, needsUpdate and update.
addNode()
| inline nodiscard virtual |
Adds a new child node to this SceneNode. The node's parent is automatically set to **this** node.
- Parameters
-
sceneNode The node to add as a child.
- Returns
The raw pointer to the newly added node, or nullptr if adding failed
Definition at line 244 of file SceneNode.ixx.
applyWorldTransform()
| inline nodiscard noexcept |
Sets the world transform for this SceneNode.
Does nothing if the current SceneNode's world transform is considered equal to the specified world transform.
- Parameters
-
wf The worldTransform to use for this SceneNode.
sceneGraphKey The sceneGraphKey as constructed by the `Scene`. Serves as the passkey so this method is not callable from outside.
- Returns
true if the world transform was updated, otherwise false.
Definition at line 382 of file SceneNode.ixx.
References inheritWorldTransform, needsUpdate, needsUpdate_, onWorldTransformUpdate and worldTransform_.
cachedWorldTransform()
| inline nodiscard noexcept |
Returns the current worldTransform matrix of this SceneNode **without triggering any recomputation**. This method is efficient for access when the world transform is known to be up-to-date.
- Returns
The current worldTransform matrix of this SceneNode.
Definition at line 443 of file SceneNode.ixx.
Reference worldTransform_.
Referenced by helios::scene::Scene::createSnapshot, helios::scene::CameraSceneNode::lookAt and helios::scene::CameraSceneNode::onWorldTransformUpdate.
children()
| inline nodiscard noexcept |
Returns a const ref to the list of this node's children.
- Returns
A const ref to the list of children of this node.
Definition at line 255 of file SceneNode.ixx.
Reference children_.
Referenced by helios::scene::CullNoneStrategy::cull.
guid()
| inline nodiscard noexcept |
Returns the globally unique identifier for this SceneNode.
- Returns
The unique identifier for this SceneNode.
Definition at line 231 of file SceneNode.ixx.
hasRenderable()
| inline nodiscard noexcept |
Returns true if this SceneNode was configured with a Renderable.
- Returns
true if the SceneNode was configured with a Renderable, otherwise false.
Definition at line 273 of file SceneNode.ixx.
Reference renderable.
Referenced by helios::scene::Scene::createSnapshot.
inheritance()
| inline nodiscard noexcept |
Returns the current transform inheritance flags for this node.
- Returns
The active inheritance mask.
- See Also
Definition at line 556 of file SceneNode.ixx.
Reference inheritance_.
inheritWorldTransform()
| inline noexcept |
Filters a parent world transform based on the node's inheritance flags.
This method extracts only the transform components (Translation, Rotation, Scale) that this node is configured to inherit from its parent. Components not included in `inheritance_` are replaced with identity values.
- Parameters
-
parentWorldTransform The parent's world transform matrix.
- Returns
A filtered transform matrix containing only the inherited components.
- See Also
- See Also
Definition at line 520 of file SceneNode.ixx.
References helios::math::All, inheritance_ and localTransform_.
Referenced by applyWorldTransform and update.
isActive()
| inline nodiscard noexcept |
Returns whether this SceneNode and its child nodes should be considered for rendering.
- Returns
true if the SceneNode should be considered for rendering, otherwise false.
Definition at line 565 of file SceneNode.ixx.
Reference isActive_.
Referenced by helios::scene::Scene::createSnapshot and helios::scene::CullNoneStrategy::cull.
isRoot()
| inline nodiscard noexcept |
localTransform()
| inline nodiscard noexcept |
Returns this SceneNode's localTransform.
- Returns
A const reference to this SceneNode's `Transform` object.
Definition at line 346 of file SceneNode.ixx.
Reference localTransform_.
Referenced by helios::scene::CameraSceneNode::lookAtLocal.
localTransform()
| inline nodiscard noexcept |
Returns this SceneNode's localTransform.
- Returns
A reference to this SceneNode's `Transform` object.
Definition at line 355 of file SceneNode.ixx.
Reference localTransform_.
needsUpdate()
| inline nodiscard noexcept |
Checks whether this SceneNode needs to be updated.
The SceneNode is considered "dirty" if either the `localTransform_` needs an update, or if the `needsUpdate_` property is set to true.
- Returns
true if this SceneNode is considered to be dirty, otherwise false.
Definition at line 455 of file SceneNode.ixx.
References localTransform_ and needsUpdate_.
Referenced by aabb, applyWorldTransform and worldTransform.
onWorldTransformUpdate()
| inline noexcept virtual |
Virtual callback invoked after the world transform has been updated.
Derived classes can override this method to perform additional processing when the node's world transform changes, such as updating dependent resources or triggering view matrix recalculations in camera nodes.
Definition at line 499 of file SceneNode.ixx.
References aabb_, renderable_ and worldTransform_.
Referenced by applyWorldTransform, helios::scene::CameraSceneNode::onWorldTransformUpdate and update.
parent()
| inline nodiscard noexcept |
Returns a pointer to this node's parent node.
- Returns
The pointer to this node's parent, or nullptr if no parent exists, e.g. for the root node.
Definition at line 365 of file SceneNode.ixx.
References parent_ and SceneNode.
Referenced by helios::scene::CameraSceneNode::lookAt.
renderable()
| inline nodiscard noexcept |
Returns a raw pointer to the Renderable of this SceneNode.
- Returns
A raw pointer to the Renderable, may be nullptr if none is set.
Definition at line 264 of file SceneNode.ixx.
Reference renderable_.
Referenced by helios::scene::Scene::createSnapshot, hasRenderable, SceneNode and SceneNode.
renderable()
| inline nodiscard noexcept |
Returns a const pointer to the non-const Renderable of this SceneNode.
- Returns
A shared_ptr to the Renderable, may be nullptr if none is set.
Definition at line 282 of file SceneNode.ixx.
Reference renderable_.
setActive()
| inline noexcept |
Sets the active state of this SceneNode.
The active state determines whether the SceneNode should be considered for rendering.
- Parameters
-
active true to consider this SceneNodefor rendering, otherwise false.
Definition at line 576 of file SceneNode.ixx.
Reference isActive_.
setInheritance()
| inline noexcept |
Sets which transform components this node inherits from its parent.
By default, nodes inherit all transform components (`TransformType::All`). Use this method to selectively inherit only Translation, Rotation, or Scale, enabling behaviors like cameras that follow an object's position but maintain independent orientation.
- Parameters
-
inherit The inheritance flags to apply.
- See Also
Definition at line 544 of file SceneNode.ixx.
References inheritance_ and needsUpdate_.
setIsRoot()
| inline noexcept |
Marks this node as the root of the scene graph.
- Parameters
-
sceneGraphKey The passkey for scene-graph-only access.
Definition at line 405 of file SceneNode.ixx.
Reference isRoot_.
setRotation()
| inline noexcept |
Applies rotation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering.
- Parameters
-
rotation The helios::math::mat4f rotation matrix.
- Returns
A reference to this SceneNode.
Definition at line 319 of file SceneNode.ixx.
References localTransform_, needsUpdate_ and SceneNode.
Referenced by helios::scene::CameraSceneNode::lookAt and helios::scene::CameraSceneNode::lookAtLocal.
setScale()
| inline noexcept |
Applies a scaling transformation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering.
- Parameters
-
scale The helios::math::vec3f representing the node's scaling factors.
- Returns
A reference to this SceneNode.
Definition at line 304 of file SceneNode.ixx.
References localTransform_, needsUpdate_ and SceneNode.
setTranslation()
| inline noexcept |
Applies translation to this node's **local** transform. Marks the node dirty. Implementing APIs should consider updating the worldTransform of this node before rendering.
- Parameters
-
translation The helios::math::vec3f representing the node's translation.
- Returns
A reference to this SceneNode.
Definition at line 335 of file SceneNode.ixx.
References localTransform_, needsUpdate_ and SceneNode.
shareRenderable()
| inline nodiscard noexcept |
Returns a shared pointer to the non-const Renderable of this SceneNode.
- Returns
A shared_ptr to the Renderable, may be nullptr if none is set.
Definition at line 291 of file SceneNode.ixx.
Reference renderable_.
update()
| inline noexcept |
Updates the world transform and axis-aligned bounding box of this SceneNode.
Recomputes the `worldTransform_` based on the parent's world transform and this node's `localTransform_`. Also updates the `aabb_` to reflect the current world-space bounds.
Definition at line 480 of file SceneNode.ixx.
References inheritWorldTransform, localTransform_, needsUpdate_, onWorldTransformUpdate, parent_ and worldTransform_.
Referenced by aabb and worldTransform.
worldTransform()
| inline noexcept |
Computes and returns the world transform for this SceneNode. Will request the current world transform from the parent node to calculate this SceneNode's world transform. For efficiency, this method should cache the result and only trigger a recompute if this SceneNode is dirty (`needsUpdate_ == true`).
- Returns
The current world transform matrix for this scene node.
Definition at line 427 of file SceneNode.ixx.
References needsUpdate, update and worldTransform_.
Referenced by helios::scene::CameraSceneNode::lookAt.
Protected Member Functions
setParent()
Protected Member Attributes
aabb_
| protected |
The axis-aligned-bounding-box for this SceneNode in world-coordinates.
Definition at line 129 of file SceneNode.ixx.
Referenced by aabb and onWorldTransformUpdate.
children_
| protected |
inheritance_
| protected |
Flags controlling which transform components are inherited from the parent node.
By default set to `TransformType::All`, meaning translation, rotation, and scale are all inherited from the parent's world transform. Use `setInheritance()` to selectively disable inheritance of specific components.
- See Also
- See Also
Definition at line 141 of file SceneNode.ixx.
Referenced by inheritance, inheritWorldTransform, helios::scene::CameraSceneNode::lookAt and setInheritance.
isActive_
| protected |
isRoot_
| protected |
localTransform_
| protected |
A local transformation representing affine transformation information for this SceneNode. Encapsulates rotation, scaling and translation.
Definition at line 118 of file SceneNode.ixx.
Referenced by inheritWorldTransform, localTransform, localTransform, needsUpdate, setRotation, setScale, setTranslation and update.
needsUpdate_
| protected |
Boolean flag to represent the dirty-state of this node. Should be set to false if the current `worldTransform_` for this node was computed, otherwise true, e.g. if the node's local transform has been changed.
Definition at line 78 of file SceneNode.ixx.
Referenced by applyWorldTransform, needsUpdate, setInheritance, setRotation, setScale, setTranslation and update.
parent_
| protected |
renderable_
| protected |
A shared pointer to the Renderable this node represents in the SceneGraph. May be nullptr if this node does not represent a.
Definition at line 89 of file SceneNode.ixx.
Referenced by onWorldTransformUpdate, renderable, renderable and shareRenderable.
worldTransform_
| protected |
The 4x4 worldTransform-Matrix of this node. This matrix is initially set to the identity matrix. Implementing APIs MUST make sure to recompute the worldTransform before each rendering pass.
Definition at line 111 of file SceneNode.ixx.
Referenced by applyWorldTransform, cachedWorldTransform, onWorldTransformUpdate, update and worldTransform.
Private Member Attributes
guid_
|
A unique identifier for this SceneNode, computed automatically during instantiation.
Definition at line 69 of file SceneNode.ixx.
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.