diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index a106af4ef..c0356d886 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -79,6 +79,7 @@ namespace Nz Matrix4& MakeTransform(const Vector3& translation, const Quaternion& rotation); Matrix4& MakeTransform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale); Matrix4& MakeTransformInverse(const Vector3& translation, const Quaternion& rotation); + Matrix4& MakeTransformInverse(const Vector3& translation, const Quaternion& rotation, const Vector3& scale); Matrix4& MakeZero(); Matrix4& Set(T r11, T r12, T r13, T r14, @@ -130,7 +131,8 @@ namespace Nz static Matrix4 Translate(const Vector3& translation); static Matrix4 Transform(const Vector3& translation, const Quaternion& rotation); static Matrix4 Transform(const Vector3& translation, const Quaternion& rotation, const Vector3& scale); - static Matrix4 TransformInverse(const Vector3&translation, const Quaternion&rotation); + static Matrix4 TransformInverse(const Vector3& translation, const Quaternion& rotation); + static Matrix4 TransformInverse(const Vector3& translation, const Quaternion& rotation, const Vector3&scale); static Matrix4 Zero(); T m11, m12, m13, m14, diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 22337b099..ccc70a6e2 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -1031,6 +1031,25 @@ namespace Nz return MakeTransform(-(invRot * translation), invRot); } + /*! + * \brief Makes the matrix an inverse transform matrix (aka view matrix) + * \return A reference to this matrix + * + * \param translation Vector3 representing the translation + * \param rotation Quaternion representing a rotation of space + * \param scale Vector3 representing the scale + * + * \see InverseTransformMatrix + */ + template + Matrix4& Matrix4::MakeTransformInverse(const Vector3& translation, const Quaternion& rotation, const Vector3& scale) + { + MakeTransformInverse(translation, rotation); + ConcatenateTransform(Scale(T(1.0) / scale)); + + return *this; + } + /*! * \brief Makes the matrix zero (with 0 everywhere) * \return A reference to this matrix with components (0 everywhere) @@ -1677,6 +1696,25 @@ namespace Nz return mat; } + /*! + * \brief Shorthand for the 'view' matrix + * \return A Matrix4 which is the 'view matrix' + * + * \param translation Vector3 representing the translation + * \param rotation Quaternion representing a rotation of space + * \param scale Vector3 representing the scale + * + * \see MakeInverseTransformMatrix + */ + template + Matrix4 Matrix4::TransformInverse(const Vector3& translation, const Quaternion& rotation, const Vector3& scale) + { + Matrix4 mat; + mat.MakeTransformInverse(translation, rotation, scale); + + return mat; + } + /*! * \brief Shorthand for the 'zero' matrix * \return A Matrix4 with components (0 everywhere)