template<class Transformation>
Object class
Object.
Contents
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::
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 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
Public functions
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>>& -
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()
Destructor.
Removes itself from parent's children list and destroys all own children.
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..., &object}
.
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::
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.