Carna  Version 3.3.2
Public Member Functions | List of all members
Carna::base::Node Class Reference

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>

+ Inheritance diagram for Carna::base::Node:
+ Collaboration diagram for Carna::base::Node:

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...
 
SpatialdetachChild (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.
 
- Public Member Functions inherited from Carna::base::Spatial
 Spatial (const std::string &tag="")
 Instantiates. More...
 
virtual ~Spatial ()
 Does nothing.
 
bool hasParent () const
 Tells whether this spatial has a parent node.
 
SpatialdetachFromParent ()
 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.
 
Nodeparent ()
 References the parent node. More...
 
const Nodeparent () const
 
NodefindRoot ()
 References the root node this spatial belongs to.
 
const NodefindRoot () const
 References the root node this spatial belongs to.
 
const math::Matrix4fworldTransform () 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

- Public Types inherited from Carna::base::Spatial
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.
 
- Public Attributes inherited from Carna::base::Spatial
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...
 

Detailed Description

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.

Author
Leonid Kostrykin
Date
21.2.15 - 6.3.15

Definition at line 44 of file Node.h.

Constructor & Destructor Documentation

◆ Node()

Carna::base::Node::Node ( const std::string &  tag = "")
explicit

Instantiates.

Parameters
tagis an arbitrary string that may be used to identify this node.

Member Function Documentation

◆ attachChild()

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.

◆ detachChild()

Spatial* Carna::base::Node::detachChild ( Spatial child)

Detaches child from this node in \(\mathcal O\left(\log n\right)\). The caller takes possession of the child.

Returns
Possessing pointer to the child if it has successfully been detached or nullptr if something went wrong, e.g. this node is not the child's parent.

◆ visitChildren()

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.


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