Magnum::Trade::ObjectData2D class

Two-dimensional object data.

Provides access to object transformation and hierarchy.

Derived classes

class MeshObjectData2D deprecated in Git master
Two-dimensional mesh object data.

Constructors, destructors, conversion operators

ObjectData2D(std::vector<UnsignedInt> children, const Matrix3& transformation, ObjectInstanceType2D instanceType, UnsignedInt instance, const void* importerState = nullptr) explicit
Construct with combined transformation.
ObjectData2D(std::vector<UnsignedInt> children, const Vector2& translation, const Complex& rotation, const Vector2& scaling, ObjectInstanceType2D instanceType, UnsignedInt instance, const void* importerState = nullptr) explicit
Construct with separate transformations.
ObjectData2D(std::vector<UnsignedInt> children, const Matrix3& transformation, const void* importerState = nullptr) explicit
Construct empty instance with combined transformation.
ObjectData2D(std::vector<UnsignedInt> children, const Vector2& translation, const Complex& rotation, const Vector2& scaling, const void* importerState = nullptr) explicit
Construct empty instance with separate transformations.
ObjectData2D(const ObjectData2D&) deleted
Copying is not allowed.
ObjectData2D(ObjectData2D&&) noexcept
Move constructor.
~ObjectData2D() virtual
Destructor.

Public functions

auto operator=(const ObjectData2D&) -> ObjectData2D& deleted
Copying is not allowed.
auto operator=(ObjectData2D&&) -> ObjectData2D& noexcept
Move assignment.
auto children() -> std::vector<UnsignedInt>&
Child objects.
auto children() const -> const std::vector<UnsignedInt>&
auto flags() const -> ObjectFlags2D
Flags.
auto translation() const -> Vector2
Translation (relative to parent)
auto rotation() const -> Complex
Rotation (relative to parent)
auto scaling() const -> Vector2
Scaling (relative to parent)
auto transformation() const -> Matrix3
Transformation (relative to parent)
auto instanceType() const -> ObjectInstanceType2D
Instance type.
auto instance() const -> Int
Instance ID.
auto importerState() const -> const void*
Importer-specific state.

Function documentation

Magnum::Trade::ObjectData2D::ObjectData2D(std::vector<UnsignedInt> children, const Matrix3& transformation, ObjectInstanceType2D instanceType, UnsignedInt instance, const void* importerState = nullptr) explicit

Construct with combined transformation.

Parameters
children Child objects
transformation Transformation (relative to parent)
instanceType Instance type
instance Instance ID
importerState Importer-specific state

Magnum::Trade::ObjectData2D::ObjectData2D(std::vector<UnsignedInt> children, const Vector2& translation, const Complex& rotation, const Vector2& scaling, ObjectInstanceType2D instanceType, UnsignedInt instance, const void* importerState = nullptr) explicit

Construct with separate transformations.

Parameters
children Child objects
translation Translation (relative to parent)
rotation Rotation (relative to parent)
scaling Scaling (relative to parent)
instanceType Instance type
instance Instance ID
importerState Importer-specific state

Magnum::Trade::ObjectData2D::ObjectData2D(std::vector<UnsignedInt> children, const Matrix3& transformation, const void* importerState = nullptr) explicit

Construct empty instance with combined transformation.

Parameters
children Child objects
transformation Transformation (relative to parent)
importerState Importer-specific state

Magnum::Trade::ObjectData2D::ObjectData2D(std::vector<UnsignedInt> children, const Vector2& translation, const Complex& rotation, const Vector2& scaling, const void* importerState = nullptr) explicit

Construct empty instance with separate transformations.

Parameters
children Child objects
translation Translation (relative to parent)
rotation Rotation (relative to parent)
scaling Scaling (relative to parent)
importerState Importer-specific state

const std::vector<UnsignedInt>& Magnum::Trade::ObjectData2D::children() const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Vector2 Magnum::Trade::ObjectData2D::translation() const

Translation (relative to parent)

Available only if ObjectFlag2D::HasTranslationRotationScaling is set, use transformation() otherwise. Applied as last in the final transformation, see transformation() for more information.

Complex Magnum::Trade::ObjectData2D::rotation() const

Rotation (relative to parent)

Available only if ObjectFlag2D::HasTranslationRotationScaling is set, use transformation() otherwise. Applied second in the final transformation, see transformation() for more information.

Vector2 Magnum::Trade::ObjectData2D::scaling() const

Scaling (relative to parent)

Available only if ObjectFlag2D::HasTranslationRotationScaling is set, use transformation() otherwise. Applied as first in the final transformation, see transformation() for more information.

Matrix3 Magnum::Trade::ObjectData2D::transformation() const

Transformation (relative to parent)

If ObjectFlag2D::HasTranslationRotationScaling is not set, returns the imported object transformation matrix. Otherwise calculates the final transformation matrix $ \boldsymbol{M} $ from translation, rotation and scaling matrices $ \boldsymbol{T} $ , $ \boldsymbol{R} $ , $ \boldsymbol{S} $ created from translation(), rotation() and scaling() in the following order:

\[ \boldsymbol{M} = \boldsymbol{T} \boldsymbol{R} \boldsymbol{S} \]

The corresponding code is as follows:

Matrix3 transformation =
    Matrix3::from(data.rotation().toMatrix(), data.translation())*
    Matrix3::scaling(data.scaling());

ObjectInstanceType2D Magnum::Trade::ObjectData2D::instanceType() const

Instance type.

Int Magnum::Trade::ObjectData2D::instance() const

Instance ID.

Returns ID of given camera / light / mesh etc., specified by instanceType(). If instanceType() is ObjectInstanceType2D::Empty, this function returns -1.

const void* Magnum::Trade::ObjectData2D::importerState() const

Importer-specific state.

See AbstractImporter::importerState() for more information.