Browse Source

SceneGraph rework, part 4: faster rotation for X, Y and Z axes.

By default implemented using rotate() so transformation implementers
don't need to bother, but MatrixTransformation3D reimplements it using
optimized rotation functions.
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
abac1d26dc
  1. 43
      src/SceneGraph/AbstractTranslationRotation3D.h
  2. 42
      src/SceneGraph/MatrixTransformation3D.h

43
src/SceneGraph/AbstractTranslationRotation3D.h

@ -20,6 +20,7 @@
*/
#include "AbstractTransformation.h"
#include "Math/Vector3.h"
namespace Magnum { namespace SceneGraph {
@ -50,6 +51,48 @@ template<class T = GLfloat> class AbstractTranslationRotation3D: public Abstract
* @see deg(), rad(), Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis()
*/
virtual AbstractTranslationRotation3D<T>* rotate(T angle, const Math::Vector3<T>& normalizedAxis, TransformationType type = TransformationType::Global) = 0;
/**
* @brief Rotate object around X axis
* @param angle Angle in radians, counterclockwise
* @param type Transformation type
* @return Pointer to self (for method chaining)
*
* In some implementations faster than calling
* `rotate(angle, Vector3::xAxis())`.
* @see deg(), rad()
*/
virtual AbstractTranslationRotation3D<T>* rotateX(T angle, TransformationType type = TransformationType::Global) {
return rotate(angle, Math::Vector3<T>::xAxis(), type);
}
/**
* @brief Rotate object around Y axis
* @param angle Angle in radians, counterclockwise
* @param type Transformation type
* @return Pointer to self (for method chaining)
*
* In some implementations faster than calling
* `rotate(angle, Vector3::yAxis())`.
* @see deg(), rad()
*/
virtual AbstractTranslationRotation3D<T>* rotateY(T angle, TransformationType type = TransformationType::Global) {
return rotate(angle, Math::Vector3<T>::yAxis(), type);
}
/**
* @brief Rotate object around Z axis
* @param angle Angle in radians, counterclockwise
* @param type Transformation type
* @return Pointer to self (for method chaining)
*
* In some implementations faster than calling
* `rotate(angle, Vector3::zAxis())`.
* @see deg(), rad()
*/
virtual AbstractTranslationRotation3D<T>* rotateZ(T angle, TransformationType type = TransformationType::Global) {
return rotate(angle, Math::Vector3<T>::zAxis(), type);
}
};
}}

42
src/SceneGraph/MatrixTransformation3D.h

@ -103,6 +103,48 @@ template<class T = GLfloat> class MatrixTransformation3D: public AbstractTransla
return this;
}
/**
* @brief Rotate object around X axis
* @param angle Angle in radians, counterclockwise
* @param type Transformation type
* @return Pointer to self (for method chaining)
*
* Same as calling multiplyTransformation() with Matrix4::rotationX().
* @see deg(), rad()
*/
inline MatrixTransformation3D<T>* rotateX(T angle, TransformationType type = TransformationType::Global) override {
multiplyTransformation(Math::Matrix4<T>::rotationX(angle), type);
return this;
}
/**
* @brief Rotate object around Y axis
* @param angle Angle in radians, counterclockwise
* @param type Transformation type
* @return Pointer to self (for method chaining)
*
* Same as calling multiplyTransformation() with Matrix4::rotationY().
* @see deg(), rad()
*/
inline MatrixTransformation3D<T>* rotateY(T angle, TransformationType type = TransformationType::Global) override {
multiplyTransformation(Math::Matrix4<T>::rotationY(angle), type);
return this;
}
/**
* @brief Rotate object around Z axis
* @param angle Angle in radians, counterclockwise
* @param type Transformation type
* @return Pointer to self (for method chaining)
*
* Same as calling multiplyTransformation() with Matrix4::rotationZ().
* @see deg(), rad()
*/
inline MatrixTransformation3D<T>* rotateZ(T angle, TransformationType type = TransformationType::Global) override {
multiplyTransformation(Math::Matrix4<T>::rotationZ(angle), type);
return this;
}
/**
* @copydoc AbstractTranslationRotationScaling3D::scale()
* Same as calling multiplyTransformation() with Matrix4::scaling().

Loading…
Cancel
Save