Carna
Version 3.3.2
|
Defines the inner node of a scene graph. Implements a spatial scene element that is allowed to have children, but cannot be rendered. More...
#include <Node.h>
Public Member Functions | |
Node (const std::string &tag="") | |
Instantiates. More... | |
virtual | ~Node () |
Deletes. | |
void | addNodeListener (NodeListener &listener) |
Notifies listener of changes related to this node in \(\mathcal O\left(\log n\right)\). | |
void | removeNodeListener (NodeListener &listener) |
Removes listener from being notified of changes related to this node in \(\mathcal O\left(\log n\right)\). | |
void | invalidate () override |
Notifies all its listeners that this subtree has changed. This may include changes of the tree structure as well as updated materials and suchlike. Also invalidates all its parent subtrees. | |
void | attachChild (Spatial *child) |
Attaches child to this node in \(\mathcal O\left(\log n\right)\) and takes it's possession. More... | |
Spatial * | detachChild (Spatial &child) |
Detaches child from this node in \(\mathcal O\left(\log n\right)\). The caller takes possession of the child. More... | |
bool | hasChild (const Spatial &child) const |
Tells whether child is among the children of this node in \(\mathcal O\left(\log n\right)\). | |
void | deleteAllChildren () |
Deletes all children of this node. | |
std::size_t | children () const |
Tells number of children. | |
void | visitChildren (bool recursively, const MutableVisitor &visit) |
Invokes visit once on each child of this node recursively. | |
void | visitChildren (bool recursively, const ImmutableVisitor &visit) const |
virtual void | updateWorldTransform () override |
Computes the transformation to world space for this node just like the base class does, than orders it's children to do the same. | |
![]() | |
Spatial (const std::string &tag="") | |
Instantiates. More... | |
virtual | ~Spatial () |
Does nothing. | |
bool | hasParent () const |
Tells whether this spatial has a parent node. | |
Spatial * | detachFromParent () |
Detaches this spatial from it's parent node in \(\mathcal O\left(\log n\right)\) where \(n\) is the number of parent's children. The caller takes possession of this spatial. More... | |
void | updateParent (Node &parent) |
Fixes tree consistency by updating parent of this spatial. This method is for internal usage only. | |
Node & | parent () |
References the parent node. More... | |
const Node & | parent () const |
Node & | findRoot () |
References the root node this spatial belongs to. | |
const Node & | findRoot () const |
References the root node this spatial belongs to. | |
const math::Matrix4f & | worldTransform () const |
Tells the transformation to world space for this spatial that was last computed. | |
template<typename UserDataType > | |
void | setUserData (const UserDataType &userData) |
Links an arbitrary object with this Spatial instance. More... | |
void | removeUserData () |
Removes any object that has been linked with this Spatial instance through setUserData previously. More... | |
bool | hasUserData () const |
Tells whether an object has been linked with this Spatial instance through setUserData previously. | |
template<typename UserDataType > | |
const UserDataType & | userData () const |
Retrieves the object previously linked with this Spatial instance. More... | |
void | setMovable (bool movable) |
Sets whether this spatial may be displaced w.r.t. it's parent through user interaction. Usually this will be false when this spatial represents a component of it's parent, like the shaft of an arrow. More... | |
bool | isMovable () const |
Tells whether this spatial may be displaced w.r.t. it's parent through user interaction. Usually this will be false when this spatial represents a component of it's parent, like the shaft of an arrow. More... | |
void | setTag (const std::string &tag) |
Sets an arbitrary tag that may be used to identify this object. | |
const std::string & | tag () const |
Tells the tag set previously. | |
Additional Inherited Members | |
![]() | |
typedef std::function< void(Spatial &) > | MutableVisitor |
Declares an entity that visits mutable Spatial instances. | |
typedef std::function< void(const Spatial &) > | ImmutableVisitor |
Declares an entity that visits mutable Spatial instances. | |
![]() | |
math::Matrix4f | localTransform |
Defines the location, rotation and scale of this spatial in relation to it's parent. If this spatial has no parent, the value has no meaning. More... | |
Defines the inner node of a scene graph. Implements a spatial scene element that is allowed to have children, but cannot be rendered.
Each node possesses it's children.
|
explicit |
Instantiates.
tag | is an arbitrary string that may be used to identify this node. |
void Carna::base::Node::attachChild | ( | Spatial * | child | ) |
Attaches child to this node in \(\mathcal O\left(\log n\right)\) and takes it's possession.
If child already has another parent, it is first detached from that one.
Detaches child from this node in \(\mathcal O\left(\log n\right)\). The caller takes possession of the child.
nullptr
if something went wrong, e.g. this node is not the child's parent. void Carna::base::Node::visitChildren | ( | bool | recursively, |
const ImmutableVisitor & | visit | ||
) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Documentation generated by Doxygen