|
Vulkan Schnee 0.0.1
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 () | |
| Ecs::LocalTransform & | getLocalTransform () |
| Gets the local transform of the scene node. The local transform is relative to the parent node. | |
| const Ecs::LocalTransform & | getLocalTransform () const |
| void | registerWithEcs () |
| 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. | |
| 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. | |
| std::vector< std::weak_ptr< SceneNode > > | getChildren () const |
| Get a list of all children of this node. | |
| void | markDirtyRecursive () |
| 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::shared_ptr< SceneNode > | parent = nullptr |
| std::vector< std::shared_ptr< SceneNode > > | children |
| size_t | indexInParent = 0 |
| entt::entity | entity |
| entt::registry * | registry |
| glm::mat4 | worldMatrix |
| bool | disableCaching = false |
Friends | |
| class | SceneGraph |
| class | NodeFactory |
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 24 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. |
Definition at line 15 of file SceneGraph.cpp.
References disableCaching, entity, registry, and worldMatrix.
Referenced by EngineCore::RootNode::RootNode().
| EngineCore::SceneNode::~SceneNode | ( | ) |
Definition at line 26 of file SceneGraph.cpp.
| void EngineCore::SceneNode::addChild | ( | const std::shared_ptr< SceneNode > & | newChild | ) |
Adds a child node to this node.
| newChild | child node to add to this node |
Definition at line 157 of file SceneGraph.cpp.
References children.
| void EngineCore::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 |
Definition at line 163 of file SceneGraph.cpp.
References children.
| void EngineCore::SceneNode::clearChildren | ( | ) |
Removes all children from this node.
Definition at line 172 of file SceneGraph.cpp.
References children.
| std::vector< std::weak_ptr< SceneNode > > EngineCore::SceneNode::getChildren | ( | ) | const |
Get a list of all children of this node.
Definition at line 217 of file SceneGraph.cpp.
References children.
| entt::entity EngineCore::SceneNode::getEntity | ( | ) | const |
Gets the entity associated with this scene node.
Definition at line 49 of file SceneGraph.cpp.
References entity.
| Ecs::LocalTransform & EngineCore::SceneNode::getLocalTransform | ( | ) |
Gets the local transform of the scene node. The local transform is relative to the parent node.
Gets the local transform of the scene node. The local transform is relative to the parent node.
Definition at line 36 of file SceneGraph.cpp.
References entity, and registry.
Referenced by setLocalModelMatrix(), setWorldModelMatrix(), setWorldPosition(), setWorldRotation(), setWorldScale(), and updateWorldMatrix().
| const Ecs::LocalTransform & EngineCore::SceneNode::getLocalTransform | ( | ) | const |
Definition at line 40 of file SceneGraph.cpp.
| const glm::mat4 & EngineCore::SceneNode::getWorldMatrix | ( | ) | const |
get the world matrix as a raw glm matrix
Definition at line 204 of file SceneGraph.cpp.
References disableCaching, isWorldMatrixDirty(), updateWorldMatrix(), and worldMatrix.
Referenced by rotateWorld(), setWorldPosition(), setWorldRotation(), and setWorldScale().
| bool EngineCore::SceneNode::isRoot | ( | ) | const |
Checks if this node is the root node.
Definition at line 213 of file SceneGraph.cpp.
References parent.
| bool EngineCore::SceneNode::isWorldMatrixDirty | ( | ) | const |
Checks if the world matrix has to be recalculated.
Definition at line 226 of file SceneGraph.cpp.
References entity, and registry.
Referenced by getWorldMatrix().
| void EngineCore::SceneNode::markDirtyRecursive | ( | ) |
Marks this node and its children as dirty.
Definition at line 230 of file SceneGraph.cpp.
References children, entity, and registry.
Referenced by setLocalModelMatrix(), setWorldModelMatrix(), setWorldPosition(), setWorldRotation(), and setWorldScale().
| void EngineCore::SceneNode::registerWithEcs | ( | ) |
Definition at line 44 of file SceneGraph.cpp.
| void EngineCore::SceneNode::removeChild | ( | const std::shared_ptr< SceneNode > & | child | ) |
Removes a single child from this node.
| child | the child to remove |
Definition at line 179 of file SceneGraph.cpp.
References children.
| void EngineCore::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 |
Definition at line 110 of file SceneGraph.cpp.
References Ecs::TransformOperators::getRotation(), getWorldMatrix(), and setWorldRotation().
| void EngineCore::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 |
Definition at line 106 of file SceneGraph.cpp.
References rotateWorld().
Referenced by rotateWorld().
| void EngineCore::SceneNode::setLocalModelMatrix | ( | const glm::mat4 & | newModelMatrix | ) |
Overwrites all components of the transform.
| newModelMatrix | new 4x4 model matrix |
Definition at line 138 of file SceneGraph.cpp.
References getLocalTransform(), markDirtyRecursive(), and Ecs::LocalTransform::matrix.
| void EngineCore::SceneNode::setWorldModelMatrix | ( | const glm::mat4 & | newModelMatrix | ) |
Overwrites all components of this transform.
| newModelMatrix | new 4x4 model matrix |
Definition at line 144 of file SceneGraph.cpp.
References getLocalTransform(), markDirtyRecursive(), Ecs::LocalTransform::matrix, and parent.
| void EngineCore::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.
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. |
| newLocation | The new position in world space. |
Definition at line 57 of file SceneGraph.cpp.
References getLocalTransform(), Ecs::TransformOperators::getRotation(), Ecs::TransformOperators::getScale(), getWorldMatrix(), markDirtyRecursive(), Ecs::LocalTransform::matrix, parent, and Ecs::TransformOperators::setPosition().
| void EngineCore::SceneNode::setWorldRotation | ( | const glm::quat & | newRotation | ) |
Sets a new world rotation with a quaternion on this node.
| newRotation | quaternion rotation |
Definition at line 85 of file SceneGraph.cpp.
References getLocalTransform(), Ecs::TransformOperators::getPosition(), Ecs::TransformOperators::getScale(), getWorldMatrix(), markDirtyRecursive(), Ecs::LocalTransform::matrix, parent, and Ecs::TransformOperators::setRotation().
| void EngineCore::SceneNode::setWorldRotation | ( | const glm::vec3 & | newRotation | ) |
Sets the world rotation of this node with euler angles.
| newRotation | yaw pitch roll |
Definition at line 81 of file SceneGraph.cpp.
References setWorldRotation().
Referenced by rotateWorld(), and setWorldRotation().
| void EngineCore::SceneNode::setWorldScale | ( | const glm::vec3 & | newScale | ) |
sets the scale for this node
| newScale | the scale to be set to |
Definition at line 117 of file SceneGraph.cpp.
References getLocalTransform(), Ecs::TransformOperators::getPosition(), Ecs::TransformOperators::getRotation(), getWorldMatrix(), markDirtyRecursive(), Ecs::LocalTransform::matrix, parent, and Ecs::TransformOperators::setScale().
|
private |
Definition at line 189 of file SceneGraph.cpp.
References disableCaching, entity, getLocalTransform(), Ecs::LocalTransform::matrix, parent, registry, and worldMatrix.
Referenced by getWorldMatrix().
|
friend |
Definition at line 26 of file SceneGraph.h.
References disableCaching, NodeFactory, and registry.
Referenced by NodeFactory.
|
friend |
|
private |
Definition at line 237 of file SceneGraph.h.
Referenced by addChild(), addChildren(), clearChildren(), getChildren(), markDirtyRecursive(), and removeChild().
|
private |
Definition at line 244 of file SceneGraph.h.
Referenced by getWorldMatrix(), NodeFactory, SceneNode(), and updateWorldMatrix().
|
private |
Definition at line 240 of file SceneGraph.h.
Referenced by getEntity(), getLocalTransform(), getLocalTransform(), isWorldMatrixDirty(), markDirtyRecursive(), registerWithEcs(), SceneNode(), updateWorldMatrix(), and ~SceneNode().
|
private |
Definition at line 238 of file SceneGraph.h.
|
private |
Definition at line 236 of file SceneGraph.h.
Referenced by isRoot(), setWorldModelMatrix(), setWorldPosition(), setWorldRotation(), setWorldScale(), and updateWorldMatrix().
|
private |
Definition at line 241 of file SceneGraph.h.
Referenced by getLocalTransform(), getLocalTransform(), isWorldMatrixDirty(), markDirtyRecursive(), NodeFactory, registerWithEcs(), EngineCore::RootNode::RootNode(), SceneNode(), updateWorldMatrix(), and ~SceneNode().
|
mutableprivate |
Definition at line 243 of file SceneGraph.h.
Referenced by getWorldMatrix(), SceneNode(), and updateWorldMatrix().