Browse Source

Getting rid of <>, part 6: SceneGraph transformations.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
346ea2feb6
  1. 50
      src/SceneGraph/AbstractTransformation.h
  2. 30
      src/SceneGraph/AbstractTranslationRotation2D.h
  3. 36
      src/SceneGraph/AbstractTranslationRotation3D.h
  4. 36
      src/SceneGraph/AbstractTranslationRotationScaling2D.h
  5. 46
      src/SceneGraph/AbstractTranslationRotationScaling3D.h
  6. 58
      src/SceneGraph/DualComplexTransformation.h
  7. 58
      src/SceneGraph/DualQuaternionTransformation.h
  8. 53
      src/SceneGraph/MatrixTransformation2D.h
  9. 64
      src/SceneGraph/MatrixTransformation3D.h
  10. 4
      src/SceneGraph/Object.hpp
  11. 63
      src/SceneGraph/RigidMatrixTransformation2D.h
  12. 75
      src/SceneGraph/RigidMatrixTransformation3D.h
  13. 39
      src/SceneGraph/SceneGraph.h
  14. 2
      src/SceneGraph/Test/AnimableTest.cpp
  15. 6
      src/SceneGraph/Test/CameraTest.cpp
  16. 12
      src/SceneGraph/Test/DualComplexTransformationTest.cpp
  17. 12
      src/SceneGraph/Test/DualQuaternionTransformationTest.cpp
  18. 12
      src/SceneGraph/Test/MatrixTransformation2DTest.cpp
  19. 12
      src/SceneGraph/Test/MatrixTransformation3DTest.cpp
  20. 4
      src/SceneGraph/Test/ObjectTest.cpp
  21. 14
      src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp
  22. 14
      src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp
  23. 4
      src/SceneGraph/Test/SceneTest.cpp
  24. 16
      src/SceneGraph/instantiation.cpp
  25. 8
      src/Shapes/Test/ShapeTest.cpp

50
src/SceneGraph/AbstractTransformation.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::AbstractTransformation, enum Magnum::SceneGraph::TransformationType, alias Magnum::SceneGraph::AbstractTransformation2D, Magnum::SceneGraph::AbstractTransformation3D
* @brief Class Magnum::SceneGraph::AbstractBasicTransformation, enum Magnum::SceneGraph::TransformationType, typedef Magnum::SceneGraph::AbstractTransformation2D, Magnum::SceneGraph::AbstractTransformation3D
*/
#include <vector>
@ -50,14 +50,10 @@ When subclassing, you have to:
- Implement all members listed in **Subclass implementation** group above
- Provide implicit (parameterless) constructor
@see @ref scenegraph, AbstractTransformation2D, AbstractTransformation3D
@see @ref AbstractTransformation2D, @ref AbstractTransformation3D,
@ref scenegraph
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<UnsignedInt dimensions, class T>
#else
template<UnsignedInt dimensions, class T = Float>
#endif
class MAGNUM_SCENEGRAPH_EXPORT AbstractTransformation {
template<UnsignedInt dimensions, class T> class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicTransformation {
public:
/** @brief Underlying floating-point type */
typedef T Type;
@ -65,8 +61,8 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractTransformation {
/** @brief Dimension count */
static const UnsignedInt Dimensions = dimensions;
explicit AbstractTransformation();
virtual ~AbstractTransformation() = 0;
explicit AbstractBasicTransformation();
virtual ~AbstractBasicTransformation() = 0;
#ifdef DOXYGEN_GENERATING_OUTPUT
/**
@ -142,7 +138,7 @@ class MAGNUM_SCENEGRAPH_EXPORT AbstractTransformation {
* @brief Reset object transformation
* @return Pointer to self (for method chaining)
*/
AbstractTransformation<dimensions, T>* resetTransformation() {
AbstractBasicTransformation<dimensions, T>* resetTransformation() {
doResetTransformation();
return this;
}
@ -165,39 +161,19 @@ enum class TransformationType: UnsignedByte {
Local = 0x01
};
#ifndef CORRADE_GCC46_COMPATIBILITY
/**
@brief Base for two-dimensional transformations
@brief Base transformation for two-dimensional float scenes
Convenience alternative to <tt>%AbstractTransformation<2, T></tt>. See
AbstractTransformation for more information.
@note Not available on GCC < 4.7. Use <tt>%AbstractTransformation<2, T></tt>
instead.
@see AbstractTransformation3D
@see @ref AbstractTransformation3D
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T = Float>
#else
template<class T>
#endif
using AbstractTransformation2D = AbstractTransformation<2, T>;
typedef AbstractBasicTransformation<2, Float> AbstractTransformation2D;
/**
@brief Base for three-dimensional transformations
@brief Base transformation for three-dimensional float scenes
Convenience alternative to <tt>%AbstractTransformation<3, T></tt>. See
AbstractTransformation for more information.
@note Not available on GCC < 4.7. Use <tt>%AbstractTransformation<3, T></tt>
instead.
@see AbstractTransformation2D
@see @ref AbstractTransformation2D
*/
#ifdef DOXYGEN_GENERATING_OUTPUT
template<class T = Float>
#else
template<class T>
#endif
using AbstractTransformation3D = AbstractTransformation<3, T>;
#endif
typedef AbstractBasicTransformation<3, Float> AbstractTransformation3D;
}}

30
src/SceneGraph/AbstractTranslationRotation2D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::AbstractTranslationRotation2D
* @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotation2D, typedef Magnum::SceneGraph::AbstractTranslationRotation2D
*/
#include "AbstractTransformation.h"
@ -33,18 +33,13 @@
namespace Magnum { namespace SceneGraph {
/**
@brief Base for two-dimensional transformations supporting translation and rotation
@brief Base translation for two-dimensional scenes supporting translation and rotation
@see @ref scenegraph, AbstractTranslationRotation3D
@see @ref AbstractTranslationRotation2D, @ref scenegraph, @ref AbstractBasicTranslationRotation3D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class AbstractTranslationRotation2D: public AbstractTransformation<2, T> {
template<class T> class AbstractBasicTranslationRotation2D: public AbstractBasicTransformation<2, T> {
public:
explicit AbstractTranslationRotation2D() = default;
explicit AbstractBasicTranslationRotation2D() = default;
/**
* @brief Translate object
@ -54,7 +49,7 @@ class AbstractTranslationRotation2D: public AbstractTransformation<2, T> {
*
* @see Vector2::xAxis(), Vector2::yAxis()
*/
AbstractTranslationRotation2D<T>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation2D<T>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
doTranslate(vector, type);
return this;
}
@ -65,15 +60,15 @@ class AbstractTranslationRotation2D: public AbstractTransformation<2, T> {
* @param type Transformation type
* @return Pointer to self (for method chaining)
*/
AbstractTranslationRotation2D<T>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation2D<T>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotate(angle, type);
return this;
}
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractTranslationRotation2D<T>* resetTransformation() {
AbstractTransformation<2, T>::resetTransformation();
AbstractBasicTranslationRotation2D<T>* resetTransformation() {
AbstractBasicTransformation<2, T>::resetTransformation();
return this;
}
#endif
@ -90,6 +85,13 @@ class AbstractTranslationRotation2D: public AbstractTransformation<2, T> {
virtual void doRotate(Math::Rad<T> angle, TransformationType type) = 0;
};
/**
@brief Base transformation for two-dimensional float scenes supporting translation and rotation
@see @ref AbstractTranslationRotation3D
*/
typedef AbstractBasicTranslationRotation2D<Float> AbstractTranslationRotation2D;
}}
#endif

36
src/SceneGraph/AbstractTranslationRotation3D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::AbstractTranslationRotation3D
* @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotation3D, typedef Magnum::SceneGraph::AbstractTranslationRotation3D
*/
#include "AbstractTransformation.h"
@ -34,18 +34,13 @@
namespace Magnum { namespace SceneGraph {
/**
@brief Base for three-dimensional transformations supporting translation and rotation
@brief Base translation for three-dimensional scenes supporting translation and rotation
@see @ref scenegraph, AbstractTranslationRotation2D
@see @ref AbstractTranslationRotation3D @ref scenegraph, @ref AbstractBasicTranslationRotation2D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class AbstractTranslationRotation3D: public AbstractTransformation<3, T> {
template<class T> class AbstractBasicTranslationRotation3D: public AbstractBasicTransformation<3, T> {
public:
explicit AbstractTranslationRotation3D() = default;
explicit AbstractBasicTranslationRotation3D() = default;
/**
* @brief Translate object
@ -55,7 +50,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> {
*
* @see Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis()
*/
AbstractTranslationRotation3D<T>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
doTranslate(vector, type);
return this;
}
@ -70,7 +65,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> {
* @see rotateX(), rotateY(), rotateZ(), Vector3::xAxis(),
* Vector3::yAxis(), Vector3::zAxis()
*/
AbstractTranslationRotation3D<T>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
doRotate(angle, normalizedAxis, type);
return this;
}
@ -84,7 +79,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> {
* In some implementations faster than calling
* `rotate(angle, Vector3::xAxis())`.
*/
AbstractTranslationRotation3D<T>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotateX(angle, type);
return this;
}
@ -98,7 +93,7 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> {
* In some implementations faster than calling
* `rotate(angle, Vector3::yAxis())`.
*/
AbstractTranslationRotation3D<T>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotateX(angle, type);
return this;
}
@ -112,15 +107,15 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> {
* In some implementations faster than calling
* `rotate(angle, Vector3::zAxis())`.
*/
AbstractTranslationRotation3D<T>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
doRotateZ(angle, type);
return this;
}
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractTranslationRotation3D<T>* resetTransformation() {
AbstractTransformation<3, T>::resetTransformation();
AbstractBasicTranslationRotation3D<T>* resetTransformation() {
AbstractBasicTransformation<3, T>::resetTransformation();
return this;
}
#endif
@ -164,6 +159,13 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> {
}
};
/**
@brief Base transformation for three-dimensional float scenes supporting translation and rotation
@see @ref AbstractTranslationRotation2D
*/
typedef AbstractBasicTranslationRotation3D<Float> AbstractTranslationRotation3D;
}}
#endif

36
src/SceneGraph/AbstractTranslationRotationScaling2D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::AbstractTranslationRotationScaling2D
* @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotationScaling2D, typedef Magnum::SceneGraph::AbstractTranslationRotationScaling2D
*/
#include "AbstractTranslationRotation2D.h"
@ -33,18 +33,13 @@
namespace Magnum { namespace SceneGraph {
/**
@brief Base for two-dimensional transformations supporting translation, rotation and scaling
@brief Base transformation for two-dimensional scenes supporting translation, rotation and scaling
@see @ref scenegraph, AbstractTranslationRotationScaling2D
@see @ref AbstractTranslationRotationScaling2D, @ref scenegraph, @ref AbstractBasicTranslationRotationScaling2D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D<T> {
template<class T> class AbstractBasicTranslationRotationScaling2D: public AbstractBasicTranslationRotation2D<T> {
public:
explicit AbstractTranslationRotationScaling2D() = default;
explicit AbstractBasicTranslationRotationScaling2D() = default;
/**
* @brief Scale object
@ -54,23 +49,23 @@ class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D
*
* @see Vector2::xScale(), Vector2::yScale()
*/
AbstractTranslationRotationScaling2D<T>* scale(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotationScaling2D<T>* scale(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
doScale(vector, type);
return this;
}
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractTranslationRotationScaling2D<T>* resetTransformation() {
AbstractTranslationRotation2D<T>::resetTransformation();
AbstractBasicTranslationRotationScaling2D<T>* resetTransformation() {
AbstractBasicTranslationRotation2D<T>::resetTransformation();
return this;
}
AbstractTranslationRotationScaling2D<T>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
AbstractTranslationRotation2D<T>::translate(vector, type);
AbstractBasicTranslationRotationScaling2D<T>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation2D<T>::translate(vector, type);
return this;
}
AbstractTranslationRotationScaling2D<T>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractTranslationRotation2D<T>::rotate(angle, type);
AbstractBasicTranslationRotationScaling2D<T>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation2D<T>::rotate(angle, type);
return this;
}
#endif
@ -84,6 +79,13 @@ class AbstractTranslationRotationScaling2D: public AbstractTranslationRotation2D
virtual void doScale(const Math::Vector2<T>& vector, TransformationType type) = 0;
};
/**
@brief Base transformation for two-dimensional float scenes supporting translation, rotation and scaling
@see @ref AbstractTranslationRotationScaling3D
*/
typedef AbstractBasicTranslationRotationScaling2D<Float> AbstractTranslationRotationScaling2D;
}}
#endif

46
src/SceneGraph/AbstractTranslationRotationScaling3D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::AbstractTranslationRotationScaling3D
* @brief Class Magnum::SceneGraph::AbstractBasicTranslationRotationScaling3D, typedef Magnum::SceneGraph::AbstractTranslationRotationScaling3D
*/
#include "AbstractTranslationRotation3D.h"
@ -35,16 +35,11 @@ namespace Magnum { namespace SceneGraph {
/**
@brief Base for three-dimensional transformations supporting translation, rotation and scaling
@see @ref scenegraph, AbstractTranslationRotationScaling2D
@see @ref AbstractTranslationRotationScaling3D, @ref scenegraph, @ref AbstractBasicTranslationRotationScaling2D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D<T> {
template<class T> class AbstractBasicTranslationRotationScaling3D: public AbstractBasicTranslationRotation3D<T> {
public:
explicit AbstractTranslationRotationScaling3D() = default;
explicit AbstractBasicTranslationRotationScaling3D() = default;
/**
* @brief Scale object
@ -54,35 +49,35 @@ class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D
*
* @see Vector3::xScale(), Vector3::yScale(), Vector3::zScale()
*/
AbstractTranslationRotationScaling3D<T>* scale(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotationScaling3D<T>* scale(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
doScale(vector, type);
return this;
}
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
AbstractTranslationRotationScaling3D<T>* resetTransformation() {
AbstractTranslationRotation3D<T>::resetTransformation();
AbstractBasicTranslationRotationScaling3D<T>* resetTransformation() {
AbstractBasicTranslationRotation3D<T>::resetTransformation();
return this;
}
AbstractTranslationRotationScaling3D<T>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
AbstractTranslationRotation3D<T>::translate(vector, type);
AbstractBasicTranslationRotationScaling3D<T>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>::translate(vector, type);
return this;
}
AbstractTranslationRotationScaling3D<T>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
AbstractTranslationRotation3D<T>::rotate(angle, normalizedAxis, type);
AbstractBasicTranslationRotationScaling3D<T>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>::rotate(angle, normalizedAxis, type);
return this;
}
AbstractTranslationRotationScaling3D<T>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractTranslationRotation3D<T>::rotateX(angle, type);
AbstractBasicTranslationRotationScaling3D<T>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>::rotateX(angle, type);
return this;
}
AbstractTranslationRotationScaling3D<T>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractTranslationRotation3D<T>::rotateY(angle, type);
AbstractBasicTranslationRotationScaling3D<T>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>::rotateY(angle, type);
return this;
}
AbstractTranslationRotationScaling3D<T>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractTranslationRotation3D<T>::rotateZ(angle, type);
AbstractBasicTranslationRotationScaling3D<T>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
AbstractBasicTranslationRotation3D<T>::rotateZ(angle, type);
return this;
}
#endif
@ -96,6 +91,13 @@ class AbstractTranslationRotationScaling3D: public AbstractTranslationRotation3D
virtual void doScale(const Math::Vector3<T>& vector, TransformationType type) = 0;
};
/**
@brief Base transformation for three-dimensional float scenes supporting translation, rotation and scaling
@see @ref AbstractTranslationRotationScaling2D
*/
typedef AbstractBasicTranslationRotationScaling3D<Float> AbstractTranslationRotationScaling3D;
}}
#endif

58
src/SceneGraph/DualComplexTransformation.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::DualComplexTransformation
* @brief Class Magnum::SceneGraph::BasicDualComplexTransformation, typedef Magnum::SceneGraph::DualComplexTransformation
*/
#include "Math/DualComplex.h"
@ -39,14 +39,9 @@ namespace Magnum { namespace SceneGraph {
This class allows only rigid transformation (i.e. only rotation and
translation).
@see @ref scenegraph, Math::DualComplex, DualQuaternionTransformation
@see @ref DualComplexTransformation, @ref scenegraph, Math::DualComplex, @ref BasicDualQuaternionTransformation
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
template<class T> class BasicDualComplexTransformation: public AbstractBasicTranslationRotation2D<T> {
public:
/** @brief Transformation type */
typedef Math::DualComplex<T> DataType;
@ -81,9 +76,9 @@ class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
* the object subsequently.
* @see DualComplex::normalized()
*/
Object<DualComplexTransformation<T>>* normalizeRotation() {
Object<BasicDualComplexTransformation<T>>* normalizeRotation() {
setTransformationInternal(_transformation.normalized());
return static_cast<Object<DualComplexTransformation<T>>*>(this);
return static_cast<Object<BasicDualComplexTransformation<T>>*>(this);
}
/**
@ -93,18 +88,18 @@ class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
* Expects that the dual complex number is normalized.
* @see DualComplex::isNormalized()
*/
Object<DualComplexTransformation<T>>* setTransformation(const Math::DualComplex<T>& transformation) {
Object<BasicDualComplexTransformation<T>>* setTransformation(const Math::DualComplex<T>& transformation) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualComplexTransformation::setTransformation(): the dual complex number is not normalized",
static_cast<Object<DualComplexTransformation<T>>*>(this));
static_cast<Object<BasicDualComplexTransformation<T>>*>(this));
setTransformationInternal(transformation);
return static_cast<Object<DualComplexTransformation<T>>*>(this);
return static_cast<Object<BasicDualComplexTransformation<T>>*>(this);
}
/** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */
Object<DualComplexTransformation<T>>* resetTransformation() {
Object<BasicDualComplexTransformation<T>>* resetTransformation() {
setTransformationInternal({});
return static_cast<Object<DualComplexTransformation<T>>*>(this);
return static_cast<Object<BasicDualComplexTransformation<T>>*>(this);
}
/**
@ -116,21 +111,21 @@ class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
* Expects that the dual complex number is normalized.
* @see DualComplex::isNormalized()
*/
Object<DualComplexTransformation<T>>* transform(const Math::DualComplex<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicDualComplexTransformation<T>>* transform(const Math::DualComplex<T>& transformation, TransformationType type = TransformationType::Global) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualComplexTransformation::transform(): the dual complex number is not normalized",
static_cast<Object<DualComplexTransformation<T>>*>(this));
static_cast<Object<BasicDualComplexTransformation<T>>*>(this));
transformInternal(transformation, type);
return static_cast<Object<DualComplexTransformation<T>>*>(this);
return static_cast<Object<BasicDualComplexTransformation<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling2D::translate()
* Same as calling transform() with DualComplex::translation().
*/
Object<DualComplexTransformation<T>>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicDualComplexTransformation<T>>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualComplex<T>::translation(vector), type);
return static_cast<Object<DualComplexTransformation<T>>*>(this);
return static_cast<Object<BasicDualComplexTransformation<T>>*>(this);
}
/**
@ -142,9 +137,9 @@ class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
* Same as calling transform() with DualComplex::rotation().
* @see normalizeRotation()
*/
Object<DualComplexTransformation<T>>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicDualComplexTransformation<T>>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualComplex<T>::rotation(angle), type);
return static_cast<Object<DualComplexTransformation<T>>*>(this);
return static_cast<Object<BasicDualComplexTransformation<T>>*>(this);
}
/**
@ -153,14 +148,14 @@ class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
* if you want to move it above all.
* @return Pointer to self (for method chaining)
*/
Object<DualComplexTransformation<T>>* move(Object<DualComplexTransformation<T>>* under) {
static_cast<Object<DualComplexTransformation>*>(this)->Containers::template LinkedList<Object<DualComplexTransformation<T>>>::move(this, under);
return static_cast<Object<DualComplexTransformation<T>>*>(this);
Object<BasicDualComplexTransformation<T>>* move(Object<BasicDualComplexTransformation<T>>* under) {
static_cast<Object<BasicDualComplexTransformation>*>(this)->Containers::template LinkedList<Object<BasicDualComplexTransformation<T>>>::move(this, under);
return static_cast<Object<BasicDualComplexTransformation<T>>*>(this);
}
protected:
/* Allow construction only from Object */
explicit DualComplexTransformation() = default;
explicit BasicDualComplexTransformation() = default;
private:
void doResetTransformation() override final { resetTransformation(); }
@ -178,9 +173,9 @@ class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<DualComplexTransformation<T>>*>(this)->isScene()) {
if(!static_cast<Object<BasicDualComplexTransformation<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<DualComplexTransformation<T>>*>(this)->setDirty();
static_cast<Object<BasicDualComplexTransformation<T>>*>(this)->setDirty();
}
}
@ -193,6 +188,13 @@ class DualComplexTransformation: public AbstractTranslationRotation2D<T> {
Math::DualComplex<T> _transformation;
};
/**
@brief Two-dimensional transformation for float scenes implemented using dual complex numbers
@see @ref DualQuaternionTransformation
*/
typedef BasicDualComplexTransformation<Float> DualComplexTransformation;
}}
#endif

58
src/SceneGraph/DualQuaternionTransformation.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::DualQuaternionTransformation
* @brief Class Magnum::SceneGraph::BasicDualQuaternionTransformation, typedef Magnum::SceneGraph::DualQuaternionTransformation
*/
#include "Math/DualQuaternion.h"
@ -39,14 +39,9 @@ namespace Magnum { namespace SceneGraph {
This class allows only rigid transformation (i.e. only rotation and
translation).
@see @ref scenegraph, Math::DualQuaternion, DualComplexTransformation
@see @ref DualQuaternionTransformation @ref scenegraph, Math::DualQuaternion, @ref BasicDualComplexTransformation
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class DualQuaternionTransformation: public AbstractTranslationRotation3D<T> {
template<class T> class BasicDualQuaternionTransformation: public AbstractBasicTranslationRotation3D<T> {
public:
/** @brief Underlying transformation type */
typedef Math::DualQuaternion<T> DataType;
@ -83,9 +78,9 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D<T> {
* the object subsequently.
* @see DualQuaternion::normalized()
*/
Object<DualQuaternionTransformation<T>>* normalizeRotation() {
Object<BasicDualQuaternionTransformation<T>>* normalizeRotation() {
setTransformation(_transformation.normalized());
return static_cast<Object<DualQuaternionTransformation<T>>*>(this);
return static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this);
}
/**
@ -95,18 +90,18 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D<T> {
* Expects that the dual quaternion is normalized.
* @see DualQuaternion::isNormalized()
*/
Object<DualQuaternionTransformation<T>>* setTransformation(const Math::DualQuaternion<T>& transformation) {
Object<BasicDualQuaternionTransformation<T>>* setTransformation(const Math::DualQuaternion<T>& transformation) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualQuaternionTransformation::setTransformation(): the dual quaternion is not normalized",
static_cast<Object<DualQuaternionTransformation<T>>*>(this));
static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this));
setTransformationInternal(transformation);
return static_cast<Object<DualQuaternionTransformation<T>>*>(this);
return static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this);
}
/** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */
Object<DualQuaternionTransformation<T>>* resetTransformation() {
Object<BasicDualQuaternionTransformation<T>>* resetTransformation() {
setTransformation({});
return static_cast<Object<DualQuaternionTransformation<T>>*>(this);
return static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this);
}
/**
@ -118,21 +113,21 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D<T> {
* Expects that the dual quaternion is normalized.
* @see DualQuaternion::isNormalized()
*/
Object<DualQuaternionTransformation<T>>* transform(const Math::DualQuaternion<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>* transform(const Math::DualQuaternion<T>& transformation, TransformationType type = TransformationType::Global) {
CORRADE_ASSERT(transformation.isNormalized(),
"SceneGraph::DualQuaternionTransformation::transform(): the dual quaternion is not normalized",
static_cast<Object<DualQuaternionTransformation<T>>*>(this));
static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this));
transformInternal(transformation, type);
return static_cast<Object<DualQuaternionTransformation<T>>*>(this);
return static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling3D::translate()
* Same as calling transform() with DualQuaternion::translation().
*/
Object<DualQuaternionTransformation<T>>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualQuaternion<T>::translation(vector), type);
return static_cast<Object<DualQuaternionTransformation<T>>*>(this);
return static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this);
}
/**
@ -146,27 +141,27 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D<T> {
* @see Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis(),
* normalizeRotation()
*/
Object<DualQuaternionTransformation<T>>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
transformInternal(Math::DualQuaternion<T>::rotation(angle, normalizedAxis), type);
return static_cast<Object<DualQuaternionTransformation<T>>*>(this);
return static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this);
}
/* Overloads to remove WTF-factor from method chaining order */
#ifndef DOXYGEN_GENERATING_OUTPUT
Object<DualQuaternionTransformation<T>>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return rotate(angle, Math::Vector3<T>::xAxis(), type);
}
Object<DualQuaternionTransformation<T>>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return rotate(angle, Math::Vector3<T>::yAxis(), type);
}
Object<DualQuaternionTransformation<T>>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicDualQuaternionTransformation<T>>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
return rotate(angle, Math::Vector3<T>::zAxis(), type);
}
#endif
protected:
/* Allow construction only from Object */
explicit DualQuaternionTransformation() = default;
explicit BasicDualQuaternionTransformation() = default;
private:
void doResetTransformation() override final { resetTransformation(); }
@ -184,9 +179,9 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D<T> {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<DualQuaternionTransformation<T>>*>(this)->isScene()) {
if(!static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<DualQuaternionTransformation<T>>*>(this)->setDirty();
static_cast<Object<BasicDualQuaternionTransformation<T>>*>(this)->setDirty();
}
}
@ -199,6 +194,13 @@ class DualQuaternionTransformation: public AbstractTranslationRotation3D<T> {
Math::DualQuaternion<T> _transformation;
};
/**
@brief Three-dimensional transformation for float scenes implemented using dual quaternions
@see @ref DualComplexTransformation
*/
typedef BasicDualQuaternionTransformation<Float> DualQuaternionTransformation;
}}
#endif

53
src/SceneGraph/MatrixTransformation2D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::MatrixTransformation2D
* @brief Class Magnum::SceneGraph::BasicMatrixTransformation2D, typedef Magnum::SceneGraph::MatrixTransformation2D
*/
#include "Math/Matrix3.h"
@ -38,14 +38,9 @@ namespace Magnum { namespace SceneGraph {
@brief Two-dimensional transformation implemented using matrices
Uses Math::Matrix3 as underlying type.
@see @ref scenegraph, RigidMatrixTransformation2D, MatrixTransformation3D
@see @ref MatrixTransformation2D, @ref scenegraph, @ref RigidBasicMatrixTransformation2D, @ref BasicMatrixTransformation3D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class MatrixTransformation2D: public AbstractTranslationRotationScaling2D<T> {
template<class T> class BasicMatrixTransformation2D: public AbstractBasicTranslationRotationScaling2D<T> {
public:
/** @brief Underlying transformation type */
typedef Math::Matrix3<T> DataType;
@ -76,16 +71,16 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D<T> {
* @brief Set transformation
* @return Pointer to self (for method chaining)
*/
Object<MatrixTransformation2D<T>>* setTransformation(const Math::Matrix3<T>& transformation) {
Object<BasicMatrixTransformation2D<T>>* setTransformation(const Math::Matrix3<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<MatrixTransformation2D<T>>*>(this)->isScene()) {
if(!static_cast<Object<BasicMatrixTransformation2D<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<MatrixTransformation2D<T>>*>(this)->setDirty();
static_cast<Object<BasicMatrixTransformation2D<T>>*>(this)->setDirty();
}
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
/**
@ -94,43 +89,43 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D<T> {
* @param type Transformation type
* @return Pointer to self (for method chaining)
*/
Object<MatrixTransformation2D<T>>* transform(const Math::Matrix3<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation2D<T>>* transform(const Math::Matrix3<T>& transformation, TransformationType type = TransformationType::Global) {
setTransformation(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
/** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */
Object<MatrixTransformation2D<T>>* resetTransformation() {
Object<BasicMatrixTransformation2D<T>>* resetTransformation() {
setTransformation({});
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling2D::translate()
* Same as calling transform() with Matrix3::translation().
*/
Object<MatrixTransformation2D<T>>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation2D<T>>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::translation(vector), type);
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling2D::rotate()
* Same as calling transform() with Matrix3::rotation().
*/
Object<MatrixTransformation2D<T>>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation2D<T>>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::rotation(angle), type);
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling2D::scale()
* Same as calling transform() with Matrix3::scaling().
*/
Object<MatrixTransformation2D<T>>* scale(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation2D<T>>* scale(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::scaling(vector), type);
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
/**
@ -142,9 +137,9 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D<T> {
*
* Same as calling transform() with Matrix3::reflection().
*/
Object<MatrixTransformation2D<T>>* reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation2D<T>>* reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
transform(Math::Matrix3<T>::reflection(normal), type);
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
/**
@ -153,14 +148,14 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D<T> {
* if you want to move it above all.
* @return Pointer to self (for method chaining)
*/
Object<MatrixTransformation2D<T>>* move(Object<MatrixTransformation2D<T>>* under) {
static_cast<Object<MatrixTransformation2D>*>(this)->Containers::template LinkedList<Object<MatrixTransformation2D<T>>>::move(this, under);
return static_cast<Object<MatrixTransformation2D<T>>*>(this);
Object<BasicMatrixTransformation2D<T>>* move(Object<BasicMatrixTransformation2D<T>>* under) {
static_cast<Object<BasicMatrixTransformation2D>*>(this)->Containers::template LinkedList<Object<BasicMatrixTransformation2D<T>>>::move(this, under);
return static_cast<Object<BasicMatrixTransformation2D<T>>*>(this);
}
protected:
/* Allow construction only from Object */
explicit MatrixTransformation2D() = default;
explicit BasicMatrixTransformation2D() = default;
private:
void doResetTransformation() override final { resetTransformation(); }
@ -180,6 +175,8 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D<T> {
Math::Matrix3<T> _transformation;
};
}}
#endif

64
src/SceneGraph/MatrixTransformation3D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::MatrixTransformation3D
* @brief Class Magnum::SceneGraph::BasicMatrixTransformation3D, typedef Magnum::SceneGraph::MatrixTransformation3D
*/
#include "Math/Matrix4.h"
@ -38,14 +38,9 @@ namespace Magnum { namespace SceneGraph {
@brief Three-dimensional transformation implemented using matrices
Uses Math::Matrix4 as underlying type.
@see @ref scenegraph, RigidMatrixTransformation3D, MatrixTransformation2D
@see @ref MatrixTransformation3D, @ref scenegraph, @ref BasicRigidMatrixTransformation3D, @ref BasicMatrixTransformation2D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
template<class T> class BasicMatrixTransformation3D: public AbstractBasicTranslationRotationScaling3D<T> {
public:
/** @brief Underlying transformation type */
typedef Math::Matrix4<T> DataType;
@ -76,22 +71,22 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
* @brief Set transformation
* @return Pointer to self (for method chaining)
*/
Object<MatrixTransformation3D<T>>* setTransformation(const Math::Matrix4<T>& transformation) {
Object<BasicMatrixTransformation3D<T>>* setTransformation(const Math::Matrix4<T>& transformation) {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<MatrixTransformation3D<T>>*>(this)->isScene()) {
if(!static_cast<Object<BasicMatrixTransformation3D<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<MatrixTransformation3D<T>>*>(this)->setDirty();
static_cast<Object<BasicMatrixTransformation3D<T>>*>(this)->setDirty();
}
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */
Object<MatrixTransformation3D<T>>* resetTransformation() {
Object<BasicMatrixTransformation3D<T>>* resetTransformation() {
setTransformation({});
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
@ -100,28 +95,28 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
* @param type Transformation type
* @return Pointer to self (for method chaining)
*/
Object<MatrixTransformation3D<T>>* transform(const Math::Matrix4<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* transform(const Math::Matrix4<T>& transformation, TransformationType type = TransformationType::Global) {
setTransformation(type == TransformationType::Global ?
transformation*_transformation : _transformation*transformation);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling3D::translate()
* Same as calling transform() with Matrix4::translation().
*/
Object<MatrixTransformation3D<T>>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::translation(vector), type);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling3D::rotate()
* Same as calling transform() with Matrix4::rotation().
*/
Object<MatrixTransformation3D<T>>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
@ -132,9 +127,9 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
*
* Same as calling transform() with Matrix4::rotationX().
*/
Object<MatrixTransformation3D<T>>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotationX(angle), type);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
@ -145,9 +140,9 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
*
* Same as calling transform() with Matrix4::rotationY().
*/
Object<MatrixTransformation3D<T>>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotationY(angle), type);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
@ -158,18 +153,18 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
*
* Same as calling transform() with Matrix4::rotationZ().
*/
Object<MatrixTransformation3D<T>>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::rotationZ(angle), type);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling3D::scale()
* Same as calling transform() with Matrix4::scaling().
*/
Object<MatrixTransformation3D<T>>* scale(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* scale(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::scaling(vector), type);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
/**
@ -181,14 +176,14 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
*
* Same as calling transform() with Matrix4::reflection().
*/
Object<MatrixTransformation3D<T>>* reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
Object<BasicMatrixTransformation3D<T>>* reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
transform(Math::Matrix4<T>::reflection(normal), type);
return static_cast<Object<MatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicMatrixTransformation3D<T>>*>(this);
}
protected:
/* Allow construction only from Object */
explicit MatrixTransformation3D() = default;
explicit BasicMatrixTransformation3D() = default;
private:
void doResetTransformation() override final { resetTransformation(); }
@ -220,6 +215,13 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D<T> {
Math::Matrix4<T> _transformation;
};
/**
@brief Three-dimensional transformation for float scenes implemented using matrices
@see @ref MatrixTransformation2D
*/
typedef BasicMatrixTransformation3D<Float> MatrixTransformation3D;
}}
#endif

4
src/SceneGraph/Object.hpp

@ -41,8 +41,8 @@ namespace Magnum { namespace SceneGraph {
template<UnsignedInt dimensions, class T> AbstractBasicObject<dimensions, T>::AbstractBasicObject() {}
template<UnsignedInt dimensions, class T> AbstractBasicObject<dimensions, T>::~AbstractBasicObject() {}
template<UnsignedInt dimensions, class T> AbstractTransformation<dimensions, T>::AbstractTransformation() {}
template<UnsignedInt dimensions, class T> AbstractTransformation<dimensions, T>::~AbstractTransformation() {}
template<UnsignedInt dimensions, class T> AbstractBasicTransformation<dimensions, T>::AbstractBasicTransformation() {}
template<UnsignedInt dimensions, class T> AbstractBasicTransformation<dimensions, T>::~AbstractBasicTransformation() {}
template<class Transformation> Object<Transformation>::~Object() = default;

63
src/SceneGraph/RigidMatrixTransformation2D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::RigidMatrixTransformation2D
* @brief Class Magnum::SceneGraph::BasicRigidMatrixTransformation2D, typedef Magnum::SceneGraph::RigidMatrixTransformation2D
*/
#include "Math/Matrix3.h"
@ -38,17 +38,13 @@ namespace Magnum { namespace SceneGraph {
/**
@brief Two-dimensional rigid transformation implemented using matrices
Unlike MatrixTransformation2D this class allows only rotation, reflection and
translation (no scaling or setting arbitrary transformations). This allows to
use Matrix3::invertedRigid() for faster computation of inverse transformations.
@see @ref scenegraph, RigidMatrixTransformation3D
Unlike BasicMatrixTransformation2D this class allows only rotation, reflection
and translation (no scaling or setting arbitrary transformations). This allows
to use Matrix3::invertedRigid() for faster computation of inverse
transformations.
@see @ref RigidMatrixTransformation2D, @ref scenegraph, @ref BasicRigidMatrixTransformation3D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
template<class T> class BasicRigidMatrixTransformation2D: public AbstractBasicTranslationRotation2D<T> {
public:
/** @brief Underlying transformation type */
typedef Math::Matrix3<T> DataType;
@ -84,11 +80,11 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* Normalizes the rotation part using Math::Algorithms::gramSchmidt()
* to prevent rounding errors when rotating the object subsequently.
*/
Object<RigidMatrixTransformation2D<T>>* normalizeRotation() {
Object<BasicRigidMatrixTransformation2D<T>>* normalizeRotation() {
setTransformationInternal(Math::Matrix3<T>::from(
Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()),
_transformation.translation()));
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
/**
@ -98,18 +94,18 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* Expects that the matrix represents rigid transformation.
* @see Matrix3::isRigidTransformation()
*/
Object<RigidMatrixTransformation2D<T>>* setTransformation(const Math::Matrix3<T>& transformation) {
Object<BasicRigidMatrixTransformation2D<T>>* setTransformation(const Math::Matrix3<T>& transformation) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation2D::setTransformation(): the matrix doesn't represent rigid transformation",
static_cast<Object<RigidMatrixTransformation2D<T>>*>(this));
static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this));
setTransformationInternal(transformation);
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
/** @copydoc AbstractTranslationRotationScaling2D::resetTransformation() */
Object<RigidMatrixTransformation2D<T>>* resetTransformation() {
Object<BasicRigidMatrixTransformation2D<T>>* resetTransformation() {
setTransformationInternal({});
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
/**
@ -121,21 +117,21 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* Expects that the matrix represents rigid transformation.
* @see Matrix3::isRigidTransformation()
*/
Object<RigidMatrixTransformation2D<T>>* transform(const Math::Matrix3<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation2D<T>>* transform(const Math::Matrix3<T>& transformation, TransformationType type = TransformationType::Global) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation2D::transform(): the matrix doesn't represent rigid transformation",
static_cast<Object<RigidMatrixTransformation2D<T>>*>(this));
static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this));
transformInternal(transformation, type);
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling2D::translate()
* Same as calling transform() with Matrix3::translation().
*/
Object<RigidMatrixTransformation2D<T>>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation2D<T>>* translate(const Math::Vector2<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix3<T>::translation(vector), type);
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
/**
@ -147,9 +143,9 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* Same as calling transform() with Matrix3::rotation().
* @see normalizeRotation()
*/
Object<RigidMatrixTransformation2D<T>>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation2D<T>>* rotate(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix3<T>::rotation(angle), type);
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
/**
@ -161,9 +157,9 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
*
* Same as calling transform() with Matrix3::reflection().
*/
Object<RigidMatrixTransformation2D<T>>* reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation2D<T>>* reflect(const Math::Vector2<T>& normal, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix3<T>::reflection(normal), type);
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
/**
@ -172,14 +168,14 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
* if you want to move it above all.
* @return Pointer to self (for method chaining)
*/
Object<RigidMatrixTransformation2D<T>>* move(Object<RigidMatrixTransformation2D<T>>* under) {
static_cast<Object<RigidMatrixTransformation2D>*>(this)->Containers::template LinkedList<Object<RigidMatrixTransformation2D<T>>>::move(this, under);
return static_cast<Object<RigidMatrixTransformation2D<T>>*>(this);
Object<BasicRigidMatrixTransformation2D<T>>* move(Object<BasicRigidMatrixTransformation2D<T>>* under) {
static_cast<Object<BasicRigidMatrixTransformation2D>*>(this)->Containers::template LinkedList<Object<BasicRigidMatrixTransformation2D<T>>>::move(this, under);
return static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this);
}
protected:
/* Allow construction only from Object */
explicit RigidMatrixTransformation2D() = default;
explicit BasicRigidMatrixTransformation2D() = default;
private:
void doResetTransformation() override final { resetTransformation(); }
@ -197,9 +193,9 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<RigidMatrixTransformation2D<T>>*>(this)->isScene()) {
if(!static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<RigidMatrixTransformation2D<T>>*>(this)->setDirty();
static_cast<Object<BasicRigidMatrixTransformation2D<T>>*>(this)->setDirty();
}
}
@ -212,6 +208,7 @@ class RigidMatrixTransformation2D: public AbstractTranslationRotation2D<T> {
Math::Matrix3<T> _transformation;
};
}}
#endif

75
src/SceneGraph/RigidMatrixTransformation3D.h

@ -25,7 +25,7 @@
*/
/** @file
* @brief Class Magnum::SceneGraph::RigidMatrixTransformation3D
* @brief Class Magnum::SceneGraph::BasicRigidMatrixTransformation3D, typedef Magnum::SceneGraph::RigidMatrixTransformation3D
*/
#include "Math/Matrix4.h"
@ -38,17 +38,13 @@ namespace Magnum { namespace SceneGraph {
/**
@brief Three-dimensional rigid transformation implemented using matrices
Unlike MatrixTransformation3D this class allows only rotation, reflection and
translation (no scaling or setting arbitrary transformations). This allows to
use Matrix4::invertedRigid() for faster computation of inverse transformations.
@see @ref scenegraph, RigidMatrixTransformation2D
Unlike BasicMatrixTransformation3D this class allows only rotation, reflection
and translation (no scaling or setting arbitrary transformations). This allows
to use Matrix4::invertedRigid() for faster computation of inverse
transformations.
@see @ref RigidMatrixTransformation3D, @ref scenegraph, @ref BasicRigidMatrixTransformation2D
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
template<class T>
#else
template<class T = Float>
#endif
class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
template<class T> class BasicRigidMatrixTransformation3D: public AbstractBasicTranslationRotation3D<T> {
public:
/** @brief Underlying transformation type */
typedef Math::Matrix4<T> DataType;
@ -84,11 +80,11 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Normalizes the rotation part using Math::Algorithms::gramSchmidt()
* to prevent rounding errors when rotating the object subsequently.
*/
Object<RigidMatrixTransformation3D<T>>* normalizeRotation() {
Object<BasicRigidMatrixTransformation3D<T>>* normalizeRotation() {
setTransformation(Math::Matrix4<T>::from(
Math::Algorithms::gramSchmidtOrthonormalize(_transformation.rotationScaling()),
_transformation.translation()));
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
@ -98,18 +94,18 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Expects that the matrix represents rigid transformation.
* @see Matrix4::isRigidTransformation()
*/
Object<RigidMatrixTransformation3D<T>>* setTransformation(const Math::Matrix4<T>& transformation) {
Object<BasicRigidMatrixTransformation3D<T>>* setTransformation(const Math::Matrix4<T>& transformation) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation3D::setTransformation(): the matrix doesn't represent rigid transformation",
static_cast<Object<RigidMatrixTransformation3D<T>>*>(this));
static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this));
setTransformationInternal(transformation);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/** @copydoc AbstractTranslationRotationScaling3D::resetTransformation() */
Object<RigidMatrixTransformation3D<T>>* resetTransformation() {
Object<BasicRigidMatrixTransformation3D<T>>* resetTransformation() {
setTransformation({});
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
@ -121,21 +117,21 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Expects that the matrix represents rigid transformation.
* @see Matrix4::isRigidTransformation()
*/
Object<RigidMatrixTransformation3D<T>>* transform(const Math::Matrix4<T>& transformation, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>* transform(const Math::Matrix4<T>& transformation, TransformationType type = TransformationType::Global) {
CORRADE_ASSERT(transformation.isRigidTransformation(),
"SceneGraph::RigidMatrixTransformation3D::transform(): the matrix doesn't represent rigid transformation",
static_cast<Object<RigidMatrixTransformation3D<T>>*>(this));
static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this));
transformInternal(transformation, type);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
* @copydoc AbstractTranslationRotationScaling3D::translate()
* Same as calling transform() with Matrix4::translation().
*/
Object<RigidMatrixTransformation3D<T>>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>* translate(const Math::Vector3<T>& vector, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::translation(vector), type);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
@ -149,9 +145,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* @see rotateX(), rotateY(), rotateZ(), Vector3::xAxis(),
* Vector3::yAxis(), Vector3::zAxis(), normalizeRotation()
*/
Object<RigidMatrixTransformation3D<T>>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>* rotate(Math::Rad<T> angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotation(angle, normalizedAxis), type);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
@ -163,9 +159,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Same as calling transform() with Matrix4::rotationX().
* @see normalizeRotation()
*/
Object<RigidMatrixTransformation3D<T>>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>* rotateX(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotationX(angle), type);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
@ -177,9 +173,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Same as calling transform() with Matrix4::rotationY().
* @see normalizeRotation()
*/
Object<RigidMatrixTransformation3D<T>>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>* rotateY(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotationY(angle), type);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
@ -191,9 +187,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
* Same as calling transform() with Matrix4::rotationZ().
* @see normalizeRotation()
*/
Object<RigidMatrixTransformation3D<T>>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>* rotateZ(Math::Rad<T> angle, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::rotationZ(angle), type);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
/**
@ -205,14 +201,14 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
*
* Same as calling transform() with Matrix4::reflection().
*/
Object<RigidMatrixTransformation3D<T>>* reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
Object<BasicRigidMatrixTransformation3D<T>>* reflect(const Math::Vector3<T>& normal, TransformationType type = TransformationType::Global) {
transformInternal(Math::Matrix4<T>::reflection(normal), type);
return static_cast<Object<RigidMatrixTransformation3D<T>>*>(this);
return static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this);
}
protected:
/* Allow construction only from Object */
explicit RigidMatrixTransformation3D() = default;
explicit BasicRigidMatrixTransformation3D() = default;
private:
void doResetTransformation() override final { resetTransformation(); }
@ -242,9 +238,9 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
/* Setting transformation is forbidden for the scene */
/** @todo Assert for this? */
/** @todo Do this in some common code so we don't need to include Object? */
if(!static_cast<Object<RigidMatrixTransformation3D<T>>*>(this)->isScene()) {
if(!static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this)->isScene()) {
_transformation = transformation;
static_cast<Object<RigidMatrixTransformation3D<T>>*>(this)->setDirty();
static_cast<Object<BasicRigidMatrixTransformation3D<T>>*>(this)->setDirty();
}
}
@ -257,6 +253,13 @@ class RigidMatrixTransformation3D: public AbstractTranslationRotation3D<T> {
Math::Matrix4<T> _transformation;
};
/**
@brief Three-dimensional rigid transformation for float scenes implemented using matrices
@see @ref RigidMatrixTransformation2D
*/
typedef BasicRigidMatrixTransformation3D<Float> RigidMatrixTransformation3D;
}}
#endif

39
src/SceneGraph/SceneGraph.h

@ -64,16 +64,19 @@ typedef AbstractBasicObject<3, Float> AbstractObject3D;
enum class TransformationType: UnsignedByte;
template<UnsignedInt dimensions, class T = Float> class AbstractTransformation;
#ifndef CORRADE_GCC46_COMPATIBILITY
template<class T = Float> using AbstractTransformation2D = AbstractTransformation<2, T>;
template<class T = Float> using AbstractTransformation3D = AbstractTransformation<3, T>;
#endif
template<UnsignedInt dimensions, class> class AbstractBasicTransformation;
typedef AbstractBasicTransformation<2, Float> AbstractTransformation2D;
typedef AbstractBasicTransformation<3, Float> AbstractTransformation3D;
template<class> class AbstractBasicTranslationRotation2D;
template<class> class AbstractBasicTranslationRotation3D;
typedef AbstractBasicTranslationRotation2D<Float> AbstractTranslationRotation2D;
typedef AbstractBasicTranslationRotation3D<Float> AbstractTranslationRotation3D;
template<class T = Float> class AbstractTranslationRotation2D;
template<class T = Float> class AbstractTranslationRotation3D;
template<class T = Float> class AbstractTranslationRotationScaling2D;
template<class T = Float> class AbstractTranslationRotationScaling3D;
template<class> class AbstractBasicTranslationRotationScaling2D;
template<class> class AbstractBasicTranslationRotationScaling3D;
typedef AbstractBasicTranslationRotationScaling2D<Float> AbstractTranslationRotationScaling2D;
typedef AbstractBasicTranslationRotationScaling3D<Float> AbstractTranslationRotationScaling3D;
template<UnsignedInt, class> class BasicAnimable;
typedef BasicAnimable<2, Float> Animable2D;
@ -94,8 +97,10 @@ template<UnsignedInt, class> class BasicDrawable;
typedef BasicDrawable<2, Float> Drawable2D;
typedef BasicDrawable<3, Float> Drawable3D;
template<class T = Float> class DualComplexTransformation;
template<class T = Float> class DualQuaternionTransformation;
template<class> class BasicDualComplexTransformation;
template<class> class BasicDualQuaternionTransformation;
typedef BasicDualComplexTransformation<Float> DualComplexTransformation;
typedef BasicDualQuaternionTransformation<Float> DualQuaternionTransformation;
template<UnsignedInt dimensions, class Feature, class T> class BasicFeatureGroup;
#ifndef CORRADE_GCC46_COMPATIBILITY
@ -111,13 +116,17 @@ template<UnsignedInt, class> class BasicDrawableGroup;
typedef BasicDrawableGroup<2, Float> DrawableGroup2D;
typedef BasicDrawableGroup<3, Float> DrawableGroup3D;
template<class T = Float> class MatrixTransformation2D;
template<class T = Float> class MatrixTransformation3D;
template<class> class BasicMatrixTransformation2D;
template<class> class BasicMatrixTransformation3D;
typedef BasicMatrixTransformation2D<Float> MatrixTransformation2D;
typedef BasicMatrixTransformation3D<Float> MatrixTransformation3D;
template<class Transformation> class Object;
template<class T = Float> class RigidMatrixTransformation2D;
template<class T = Float> class RigidMatrixTransformation3D;
template<class> class BasicRigidMatrixTransformation2D;
template<class> class BasicRigidMatrixTransformation3D;
typedef BasicRigidMatrixTransformation2D<Float> RigidMatrixTransformation2D;
typedef BasicRigidMatrixTransformation3D<Float> RigidMatrixTransformation3D;
template<class Transformation> class Scene;
#endif

2
src/SceneGraph/Test/AnimableTest.cpp

@ -45,7 +45,7 @@ class AnimableTest: public TestSuite::Tester {
void debug();
};
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D;
AnimableTest::AnimableTest() {
addTests({&AnimableTest::state,

6
src/SceneGraph/Test/CameraTest.cpp

@ -48,9 +48,9 @@ class CameraTest: public TestSuite::Tester {
void draw();
};
typedef SceneGraph::Object<SceneGraph::MatrixTransformation2D<>> Object2D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<>> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation2D> Object2D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D;
CameraTest::CameraTest() {
addTests({&CameraTest::fixAspectRatio,

12
src/SceneGraph/Test/DualComplexTransformationTest.cpp

@ -30,8 +30,8 @@
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<DualComplexTransformation<>> Object2D;
typedef Scene<DualComplexTransformation<>> Scene2D;
typedef Object<DualComplexTransformation> Object2D;
typedef Scene<DualComplexTransformation> Scene2D;
class DualComplexTransformationTest: public TestSuite::Tester {
public:
@ -67,24 +67,24 @@ DualComplexTransformationTest::DualComplexTransformationTest() {
void DualComplexTransformationTest::fromMatrix() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
DualComplex c = DualComplex::rotation(Deg(17.0f))*DualComplex::translation({1.0f, -0.3f});
CORRADE_COMPARE(DualComplexTransformation<>::fromMatrix(m), c);
CORRADE_COMPARE(DualComplexTransformation::fromMatrix(m), c);
}
void DualComplexTransformationTest::toMatrix() {
DualComplex c = DualComplex::rotation(Deg(17.0f))*DualComplex::translation({1.0f, -0.3f});
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(DualComplexTransformation<>::toMatrix(c), m);
CORRADE_COMPARE(DualComplexTransformation::toMatrix(c), m);
}
void DualComplexTransformationTest::compose() {
DualComplex parent = DualComplex::rotation(Deg(17.0f));
DualComplex child = DualComplex::translation({1.0f, -0.3f});
CORRADE_COMPARE(DualComplexTransformation<>::compose(parent, child), parent*child);
CORRADE_COMPARE(DualComplexTransformation::compose(parent, child), parent*child);
}
void DualComplexTransformationTest::inverted() {
DualComplex c = DualComplex::rotation(Deg(17.0f))*DualComplex::translation({1.0f, -0.3f});
CORRADE_COMPARE(DualComplexTransformation<>::inverted(c)*c, DualComplex());
CORRADE_COMPARE(DualComplexTransformation::inverted(c)*c, DualComplex());
}
void DualComplexTransformationTest::setTransformation() {

12
src/SceneGraph/Test/DualQuaternionTransformationTest.cpp

@ -30,8 +30,8 @@
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<DualQuaternionTransformation<>> Object3D;
typedef Scene<DualQuaternionTransformation<>> Scene3D;
typedef Object<DualQuaternionTransformation> Object3D;
typedef Scene<DualQuaternionTransformation> Scene3D;
class DualQuaternionTransformationTest: public TestSuite::Tester {
public:
@ -67,24 +67,24 @@ DualQuaternionTransformationTest::DualQuaternionTransformationTest() {
void DualQuaternionTransformationTest::fromMatrix() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
DualQuaternion q = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())*DualQuaternion::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(DualQuaternionTransformation<>::fromMatrix(m), q);
CORRADE_COMPARE(DualQuaternionTransformation::fromMatrix(m), q);
}
void DualQuaternionTransformationTest::toMatrix() {
DualQuaternion q = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())*DualQuaternion::translation({1.0f, -0.3f, 2.3f});
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(DualQuaternionTransformation<>::toMatrix(q), m);
CORRADE_COMPARE(DualQuaternionTransformation::toMatrix(q), m);
}
void DualQuaternionTransformationTest::compose() {
DualQuaternion parent = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis());
DualQuaternion child = DualQuaternion::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(DualQuaternionTransformation<>::compose(parent, child), parent*child);
CORRADE_COMPARE(DualQuaternionTransformation::compose(parent, child), parent*child);
}
void DualQuaternionTransformationTest::inverted() {
DualQuaternion q = DualQuaternion::rotation(Deg(17.0f), Vector3::xAxis())*DualQuaternion::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(DualQuaternionTransformation<>::inverted(q)*q, DualQuaternion());
CORRADE_COMPARE(DualQuaternionTransformation::inverted(q)*q, DualQuaternion());
}
void DualQuaternionTransformationTest::setTransformation() {

12
src/SceneGraph/Test/MatrixTransformation2DTest.cpp

@ -29,8 +29,8 @@
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<MatrixTransformation2D<>> Object2D;
typedef Scene<MatrixTransformation2D<>> Scene2D;
typedef Object<MatrixTransformation2D> Object2D;
typedef Scene<MatrixTransformation2D> Scene2D;
class MatrixTransformation2DTest: public TestSuite::Tester {
public:
@ -67,23 +67,23 @@ MatrixTransformation2DTest::MatrixTransformation2DTest() {
void MatrixTransformation2DTest::fromMatrix() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(MatrixTransformation2D<>::fromMatrix(m), m);
CORRADE_COMPARE(MatrixTransformation2D::fromMatrix(m), m);
}
void MatrixTransformation2DTest::toMatrix() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(MatrixTransformation2D<>::toMatrix(m), m);
CORRADE_COMPARE(MatrixTransformation2D::toMatrix(m), m);
}
void MatrixTransformation2DTest::compose() {
Matrix3 parent = Matrix3::rotation(Deg(17.0f));
Matrix3 child = Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(MatrixTransformation2D<>::compose(parent, child), parent*child);
CORRADE_COMPARE(MatrixTransformation2D::compose(parent, child), parent*child);
}
void MatrixTransformation2DTest::inverted() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(MatrixTransformation2D<>::inverted(m)*m, Matrix3());
CORRADE_COMPARE(MatrixTransformation2D::inverted(m)*m, Matrix3());
}
void MatrixTransformation2DTest::setTransformation() {

12
src/SceneGraph/Test/MatrixTransformation3DTest.cpp

@ -29,8 +29,8 @@
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<MatrixTransformation3D<>> Object3D;
typedef Scene<MatrixTransformation3D<>> Scene3D;
typedef Object<MatrixTransformation3D> Object3D;
typedef Scene<MatrixTransformation3D> Scene3D;
class MatrixTransformation3DTest: public TestSuite::Tester {
public:
@ -67,23 +67,23 @@ MatrixTransformation3DTest::MatrixTransformation3DTest() {
void MatrixTransformation3DTest::fromMatrix() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f});
CORRADE_COMPARE(MatrixTransformation3D<>::fromMatrix(m), m);
CORRADE_COMPARE(MatrixTransformation3D::fromMatrix(m), m);
}
void MatrixTransformation3DTest::toMatrix() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f});
CORRADE_COMPARE(MatrixTransformation3D<>::toMatrix(m), m);
CORRADE_COMPARE(MatrixTransformation3D::toMatrix(m), m);
}
void MatrixTransformation3DTest::compose() {
Matrix4 parent = Matrix4::rotationX(Deg(17.0f));
Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(MatrixTransformation3D<>::compose(parent, child), parent*child);
CORRADE_COMPARE(MatrixTransformation3D::compose(parent, child), parent*child);
}
void MatrixTransformation3DTest::inverted() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f});
CORRADE_COMPARE(MatrixTransformation3D<>::inverted(m)*m, Matrix4());
CORRADE_COMPARE(MatrixTransformation3D::inverted(m)*m, Matrix4());
}
void MatrixTransformation3DTest::setTransformation() {

4
src/SceneGraph/Test/ObjectTest.cpp

@ -47,8 +47,8 @@ class ObjectTest: public TestSuite::Tester {
void setCleanListBulk();
};
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<>> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D;
class CachingObject: public Object3D, AbstractFeature3D {
public:

14
src/SceneGraph/Test/RigidMatrixTransformation2DTest.cpp

@ -30,8 +30,8 @@
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<RigidMatrixTransformation2D<>> Object2D;
typedef Scene<RigidMatrixTransformation2D<>> Scene2D;
typedef Object<RigidMatrixTransformation2D> Object2D;
typedef Scene<RigidMatrixTransformation2D> Scene2D;
class RigidMatrixTransformation2DTest: public TestSuite::Tester {
public:
@ -69,27 +69,27 @@ RigidMatrixTransformation2DTest::RigidMatrixTransformation2DTest() {
void RigidMatrixTransformation2DTest::fromMatrix() {
std::ostringstream o;
Error::setOutput(&o);
RigidMatrixTransformation2D<>::fromMatrix(Matrix3::scaling(Vector2(4.0f)));
RigidMatrixTransformation2D::fromMatrix(Matrix3::scaling(Vector2(4.0f)));
CORRADE_COMPARE(o.str(), "SceneGraph::RigidMatrixTransformation2D::fromMatrix(): the matrix doesn't represent rigid transformation\n");
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(RigidMatrixTransformation2D<>::fromMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation2D::fromMatrix(m), m);
}
void RigidMatrixTransformation2DTest::toMatrix() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(RigidMatrixTransformation2D<>::toMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation2D::toMatrix(m), m);
}
void RigidMatrixTransformation2DTest::compose() {
Matrix3 parent = Matrix3::rotation(Deg(17.0f));
Matrix3 child = Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(RigidMatrixTransformation2D<>::compose(parent, child), parent*child);
CORRADE_COMPARE(RigidMatrixTransformation2D::compose(parent, child), parent*child);
}
void RigidMatrixTransformation2DTest::inverted() {
Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f});
CORRADE_COMPARE(RigidMatrixTransformation2D<>::inverted(m)*m, Matrix3());
CORRADE_COMPARE(RigidMatrixTransformation2D::inverted(m)*m, Matrix3());
}
void RigidMatrixTransformation2DTest::setTransformation() {

14
src/SceneGraph/Test/RigidMatrixTransformation3DTest.cpp

@ -30,8 +30,8 @@
namespace Magnum { namespace SceneGraph { namespace Test {
typedef Object<RigidMatrixTransformation3D<>> Object3D;
typedef Scene<RigidMatrixTransformation3D<>> Scene3D;
typedef Object<RigidMatrixTransformation3D> Object3D;
typedef Scene<RigidMatrixTransformation3D> Scene3D;
class RigidMatrixTransformation3DTest: public TestSuite::Tester {
public:
@ -69,27 +69,27 @@ RigidMatrixTransformation3DTest::RigidMatrixTransformation3DTest() {
void RigidMatrixTransformation3DTest::fromMatrix() {
std::ostringstream o;
Error::setOutput(&o);
RigidMatrixTransformation3D<>::fromMatrix(Matrix4::scaling(Vector3(4.0f)));
RigidMatrixTransformation3D::fromMatrix(Matrix4::scaling(Vector3(4.0f)));
CORRADE_COMPARE(o.str(), "SceneGraph::RigidMatrixTransformation3D::fromMatrix(): the matrix doesn't represent rigid transformation\n");
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(RigidMatrixTransformation3D<>::fromMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation3D::fromMatrix(m), m);
}
void RigidMatrixTransformation3DTest::toMatrix() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(RigidMatrixTransformation3D<>::toMatrix(m), m);
CORRADE_COMPARE(RigidMatrixTransformation3D::toMatrix(m), m);
}
void RigidMatrixTransformation3DTest::compose() {
Matrix4 parent = Matrix4::rotationX(Deg(17.0f));
Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(RigidMatrixTransformation3D<>::compose(parent, child), parent*child);
CORRADE_COMPARE(RigidMatrixTransformation3D::compose(parent, child), parent*child);
}
void RigidMatrixTransformation3DTest::inverted() {
Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f});
CORRADE_COMPARE(RigidMatrixTransformation3D<>::inverted(m)*m, Matrix4());
CORRADE_COMPARE(RigidMatrixTransformation3D::inverted(m)*m, Matrix4());
}
void RigidMatrixTransformation3DTest::setTransformation() {

4
src/SceneGraph/Test/SceneTest.cpp

@ -37,8 +37,8 @@ class SceneTest: public TestSuite::Tester {
void parent();
};
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<Float>> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<Float>> Object3D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D;
SceneTest::SceneTest() {
addTests({&SceneTest::transformation,

16
src/SceneGraph/instantiation.cpp

@ -39,8 +39,8 @@ namespace Magnum { namespace SceneGraph {
#ifndef DOXYGEN_GENERATING_OUTPUT
template class AbstractBasicObject<2, Float>;
template class AbstractBasicObject<3, Float>;
template class AbstractTransformation<2, Float>;
template class AbstractTransformation<3, Float>;
template class AbstractBasicTransformation<2, Float>;
template class AbstractBasicTransformation<3, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<2, Float>;
template class MAGNUM_SCENEGRAPH_EXPORT AbstractBasicFeature<3, Float>;
@ -52,12 +52,12 @@ template class AbstractBasicCamera<3, Float>;
template class BasicCamera2D<Float>;
template class BasicCamera3D<Float>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<DualComplexTransformation<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<DualQuaternionTransformation<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<MatrixTransformation2D<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<MatrixTransformation3D<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<RigidMatrixTransformation2D<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<RigidMatrixTransformation3D<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicDualComplexTransformation<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicDualQuaternionTransformation<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicMatrixTransformation2D<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicMatrixTransformation3D<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicRigidMatrixTransformation2D<Float>>;
template class MAGNUM_SCENEGRAPH_EXPORT Object<BasicRigidMatrixTransformation3D<Float>>;
#endif
}}

8
src/Shapes/Test/ShapeTest.cpp

@ -44,10 +44,10 @@ class ShapeTest: public TestSuite::Tester {
void shapeGroup();
};
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation2D<>> Scene2D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation2D<>> Object2D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D<>> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D<>> Object3D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation2D> Scene2D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation2D> Object2D;
typedef SceneGraph::Scene<SceneGraph::MatrixTransformation3D> Scene3D;
typedef SceneGraph::Object<SceneGraph::MatrixTransformation3D> Object3D;
ShapeTest::ShapeTest() {
addTests({&ShapeTest::clean,

Loading…
Cancel
Save