This is a snapshot of a work-in-progress documentation theme. If you feel lost, miss something, or want to see the original Doxygen docs instead, head over to the archived version of this documentation page.

template<class Transformation>
Magnum::SceneGraph::Object class

Object.

Base of scene graph. Contains specific transformation implementation, takes care of parent/children relationship and contains features. See Using 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::Containers::LinkedList for efficient hierarchy management. Traversing through the list of child objects can be done using range-based for:

Object3D o;
for(AbstractFeature3D& feature: o.features()) {
    // ...
}

Or, if you need more flexibility, like in the following code. It is also possible to go in reverse order using Corrade::Containers::LinkedList::last() and previousSibling().

for(Object3D* child = o->children().first(); child; child = child->nextSibling()) {
    // ...
}

Explicit template specializations

The following specializations are explicitly compiled into SceneGraph library. For other specializations (e.g. using Double type or special transformation class) you have to use Object.hpp implementation file to avoid linker errors. See also relevant sections in AbstractObject and AbstractTransformation class documentation or Template headers and implementation files for more information.

Base classes

template<UnsignedInt dimensions, class T>
class AbstractObject
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

Object(Object<Transformation>* parent = nullptr) explicit
Constructor.
Object(const Object<Transformation>&) deleted
Copying is not allowed.
Object(Object<Transformation>&&) deleted
Moving is not allowed.
~Object()
Destructor.

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.

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 root object.
auto parent() const -> const Object<Transformation>*
auto previousSibling() -> Object<Transformation>*
Previous sibling object or nullptr, if this is first object.
auto previousSibling() const -> const Object<Transformation>*
auto nextSibling() -> Object<Transformation>*
Next sibling object or nullptr, if this is last object.
auto nextSibling() const -> const Object<Transformation>*
auto children() -> Containers::LinkedList<Object<Transformation>>&
Child objects.
auto children() const -> const Containers::LinkedList<Object<Transformation>>&
auto hasChildren() const -> bool
Whether this object has children.
auto firstChild() -> Object<Transformation>*
First child object or nullptr, if this object has no children.
auto firstChild() const -> const Object<Transformation>*
auto lastChild() -> Object<Transformation>*
Last child object or nullptr, if this object has no children.
auto lastChild() const -> const 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 root object.
auto absoluteTransformation() const -> Transformation::DataType
Transformation relative to root object.
auto transformationMatrices(const std::vector<std::reference_wrapper<Object<Transformation>>>& objects, const MatrixType& initialTransformationMatrix = 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& initialTransformation = 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(Object<Transformation>* parent = nullptr) explicit

Constructor.

Parameters
parent Parent object

template<class Transformation>
Magnum::SceneGraph::Object<Transformation>::~Object()

Destructor.

Removes itself from parent's children list and destroys all own children.

template<class Transformation>
Scene<Transformation>* Magnum::SceneGraph::Object<Transformation>::scene()

Scene.

Returns Scene or nullptr, if the object is not part of any scene.

template<class Transformation>
const Scene<Transformation>* Magnum::SceneGraph::Object<Transformation>::scene() 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>::parent() 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>::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>
bool Magnum::SceneGraph::Object<Transformation>::hasChildren() const

Whether this object has children.

template<class Transformation>
Object<Transformation>* Magnum::SceneGraph::Object<Transformation>::firstChild()

First child object or nullptr, if this object has no children.

template<class Transformation>
const Object<Transformation>* Magnum::SceneGraph::Object<Transformation>::firstChild() 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>
Object<Transformation>* Magnum::SceneGraph::Object<Transformation>::lastChild()

Last child object or nullptr, if this object has no children.

template<class Transformation>
const Object<Transformation>* Magnum::SceneGraph::Object<Transformation>::lastChild() 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..., &object}.

template<class Transformation>
Object<Transformation>& Magnum::SceneGraph::Object<Transformation>::setParent(Object<Transformation>* parent)

Set parent object.

Returns Reference to self (for method chaining)

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 root object.

template<class Transformation>
Transformation::DataType Magnum::SceneGraph::Object<Transformation>::absoluteTransformation() const

Transformation relative to root object.

template<class Transformation>
std::vector<MatrixType> Magnum::SceneGraph::Object<Transformation>::transformationMatrices(const std::vector<std::reference_wrapper<Object<Transformation>>>& objects, const MatrixType& initialTransformationMatrix = MatrixType()) const

Transformation matrices of given set of objects relative to this object.

All transformations are premultiplied with initialTransformationMatrix, if specified.

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& initialTransformation = typename Transformation::DataType()) const

Transformations of given group of objects relative to this object.

All transformations can be premultiplied with initialTransformation, if specified.

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::markDirty() on all object features and recursively calls setDirty() on every child object which is not already dirty. If the object is already marked as dirty, the function does nothing.

template<class Transformation>
void Magnum::SceneGraph::Object<Transformation>::setClean()

Clean object absolute transformation.

Calls AbstractFeature::clean() and/or AbstractFeature::cleanInverted() on all object features which have caching enabled and recursively calls setClean() on every parent which is not already clean. If the object is already clean, the function does nothing.

See also setClean(std::vector<std::reference_wrapper<Object<Transformation>>>), which cleans given set of objects more efficiently than when calling setClean() on each object individually.

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.