#include <Magnum/SceneGraph/Object.h>
template<class Transformation>
Object class
Object.
Base of scene graph. Contains specific transformation implementation, takes care of parent/children relationship and contains features. See Using the scene graph for introduction.
Common usage is to typedef Object with desired transformation type to save unnecessary typing later, along with Scene and possibly other types, e.g.:
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D; typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D;
Uses Corrade::
Object3D o; for(Object3D& child: o.children()) { …; }
Or, if you need more flexibility, like in the following code. It is also possible to go in reverse order using Corrade::
for(Object3D* child = o.children().first(); child; child = child->nextSibling()) { … }
Explicit template specializations
The following specializations are explicitly compiled into the SceneGraph library. For other specializations (e.g. using Double type or special transformation class) you have to use the Object.hpp implementation file (and possibly others) to avoid linker errors. See also relevant sections in the AbstractObject and AbstractTransformation class documentation or Template headers and implementation files for more information.
- Object<DualComplexTransformation>
- Object<DualQuaternionTransformation>
- Object<MatrixTransformation2D> (custom specializations need also MatrixTransformation2D.hpp)
- Object<MatrixTransformation3D> (custom specializations need also MatrixTransformation3D.hpp)
- Object<RigidMatrixTransformation2D> (custom specializations need also RigidMatrixTransformation2D.hpp)
- Object<RigidMatrixTransformation3D> (custom specializations need also RigidMatrixTransformation3D.hpp)
- Object<TranslationTransformation2D>
- Object<TranslationTransformation3D>
Base classes
-
template<UnsignedInt dimensions, class T>class AbstractObject<Transformation::Dimensions, Transformation::Type>
- Base for objects.
Derived classes
-
template<class Transformation>class Scene
- Scene.
Public types
- using MatrixType = MatrixTypeFor<Transformation::Dimensions, typename Transformation::Type>
- Matrix type.
Constructors, destructors, conversion operators
Public functions
- auto operator=(const Object<Transformation>&) -> Object<Transformation>& deleted
- Copying is not allowed.
- auto operator=(Object<Transformation>&&) -> Object<Transformation>& deleted
- Moving is not allowed.
-
template<class U, class ... Args>auto addFeature(Args && ... args) -> U& new in Git master
- Add a feature.
Scene hierarchy
See Scene hierarchy for more information.
- auto scene() -> Scene<Transformation>*
- Scene.
- auto scene() const -> const Scene<Transformation>*
- auto parent() -> Object<Transformation>*
- Parent object or
nullptr
, if this is the root object. - auto parent() const -> const Object<Transformation>*
- auto move(Object<Transformation>& child, Object<Transformation>* before) -> Object<Transformation>& new in Git master
- Move a child object before another.
- auto previousSibling() -> Object<Transformation>*
- Previous sibling object or
nullptr
, if this is the first object. - auto previousSibling() const -> const Object<Transformation>*
- auto nextSibling() -> Object<Transformation>*
- Next sibling object or
nullptr
, if this is the last object. - auto nextSibling() const -> const Object<Transformation>*
-
auto children() -> Containers::
LinkedList<Object<Transformation>>& - Child objects.
-
auto children() const -> const Containers::
LinkedList<Object<Transformation>>& -
template<class T, class ... Args>auto addChild(Args && ... args) -> T&
- Add a child.
- auto setParent(Object<Transformation>* parent) -> Object<Transformation>&
- Set parent object.
- auto setParentKeepTransformation(Object<Transformation>* parent) -> Object<Transformation>&
- Set parent object and keep absolute transformation.
Object transformation
- auto transformationMatrix() const -> MatrixType
- Transformation matrix.
- auto absoluteTransformationMatrix() const -> MatrixType
- Transformation matrix relative to the root object.
- auto absoluteTransformation() const -> Transformation::DataType
- Transformation relative to the root object.
-
auto transformationMatrices(const std::
vector<std:: reference_wrapper<Object<Transformation>>>& objects, const MatrixType& finalTransformationMatrix = MatrixType()) const -> std:: vector<MatrixType> - Transformation matrices of given set of objects relative to this object.
-
auto transformations(std::
vector<std:: reference_wrapper<Object<Transformation>>> objects, const typename Transformation::DataType& finalTransformation = typename Transformation::DataType()) const -> std:: vector<typename Transformation::DataType> - Transformations of given group of objects relative to this object.
Transformation caching
See Transformation caching in features for more information.
- auto isDirty() const -> bool
- Whether absolute transformation is dirty.
- void setDirty()
- Set object absolute transformation as dirty.
- void setClean()
- Clean object absolute transformation.
-
static void setClean(std::
vector<std:: reference_wrapper<Object<Transformation>>> objects) - Clean absolute transformations of given set of objects.
Function documentation
template<class Transformation>
Magnum:: SceneGraph:: Object<Transformation>:: ~Object()
Destructor.
Destroys all own children and then removes itself from the parent list. Features are then deleted in the AbstractObject destructor.
template<class Transformation>
template<class U, class ... Args>
U& Magnum:: SceneGraph:: Object<Transformation>:: addFeature(Args && ... args) new in Git master
Add a feature.
Like AbstractObject::
template<class Transformation>
Object<Transformation>& Magnum:: SceneGraph:: Object<Transformation>:: move(Object<Transformation>& child,
Object<Transformation>* before) new in Git master
Move a child object before another.
Returns | Reference to self (for method chaining) |
---|
Doesn't have any effect on draw order, only on the child order when iterating through children(). The child
is expected to be a child of this object, before
is either a child of this object or nullptr
in which case the child
is moved to the last position in the child list.
template<class Transformation>
const Object<Transformation>* Magnum:: SceneGraph:: Object<Transformation>:: previousSibling() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class Transformation>
const Object<Transformation>* Magnum:: SceneGraph:: Object<Transformation>:: nextSibling() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class Transformation>
Containers:: LinkedList<Object<Transformation>>& Magnum:: SceneGraph:: Object<Transformation>:: children()
Child objects.
template<class Transformation>
const Containers:: LinkedList<Object<Transformation>>& Magnum:: SceneGraph:: Object<Transformation>:: children() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class Transformation>
template<class T, class ... Args>
T& Magnum:: SceneGraph:: Object<Transformation>:: addChild(Args && ... args)
Add a child.
Calling object.addChild<MyObject>(args...)
is equivalent to new MyObject{args...}
followed by an appropriate setParent() call.
template<class Transformation>
Object<Transformation>& Magnum:: SceneGraph:: Object<Transformation>:: setParentKeepTransformation(Object<Transformation>* parent)
Set parent object and keep absolute transformation.
Returns | Reference to self (for method chaining) |
---|
While setParent() preserves relative transformation of the object, this function preserves absolute transformation (i.e., the object stays in place after reparenting).
template<class Transformation>
MatrixType Magnum:: SceneGraph:: Object<Transformation>:: transformationMatrix() const
Transformation matrix.
See also transformation()
function of various transformation classes.
template<class Transformation>
MatrixType Magnum:: SceneGraph:: Object<Transformation>:: absoluteTransformationMatrix() const
Transformation matrix relative to the root object.
template<class Transformation>
Transformation::DataType Magnum:: SceneGraph:: Object<Transformation>:: absoluteTransformation() const
Transformation relative to the root object.
template<class Transformation>
std:: vector<MatrixType> Magnum:: SceneGraph:: Object<Transformation>:: transformationMatrices(const std:: vector<std:: reference_wrapper<Object<Transformation>>>& objects,
const MatrixType& finalTransformationMatrix = MatrixType()) const
Transformation matrices of given set of objects relative to this object.
All transformations are post-multiplied with finalTransformationMatrix
, if specified (it gets applied on the left-most side, suitable for example for an inverse camera transformation or a projection matrix).
template<class Transformation>
std:: vector<typename Transformation::DataType> Magnum:: SceneGraph:: Object<Transformation>:: transformations(std:: vector<std:: reference_wrapper<Object<Transformation>>> objects,
const typename Transformation::DataType& finalTransformation = typename Transformation::DataType()) const
Transformations of given group of objects relative to this object.
All transformations are post-multiplied with finalTransformation
, if specified (it gets applied on the left-most side, suitable for example for an inverse camera transformation).
template<class Transformation>
bool Magnum:: SceneGraph:: Object<Transformation>:: isDirty() const
Whether absolute transformation is dirty.
Returns true
if transformation of the object or any parent has changed since last call to setClean(), false
otherwise. All objects are dirty by default.
template<class Transformation>
void Magnum:: SceneGraph:: Object<Transformation>:: setDirty()
Set object absolute transformation as dirty.
Calls AbstractFeature::
template<class Transformation>
void Magnum:: SceneGraph:: Object<Transformation>:: setClean()
Clean object absolute transformation.
Calls AbstractFeature::
See also setClean(std::
template<class Transformation>
static void Magnum:: SceneGraph:: Object<Transformation>:: setClean(std:: vector<std:: reference_wrapper<Object<Transformation>>> objects)
Clean absolute transformations of given set of objects.
Only dirty objects in the list are cleaned.