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>
|
| | ~SceneNode () |
| 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 |
| 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 () const |
| | Marks this node and its children as dirty.
|
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 18 of file SceneGraph.h.
◆ SceneNode()
| Engine::Entities::SceneNode::SceneNode |
( |
entt::registry & | registry, |
|
|
bool | disableCaching = false ) |
|
explicitprotected |
Constructs a new Scene Node object.
- Parameters
-
| 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.
◆ ~SceneNode()
| Engine::Entities::SceneNode::~SceneNode |
( |
| ) |
|
◆ addChild()
| void Engine::Entities::SceneNode::addChild |
( |
const std::shared_ptr< SceneNode > & | newChild | ) |
|
Adds a child node to this node.
- Parameters
-
| newChild | child node to add to this node |
◆ addChildren()
| void Engine::Entities::SceneNode::addChildren |
( |
std::vector< std::shared_ptr< SceneNode > > | newChildren | ) |
|
adds new children to this node
- Parameters
-
| newChildren | list of new children to add to this node |
◆ clearChildren()
| void Engine::Entities::SceneNode::clearChildren |
( |
| ) |
|
Removes all children from this node.
◆ getChildren()
| std::vector< std::weak_ptr< SceneNode > > Engine::Entities::SceneNode::getChildren |
( |
| ) |
const |
Get a list of all children of this node.
- Returns
- list of all children of this node
◆ getEntity()
| entt::entity Engine::Entities::SceneNode::getEntity |
( |
| ) |
const |
Gets the entity associated with this scene node.
- Returns
- The entt entity for this node.
◆ getLocalTransform() [1/2]
Gets the local transform of the scene node. The local transform is relative to the parent node.
- Returns
- A reference to the local LocalTransform ECS component.
◆ getLocalTransform() [2/2]
| const Ecs::Transform & Engine::Entities::SceneNode::getLocalTransform |
( |
| ) |
const |
◆ getWorldMatrix()
| const glm::mat4 & Engine::Entities::SceneNode::getWorldMatrix |
( |
| ) |
const |
get the world matrix as a raw glm matrix
- Returns
- the world matrix
◆ isRoot()
| bool Engine::Entities::SceneNode::isRoot |
( |
| ) |
const |
Checks if this node is the root node.
- Returns
- true if it is the root node
◆ isWorldMatrixDirty()
| bool Engine::Entities::SceneNode::isWorldMatrixDirty |
( |
| ) |
const |
Checks if the world matrix has to be recalculated.
- Returns
- if the world matrix is dirty
◆ markDirtyRecursive()
| void Engine::Entities::SceneNode::markDirtyRecursive |
( |
| ) |
const |
Marks this node and its children as dirty.
◆ registerWithEcs()
| void Engine::Entities::SceneNode::registerWithEcs |
( |
| ) |
|
◆ removeChild()
| void Engine::Entities::SceneNode::removeChild |
( |
const std::shared_ptr< SceneNode > & | child | ) |
|
Removes a single child from this node.
- Parameters
-
◆ rotateWorld() [1/2]
| void Engine::Entities::SceneNode::rotateWorld |
( |
const glm::quat & | deltaRotation | ) |
|
Applies an incremental rotation to the current world rotation using quaternion multiplication.
- Parameters
-
| deltaRotation | quaternion to multiply with the current rotation |
◆ rotateWorld() [2/2]
| 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.
- Parameters
-
| deltaRotation | euler angles (degrees) to rotate by |
◆ setLocalModelMatrix()
| void Engine::Entities::SceneNode::setLocalModelMatrix |
( |
const glm::mat4 & | newModelMatrix | ) |
|
Overwrites all components of the transform.
- Parameters
-
| newModelMatrix | new 4x4 model matrix |
◆ setWorldModelMatrix()
| void Engine::Entities::SceneNode::setWorldModelMatrix |
( |
const glm::mat4 & | newModelMatrix | ) |
|
Overwrites all components of this transform.
- Parameters
-
| newModelMatrix | new 4x4 model matrix |
◆ setWorldPosition()
| 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.
- Parameters
-
| newLocation | The new position in world space. |
◆ setWorldRotation() [1/2]
| void Engine::Entities::SceneNode::setWorldRotation |
( |
const glm::quat & | newRotation | ) |
|
Sets a new world rotation with a quaternion on this node.
- Parameters
-
| newRotation | quaternion rotation |
◆ setWorldRotation() [2/2]
| void Engine::Entities::SceneNode::setWorldRotation |
( |
const glm::vec3 & | newRotation | ) |
|
Sets the world rotation of this node with euler angles.
- Parameters
-
| newRotation | yaw pitch roll |
◆ setWorldScale()
| void Engine::Entities::SceneNode::setWorldScale |
( |
const glm::vec3 & | newScale | ) |
|
sets the scale for this node
- Parameters
-
| newScale | the scale to be set to |
◆ updateWorldMatrix()
| void Engine::Entities::SceneNode::updateWorldMatrix |
( |
| ) |
const |
|
private |
◆ children_
| std::vector<std::shared_ptr<SceneNode> > Engine::Entities::SceneNode::children_ |
|
private |
◆ disableCaching
| bool Engine::Entities::SceneNode::disableCaching = false |
|
private |
◆ entity_
| entt::entity Engine::Entities::SceneNode::entity_ |
|
private |
◆ indexInParent_
| size_t Engine::Entities::SceneNode::indexInParent_ = 0 |
|
private |
◆ parent_
| std::weak_ptr<SceneNode> Engine::Entities::SceneNode::parent_ |
|
private |
◆ registry
| entt::registry* Engine::Entities::SceneNode::registry |
|
private |
◆ worldMatrix
| glm::mat4 Engine::Entities::SceneNode::worldMatrix |
|
mutableprivate |
The documentation for this class was generated from the following file:
- /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/World/SceneGraph.h