From a8066a58af198107d3164abf0666385259ff3f1e Mon Sep 17 00:00:00 2001 From: Lynix Date: Fri, 3 May 2013 02:50:38 +0200 Subject: [PATCH] Added Matrix4::(Make)Transform(T, R) Former-commit-id: 556554c8cc589dfe64b3a8be903f62af894011c4 --- include/Nazara/Math/Matrix4.hpp | 2 ++ include/Nazara/Math/Matrix4.inl | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/Nazara/Math/Matrix4.hpp b/include/Nazara/Math/Matrix4.hpp index b69f0f00d..08265e983 100644 --- a/include/Nazara/Math/Matrix4.hpp +++ b/include/Nazara/Math/Matrix4.hpp @@ -61,6 +61,7 @@ class NzMatrix4 NzMatrix4& MakeRotation(const NzQuaternion& rotation); NzMatrix4& MakeScale(const NzVector3& scale); NzMatrix4& MakeTranslation(const NzVector3& translation); + NzMatrix4& MakeTransform(const NzVector3& translation, const NzQuaternion& rotation); NzMatrix4& MakeTransform(const NzVector3& translation, const NzQuaternion& rotation, const NzVector3& scale); NzMatrix4& MakeZero(); @@ -112,6 +113,7 @@ class NzMatrix4 static NzMatrix4 Rotate(const NzQuaternion& rotation); static NzMatrix4 Scale(const NzVector3& scale); static NzMatrix4 Translate(const NzVector3& translation); + static NzMatrix4 Transform(const NzVector3& translation, const NzQuaternion& rotation); static NzMatrix4 Transform(const NzVector3& translation, const NzQuaternion& rotation, const NzVector3& scale); static NzMatrix4 Zero(); diff --git a/include/Nazara/Math/Matrix4.inl b/include/Nazara/Math/Matrix4.inl index 6d3e26639..a1852ec73 100644 --- a/include/Nazara/Math/Matrix4.inl +++ b/include/Nazara/Math/Matrix4.inl @@ -561,7 +561,7 @@ NzMatrix4& NzMatrix4::MakeTranslation(const NzVector3& translation) } template -NzMatrix4& NzMatrix4::MakeTransform(const NzVector3& translation, const NzQuaternion& rotation, const NzVector3& scale) +NzMatrix4& NzMatrix4::MakeTransform(const NzVector3& translation, const NzQuaternion& rotation) { // La rotation et la translation peuvent être appliquées directement SetRotation(rotation); @@ -573,6 +573,14 @@ NzMatrix4& NzMatrix4::MakeTransform(const NzVector3& translation, const m34 = F(0.0); m44 = F(1.0); + return *this; +} + +template +NzMatrix4& NzMatrix4::MakeTransform(const NzVector3& translation, const NzQuaternion& rotation, const NzVector3& scale) +{ + MakeTransform(translation, rotation); + // Ensuite on fait une mise à l'échelle des valeurs déjà présentes ApplyScale(scale); @@ -919,6 +927,15 @@ NzMatrix4 NzMatrix4::Translate(const NzVector3& translation) return mat; } +template +NzMatrix4 NzMatrix4::Transform(const NzVector3& translation, const NzQuaternion& rotation) +{ + NzMatrix4 mat; + mat.MakeTransform(translation, rotation); + + return mat; +} + template NzMatrix4 NzMatrix4::Transform(const NzVector3& translation, const NzQuaternion& rotation, const NzVector3& scale) {