Added Matrix4::(Make)Transform(T, R)

Former-commit-id: 556554c8cc589dfe64b3a8be903f62af894011c4
This commit is contained in:
Lynix 2013-05-03 02:50:38 +02:00
parent f694c3be40
commit a8066a58af
2 changed files with 20 additions and 1 deletions

View File

@ -61,6 +61,7 @@ class NzMatrix4
NzMatrix4& MakeRotation(const NzQuaternion<T>& rotation); NzMatrix4& MakeRotation(const NzQuaternion<T>& rotation);
NzMatrix4& MakeScale(const NzVector3<T>& scale); NzMatrix4& MakeScale(const NzVector3<T>& scale);
NzMatrix4& MakeTranslation(const NzVector3<T>& translation); NzMatrix4& MakeTranslation(const NzVector3<T>& translation);
NzMatrix4& MakeTransform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation);
NzMatrix4& MakeTransform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale); NzMatrix4& MakeTransform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale);
NzMatrix4& MakeZero(); NzMatrix4& MakeZero();
@ -112,6 +113,7 @@ class NzMatrix4
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation); static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
static NzMatrix4 Scale(const NzVector3<T>& scale); static NzMatrix4 Scale(const NzVector3<T>& scale);
static NzMatrix4 Translate(const NzVector3<T>& translation); static NzMatrix4 Translate(const NzVector3<T>& translation);
static NzMatrix4 Transform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation);
static NzMatrix4 Transform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale); static NzMatrix4 Transform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale);
static NzMatrix4 Zero(); static NzMatrix4 Zero();

View File

@ -561,7 +561,7 @@ NzMatrix4<T>& NzMatrix4<T>::MakeTranslation(const NzVector3<T>& translation)
} }
template<typename T> template<typename T>
NzMatrix4<T>& NzMatrix4<T>::MakeTransform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale) NzMatrix4<T>& NzMatrix4<T>::MakeTransform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation)
{ {
// La rotation et la translation peuvent être appliquées directement // La rotation et la translation peuvent être appliquées directement
SetRotation(rotation); SetRotation(rotation);
@ -573,6 +573,14 @@ NzMatrix4<T>& NzMatrix4<T>::MakeTransform(const NzVector3<T>& translation, const
m34 = F(0.0); m34 = F(0.0);
m44 = F(1.0); m44 = F(1.0);
return *this;
}
template<typename T>
NzMatrix4<T>& NzMatrix4<T>::MakeTransform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale)
{
MakeTransform(translation, rotation);
// Ensuite on fait une mise à l'échelle des valeurs déjà présentes // Ensuite on fait une mise à l'échelle des valeurs déjà présentes
ApplyScale(scale); ApplyScale(scale);
@ -919,6 +927,15 @@ NzMatrix4<T> NzMatrix4<T>::Translate(const NzVector3<T>& translation)
return mat; return mat;
} }
template<typename T>
NzMatrix4<T> NzMatrix4<T>::Transform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation)
{
NzMatrix4 mat;
mat.MakeTransform(translation, rotation);
return mat;
}
template<typename T> template<typename T>
NzMatrix4<T> NzMatrix4<T>::Transform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale) NzMatrix4<T> NzMatrix4<T>::Transform(const NzVector3<T>& translation, const NzQuaternion<T>& rotation, const NzVector3<T>& scale)
{ {