|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Represents a node in the scene graph, containing information about its position, rotation, and scale relative to its parent. It also holds references to its parent and children nodes. More...
#include <SceneGraph.h>
Public Member Functions | |
| ~SceneNode () | |
| Destroys this scene node and releases its ECS registration state. | |
| Ecs::Transform & | getLocalTransform () |
| Gets the local transform of the scene node. The local transform is relative to the parent node. | |
| const Ecs::Transform & | getLocalTransform () const |
| Gets the local transform of the scene node. The local transform is relative to the parent node. | |
| void | registerWithEcs () |
| Registers this scene node and its transform data in the ECS registry. | |
| entt::entity | getEntity () const |
| Gets the entity associated with this scene node. | |
| void | setWorldPosition (const glm::vec3 &newLocation) |
| Sets the world position of the scene node. This will calculate the corresponding local position based on the parent's world transform. | |
| void | setWorldRotation (const glm::vec3 &newRotation) |
| Sets the world rotation of this node with euler angles. | |
| void | setWorldRotation (const glm::quat &newRotation) |
| Sets a new world rotation with a quaternion on this node. | |
| void | rotateWorld (const glm::vec3 &deltaRotation) |
| Applies an incremental rotation to the current world rotation using quaternion multiplication. This avoids euler angle instability that occurs with get/set rotation round-trips. | |
| void | rotateWorld (const glm::quat &deltaRotation) |
| Applies an incremental rotation to the current world rotation using quaternion multiplication. | |
| void | setWorldScale (const glm::vec3 &newScale) |
| sets the scale for this node | |
| void | setLocalModelMatrix (const glm::mat4 &newModelMatrix) |
| Overwrites all components of the transform. | |
| void | setWorldModelMatrix (const glm::mat4 &newModelMatrix) |
| Overwrites all components of this transform. | |
| void | addChild (const std::shared_ptr< SceneNode > &newChild) |
| Adds a child node to this node. | |
| void | addChildren (std::vector< std::shared_ptr< SceneNode > > newChildren) |
| adds new children to this node | |
| void | clearChildren () |
| Removes all children from this node. | |
| void | removeChild (const std::shared_ptr< SceneNode > &child) |
| Removes a single child from this node. | |
| void | reparentTo (const std::shared_ptr< SceneNode > &newParent, AttachmentTransformRule rule=AttachmentTransformRule::KeepWorld) |
| Safely reparents this node while preserving either world or local transform. | |
| void | detachFromParent () |
| Detaches this node from its parent, transferring ownership away from the scene graph. | |
| const glm::mat4 & | getWorldMatrix () const |
| get the world matrix as a raw glm matrix | |
| bool | isWorldMatrixDirty () const |
| Checks if the world matrix has to be recalculated. | |
| bool | isRoot () const |
| Checks if this node is the root node. | |
| bool | isDirectChildOf (const std::shared_ptr< SceneNode > &potentialParent) const |
| Checks whether this node is directly attached to the given parent. | |
| std::vector< std::weak_ptr< SceneNode > > | getChildren () const |
| Get a list of all children of this node. | |
| void | markDirtyRecursive () const |
| Marks this node and its children as dirty. | |
Protected Member Functions | |
| SceneNode (entt::registry ®istry, bool disableCaching=false) | |
| Constructs a new Scene Node object. | |
Private Member Functions | |
| void | updateWorldMatrix () const |
Private Attributes | |
| std::weak_ptr< SceneNode > | parent_ |
| std::vector< std::shared_ptr< SceneNode > > | children_ |
| size_t | indexInParent_ = 0 |
| entt::entity | entity_ |
| entt::registry * | registry |
| glm::mat4 | worldMatrix |
| bool | disableCaching = false |
Represents a node in the scene graph, containing information about its position, rotation, and scale relative to its parent. It also holds references to its parent and children nodes.
Definition at line 27 of file SceneGraph.h.
|
explicitprotected |
Constructs a new Scene Node object.
| registry | entt registry where the transform should be registered to |
| disableCaching | If true, the world matrix of this node will be recalculated every time it is requested, rather than being cached. This is useful for nodes that change frequently. |
References disableCaching, and registry.
| Engine::Entities::SceneNode::~SceneNode | ( | ) |
Destroys this scene node and releases its ECS registration state.
| void Engine::Entities::SceneNode::addChild | ( | const std::shared_ptr< SceneNode > & | newChild | ) |
Adds a child node to this node.
| newChild | child node to add to this node |
| void Engine::Entities::SceneNode::addChildren | ( | std::vector< std::shared_ptr< SceneNode > > | newChildren | ) |
adds new children to this node
| newChildren | list of new children to add to this node |
| void Engine::Entities::SceneNode::clearChildren | ( | ) |
Removes all children from this node.
| void Engine::Entities::SceneNode::detachFromParent | ( | ) |
Detaches this node from its parent, transferring ownership away from the scene graph.
| std::vector< std::weak_ptr< SceneNode > > Engine::Entities::SceneNode::getChildren | ( | ) | const |
Get a list of all children of this node.
| entt::entity Engine::Entities::SceneNode::getEntity | ( | ) | const |
Gets the entity associated with this scene node.
| Ecs::Transform & Engine::Entities::SceneNode::getLocalTransform | ( | ) |
Gets the local transform of the scene node. The local transform is relative to the parent node.
| const Ecs::Transform & Engine::Entities::SceneNode::getLocalTransform | ( | ) | const |
Gets the local transform of the scene node. The local transform is relative to the parent node.
| const glm::mat4 & Engine::Entities::SceneNode::getWorldMatrix | ( | ) | const |
get the world matrix as a raw glm matrix
| bool Engine::Entities::SceneNode::isDirectChildOf | ( | const std::shared_ptr< SceneNode > & | potentialParent | ) | const |
Checks whether this node is directly attached to the given parent.
| bool Engine::Entities::SceneNode::isRoot | ( | ) | const |
Checks if this node is the root node.
| bool Engine::Entities::SceneNode::isWorldMatrixDirty | ( | ) | const |
Checks if the world matrix has to be recalculated.
| void Engine::Entities::SceneNode::markDirtyRecursive | ( | ) | const |
Marks this node and its children as dirty.
| void Engine::Entities::SceneNode::registerWithEcs | ( | ) |
Registers this scene node and its transform data in the ECS registry.
| void Engine::Entities::SceneNode::removeChild | ( | const std::shared_ptr< SceneNode > & | child | ) |
Removes a single child from this node.
| child | the child to remove |
| void Engine::Entities::SceneNode::reparentTo | ( | const std::shared_ptr< SceneNode > & | newParent, |
| AttachmentTransformRule | rule = AttachmentTransformRule::KeepWorld ) |
Safely reparents this node while preserving either world or local transform.
| newParent | New non-null parent node. |
| rule | Whether to keep this node's world or local transform during reparenting. |
References Engine::Entities::KeepWorld.
| void Engine::Entities::SceneNode::rotateWorld | ( | const glm::quat & | deltaRotation | ) |
Applies an incremental rotation to the current world rotation using quaternion multiplication.
| deltaRotation | quaternion to multiply with the current rotation |
| void Engine::Entities::SceneNode::rotateWorld | ( | const glm::vec3 & | deltaRotation | ) |
Applies an incremental rotation to the current world rotation using quaternion multiplication. This avoids euler angle instability that occurs with get/set rotation round-trips.
| deltaRotation | euler angles (degrees) to rotate by |
| void Engine::Entities::SceneNode::setLocalModelMatrix | ( | const glm::mat4 & | newModelMatrix | ) |
Overwrites all components of the transform.
| newModelMatrix | new 4x4 model matrix |
| void Engine::Entities::SceneNode::setWorldModelMatrix | ( | const glm::mat4 & | newModelMatrix | ) |
Overwrites all components of this transform.
| newModelMatrix | new 4x4 model matrix |
| void Engine::Entities::SceneNode::setWorldPosition | ( | const glm::vec3 & | newLocation | ) |
Sets the world position of the scene node. This will calculate the corresponding local position based on the parent's world transform.
| newLocation | The new position in world space. |
| void Engine::Entities::SceneNode::setWorldRotation | ( | const glm::quat & | newRotation | ) |
Sets a new world rotation with a quaternion on this node.
| newRotation | quaternion rotation |
| void Engine::Entities::SceneNode::setWorldRotation | ( | const glm::vec3 & | newRotation | ) |
Sets the world rotation of this node with euler angles.
| newRotation | yaw pitch roll |
| void Engine::Entities::SceneNode::setWorldScale | ( | const glm::vec3 & | newScale | ) |
sets the scale for this node
| newScale | the scale to be set to |
|
private |
|
private |
Definition at line 210 of file SceneGraph.h.
|
private |
Definition at line 217 of file SceneGraph.h.
Referenced by SceneNode().
|
private |
Definition at line 213 of file SceneGraph.h.
|
private |
Definition at line 211 of file SceneGraph.h.
|
private |
Definition at line 209 of file SceneGraph.h.
|
private |
Definition at line 214 of file SceneGraph.h.
Referenced by Engine::Entities::RootNode::RootNode(), and SceneNode().
|
mutableprivate |
Definition at line 216 of file SceneGraph.h.