Browse Source

SceneGraph: deprecating TransformationType enum and related functions.

The enum was only two-state, in almost all cases it included unnecessary
branching and the non-default usage was too verbose, thus all
transformation functions were split into two variants, <transform>() and
<transform>Local(). The <transform>() behaves exactly like the previous
implementation with TransformationType::Global, the <transform>Local()
behaves like the previous implementation with TransformationType::Local.

The enum and original functions were kept, they are marked as deprecated
and will be removed in future release.

This is rather large changeset, I triple checked that the new (both
deprecated and non-deprecated) implementations work as intended, but
can't possibly test every possible use case, so I'm sorry if I messed
something up :-) Also there was probably some bug in internal virtual
function implementations before, it should be now fixed.
pull/77/head
Vladimír Vondruš 12 years ago
parent
commit
a648821912
  1. 10
      src/Magnum/SceneGraph/AbstractTransformation.h
  2. 48
      src/Magnum/SceneGraph/AbstractTranslation.h
  3. 49
      src/Magnum/SceneGraph/AbstractTranslationRotation2D.h
  4. 188
      src/Magnum/SceneGraph/AbstractTranslationRotation3D.h
  5. 61
      src/Magnum/SceneGraph/AbstractTranslationRotationScaling2D.h
  6. 98
      src/Magnum/SceneGraph/AbstractTranslationRotationScaling3D.h
  7. 115
      src/Magnum/SceneGraph/DualComplexTransformation.h
  8. 151
      src/Magnum/SceneGraph/DualQuaternionTransformation.h
  9. 175
      src/Magnum/SceneGraph/MatrixTransformation2D.h
  10. 283
      src/Magnum/SceneGraph/MatrixTransformation3D.h
  11. 145
      src/Magnum/SceneGraph/RigidMatrixTransformation2D.h
  12. 261
      src/Magnum/SceneGraph/RigidMatrixTransformation3D.h
  13. 2
      src/Magnum/SceneGraph/SceneGraph.h
  14. 6
      src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp
  15. 12
      src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp
  16. 10
      src/Magnum/SceneGraph/Test/MatrixTransformation2DTest.cpp
  17. 16
      src/Magnum/SceneGraph/Test/MatrixTransformation3DTest.cpp
  18. 8
      src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp
  19. 14
      src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp
  20. 39
      src/Magnum/SceneGraph/TranslationTransformation.h

10
src/Magnum/SceneGraph/AbstractTransformation.h

@ -29,6 +29,8 @@
* @brief Class @ref Magnum::SceneGraph::AbstractTransformation, alias @ref Magnum::SceneGraph::AbstractBasicTransformation2D, @ref Magnum::SceneGraph::AbstractBasicTransformation3D, typedef @ref Magnum::SceneGraph::AbstractTransformation2D, @ref Magnum::SceneGraph::AbstractTransformation3D, enum @ref Magnum::SceneGraph::TransformationType
*/
#include <Corrade/Utility/Macros.h>
#include "Magnum/SceneGraph/SceneGraph.h"
#include "Magnum/SceneGraph/visibility.h"
@ -85,18 +87,20 @@ template<UnsignedInt dimensions, class T> class AbstractTransformation {
virtual void doResetTransformation() = 0;
};
#ifdef MAGNUM_BUILD_DEPRECATED
/**
@brief Transformation type
@todo Get rid of this in favor of separate function for each type (less branching)
@deprecated Use `*Transformation*::*()` and `*Transformation::*Local*()`
overloads instead.
*/
enum class TransformationType: UnsignedByte {
enum class TransformationType: UnsignedByte CORRADE_DEPRECATED("use *() and *Local() overloads instead") {
/** Global transformation, applied after all other transformations. */
Global = 0x00,
/** Local transformation, applied before all other transformations. */
Local = 0x01
};
#endif
/**
@brief Base transformation for two-dimensional scenes

48
src/Magnum/SceneGraph/AbstractTranslation.h

@ -57,19 +57,48 @@ class AbstractTranslation: public AbstractTransformation<dimensions, T> {
/**
* @brief Translate object
* @param vector Translation vector
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* @see @ref Math::Vector2::xAxis(), @ref Math::Vector2::yAxis(),
* @ref Math::Vector3::xAxis(), @ref Math::Vector3::yAxis(),
* @ref Math::Vector3::zAxis()
* @see @ref translateLocal(), @ref Math::Vector2::xAxis(),
* @ref Math::Vector2::yAxis(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis()
*/
AbstractTranslation<dimensions, T, TranslationType>& translate(const VectorTypeFor<dimensions, TranslationType>& vector, TransformationType type = TransformationType::Global) {
doTranslate(vector, type);
AbstractTranslation<dimensions, T, TranslationType>& translate(const VectorTypeFor<dimensions, TranslationType>& vector) {
doTranslate(vector);
return *this;
}
/**
* @brief Translate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
AbstractTranslation<dimensions, T, TranslationType>& translateLocal(const VectorTypeFor<dimensions, TranslationType>& vector) {
doTranslateLocal(vector);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslation::translate() "translate()"
* or @ref Magnum::SceneGraph::AbstractTranslation::translateLocal() "translateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use translate() or translateLocal() instead") AbstractTranslation<dimensions, T, TranslationType>& translate(const VectorTypeFor<dimensions, TranslationType>& vector, TransformationType type) {
return type == TransformationType::Global ? translate(vector) : translateLocal(vector);
}
#endif
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractTranslation<dimensions, T, TranslationType>& resetTransformation() {
AbstractTransformation<dimensions, T>::resetTransformation();
return *this;
}
#endif
protected:
~AbstractTranslation() = default;
@ -79,7 +108,10 @@ class AbstractTranslation: public AbstractTransformation<dimensions, T> {
private:
#endif
/** @brief Polymorphic implementation for @ref translate() */
virtual void doTranslate(const VectorTypeFor<dimensions, TranslationType>& vector, TransformationType type) = 0;
virtual void doTranslate(const VectorTypeFor<dimensions, TranslationType>& vector) = 0;
/** @brief Polymorphic implementation for @ref translateLocal() */
virtual void doTranslateLocal(const VectorTypeFor<dimensions, TranslationType>& vector) = 0;
};
/**

49
src/Magnum/SceneGraph/AbstractTranslationRotation2D.h

@ -47,20 +47,58 @@ template<class T> class AbstractBasicTranslationRotation2D: public AbstractBasic
/**
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* @see @ref rotateLocal()
*/
AbstractBasicTranslationRotation2D<T>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotate(angle, type);
AbstractBasicTranslationRotation2D<T>& rotate(Math::Rad<T> angle) {
doRotate(angle);
return *this;
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
AbstractBasicTranslationRotation2D<T>& rotateLocal(Math::Rad<T> angle) {
doRotateLocal(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslationRotation2D::rotate() "rotate()"
* or @ref Magnum::SceneGraph::AbstractTranslationRotation2D::rotateLocal() "rotateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") AbstractBasicTranslationRotation2D<T>& rotate(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotate(angle, type) : rotateLocal(angle, type);
}
#endif
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractBasicTranslationRotation2D<T>& resetTransformation() {
AbstractBasicTranslation2D<T>::resetTransformation();
return *this;
}
AbstractBasicTranslationRotation2D<T>& translate(const Math::Vector2<T>& vector) {
AbstractBasicTranslation2D<T>::translate(vector);
return *this;
}
AbstractBasicTranslationRotation2D<T>& translateLocal(const Math::Vector2<T>& vector) {
AbstractBasicTranslation2D<T>::translateLocal(vector);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use translate() or translateLocal() instead") AbstractBasicTranslationRotation2D<T>& translate(const Math::Vector2<T>& vector, TransformationType type) {
AbstractBasicTranslation2D<T>::translate(vector, type);
return *this;
}
#endif
#endif
protected:
@ -72,7 +110,10 @@ template<class T> class AbstractBasicTranslationRotation2D: public AbstractBasic
private:
#endif
/** @brief Polymorphic implementation for @ref rotate() */
virtual void doRotate(Math::Rad<T> angle, TransformationType type) = 0;
virtual void doRotate(Math::Rad<T> angle) = 0;
/** @brief Polymorphic implementation for @ref rotateLocal() */
virtual void doRotateLocal(Math::Rad<T> angle) = 0;
};
/**

188
src/Magnum/SceneGraph/AbstractTranslationRotation3D.h

@ -49,69 +49,180 @@ template<class T> class AbstractBasicTranslationRotation3D: public AbstractBasic
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @param normalizedAxis Normalized rotation axis
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* @see @ref rotateX(), @ref rotateY(), @ref rotateZ(),
* @ref Math::Vector3::xAxis(), @ref Math::Vector3::yAxis(),
* @ref Math::Vector3::zAxis()
* @see @ref rotateLocal(), @ref rotateX(), @ref rotateY(),
* @ref rotateZ(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis()
*/
AbstractBasicTranslationRotation3D<T>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
doRotate(angle, normalizedAxis, type);
AbstractBasicTranslationRotation3D<T>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
doRotate(angle, normalizedAxis);
return *this;
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
AbstractBasicTranslationRotation3D<T>& rotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
doRotateLocal(angle, normalizedAxis);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotate() "rotate()"
* or @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotateLocal() "rotateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") AbstractBasicTranslationRotation3D<T>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) {
return type == TransformationType::Global ? rotate(angle, normalizedAxis) : rotateLocal(angle, normalizedAxis);
}
#endif
/**
* @brief Rotate object around X axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* In some implementations faster than calling
* `rotate(angle, Vector3::xAxis())`, see subclasses for more
* information.
* @see @ref rotateXLocal()
*/
AbstractBasicTranslationRotation3D<T>& rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotateX(angle, type);
AbstractBasicTranslationRotation3D<T>& rotateX(Math::Rad<T> angle) {
doRotateX(angle);
return *this;
}
/**
* @brief Rotate object around X axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. In some implementations faster than calling
* `rotateLocal(angle, Vector3::xAxis())`, see subclasses for more
* information.
*/
AbstractBasicTranslationRotation3D<T>& rotateXLocal(Math::Rad<T> angle) {
doRotateXLocal(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateX()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotateX() "rotateX()"
* or @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotateXLocal() "rotateXLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateX() or rotateXLocal() instead") AbstractBasicTranslationRotation3D<T>& rotateX(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateX(angle) : rotateXLocal(angle);
}
#endif
/**
* @brief Rotate object around Y axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* In some implementations faster than calling
* `rotate(angle, Vector3::yAxis())`, see subclasses for more
* information.
* @see @ref rotateYLocal()
*/
AbstractBasicTranslationRotation3D<T>& rotateY(Math::Rad<T> angle) {
doRotateY(angle);
return *this;
}
/**
* @brief Rotate object around Y axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. In some implementations faster than calling
* `rotateLocal(angle, Vector3::yAxis())`, see subclasses for more
* information.
*/
AbstractBasicTranslationRotation3D<T>& rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotateX(angle, type);
AbstractBasicTranslationRotation3D<T>& rotateYLocal(Math::Rad<T> angle) {
doRotateY(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief roateY()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotateY() "rotateY()"
* or @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotateYLocal() "rotateYLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateY() or rotateYLocal() instead") AbstractBasicTranslationRotation3D<T>& rotateY(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateY(angle) : rotateYLocal(angle);
}
#endif
/**
* @brief Rotate object around Z axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* In some implementations faster than calling
* `rotate(angle, Vector3::zAxis())`, see subclasses for more
* information.
* @see @ref rotateZLocal()
*/
AbstractBasicTranslationRotation3D<T>& rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotateZ(angle, type);
AbstractBasicTranslationRotation3D<T>& rotateZ(Math::Rad<T> angle) {
doRotateZ(angle);
return *this;
}
/**
* @brief Rotate object around Z axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. In some implementations faster than calling
* `rotateLocal(angle, Vector3::zAxis())`, see subclasses for more
* information.
*/
AbstractBasicTranslationRotation3D<T>& rotateZLocal(Math::Rad<T> angle) {
doRotateZLocal(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateZ()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotateZ() "rotateZ()"
* or @ref Magnum::SceneGraph::AbstractTranslationRotation3D::rotateZLocal() "rotateZLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateZ() or rotateZLocal() instead") AbstractBasicTranslationRotation3D<T>& rotateZ(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateZ(angle) : rotateZLocal();
}
#endif
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractBasicTranslationRotation3D<T>& resetTransformation() {
AbstractBasicTranslation3D<T>::resetTransformation();
return *this;
}
AbstractBasicTranslationRotation3D<T>& translate(const Math::Vector3<T>& vector) {
AbstractBasicTranslation3D<T>::translate(vector);
return *this;
}
AbstractBasicTranslationRotation3D<T>& translateLocal(const Math::Vector3<T>& vector) {
AbstractBasicTranslation3D<T>::translateLocal(vector);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use translate() or translateLocal() instead") AbstractBasicTranslationRotation3D<T>& translate(const Math::Vector2<T>& vector, TransformationType type) {
AbstractBasicTranslation3D<T>::translate(vector, type);
return *this;
}
#endif
#endif
protected:
@ -123,7 +234,10 @@ template<class T> class AbstractBasicTranslationRotation3D: public AbstractBasic
private:
#endif
/** @brief Polymorphic implementation for @ref rotate() */
virtual void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) = 0;
virtual void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) = 0;
/** @brief Polymorphic implementation for @ref rotateLocal() */
virtual void doRotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) = 0;
/**
* @brief Polymorphic implementation for @ref rotateX()
@ -131,8 +245,18 @@ template<class T> class AbstractBasicTranslationRotation3D: public AbstractBasic
* Default implementation calls @ref rotate() with
* @ref Math::Vector3::xAxis().
*/
virtual void doRotateX(Math::Rad<T> angle, TransformationType type) {
rotate(angle, Math::Vector3<T>::xAxis(), type);
virtual void doRotateX(Math::Rad<T> angle) {
rotate(angle, Math::Vector3<T>::xAxis());
}
/**
* @brief Polymorphic implementation for @ref rotateXLocal()
*
* Default implementation calls @ref rotateLocal() with
* @ref Math::Vector3::xAxis().
*/
virtual void doRotateXLocal(Math::Rad<T> angle) {
rotateLocal(angle, Math::Vector3<T>::xAxis());
}
/**
@ -141,8 +265,18 @@ template<class T> class AbstractBasicTranslationRotation3D: public AbstractBasic
* Default implementation calls @ref rotate() with
* @ref Math::Vector3::yAxis().
*/
virtual void doRotateY(Math::Rad<T> angle, TransformationType type) {
rotate(angle, Math::Vector3<T>::yAxis(), type);
virtual void doRotateY(Math::Rad<T> angle) {
rotate(angle, Math::Vector3<T>::yAxis());
}
/**
* @brief Polymorphic implementation for @ref rotateYLocal()
*
* Default implementation calls @ref rotateLocal() with
* @ref Math::Vector3::yAxis().
*/
virtual void doRotateYLocal(Math::Rad<T> angle) {
rotateLocal(angle, Math::Vector3<T>::yAxis());
}
/**
@ -151,8 +285,18 @@ template<class T> class AbstractBasicTranslationRotation3D: public AbstractBasic
* Default implementation calls @ref rotate() with
* @ref Math::Vector3::zAxis().
*/
virtual void doRotateZ(Math::Rad<T> angle, TransformationType type) {
rotate(angle, Math::Vector3<T>::zAxis(), type);
virtual void doRotateZ(Math::Rad<T> angle) {
rotate(angle, Math::Vector3<T>::zAxis());
}
/**
* @brief Polymorphic implementation for @ref rotateZLocal()
*
* Default implementation calls @ref rotateLocal() with
* @ref Math::Vector3::zAxis().
*/
virtual void doRotateZLocal(Math::Rad<T> angle) {
rotateLocal(angle, Math::Vector3<T>::zAxis());
}
};

61
src/Magnum/SceneGraph/AbstractTranslationRotationScaling2D.h

@ -46,32 +46,74 @@ template<class T> class AbstractBasicTranslationRotationScaling2D: public Abstra
/**
* @brief Scale object
* @param vector Scaling vector
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* @see @ref Math::Vector2::xScale(), @ref Math::Vector2::yScale()
* @see @ref scaleLocal(), @ref Math::Vector2::xScale(),
* @ref Math::Vector2::yScale()
*/
AbstractBasicTranslationRotationScaling2D<T>& scale(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
doScale(vector, type);
AbstractBasicTranslationRotationScaling2D<T>& scale(const Math::Vector2<T>& vector) {
doScale(vector);
return *this;
}
/**
* @brief Scale object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
AbstractBasicTranslationRotationScaling2D<T>& scaleLocal(const Math::Vector2<T>& vector) {
doScaleLocal(vector);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief scale()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslationRotationScaling2D::scale() "scale()"
* or @ref Magnum::SceneGraph::AbstractTranslationRotationScaling2D::scaleLocal() "scaleLocal()"
* instead.
*/
CORRADE_DEPRECATED("use scale() or scaleLocal() instead") AbstractBasicTranslationRotationScaling2D<T>& scale(const Math::Vector2<T>& vector, TransformationType type) {
return type == TransformationType::Global ? scale(vector) : scaleLocal(vector);
}
#endif
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractBasicTranslationRotationScaling2D<T>& resetTransformation() {
AbstractBasicTranslationRotation2D<T>::resetTransformation();
return *this;
}
AbstractBasicTranslationRotationScaling2D<T>& translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotationScaling2D<T>& translate(const Math::Vector2<T>& vector) {
AbstractBasicTranslationRotation2D<T>::translate(vector);
return *this;
}
AbstractBasicTranslationRotationScaling2D<T>& translateLocal(const Math::Vector2<T>& vector) {
AbstractBasicTranslationRotation2D<T>::translateLocal(vector);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use translate() or translateLocal() instead") AbstractBasicTranslationRotationScaling2D<T>& translate(const Math::Vector2<T>& vector, TransformationType type) {
AbstractBasicTranslationRotation2D<T>::translate(vector, type);
return *this;
}
AbstractBasicTranslationRotationScaling2D<T>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
#endif
AbstractBasicTranslationRotationScaling2D<T>& rotate(Math::Rad<T> angle) {
AbstractBasicTranslationRotation2D<T>::rotate(angle);
return *this;
}
AbstractBasicTranslationRotationScaling2D<T>& rotateLocal(Math::Rad<T> angle) {
AbstractBasicTranslationRotation2D<T>::rotateLocal(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") AbstractBasicTranslationRotationScaling2D<T>& rotate(Math::Rad<T> angle, TransformationType type) {
AbstractBasicTranslationRotation2D<T>::rotate(angle, type);
return *this;
}
#endif
#endif
protected:
~AbstractBasicTranslationRotationScaling2D() = default;
@ -82,7 +124,10 @@ template<class T> class AbstractBasicTranslationRotationScaling2D: public Abstra
private:
#endif
/** @brief Polymorphic implementation for @ref scale() */
virtual void doScale(const Math::Vector2<T>& vector, TransformationType type) = 0;
virtual void doScale(const Math::Vector2<T>& vector) = 0;
/** @brief Polymorphic implementation for @ref scaleLocal() */
virtual void doScaleLocal(const Math::Vector2<T>& vector) = 0;
};
/**

98
src/Magnum/SceneGraph/AbstractTranslationRotationScaling3D.h

@ -46,45 +46,116 @@ template<class T> class AbstractBasicTranslationRotationScaling3D: public Abstra
/**
* @brief Scale object
* @param vector Scaling vector
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* @see @ref Math::Vector3::xScale(), @ref Math::Vector3::yScale(),
* @ref Math::Vector3::zScale()
* @see @ref scaleLocal(), @ref Math::Vector3::xScale(),
* @ref Math::Vector3::yScale(), @ref Math::Vector3::zScale()
*/
AbstractBasicTranslationRotationScaling3D<T>& scale(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
doScale(vector, type);
AbstractBasicTranslationRotationScaling3D<T>& scale(const Math::Vector3<T>& vector) {
doScale(vector);
return *this;
}
/**
* @brief Scale object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
AbstractBasicTranslationRotationScaling3D<T>& scaleLocal(const Math::Vector3<T>& vector) {
doScaleLocal(vector);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief scale()
* @deprecated Use @ref Magnum::SceneGraph::AbstractTranslationRotationScaling3D::scale() "scale()"
* or @ref Magnum::SceneGraph::AbstractTranslationRotationScaling3D::scaleLocal() "scaleLocal()"
* instead.
*/
CORRADE_DEPRECATED("use scale() or scaleLocal() instead") AbstractBasicTranslationRotationScaling3D<T>& scale(const Math::Vector3<T>& vector, TransformationType type) {
return type == TransformationType::Global ? scale(vector) : scaleLocal(vector);
}
#endif
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractBasicTranslationRotationScaling3D<T>& resetTransformation() {
AbstractBasicTranslationRotation3D<T>::resetTransformation();
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotationScaling3D<T>& translate(const Math::Vector3<T>& vector) {
AbstractBasicTranslationRotation3D<T>::translate(vector);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& translateLocal(const Math::Vector3<T>& vector) {
AbstractBasicTranslationRotation3D<T>::translateLocal(vector);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use translate() or translateLocal() instead") AbstractBasicTranslationRotationScaling3D<T>& translate(const Math::Vector3<T>& vector, TransformationType type) {
AbstractBasicTranslationRotation3D<T>::translate(vector, type);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
#endif
AbstractBasicTranslationRotationScaling3D<T>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
AbstractBasicTranslationRotation3D<T>::rotate(angle, normalizedAxis);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
AbstractBasicTranslationRotation3D<T>::rotateLocal(angle, normalizedAxis);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") AbstractBasicTranslationRotationScaling3D<T>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) {
AbstractBasicTranslationRotation3D<T>::rotate(angle, normalizedAxis, type);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
#endif
AbstractBasicTranslationRotationScaling3D<T>& rotateX(Math::Rad<T> angle) {
AbstractBasicTranslationRotation3D<T>::rotateX(angle);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotateXLocal(Math::Rad<T> angle) {
AbstractBasicTranslationRotation3D<T>::rotateXLocal(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotateX() or rotateXLocal() instead") AbstractBasicTranslationRotationScaling3D<T>& rotateX(Math::Rad<T> angle, TransformationType type) {
AbstractBasicTranslationRotation3D<T>::rotateX(angle, type);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
#endif
AbstractBasicTranslationRotationScaling3D<T>& rotateY(Math::Rad<T> angle) {
AbstractBasicTranslationRotation3D<T>::rotateY(angle);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotateYLocal(Math::Rad<T> angle) {
AbstractBasicTranslationRotation3D<T>::rotateYLocal(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotateY() or rotateYLocal() instead") AbstractBasicTranslationRotationScaling3D<T>& rotateY(Math::Rad<T> angle, TransformationType type) {
AbstractBasicTranslationRotation3D<T>::rotateY(angle, type);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
#endif
AbstractBasicTranslationRotationScaling3D<T>& rotateZ(Math::Rad<T> angle) {
AbstractBasicTranslationRotation3D<T>::rotateZ(angle);
return *this;
}
AbstractBasicTranslationRotationScaling3D<T>& rotateZLocal(Math::Rad<T> angle) {
AbstractBasicTranslationRotation3D<T>::rotateZLocal(angle);
return *this;
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotateZ() or rotateZLocal() instead") AbstractBasicTranslationRotationScaling3D<T>& rotateZ(Math::Rad<T> angle, TransformationType type) {
AbstractBasicTranslationRotation3D<T>::rotateZ(angle, type);
return *this;
}
#endif
#endif
protected:
~AbstractBasicTranslationRotationScaling3D() = default;
@ -95,7 +166,10 @@ template<class T> class AbstractBasicTranslationRotationScaling3D: public Abstra
private:
#endif
/** @brief Polymorphic implementation for @ref scale() */
virtual void doScale(const Math::Vector3<T>& vector, TransformationType type) = 0;
virtual void doScale(const Math::Vector3<T>& vector) = 0;
/** @brief Polymorphic implementation for @ref scaleLocal() */
virtual void doScaleLocal(const Math::Vector3<T>& vector) = 0;
};
/**

115
src/Magnum/SceneGraph/DualComplexTransformation.h

@ -84,41 +84,112 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
/**
* @brief Transform object
* @param transformation Transformation
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Expects that the dual complex number is normalized.
* @see @ref Math::DualComplex::isNormalized()
* @see @ref transformLocal(), @ref Math::DualComplex::isNormalized()
*/
Object<BasicDualComplexTransformation<T>>& transform(const Math::DualComplex<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicDualComplexTransformation<T>>& transform(const Math::DualComplex<T>& transformation) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualComplexTransformation::transform(): the dual complex number is not normalized",
static_cast<Object<BasicDualComplexTransformation<T>>&>(*this));
return transformInternal(transformation, type);
return transformInternal(transformation);
}
/**
* @brief Transform object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicDualComplexTransformation<T>>& transformLocal(const Math::DualComplex<T>& transformation) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualComplexTransformation::transformLocal(): the dual complex number is not normalized",
static_cast<Object<BasicDualComplexTransformation<T>>&>(*this));
return transformLocalInternal(transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief transform()
* @deprecated Use @ref Magnum::SceneGraph::DualComplexTransformation::transform() "transform()"
* or @ref Magnum::SceneGraph::DualComplexTransformation::transformLocal() "transformLocal()"
* instead.
*/
CORRADE_DEPRECATED("use transform() or transformLocal() instead") Object<BasicDualComplexTransformation<T>>& transform(const Math::DualComplex<T>& transformation, TransformationType type) {
return type == TransformationType::Global ? transform(transformation) : transformLocal(transformation);
}
#endif
/**
* @copydoc AbstractTranslationRotationScaling2D::translate()
* @brief Translate object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::DualComplex::translation().
* @see @ref translateLocal(), @ref Math::Vector2::xAxis(),
* @ref Math::Vector2::yAxis()
*/
Object<BasicDualComplexTransformation<T>>& translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
return transformInternal(Math::DualComplex<T>::translation(vector), type);
Object<BasicDualComplexTransformation<T>>& translate(const Math::Vector2<T>& vector) {
return transformInternal(Math::DualComplex<T>::translation(vector));
}
/**
* @brief Translate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::DualComplex::translation().
*/
Object<BasicDualComplexTransformation<T>>& translateLocal(const Math::Vector2<T>& vector) {
return transformLocalInternal(Math::DualComplex<T>::translation(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::DualComplexTransformation::translate() "translate()"
* or @ref Magnum::SceneGraph::DualComplexTransformation::translateLocal() "translateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use translate() or translateLocal() instead") Object<BasicDualComplexTransformation<T>>& translate(const Math::Vector2<T>& vector, TransformationType type) {
return type == TransformationType::Global ? translate(vector) : translateLocal(vector);
}
#endif
/**
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::DualComplex::rotation().
* @see @ref normalizeRotation()
* @see @ref rotateLocal(), @ref normalizeRotation()
*/
Object<BasicDualComplexTransformation<T>>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transformInternal(Math::DualComplex<T>::rotation(angle), type);
Object<BasicDualComplexTransformation<T>>& rotate(Math::Rad<T> angle) {
return transformInternal(Math::DualComplex<T>::rotation(angle));
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicDualComplexTransformation<T>>& rotateLocal(Math::Rad<T> angle) {
return transformLocalInternal(Math::DualComplex<T>::rotation(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::DualComplexTransformation::rotate() "rotate()"
* or @ref Magnum::SceneGraph::DualComplexTransformation::rotateLocal() "rotateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") Object<BasicDualComplexTransformation<T>>& rotate(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotate(angle) : rotateLocal(angle);
}
#endif
protected:
/* Allow construction only from Object */
explicit BasicDualComplexTransformation() = default;
@ -126,14 +197,16 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
private:
void doResetTransformation() override final { resetTransformation(); }
void doTranslate(const Math::Vector2<T>& vector, TransformationType type) override final {
translate(vector, type);
void doTranslate(const Math::Vector2<T>& vector) override final {
translate(vector);
}
void doRotate(Math::Rad<T> angle, TransformationType type) override final {
rotate(angle, type);
void doTranslateLocal(const Math::Vector2<T>& vector) override final {
translateLocal(vector);
}
void doRotate(Math::Rad<T> angle) override final { rotate(angle); }
void doRotateLocal(Math::Rad<T> angle) override final { rotateLocal(angle); }
/* No assertions fired, for internal use */
Object<BasicDualComplexTransformation<T>>& setTransformationInternal(const Math::DualComplex<T>& transformation) {
/* Setting transformation is forbidden for the scene */
@ -148,9 +221,11 @@ template<class T> class BasicDualComplexTransformation: public AbstractBasicTran
}
/* No assertions fired, for internal use */
Object<BasicDualComplexTransformation<T>>& transformInternal(const Math::DualComplex<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
Object<BasicDualComplexTransformation<T>>& transformInternal(const Math::DualComplex<T>& transformation) {
return setTransformationInternal(transformation*_transformation);
}
Object<BasicDualComplexTransformation<T>>& transformLocalInternal(const Math::DualComplex<T>& transformation) {
return setTransformationInternal(_transformation*transformation);
}
Math::DualComplex<T> _transformation;

151
src/Magnum/SceneGraph/DualQuaternionTransformation.h

@ -83,56 +83,151 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
}
/**
* @brief Multiply transformation
* @param transformation Transformation
* @param type Transformation type
* @brief Transform object
* @return Reference to self (for method chaining)
*
* Expects that the dual quaternion is normalized.
* @see @ref Math::DualQuaternion::isNormalized()
* @see @ref transformLocal(), @ref Math::DualQuaternion::isNormalized()
*/
Object<BasicDualQuaternionTransformation<T>>& transform(const Math::DualQuaternion<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>& transform(const Math::DualQuaternion<T>& transformation) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualQuaternionTransformation::transform(): the dual quaternion is not normalized",
static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this));
return transformInternal(transformation, type);
return transformInternal(transformation);
}
/**
* @brief Transform object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicDualQuaternionTransformation<T>>& transformLocal(const Math::DualQuaternion<T>& transformation) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualQuaternionTransformation::transformLocal(): the dual quaternion is not normalized",
static_cast<Object<BasicDualQuaternionTransformation<T>>&>(*this));
return transformLocalInternal(transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief transform()
* @deprecated Use @ref Magnum::SceneGraph::DualQuaternionTransformation::transform() "transform()"
* or @ref Magnum::SceneGraph::DualQuaternionTransformation::transformLocal() "transformLocal()"
* instead.
*/
Object<BasicDualQuaternionTransformation<T>>& transform(const Math::DualQuaternion<T>& transformation, TransformationType type) {
return type == TransformationType::Global ? transform(transformation) : transformLocal(transformation);
}
#endif
/**
* @copydoc AbstractTranslationRotationScaling3D::translate()
* @brief Translate object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::DualQuaternion::translation().
* @see @ref translateLocal(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis()
*/
Object<BasicDualQuaternionTransformation<T>>& translate(const Math::Vector3<T>& vector) {
return transformInternal(Math::DualQuaternion<T>::translation(vector));
}
/**
* @brief Translate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicDualQuaternionTransformation<T>>& translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
return transformInternal(Math::DualQuaternion<T>::translation(vector), type);
Object<BasicDualQuaternionTransformation<T>>& translateLocal(const Math::Vector3<T>& vector) {
return transformLocalInternal(Math::DualQuaternion<T>::translation(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::DualQuaternionTransformation::translate() "translate()"
* or @ref Magnum::SceneGraph::DualQuaternionTransformation::translateLocal() "translateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use translate() or translateLocal() instead") Object<BasicDualQuaternionTransformation<T>>& translate(const Math::Vector3<T>& vector, TransformationType type) {
return type == TransformationType::Global ? translate(vector) : translateLocal(vector);
}
#endif
/**
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @param normalizedAxis Normalized rotation axis
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::DualQuaternion::rotation().
* @see @ref Math::Vector3::xAxis(), @ref Math::Vector3::yAxis(),
* @ref Math::Vector3::zAxis(), @ref normalizeRotation()
* @see @ref rotateLocal(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis(),
* @ref normalizeRotation()
*/
Object<BasicDualQuaternionTransformation<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
return transformInternal(Math::DualQuaternion<T>::rotation(angle, normalizedAxis));
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicDualQuaternionTransformation<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
return transformInternal(Math::DualQuaternion<T>::rotation(angle, normalizedAxis), type);
Object<BasicDualQuaternionTransformation<T>>& rotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
return transformLocalInternal(Math::DualQuaternion<T>::rotation(angle, normalizedAxis));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::DualQuaternionTransformation::rotate() "rotate()"
* or @ref Magnum::SceneGraph::DualQuaternionTransformation::rotateLocal() "rotateLocal()"
* instead.
*/
CORRADE_DEPRECATED("usr rotate() or rotateLocal() instead") Object<BasicDualQuaternionTransformation<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) {
return type == TransformationType::Global ? rotate(angle, normalizedAxis) : rotateLocal(angle, normalizedAxis);
}
#endif
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
Object<BasicDualQuaternionTransformation<T>>& rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>& rotateX(Math::Rad<T> angle) {
return rotate(angle, Math::Vector3<T>::xAxis());
}
Object<BasicDualQuaternionTransformation<T>>& rotateXLocal(Math::Rad<T> angle) {
return rotateLocal(angle, Math::Vector3<T>::xAxis());
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotateX() or rotateXLocal() instead") Object<BasicDualQuaternionTransformation<T>>& rotateX(Math::Rad<T> angle, TransformationType type) {
return rotate(angle, Math::Vector3<T>::xAxis(), type);
}
Object<BasicDualQuaternionTransformation<T>>& rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
#endif
Object<BasicDualQuaternionTransformation<T>>& rotateY(Math::Rad<T> angle) {
return rotate(angle, Math::Vector3<T>::yAxis());
}
Object<BasicDualQuaternionTransformation<T>>& rotateYLocal(Math::Rad<T> angle) {
return rotateLocal(angle, Math::Vector3<T>::yAxis());
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotateY() or rotateYLocal() instead") Object<BasicDualQuaternionTransformation<T>>& rotateY(Math::Rad<T> angle, TransformationType type) {
return rotate(angle, Math::Vector3<T>::yAxis(), type);
}
Object<BasicDualQuaternionTransformation<T>>& rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
#endif
Object<BasicDualQuaternionTransformation<T>>& rotateZ(Math::Rad<T> angle) {
return rotate(angle, Math::Vector3<T>::zAxis());
}
Object<BasicDualQuaternionTransformation<T>>& rotateZLocal(Math::Rad<T> angle) {
return rotateLocal(angle, Math::Vector3<T>::zAxis());
}
#ifdef MAGNUM_BUILD_DEPRECATED
CORRADE_DEPRECATED("use rotateZ() or rotateZLocal() instead") Object<BasicDualQuaternionTransformation<T>>& rotateZ(Math::Rad<T> angle, TransformationType type) {
return rotate(angle, Math::Vector3<T>::zAxis(), type);
}
#endif
#endif
protected:
/* Allow construction only from Object */
@ -141,12 +236,18 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
private:
void doResetTransformation() override final { resetTransformation(); }
void doTranslate(const Math::Vector3<T>& vector, TransformationType type) override final {
translate(vector, type);
void doTranslate(const Math::Vector3<T>& vector) override final {
translate(vector);
}
void doTranslateLocal(const Math::Vector3<T>& vector) override final {
translateLocal(vector);
}
void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) override final {
rotate(angle, normalizedAxis, type);
void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final {
rotate(angle, normalizedAxis);
}
void doRotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final {
rotateLocal(angle, normalizedAxis);
}
/* No assertions fired, for internal use */
@ -163,9 +264,11 @@ template<class T> class BasicDualQuaternionTransformation: public AbstractBasicT
}
/* No assertions fired, for internal use */
Object<BasicDualQuaternionTransformation<T>>& transformInternal(const Math::DualQuaternion<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
Object<BasicDualQuaternionTransformation<T>>& transformInternal(const Math::DualQuaternion<T>& transformation) {
return setTransformationInternal(transformation*_transformation);
}
Object<BasicDualQuaternionTransformation<T>>& transformLocalInternal(const Math::DualQuaternion<T>& transformation) {
return setTransformationInternal(_transformation*transformation);
}
Math::DualQuaternion<T> _transformation;

175
src/Magnum/SceneGraph/MatrixTransformation2D.h

@ -68,14 +68,35 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
/**
* @brief Transform object
* @param transformation Transformation
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* @see @ref transformLocal()
*/
Object<BasicMatrixTransformation2D<T>>& transform(const Math::Matrix3<T>& transformation) {
return setTransformation(transformation*_transformation);
}
/**
* @brief Transform object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicMatrixTransformation2D<T>>& transformLocal(const Math::Matrix3<T>& transformation) {
return setTransformation(_transformation*transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief transform()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation2D::transform() "transform()"
* or @ref Magnum::SceneGraph::MatrixTransformation2D::transformLocal() "transformLocal()"
* instead.
*/
Object<BasicMatrixTransformation2D<T>>& transform(const Math::Matrix3<T>& transformation, TransformationType type = TransformationType::Global) {
return setTransformation(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
CORRADE_DEPRECATED("use transform() or transformLocal() instead") Object<BasicMatrixTransformation2D<T>>& transform(const Math::Matrix3<T>& transformation, TransformationType type) {
return type == TransformationType::Global ? transform(transformation) : transformLocal(transformation);
}
#endif
/** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */
Object<BasicMatrixTransformation2D<T>>& resetTransformation() {
@ -83,42 +104,147 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
}
/**
* @copydoc AbstractTranslationRotationScaling2D::translate()
* Translate object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix3::translation().
* @see @ref translateLocal(), @ref Math::Vector2::xAxis(),
* @ref Math::Vector2::yAxis()
*/
Object<BasicMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector) {
return transform(Math::Matrix3<T>::translation(vector));
}
/**
* @brief Translate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix3::translation().
*/
Object<BasicMatrixTransformation2D<T>>& translateLocal(const Math::Vector2<T>& vector) {
return transformLocal(Math::Matrix3<T>::translation(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation2D::translate() "translate()"
* or @ref Magnum::SceneGraph::MatrixTransformation2D::translateLocal() "translateLocal()"
* instead.
*/
Object<BasicMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix3<T>::translation(vector), type);
CORRADE_DEPRECATED("use translate() or translateLocal() instead") Object<BasicMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector, TransformationType type) {
return type == TransformationType::Global ? translate(vector) : translateLocal(vector);
}
#endif
/**
* @copydoc AbstractTranslationRotationScaling2D::rotate()
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix3::rotation().
* @see @ref rotateLocal()
*/
Object<BasicMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle) {
return transform(Math::Matrix3<T>::rotation(angle));
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix3::rotation().
*/
Object<BasicMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix3<T>::rotation(angle), type);
Object<BasicMatrixTransformation2D<T>>& rotateLocal(Math::Rad<T> angle) {
return transformLocal(Math::Matrix3<T>::rotation(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copydoc AbstractTranslationRotationScaling2D::scale()
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation2D::rotate() "rotate()"
* or @ref Magnum::SceneGraph::MatrixTransformation2D::rotateLocal() "rotateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") Object<BasicMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotate(angle) : rotateLocal(angle);
}
#endif
/**
* @brief Scale object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix3::scaling().
* @see @ref scaleLocal(), @ref Math::Vector2::xScale(),
* @ref Math::Vector2::yScale()
*/
Object<BasicMatrixTransformation2D<T>>& scale(const Math::Vector2<T>& vector) {
return transform(Math::Matrix3<T>::scaling(vector));
}
/**
* @brief Scale object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix3::scaling().
*/
Object<BasicMatrixTransformation2D<T>>& scale(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix3<T>::scaling(vector), type);
Object<BasicMatrixTransformation2D<T>>& scaleLocal(const Math::Vector2<T>& vector) {
return transformLocal(Math::Matrix3<T>::scaling(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief scale()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation2D::scale() "scale()"
* or @ref Magnum::SceneGraph::MatrixTransformation2D::scaleLocal() "scaleLocal()"
* instead.
*/
CORRADE_DEPRECATED("use scale() or scaleLocal() instead") Object<BasicMatrixTransformation2D<T>>& scale(const Math::Vector2<T>& vector, TransformationType type) {
return type == TransformationType::Global ? scale(vector) : scaleLocal(vector);
}
#endif
/**
* @brief Reflect object
* @param normal Normal of the line through which to reflect
* (normalized)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix3::reflection().
* @see @ref reflectLocal(), @ref Math::Vector2::xAxis(),
* @ref Math::Vector2::yAxis()
*/
Object<BasicMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix3<T>::reflection(normal), type);
Object<BasicMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal) {
return transform(Math::Matrix3<T>::reflection(normal));
}
/**
* @brief Reflect object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix3::reflection().
*/
Object<BasicMatrixTransformation2D<T>>& reflectLocal(const Math::Vector2<T>& normal) {
return transformLocal(Math::Matrix3<T>::reflection(normal));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief reflect()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation2D::reflect() "reflect()"
* or @ref Magnum::SceneGraph::MatrixTransformation2D::reflectLocal() "reflectLocal()"
* instead.
*/
CORRADE_DEPRECATED("use reflect() or reflectLocal() instead") Object<BasicMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal, TransformationType type) {
return type == TransformationType::Global ? reflect(normal) : reflectLocal(normal);
}
#endif
protected:
/* Allow construction only from Object */
explicit BasicMatrixTransformation2D() = default;
@ -126,17 +252,14 @@ template<class T> class BasicMatrixTransformation2D: public AbstractBasicTransla
private:
void doResetTransformation() override final { resetTransformation(); }
void doTranslate(const Math::Vector2<T>& vector, TransformationType type) override final {
translate(vector, type);
}
void doTranslate(const Math::Vector2<T>& vector) override final { translate(vector); }
void doTranslateLocal(const Math::Vector2<T>& vector) override final { translateLocal(vector); }
void doRotate(Math::Rad<T> angle, TransformationType type) override final {
rotate(angle, type);
}
void doRotate(Math::Rad<T> angle) override final { rotate(angle); }
void doRotateLocal(Math::Rad<T> angle) override final { rotateLocal(angle); }
void doScale(const Math::Vector2<T>& vector, TransformationType type) override final {
scale(vector, type);
}
void doScale(const Math::Vector2<T>& vector) override final { scale(vector); }
void doScaleLocal(const Math::Vector2<T>& vector) override final { scaleLocal(vector); }
Math::Matrix3<T> _transformation;
};

283
src/Magnum/SceneGraph/MatrixTransformation3D.h

@ -71,89 +71,286 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
}
/**
* @brief Multiply transformation
* @param transformation Transformation
* @param type Transformation type
* @brief Transform object
* @return Reference to self (for method chaining)
*
* @see @ref transformLocal()
*/
Object<BasicMatrixTransformation3D<T>>& transform(const Math::Matrix4<T>& transformation) {
return setTransformation(transformation*_transformation);
}
/**
* @brief Transform object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicMatrixTransformation3D<T>>& transform(const Math::Matrix4<T>& transformation, TransformationType type = TransformationType::Global) {
return setTransformation(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
Object<BasicMatrixTransformation3D<T>>& transformLocal(const Math::Matrix4<T>& transformation) {
return setTransformation(_transformation*transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copydoc AbstractTranslationRotationScaling3D::translate()
* @copybrief transform()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::transform() "transform()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::transformLocal() "transformLocal()"
* instead.
*/
CORRADE_DEPRECATED("use transform() or transformLocal() instead") Object<BasicMatrixTransformation3D<T>>& transform(const Math::Matrix4<T>& transformation, TransformationType type) {
return type == TransformationType::Global ? transform(transformation) : transformLocal(transformation);
}
#endif
/**
* @brief Translate object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::translation().
* @see @ref translateLocal(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis()
*/
Object<BasicMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector) {
return transform(Math::Matrix4<T>::translation(vector));
}
/**
* @brief Translate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::translation().
*/
Object<BasicMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix4<T>::translation(vector), type);
Object<BasicMatrixTransformation3D<T>>& translateLocal(const Math::Vector3<T>& vector) {
return transformLocal(Math::Matrix4<T>::translation(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copydoc AbstractTranslationRotationScaling3D::rotate()
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::translate() "translate()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::translateLocal() "translateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use translate() or translateLocal() instead") Object<BasicMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector, TransformationType type) {
return type == TransformationType::Global ? translate(vector) : translateLocal(vector);
}
#endif
/**
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @param normalizedAxis Normalized rotation axis
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::rotation().
* @see @ref rotateLocal(), @ref rotateX(), @ref rotateY(),
* @ref rotateZ(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis()
*/
Object<BasicMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
return transform(Math::Matrix4<T>::rotation(angle, normalizedAxis));
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotation().
*/
Object<BasicMatrixTransformation3D<T>>& rotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
return transformLocal(Math::Matrix4<T>::rotation(angle, normalizedAxis));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::rotate() "rotate()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::rotateLocal() "rotateLocal()"
* instead.
*/
Object<BasicMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") Object<BasicMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) {
return type == TransformationType::Global ? rotate(angle, normalizedAxis) : rotateLocal(angle, normalizedAxis);
}
#endif
/**
* @brief Rotate object around X axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::rotationX().
* @see @ref rotateXLocal()
*/
Object<BasicMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix4<T>::rotationX(angle), type);
Object<BasicMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle) {
return transform(Math::Matrix4<T>::rotationX(angle));
}
/**
* @brief Rotate object around X axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotationX().
*/
Object<BasicMatrixTransformation3D<T>>& rotateXLocal(Math::Rad<T> angle) {
return transformLocal(Math::Matrix4<T>::rotationX(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateX()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::rotateX() "rotateX()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::rotateXLocal() "rotateXLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateX() or rotateXLocal() instead") Object<BasicMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateX(angle) : rotateXLocal(angle);
}
#endif
/**
* @brief Rotate object around Y axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::rotationY().
* @see @ref rotateYLocal()
*/
Object<BasicMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle) {
return transform(Math::Matrix4<T>::rotationY(angle));
}
/**
* @brief Rotate object around Y axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotationY().
*/
Object<BasicMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix4<T>::rotationY(angle), type);
Object<BasicMatrixTransformation3D<T>>& rotateYLocal(Math::Rad<T> angle) {
return transformLocal(Math::Matrix4<T>::rotationY(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateY()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::rotateY() "rotateY()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::rotateYLocal() "rotateYLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateY() or rotateYLocal() instead") Object<BasicMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateY(angle) : rotateYLocal(angle);
}
#endif
/**
* @brief Rotate object around Z axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::rotationZ().
* @see @ref rotateZLocal()
*/
Object<BasicMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle) {
return transform(Math::Matrix4<T>::rotationZ(angle));
}
/**
* @brief Rotate object around Z axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotationZ().
*/
Object<BasicMatrixTransformation3D<T>>& rotateZLocal(Math::Rad<T> angle) {
return transformLocal(Math::Matrix4<T>::rotationZ(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateZ()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::rotateZ() "rotateZ()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::rotateZLocal() "rotateZLocal()"
* instead.
*/
Object<BasicMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix4<T>::rotationZ(angle), type);
CORRADE_DEPRECATED("use rotateZ() or rotateZLocal() instead") Object<BasicMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateZ(angle) : rotateZLocal(angle);
}
#endif
/**
* @copydoc AbstractTranslationRotationScaling3D::scale()
* @brief Scale object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::scaling().
* @see @ref scaleLocal(), @ref Math::Vector3::xScale(),
* @ref Math::Vector3::yScale(), @ref Math::Vector3::zScale()
*/
Object<BasicMatrixTransformation3D<T>>& scale(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix4<T>::scaling(vector), type);
Object<BasicMatrixTransformation3D<T>>& scale(const Math::Vector3<T>& vector) {
return transform(Math::Matrix4<T>::scaling(vector));
}
/**
* @brief Scale object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::scaling().
*/
Object<BasicMatrixTransformation3D<T>>& scaleLocal(const Math::Vector3<T>& vector) {
return transformLocal(Math::Matrix4<T>::scaling(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief scale()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::scale() "scale()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::scaleLocal() "scaleLocal()"
* instead.
*/
CORRADE_DEPRECATED("use scale() or scaleLocal() instead") Object<BasicMatrixTransformation3D<T>>& scale(const Math::Vector3<T>& vector, TransformationType type) {
return type == TransformationType::Global ? scale(vector) : scaleLocal(vector);
}
#endif
/**
* @brief Reflect object
* @param normal Normal of the plane through which to reflect
* (normalized)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::reflection().
* @see @ref reflectLocal()
*/
Object<BasicMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal) {
return transform(Math::Matrix4<T>::reflection(normal));
}
/**
* @brief Reflect object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::reflection().
*/
Object<BasicMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
return transform(Math::Matrix4<T>::reflection(normal), type);
Object<BasicMatrixTransformation3D<T>>& reflectLocal(const Math::Vector3<T>& normal) {
return transformLocal(Math::Matrix4<T>::reflection(normal));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief reflect()
* @deprecated Use @ref Magnum::SceneGraph::MatrixTransformation3D::reflect() "reflect()"
* or @ref Magnum::SceneGraph::MatrixTransformation3D::reflectLocal() "reflectLocal()"
* instead.
*/
CORRADE_DEPRECATED("use reflect() or reflectLocal() instead") Object<BasicMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal, TransformationType type) {
return type == TransformationType::Global ? reflect(normal) : reflectLocal(normal);
}
#endif
protected:
/* Allow construction only from Object */
explicit BasicMatrixTransformation3D() = default;
@ -161,29 +358,27 @@ template<class T> class BasicMatrixTransformation3D: public AbstractBasicTransla
private:
void doResetTransformation() override final { resetTransformation(); }
void doTranslate(const Math::Vector3<T>& vector, TransformationType type) override final {
translate(vector, type);
}
void doTranslate(const Math::Vector3<T>& vector) override final { translate(vector); }
void doTranslateLocal(const Math::Vector3<T>& vector) override final { translateLocal(vector); }
void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) override final {
rotate(angle, normalizedAxis, type);
void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final {
rotate(angle, normalizedAxis);
}
void doRotateX(Math::Rad<T> angle, TransformationType type) override final {
rotateX(angle, type);
void doRotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final {
rotateLocal(angle, normalizedAxis);
}
void doRotateY(Math::Rad<T> angle, TransformationType type) override final {
rotateY(angle, type);
}
void doRotateX(Math::Rad<T> angle) override final { rotateX(angle); }
void doRotateXLocal(Math::Rad<T> angle) override final { rotateXLocal(angle); }
void doRotateZ(Math::Rad<T> angle, TransformationType type) override final {
rotateZ(angle, type);
}
void doRotateY(Math::Rad<T> angle) override final { rotateY(angle); }
void doRotateYLocal(Math::Rad<T> angle) override final { rotateYLocal(angle); }
void doScale(const Math::Vector3<T>& vector, TransformationType type) override final {
scale(vector, type);
}
void doRotateZ(Math::Rad<T> angle) override final { rotateZ(angle); }
void doRotateZLocal(Math::Rad<T> angle) override final { rotateZLocal(angle); }
void doScale(const Math::Vector3<T>& vector) override final { scale(vector); }
void doScaleLocal(const Math::Vector3<T>& vector) override final { scaleLocal(vector); }
Math::Matrix4<T> _transformation;
};

145
src/Magnum/SceneGraph/RigidMatrixTransformation2D.h

@ -89,57 +89,150 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
/**
* @brief Transform object
* @param transformation Transformation
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Expects that the matrix represents rigid transformation.
* @see @ref Math::Matrix3::isRigidTransformation()
* @see @ref transformLocal(), @ref Math::Matrix3::isRigidTransformation()
*/
Object<BasicRigidMatrixTransformation2D<T>>& transform(const Math::Matrix3<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation2D<T>>& transform(const Math::Matrix3<T>& transformation) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation2D::transform(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this));
return transformInternal(transformation, type);
return transformInternal(transformation);
}
/**
* @brief Transform object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicRigidMatrixTransformation2D<T>>& transformLocal(const Math::Matrix3<T>& transformation) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation2D::transformLocal(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation2D<T>>&>(*this));
return transformLocalInternal(transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief transform()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation2D::transform() "transform()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation2D::transformLocal() "transformLocal()"
* instead.
*/
CORRADE_DEPRECATED("use transform() or transformLocal() instead") Object<BasicRigidMatrixTransformation2D<T>>& transform(const Math::Matrix3<T>& transformation, TransformationType type) {
return type == TransformationType::Global ? transform(transformation) : transformLocal(transformation);
}
#endif
/**
* @copydoc AbstractTranslationRotationScaling2D::translate()
* Same as calling @ref transform() with
* Translate object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix3::translation().
* @see @ref translateLocal(), @ref Math::Vector2::xAxis(),
* @ref Math::Vector2::yAxis()
*/
Object<BasicRigidMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector) {
return transformInternal(Math::Matrix3<T>::translation(vector));
}
/**
* @brief Translate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix3::translation().
*/
Object<BasicRigidMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix3<T>::translation(vector), type);
Object<BasicRigidMatrixTransformation2D<T>>& translateLocal(const Math::Vector2<T>& vector) {
return transformLocalInternal(Math::Matrix3<T>::translation(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation2D::translate() "translate()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation2D::translateLocal() "translateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use translate() or translateLocal() instead") Object<BasicRigidMatrixTransformation2D<T>>& translate(const Math::Vector2<T>& vector, TransformationType type) {
return type == TransformationType::Global ? translate(vector) : translateLocal(vector);
}
#endif
/**
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with
* Same as calling @ref transform() with @ref Math::Matrix3::rotation().
* @see @ref rotateLocal(), @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle) {
return transformInternal(Math::Matrix3<T>::rotation(angle));
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix3::rotation().
* @see @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix3<T>::rotation(angle), type);
Object<BasicRigidMatrixTransformation2D<T>>& rotateLocal(Math::Rad<T> angle) {
return transformLocalInternal(Math::Matrix3<T>::rotation(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation2D::rotate() "rotate()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation2D::rotateLocal() "rotateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") Object<BasicRigidMatrixTransformation2D<T>>& rotate(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotate(angle) : rotateLocal(angle);
}
#endif
/**
* @brief Reflect object
* @param normal Normal of the line through which to reflect
* (normalized)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with
* Same as calling @ref transform() with @ref Math::Matrix3::reflection().
* @see @ref reflectLocal()
*/
Object<BasicRigidMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal) {
return transformInternal(Math::Matrix3<T>::reflection(normal));
}
/**
* @brief Reflect object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix3::reflection().
*/
Object<BasicRigidMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix3<T>::reflection(normal), type);
Object<BasicRigidMatrixTransformation2D<T>>& reflectLocal(const Math::Vector2<T>& normal) {
return transformLocalInternal(Math::Matrix3<T>::reflection(normal));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief reflect()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation2D::reflect() "reflect()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation2D::reflectLocal() "reflectLocal()"
* instead.
*/
CORRADE_DEPRECATED("use reflect() or reflectInternal() instead") Object<BasicRigidMatrixTransformation2D<T>>& reflect(const Math::Vector2<T>& normal, TransformationType type) {
return type == TransformationType::Global ? reflect(normal) : reflectLocal(normal);
}
#endif
protected:
/* Allow construction only from Object */
explicit BasicRigidMatrixTransformation2D() = default;
@ -147,13 +240,11 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
private:
void doResetTransformation() override final { resetTransformation(); }
void doTranslate(const Math::Vector2<T>& vector, TransformationType type) override final {
translate(vector, type);
}
void doTranslate(const Math::Vector2<T>& vector) override final { translate(vector); }
void doTranslateLocal(const Math::Vector2<T>& vector) override final { translateLocal(vector); }
void doRotate(Math::Rad<T> angle, TransformationType type) override final {
rotate(angle, type);
}
void doRotate(Math::Rad<T> angle) override final { rotate(angle); }
void doRotateLocal(Math::Rad<T> angle) override final { rotateLocal(angle); }
/* No assertions fired, for internal use */
Object<BasicRigidMatrixTransformation2D<T>>& setTransformationInternal(const Math::Matrix3<T>& transformation) {
@ -169,9 +260,11 @@ template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTr
}
/* No assertions fired, for internal use */
Object<BasicRigidMatrixTransformation2D<T>>& transformInternal(const Math::Matrix3<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
Object<BasicRigidMatrixTransformation2D<T>>& transformInternal(const Math::Matrix3<T>& transformation) {
return setTransformationInternal(transformation*_transformation);
}
Object<BasicRigidMatrixTransformation2D<T>>& transformLocalInternal(const Math::Matrix3<T>& transformation) {
return setTransformationInternal(_transformation*transformation);
}
Math::Matrix3<T> _transformation;

261
src/Magnum/SceneGraph/RigidMatrixTransformation3D.h

@ -86,101 +86,259 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
}
/**
* @brief Multiply transformation
* @param transformation Transformation
* @param type Transformation type
* @brief Transform object
* @return Reference to self (for method chaining)
*
* Expects that the matrix represents rigid transformation.
* @see @ref Math::Matrix4::isRigidTransformation()
* @see @ref transformLocal(), @ref Math::Matrix4::isRigidTransformation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& transform(const Math::Matrix4<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>& transform(const Math::Matrix4<T>& transformation) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this));
return transformInternal(transformation, type);
return transformInternal(transformation);
}
/**
* @copydoc AbstractTranslationRotationScaling3D::translate()
* @brief Transform object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others.
*/
Object<BasicRigidMatrixTransformation3D<T>>& transformLocal(const Math::Matrix4<T>& transformation) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation",
static_cast<Object<BasicRigidMatrixTransformation3D<T>>&>(*this));
return transformLocalInternal(transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief transform()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation3D::transform() "transform()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation3D::transformLocal() "transformLocal()"
* instead.
*/
CORRADE_DEPRECATED("use transform() or transformLocal() instead") Object<BasicRigidMatrixTransformation3D<T>>& transform(const Math::Matrix4<T>& transformation, TransformationType type) {
return type == TransformationType::Global ? transform(transformation) : transformLocal(transformation);
}
#endif
/**
* @brief Translate object
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::translation().
* @see @ref translateLocal(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis()
*/
Object<BasicRigidMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector) {
return transformInternal(Math::Matrix4<T>::translation(vector));
}
/**
* @brief Translate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::translation().
*/
Object<BasicRigidMatrixTransformation3D<T>>& translateLocal(const Math::Vector3<T>& vector) {
return transformLocalInternal(Math::Matrix4<T>::translation(vector));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation3D::translate() "translate()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation3D::translateLocal() "translateLocal()"
* instead.
*/
Object<BasicRigidMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix4<T>::translation(vector), type);
CORRADE_DEPRECATED("use translate() or translateLocal() instead") Object<BasicRigidMatrixTransformation3D<T>>& translate(const Math::Vector3<T>& vector, TransformationType type) {
return type == TransformationType::Global ? translate(vector) : translateLocal(vector);
}
#endif
/**
* @brief Rotate object
* @param angle Angle (counterclockwise)
* @param normalizedAxis Normalized rotation axis
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with @ref Math::Matrix4::rotation().
* @see @ref rotateX(), @ref rotateY(), @ref rotateZ(),
* @ref normalizeRotation(), @ref Math::Vector3::xAxis(),
* @ref Math::Vector3::yAxis(), @ref Math::Vector3::zAxis()
* @see @ref rotateLocal(), @ref rotateX(), @ref rotateY(),
* @ref rotateZ(), @ref normalizeRotation(),
* @ref Math::Vector3::xAxis(), @ref Math::Vector3::yAxis(),
* @ref Math::Vector3::zAxis()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
Object<BasicRigidMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
return transformInternal(Math::Matrix4<T>::rotation(angle, normalizedAxis));
}
/**
* @brief Rotate object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotation().
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) {
return transformLocalInternal(Math::Matrix4<T>::rotation(angle, normalizedAxis));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotate()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotate() "rotate()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotateLocal() "rotateLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotate() or rotateLocal() instead") Object<BasicRigidMatrixTransformation3D<T>>& rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) {
return type == TransformationType::Global ? rotate(angle, normalizedAxis) : rotateLocal(angle, normalizedAxis);
}
#endif
/**
* @brief Rotate object around X axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with
* Same as calling @ref transform() with @ref Math::Matrix4::rotationX().
* @see @ref rotateXLocal(), @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle) {
return transformInternal(Math::Matrix4<T>::rotationX(angle));
}
/**
* @brief Rotate object around X axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotationX().
* @see @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix4<T>::rotationX(angle), type);
Object<BasicRigidMatrixTransformation3D<T>>& rotateXLocal(Math::Rad<T> angle) {
return transformLocalInternal(Math::Matrix4<T>::rotationX(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateX()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotateX() "rotateX()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotateXLocal() "rotateXLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateX() or rotateXLocal() instead") Object<BasicRigidMatrixTransformation3D<T>>& rotateX(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateX(angle) : rotateXLocal(angle);
}
#endif
/**
* @brief Rotate object around Y axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with
* Same as calling @ref transform() with @ref Math::Matrix4::rotationY().
* @see @ref rotateYLocal(), @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle) {
return transformInternal(Math::Matrix4<T>::rotationY(angle));
}
/**
* @brief Rotate object around Y axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotationY().
* @see @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix4<T>::rotationY(angle), type);
Object<BasicRigidMatrixTransformation3D<T>>& rotateYLocal(Math::Rad<T> angle) {
return transformLocalInternal(Math::Matrix4<T>::rotationY(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateY()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotateY() "rotateY()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotateYLocal() "rotateYLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateY() or rotateYLocal() instead") Object<BasicRigidMatrixTransformation3D<T>>& rotateY(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateY(angle) : rotateYLocal(angle);
}
#endif
/**
* @brief Rotate object around Z axis
* @param angle Angle (counterclockwise)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with
* Same as calling @ref transform() with @ref Math::Matrix4::rotationZ().
* @see @ref rotateZLocal(), @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle) {
return transformInternal(Math::Matrix4<T>::rotationZ(angle));
}
/**
* @brief Rotate object around Z axis as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::rotationZ().
* @see @ref normalizeRotation()
*/
Object<BasicRigidMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix4<T>::rotationZ(angle), type);
Object<BasicRigidMatrixTransformation3D<T>>& rotateZLocal(Math::Rad<T> angle) {
return transformLocalInternal(Math::Matrix4<T>::rotationZ(angle));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief rotateZ()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotateZ() "rotateZ()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation3D::rotateZLocal() "rotateZLocal()"
* instead.
*/
CORRADE_DEPRECATED("use rotateZ() or rotateZLocal() instead") Object<BasicRigidMatrixTransformation3D<T>>& rotateZ(Math::Rad<T> angle, TransformationType type) {
return type == TransformationType::Global ? rotateZ(angle) : rotateZLocal(angle);
}
#endif
/**
* @brief Reflect object
* @param normal Normal of the plane through which to reflect
* (normalized)
* @param type Transformation type
* @return Reference to self (for method chaining)
*
* Same as calling @ref transform() with
* Same as calling @ref transform() with @ref Math::Matrix4::reflection().
* @see @ref reflectLocal()
*/
Object<BasicRigidMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal) {
return transformInternal(Math::Matrix4<T>::reflection(normal));
}
/**
* @brief Reflect object as a local transformation
*
* Similar to the above, except that the transformation is applied
* before all others. Same as calling @ref transformLocal() with
* @ref Math::Matrix4::reflection().
*/
Object<BasicRigidMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
return transformInternal(Math::Matrix4<T>::reflection(normal), type);
Object<BasicRigidMatrixTransformation3D<T>>& reflectLocal(const Math::Vector3<T>& normal) {
return transformLocalInternal(Math::Matrix4<T>::reflection(normal));
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief reflect()
* @deprecated Use @ref Magnum::SceneGraph::RigidMatrixTransformation3D::reflect() "reflect()"
* or @ref Magnum::SceneGraph::RigidMatrixTransformation3D::reflectLocal() "reflectLocal()"
* instead.
*/
CORRADE_DEPRECATED("use reflect() or reflectLocal() instead") Object<BasicRigidMatrixTransformation3D<T>>& reflect(const Math::Vector3<T>& normal, TransformationType type) {
return type == TransformationType::Global ? reflect(normal) : reflectLocal(normal);
}
#endif
protected:
/* Allow construction only from Object */
explicit BasicRigidMatrixTransformation3D() = default;
@ -188,25 +346,24 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
private:
void doResetTransformation() override final { resetTransformation(); }
void doTranslate(const Math::Vector3<T>& vector, TransformationType type) override final {
translate(vector, type);
}
void doTranslate(const Math::Vector3<T>& vector) override final { translate(vector); }
void doTranslateLocal(const Math::Vector3<T>& vector) override final { translateLocal(vector); }
void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type) override final {
rotate(angle, normalizedAxis, type);
void doRotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final {
rotate(angle, normalizedAxis);
}
void doRotateX(Math::Rad<T> angle, TransformationType type) override final {
rotateX(angle, type);
void doRotateLocal(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis) override final {
rotateLocal(angle, normalizedAxis);
}
void doRotateY(Math::Rad<T> angle, TransformationType type) override final {
rotateY(angle, type);
}
void doRotateX(Math::Rad<T> angle) override final { rotateX(angle); }
void doRotateXLocal(Math::Rad<T> angle) override final { rotateXLocal(angle); }
void doRotateZ(Math::Rad<T> angle, TransformationType type) override final {
rotateZ(angle, type);
}
void doRotateY(Math::Rad<T> angle) override final { rotateY(angle); }
void doRotateYLocal(Math::Rad<T> angle) override final { rotateYLocal(angle); }
void doRotateZ(Math::Rad<T> angle) override final { rotateZ(angle); }
void doRotateZLocal(Math::Rad<T> angle) override final { rotateZLocal(angle); }
/* No assertions fired, for internal use */
Object<BasicRigidMatrixTransformation3D<T>>& setTransformationInternal(const Math::Matrix4<T>& transformation) {
@ -222,9 +379,11 @@ template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTr
}
/* No assertions fired, for internal use */
Object<BasicRigidMatrixTransformation3D<T>>& transformInternal(const Math::Matrix4<T>& transformation, TransformationType type) {
return setTransformationInternal(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
Object<BasicRigidMatrixTransformation3D<T>>& transformInternal(const Math::Matrix4<T>& transformation) {
return setTransformationInternal(transformation*_transformation);
}
Object<BasicRigidMatrixTransformation3D<T>>& transformLocalInternal(const Math::Matrix4<T>& transformation) {
return setTransformationInternal(_transformation*transformation);
}
Math::Matrix4<T> _transformation;

2
src/Magnum/SceneGraph/SceneGraph.h

@ -64,7 +64,9 @@ template<class T> using AbstractBasicObject3D = AbstractObject<3, T>;
typedef AbstractBasicObject2D<Float> AbstractObject2D;
typedef AbstractBasicObject3D<Float> AbstractObject3D;
#ifdef MAGNUM_BUILD_DEPRECATED
enum class TransformationType: UnsignedByte;
#endif
template<UnsignedInt, class> class AbstractTransformation;
template<class T> using AbstractBasicTransformation2D = AbstractTransformation<2, T>;

6
src/Magnum/SceneGraph/Test/DualComplexTransformationTest.cpp

@ -136,7 +136,7 @@ void DualComplexTransformationTest::transform() {
} {
Object2D o;
o.setTransformation(DualComplex::rotation(Deg(17.0f)));
o.transform(DualComplex::translation({1.0f, -0.3f}), TransformationType::Local);
o.transformLocal(DualComplex::translation({1.0f, -0.3f}));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}));
}
}
@ -150,7 +150,7 @@ void DualComplexTransformationTest::translate() {
} {
Object2D o;
o.setTransformation(DualComplex::rotation(Deg(17.0f)));
o.translate({1.0f, -0.3f}, TransformationType::Local);
o.translateLocal({1.0f, -0.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}));
}
}
@ -164,7 +164,7 @@ void DualComplexTransformationTest::rotate() {
} {
Object2D o;
o.setTransformation(DualComplex::translation({1.0f, -0.3f}));
o.rotate(Deg(17.0f), TransformationType::Local);
o.rotateLocal(Deg(17.0f));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f)));
}
}

12
src/Magnum/SceneGraph/Test/DualQuaternionTransformationTest.cpp

@ -142,7 +142,7 @@ void DualQuaternionTransformationTest::transform() {
} {
Object3D o;
o.setTransformation(DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis()));
o.transform(DualQuaternion::translation({1.0f, -0.3f, 2.3f}), TransformationType::Local);
o.transformLocal(DualQuaternion::translation({1.0f, -0.3f, 2.3f}));
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}));
}
}
@ -156,7 +156,7 @@ void DualQuaternionTransformationTest::translate() {
} {
Object3D o;
o.setTransformation(DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis()));
o.translate({1.0f, -0.3f, 2.3f}, TransformationType::Local);
o.translateLocal({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}));
}
}
@ -178,10 +178,10 @@ void DualQuaternionTransformationTest::rotate() {
} {
Object3D o;
o.transform(DualQuaternion::translation({1.0f, -0.3f, 2.3f}));
o.rotateX(Deg(17.0f), TransformationType::Local)
.rotateY(Deg(25.0f), TransformationType::Local)
.rotateZ(Deg(-23.0f), TransformationType::Local)
.rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local);
o.rotateXLocal(Deg(17.0f))
.rotateYLocal(Deg(25.0f))
.rotateZLocal(Deg(-23.0f))
.rotateLocal(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()));
CORRADE_COMPARE(o.transformationMatrix(),
Matrix4::translation({1.0f, -0.3f, 2.3f})*
Matrix4::rotationX(Deg(17.0f))*

10
src/Magnum/SceneGraph/Test/MatrixTransformation2DTest.cpp

@ -122,7 +122,7 @@ void MatrixTransformation2DTest::transform() {
} {
Object2D o;
o.setTransformation(Matrix3::rotation(Deg(17.0f)));
o.transform(Matrix3::translation({1.0f, -0.3f}), TransformationType::Local);
o.transformLocal(Matrix3::translation({1.0f, -0.3f}));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}));
}
}
@ -136,7 +136,7 @@ void MatrixTransformation2DTest::translate() {
} {
Object2D o;
o.setTransformation(Matrix3::rotation(Deg(17.0f)));
o.translate({1.0f, -0.3f}, TransformationType::Local);
o.translateLocal({1.0f, -0.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}));
}
}
@ -150,7 +150,7 @@ void MatrixTransformation2DTest::rotate() {
} {
Object2D o;
o.setTransformation(Matrix3::translation({1.0f, -0.3f}));
o.rotate(Deg(17.0f), TransformationType::Local);
o.rotateLocal(Deg(17.0f));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f)));
}
}
@ -164,7 +164,7 @@ void MatrixTransformation2DTest::scale() {
} {
Object2D o;
o.setTransformation(Matrix3::rotation(Deg(17.0f)));
o.scale({1.0f, -0.3f}, TransformationType::Local);
o.scaleLocal({1.0f, -0.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::scaling({1.0f, -0.3f}));
}
}
@ -178,7 +178,7 @@ void MatrixTransformation2DTest::reflect() {
} {
Object2D o;
o.setTransformation(Matrix3::rotation(Deg(17.0f)));
o.reflect(Vector2(-1.0f/Constants::sqrt2()), TransformationType::Local);
o.reflectLocal(Vector2(-1.0f/Constants::sqrt2()));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2())));
}
}

16
src/Magnum/SceneGraph/Test/MatrixTransformation3DTest.cpp

@ -122,7 +122,7 @@ void MatrixTransformation3DTest::transform() {
} {
Object3D o;
o.setTransformation(Matrix4::rotationX(Deg(17.0f)));
o.transform(Matrix4::translation({1.0f, -0.3f, 2.3f}), TransformationType::Local);
o.transformLocal(Matrix4::translation({1.0f, -0.3f, 2.3f}));
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}));
}
}
@ -136,7 +136,7 @@ void MatrixTransformation3DTest::translate() {
} {
Object3D o;
o.setTransformation(Matrix4::rotationX(Deg(17.0f)));
o.translate({1.0f, -0.3f, 2.3f}, TransformationType::Local);
o.translateLocal({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}));
}
}
@ -158,10 +158,10 @@ void MatrixTransformation3DTest::rotate() {
} {
Object3D o;
o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f}));
o.rotateX(Deg(17.0f), TransformationType::Local)
.rotateY(Deg(25.0f), TransformationType::Local)
.rotateZ(Deg(-23.0f), TransformationType::Local)
.rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local);
o.rotateXLocal(Deg(17.0f))
.rotateYLocal(Deg(25.0f))
.rotateZLocal(Deg(-23.0f))
.rotateLocal(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()));
CORRADE_COMPARE(o.transformationMatrix(),
Matrix4::translation({1.0f, -0.3f, 2.3f})*
Matrix4::rotationX(Deg(17.0f))*
@ -180,7 +180,7 @@ void MatrixTransformation3DTest::scale() {
} {
Object3D o;
o.setTransformation(Matrix4::rotationX(Deg(17.0f)));
o.scale({1.0f, -0.3f, 2.3f}, TransformationType::Local);
o.scaleLocal({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::scaling({1.0f, -0.3f, 2.3f}));
}
}
@ -194,7 +194,7 @@ void MatrixTransformation3DTest::reflect() {
} {
Object3D o;
o.setTransformation(Matrix4::rotationX(Deg(17.0f)));
o.reflect(Vector3(-1.0f/Constants::sqrt3()), TransformationType::Local);
o.reflectLocal(Vector3(-1.0f/Constants::sqrt3()));
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3())));
}
}

8
src/Magnum/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp

@ -141,7 +141,7 @@ void RigidMatrixTransformation2DTest::transform() {
} {
Object2D o;
o.setTransformation(Matrix3::rotation(Deg(17.0f)));
o.transform(Matrix3::translation({1.0f, -0.3f}), TransformationType::Local);
o.transformLocal(Matrix3::translation({1.0f, -0.3f}));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}));
}
}
@ -155,7 +155,7 @@ void RigidMatrixTransformation2DTest::translate() {
} {
Object2D o;
o.setTransformation(Matrix3::rotation(Deg(17.0f)));
o.translate({1.0f, -0.3f}, TransformationType::Local);
o.translateLocal({1.0f, -0.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}));
}
}
@ -169,7 +169,7 @@ void RigidMatrixTransformation2DTest::rotate() {
} {
Object2D o;
o.setTransformation(Matrix3::translation({1.0f, -0.3f}));
o.rotate(Deg(17.0f), TransformationType::Local);
o.rotateLocal(Deg(17.0f));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f)));
}
}
@ -183,7 +183,7 @@ void RigidMatrixTransformation2DTest::reflect() {
} {
Object2D o;
o.setTransformation(Matrix3::rotation(Deg(17.0f)));
o.reflect(Vector2(-1.0f/Constants::sqrt2()), TransformationType::Local);
o.reflectLocal(Vector2(-1.0f/Constants::sqrt2()));
CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2())));
}
}

14
src/Magnum/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp

@ -142,7 +142,7 @@ void RigidMatrixTransformation3DTest::transform() {
} {
Object3D o;
o.setTransformation(Matrix4::rotationX(Deg(17.0f)));
o.transform(Matrix4::translation({1.0f, -0.3f, 2.3f}), TransformationType::Local);
o.transformLocal(Matrix4::translation({1.0f, -0.3f, 2.3f}));
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}));
}
}
@ -156,7 +156,7 @@ void RigidMatrixTransformation3DTest::translate() {
} {
Object3D o;
o.setTransformation(Matrix4::rotationX(Deg(17.0f)));
o.translate({1.0f, -0.3f, 2.3f}, TransformationType::Local);
o.translateLocal({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}));
}
}
@ -178,10 +178,10 @@ void RigidMatrixTransformation3DTest::rotate() {
} {
Object3D o;
o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f}));
o.rotateX(Deg(17.0f), TransformationType::Local)
.rotateY(Deg(25.0f), TransformationType::Local)
.rotateZ(Deg(-23.0f), TransformationType::Local)
.rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local);
o.rotateXLocal(Deg(17.0f))
.rotateYLocal(Deg(25.0f))
.rotateZLocal(Deg(-23.0f))
.rotateLocal(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()));
CORRADE_COMPARE(o.transformationMatrix(),
Matrix4::translation({1.0f, -0.3f, 2.3f})*
Matrix4::rotationX(Deg(17.0f))*
@ -200,7 +200,7 @@ void RigidMatrixTransformation3DTest::reflect() {
} {
Object3D o;
o.setTransformation(Matrix4::rotationX(Deg(17.0f)));
o.reflect(Vector3(-1.0f/Constants::sqrt3()), TransformationType::Local);
o.reflectLocal(Vector3(-1.0f/Constants::sqrt3()));
CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3())));
}
}

39
src/Magnum/SceneGraph/TranslationTransformation.h

@ -87,31 +87,53 @@ class TranslationTransformation: public AbstractTranslation<dimensions, T, Trans
}
/**
* @brief Add transformation
* @param transformation Transformation
* @brief Transform object
* @return Reference to self (for method chaining)
*
* Equivalent to @ref translate(), provided only for compatibility with
* other implementations.
* other implementations. There is no difference between global and
* local transformation.
*/
Object<TranslationTransformation<dimensions, T, TranslationType>>& transform(const VectorTypeFor<dimensions, TranslationType>& transformation, TransformationType = TransformationType::Global) {
Object<TranslationTransformation<dimensions, T, TranslationType>>& transform(const VectorTypeFor<dimensions, TranslationType>& transformation) {
return translate(transformation);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief transform()
* @deprecated Use @ref Magnum::SceneGraph::TranslationTransformation::transform() "transform()"
* instead.
*/
CORRADE_DEPRECATED("use transform() instead") Object<TranslationTransformation<dimensions, T, TranslationType>>& transform(const VectorTypeFor<dimensions, TranslationType>& transformation, TransformationType) {
return transform(transformation);
}
#endif
/**
* @brief Translate object
* @param vector Translation vector
* @return Reference to self (for method chaining)
*
* There is no difference between global and local translation.
* @see @ref Math::Vector2::xAxis(), @ref Math::Vector2::yAxis(),
* @ref Math::Vector3::xAxis(), @ref Math::Vector3::yAxis(),
* @ref Math::Vector3::zAxis()
*/
Object<TranslationTransformation<dimensions, T, TranslationType>>& translate(const VectorTypeFor<dimensions, TranslationType>& vector, TransformationType = TransformationType::Global) {
Object<TranslationTransformation<dimensions, T, TranslationType>>& translate(const VectorTypeFor<dimensions, TranslationType>& vector) {
_transformation += vector;
return static_cast<Object<TranslationTransformation<dimensions, T, TranslationType>>&>(*this);
}
#ifdef MAGNUM_BUILD_DEPRECATED
/**
* @copybrief translate()
* @deprecated Use @ref Magnum::SceneGraph::TranslationTransformation::translate() "translate()"
* instead.
*/
CORRADE_DEPRECATED("use translate() instead") Object<TranslationTransformation<dimensions, T, TranslationType>>& translate(const VectorTypeFor<dimensions, TranslationType>& vector, TransformationType) {
return translate(vector);
}
#endif
protected:
/* Allow construction only from Object */
explicit TranslationTransformation() = default;
@ -119,7 +141,10 @@ class TranslationTransformation: public AbstractTranslation<dimensions, T, Trans
private:
void doResetTransformation() override final { resetTransformation(); }
void doTranslate(const VectorTypeFor<dimensions, TranslationType>& vector, TransformationType) override final {
void doTranslate(const VectorTypeFor<dimensions, TranslationType>& vector) override final {
translate(vector);
}
void doTranslateLocal(const VectorTypeFor<dimensions, TranslationType>& vector) override final {
translate(vector);
}

Loading…
Cancel
Save