![]() |
Carna Version 3.3.3
|
Represents a spatial scene element. It's location is determined relatively to another spatial that is called its parent. This parent-child relationship induces the scene graph concept. More...
#include <Spatial.h>
Public Types | |
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 Member Functions | |
Spatial (const std::string &tag="") | |
Instantiates. | |
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. | |
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. | |
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. | |
virtual void | updateWorldTransform () |
Computes the transformation to world space for this spatial. | |
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. | |
void | removeUserData () |
Removes any object that has been linked with this Spatial instance through setUserData previously. | |
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. | |
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. | |
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. | |
virtual void | invalidate () |
Notifies all listeners of its parent nodes that their subtrees have changed. This may include changes of the tree structure as well as updated materials and suchlike. | |
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. | |
Public Attributes | |
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. | |
Represents a spatial scene element. It's location is determined relatively to another spatial that is called its parent. This parent-child relationship induces the scene graph concept.
typedef std::function< void( const Spatial& ) > Carna::base::Spatial::ImmutableVisitor |
typedef std::function< void( Spatial& ) > Carna::base::Spatial::MutableVisitor |
|
explicit |
Instantiates.
tag | is an arbitrary string that may be used to identify this node. |
Spatial * Carna::base::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.
hasParent() == true
hasParent() == false
nullptr
if it has no parent. Notifies all listeners of its parent nodes that their subtrees have changed. This may include changes of the tree structure as well as updated materials and suchlike.
Reimplemented in Carna::base::Node.
bool Carna::base::Spatial::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.
Each spatial is movable by default.
Node & Carna::base::Spatial::parent | ( | ) |
References the parent node.
hasParent() == true
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
void Carna::base::Spatial::removeUserData | ( | ) |
Removes any object that has been linked with this Spatial
instance through setUserData previously.
hasUserData() == false
Does nothing if hasUserData is false
.
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.
Each spatial is movable by default.
void Carna::base::Spatial::setUserData | ( | const UserDataType & | userData | ) |
Links an arbitrary object with this Spatial
instance.
hasUserData() == true
Computes the transformation to world space for this spatial.
The default implementation concatenates the parent's world transformation with the local transformation of this spatial.
Reimplemented in Carna::base::Camera, and Carna::base::Node.
const UserDataType & Carna::base::Spatial::userData | ( | ) | const |
Retrieves the object previously linked with this Spatial
instance.
hasUserData()
math::Matrix4f Carna::base::Spatial::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.
The default value is math::identity4f.
Documentation generated by Doxygen