Oxygen Engine
Modern C++ 3D Engine using OpenGL
Loading...
Searching...
No Matches
oe::scene::Node Class Reference

Scene node. More...

#include <OxygenEngine/scene/node.h>

+ Inheritance diagram for oe::scene::Node:
+ Collaboration diagram for oe::scene::Node:

Public Member Functions

 Node (const NodePtr &identifier)
 
void setChild (const NodePtr &child)
 Change the parent of a node to be this one.
 
void setParent (const NodePtr &new_parent)
 Change the parent of this node to "parent".
 
void moveToRoot () noexcept
 Detach the node from parent to make it a root node.
 
const std::string getAbsoluteName (const std::string &separator="/") const noexcept
 Get absolute name (from the hierarchy)
 
NodePtr search (const std::string path, const std::string separator="/")
 Search for a node among children using a name path.
 
NodePtr searchFromThisNode (const std::string &path, const std::string &separator) noexcept
 search starting from this node
 
const AABBgetBoundingBox () const
 Recompute and return bounding box from raw AABB.
 
const AABB getEnglobingBoundingBox () const
 Compute englobing bounding box including all children ones.
 
Transform getAbsoluteTransform () const
 Get Node transform relative from world origin.
 
glm::vec3 getAbsolutePosition () const
 Get Node position from world origin.
 
const glm::mat4 & getAbsoluteModelMatrix () const
 Get absolute model matrix (by taking the parents into account)
 
const glm::mat4 getAbsoluteInverseModelMatrix () const
 Get absolute inverse model matrix (by taking the parents into account)
 
void generateModel (const bool recursive=true) const
 Force regeneration of Models Matrices.
 
- Public Member Functions inherited from oe::scene::Transform
 Transform (const glm::vec3 &translation=glm::vec3(0.f), const glm::quat &rotation=glm::quat(1.f, 0.f, 0.f, 0.f), const glm::vec3 &scale=glm::vec3(1.f), const glm::vec3 &skew=glm::vec3(0.f), const glm::vec4 &perspective=glm::vec4(glm::vec3(0.f), 1.f))
 Generate Transform from its translation, rotation, scale values.
 
 Transform (const glm::mat4 &model)
 Generate Transform from a model matrix.
 
const glm::vec3 & getTranslation () const noexcept
 Get Translation component value of the transform.
 
const glm::vec3 & getPosition () const noexcept
 Get Translation component value of the transform.
 
const glm::quat & getRotation () const noexcept
 Get Rotation component value of the transform.
 
const glm::quat & getOrientation () const noexcept
 Get orientation of the transform.
 
const glm::vec3 & getScale () const noexcept
 Get Scaling component value of the transform.
 
const glm::vec3 & getSkew () const noexcept
 Get Skew component value of the transform.
 
const glm::vec4 & getPerspective () const noexcept
 get Perspective component value of the transform
 
void setTranslation (const float x, const float y, const float z) noexcept
 Translate to the specified position, filled component wise.
 
void setPosition (const float x, const float y, const float z) noexcept
 Translate to the specified position.
 
void setPosition (const glm::vec3 &position) noexcept
 Translate to the specified position.
 
void setRotation (const lit::Angle &x, const lit::Angle &y, const lit::Angle &z) noexcept
 Rotate the transform from Euler angles.
 
void setRotation (const glm::quat &rotation) noexcept
 Rotate the transform using a quaternion.
 
void setOrientation (const lit::Angle &x, const lit::Angle &y, const lit::Angle &z) noexcept
 Set orientation of transform using lit::Angle triad.
 
void setOrientation (const glm::quat &rotation) noexcept
 Set orientation of the transform using a quaternion.
 
void setScale (const float x, const float y, const float z) noexcept
 Set scaling.
 
void relativeTranslate (const glm::vec3 &translation) noexcept
 Translate the transform from current position.
 
void relativeTranslate (const float x, const float y, const float z) noexcept
 relative translate the transform from current position, component wise
 
void loadFromModel (const glm::mat4 &model) noexcept
 Fill the transform from a model matrix.
 
void relativeMove (const glm::vec3 &translation) noexcept
 Move the transform relative to current translation.
 
void relativeRotate (const glm::quat &quaternion) noexcept
 Rotate the transform relative to current rotation.
 
void relativeRotate (const float x, const float y, const float z) noexcept
 Rotate the transform from Euler angles (component wise)
 
void relativeRotate (const lit::Angle &x, const lit::Angle &y, const lit::Angle &z) noexcept
 Relatively rotate the transform using a lit::Angle triad.
 
void relativeScale (const glm::vec3 &scale) noexcept
 Multiply current scale by the new one.
 
void setSkew (const glm::vec3 &skew) noexcept
 Set skew of the transform.
 
void setPerspective (const glm::vec4 &perspective) noexcept
 Set perspective effect of the transform.
 
void interpolateWith (const float ratio, const Transform &target) noexcept
 Interpolate this transform with another one.
 
void fillFrom (const Transform &transform) noexcept
 Fill current values from another transform.
 
template<TranslationType T>
void setTranslation (const T &translation) noexcept
 Translate to the specified position.
 
template<RotationType R>
void setRotation (const R &rotation) noexcept
 Get rotation quaternion from a generic type.
 
template<ScaleType S>
void setScale (const S &scale) noexcept
 Set scale vector from a generic type.
 
template<TranslationType T>
void getTranslationAs (T &result) const noexcept
 Get translation vector and fill in generic type.
 
template<RotationType R>
void getRotationAs (R &result) const noexcept
 Get rotation quaternion and fill in generic type.
 
template<ScaleType S>
void getScaleAs (S &result) const noexcept
 Get scale vector and fill in generic type.
 
glm::mat4 getModelMatrix () const noexcept
 Generate a Model matrix from the transform.
 
bool isDirty () const noexcept
 Check if something modified this transform.
 

Public Attributes

NodePtr scene_data
 Scene pointer to this node.
 
void * user_data = 0
 Custom user data, you can use it to store flags / pointer / physics / etc... related to this node.
 
bool is_active = true
 Toggle to check if the Node is active.
 
std::string name = ""
 Name, used as identifier for search.
 
AABB raw_aabb
 Raw bounding box (ie. without taking node transform)
 
NodePtr parent
 
std::vector< NodePtrchildren
 

Protected Attributes

AABB aabb
 Computed AABB (taking node transform into account)
 

Additional Inherited Members

- Protected Member Functions inherited from oe::scene::Transform
void forceDirty (const bool is_dirty) const noexcept
 Set custom dirty status.
 

Detailed Description

Scene node.

Note
Functions related to hierarchy will assert if related nodes belongs to the same scene

Member Function Documentation

◆ generateModel()

void oe::scene::Node::generateModel ( const bool  recursive = true) const

Force regeneration of Models Matrices.

Parameters
recursiveRun computations of all children

◆ getAbsoluteInverseModelMatrix()

const glm::mat4 oe::scene::Node::getAbsoluteInverseModelMatrix ( ) const
inline

Get absolute inverse model matrix (by taking the parents into account)

This matrix let you fill a transform that will convert world space coordinates to local node ones

Note
Can be used for physics or for changing node hierarchy without changing their Transform

◆ getBoundingBox()

const AABB & oe::scene::Node::getBoundingBox ( ) const

Recompute and return bounding box from raw AABB.

Note
if raw bounding box is empty, the bounding box is assumed to have been updated by other means (eg. by a component)
Todo:
optimize when raw_bbox is not empty to not recompute each time but only when transform or raw_bbox changes

◆ getEnglobingBoundingBox()

const AABB oe::scene::Node::getEnglobingBoundingBox ( ) const

Compute englobing bounding box including all children ones.

Note
Mainly used for collision detection

◆ moveToRoot()

void oe::scene::Node::moveToRoot ( )
inlinenoexcept

Detach the node from parent to make it a root node.

Children of this node are not changed

Note
If this node is already a root node, this function will be silently ignored

◆ search()

NodePtr oe::scene::Node::search ( const std::string  path,
const std::string  separator = "/" 
)
inline

Search for a node among children using a name path.

Note
if multiple nodes at same level have same name, only the first one is returned
Parameters
pathPath to search (starting from children)

◆ searchFromThisNode()

NodePtr oe::scene::Node::searchFromThisNode ( const std::string &  path,
const std::string &  separator 
)
noexcept

search starting from this node

First path member should be this node

◆ setChild()

void oe::scene::Node::setChild ( const NodePtr child)
inline

Change the parent of a node to be this one.

Hierarchy properties on both nodes are automaticly updated

Parameters
childThe new child
Note
If child is already a child of this node, this function will be silently ignored

◆ setParent()

void oe::scene::Node::setParent ( const NodePtr new_parent)
inline

Change the parent of this node to "parent".

Hierarchy properties of this node and old parent are automaticly updated

Parameters
new_parentThe new node parent

Member Data Documentation

◆ aabb

AABB oe::scene::Node::aabb
mutableprotected

Computed AABB (taking node transform into account)

Will be overwritten on updates if raw_aabb is not empty

Only fill manually if you generate the absolute bbox yourself (ex via bone skinning). In this case, only update this one and keep the raw_aabb empty

Note
For getting the bounding box, it is recomended to use getBoundingBox() instead of using this one

◆ is_active

bool oe::scene::Node::is_active = true

Toggle to check if the Node is active.

Actual meaning heavily depends of the components, but mainly used to prevent node update / rendering

◆ raw_aabb

AABB oe::scene::Node::raw_aabb

Raw bounding box (ie. without taking node transform)

Note
If your components have geometry, this is the bbox to update

◆ scene_data

NodePtr oe::scene::Node::scene_data

Scene pointer to this node.

Used to keep pointer to the scene and keep the unique id of the node

◆ user_data

void* oe::scene::Node::user_data = 0

Custom user data, you can use it to store flags / pointer / physics / etc... related to this node.

Note
OxygenEngine won't touch this member

The documentation for this class was generated from the following file: