|
|
|
|
@ -17,6 +17,7 @@
|
|
|
|
|
#include <AzCore/Math/PackedVector3.h>
|
|
|
|
|
#include <MCore/Source/Algorithms.h>
|
|
|
|
|
#include <MCore/Source/Color.h>
|
|
|
|
|
#include <MCore/Source/Vector.h>
|
|
|
|
|
#include <MCore/Source/Quaternion.h>
|
|
|
|
|
#include <EMotionFX/Source/Transform.h>
|
|
|
|
|
|
|
|
|
|
@ -37,18 +38,6 @@ namespace MCore
|
|
|
|
|
return RGBAColor(static_cast<float>(azColor.GetR()), static_cast<float>(azColor.GetG()), static_cast<float>(azColor.GetB()), static_cast<float>(azColor.GetA()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Deprecated
|
|
|
|
|
AZ_FORCE_INLINE AZ::Quaternion EmfxQuatToAzQuat(const MCore::Quaternion& emfxQuat)
|
|
|
|
|
{
|
|
|
|
|
return AZ::Quaternion(emfxQuat.x, emfxQuat.y, emfxQuat.z, emfxQuat.w);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Deprecated
|
|
|
|
|
AZ_FORCE_INLINE MCore::Quaternion AzQuatToEmfxQuat(const AZ::Quaternion& azQuat)
|
|
|
|
|
{
|
|
|
|
|
return MCore::Quaternion(azQuat.GetX(), azQuat.GetY(), azQuat.GetZ(), azQuat.GetW());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AZ_FORCE_INLINE AZ::Transform EmfxTransformToAzTransform(const EMotionFX::Transform& emfxTransform)
|
|
|
|
|
{
|
|
|
|
|
AZ::Transform transform = AZ::Transform::CreateFromQuaternionAndTranslation(emfxTransform.mRotation, emfxTransform.mPosition);
|
|
|
|
|
@ -530,91 +519,4 @@ namespace MCore
|
|
|
|
|
AZ::Vector3ToVector4(m33.GetRow(2), translation.GetZ()),
|
|
|
|
|
mat.GetRow(3));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Deprecated. Please use AZ::Transform instead of MCore::Matrix.
|
|
|
|
|
MCORE_INLINE AZ::Quaternion MCoreMatrixToQuaternion(const MCore::Matrix& m)
|
|
|
|
|
{
|
|
|
|
|
const float trace = MMAT(m, 0, 0) + MMAT(m, 1, 1) + MMAT(m, 2, 2);
|
|
|
|
|
if (trace > 0.0f /*Math::epsilon*/)
|
|
|
|
|
{
|
|
|
|
|
const float s = 0.5f / Math::Sqrt(trace + 1.0f);
|
|
|
|
|
return AZ::Quaternion((MMAT(m, 1, 2) - MMAT(m, 2, 1)) * s,
|
|
|
|
|
(MMAT(m, 2, 0) - MMAT(m, 0, 2)) * s,
|
|
|
|
|
(MMAT(m, 0, 1) - MMAT(m, 1, 0)) * s,
|
|
|
|
|
0.25f / s);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (MMAT(m, 0, 0) > MMAT(m, 1, 1) && MMAT(m, 0, 0) > MMAT(m, 2, 2))
|
|
|
|
|
{
|
|
|
|
|
const float s = 2.0f * Math::Sqrt(1.0f + MMAT(m, 0, 0) - MMAT(m, 1, 1) - MMAT(m, 2, 2));
|
|
|
|
|
const float oneOverS = 1.0f / s;
|
|
|
|
|
return AZ::Quaternion(0.25f * s,
|
|
|
|
|
(MMAT(m, 1, 0) + MMAT(m, 0, 1)) * oneOverS,
|
|
|
|
|
(MMAT(m, 2, 0) + MMAT(m, 0, 2)) * oneOverS,
|
|
|
|
|
(MMAT(m, 1, 2) - MMAT(m, 2, 1)) * oneOverS);
|
|
|
|
|
}
|
|
|
|
|
else if (MMAT(m, 1, 1) > MMAT(m, 2, 2))
|
|
|
|
|
{
|
|
|
|
|
const float s = 2.0f * Math::Sqrt(1.0f + MMAT(m, 1, 1) - MMAT(m, 0, 0) - MMAT(m, 2, 2));
|
|
|
|
|
const float oneOverS = 1.0f / s;
|
|
|
|
|
return AZ::Quaternion((MMAT(m, 1, 0) + MMAT(m, 0, 1)) * oneOverS,
|
|
|
|
|
0.25f * s,
|
|
|
|
|
(MMAT(m, 2, 1) + MMAT(m, 1, 2)) * oneOverS,
|
|
|
|
|
(MMAT(m, 2, 0) - MMAT(m, 0, 2)) * oneOverS);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const float s = 2.0f * Math::Sqrt(1.0f + MMAT(m, 2, 2) - MMAT(m, 0, 0) - MMAT(m, 1, 1));
|
|
|
|
|
const float oneOverS = 1.0f / s;
|
|
|
|
|
return AZ::Quaternion((MMAT(m, 2, 0) + MMAT(m, 0, 2)) * oneOverS,
|
|
|
|
|
(MMAT(m, 2, 1) + MMAT(m, 1, 2)) * oneOverS,
|
|
|
|
|
0.25f * s,
|
|
|
|
|
(MMAT(m, 0, 1) - MMAT(m, 1, 0)) * oneOverS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
const float trace = MMAT(m,0,0) + MMAT(m,1,1) + MMAT(m,2,2) + 1.0f;
|
|
|
|
|
if (trace > Math::epsilon)
|
|
|
|
|
{
|
|
|
|
|
const float s = 0.5f / Math::Sqrt(trace);
|
|
|
|
|
result.w = 0.25f / s;
|
|
|
|
|
result.x = ( MMAT(m,1,2) - MMAT(m,2,1) ) * s;
|
|
|
|
|
result.y = ( MMAT(m,2,0) - MMAT(m,0,2) ) * s;
|
|
|
|
|
result.z = ( MMAT(m,0,1) - MMAT(m,1,0) ) * s;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (MMAT(m,0,0) > MMAT(m,1,1) && MMAT(m,0,0) > MMAT(m,2,2))
|
|
|
|
|
{
|
|
|
|
|
const float s = 2.0f * Math::Sqrt( 1.0f + MMAT(m,0,0) - MMAT(m,1,1) - MMAT(m,2,2));
|
|
|
|
|
const float oneOverS = 1.0f / s;
|
|
|
|
|
result.x = 0.25f * s;
|
|
|
|
|
result.y = (MMAT(m,1,0) + MMAT(m,0,1) ) * oneOverS;
|
|
|
|
|
result.z = (MMAT(m,2,0) + MMAT(m,0,2) ) * oneOverS;
|
|
|
|
|
result.w = (MMAT(m,2,1) - MMAT(m,1,2) ) * oneOverS;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
if (MMAT(m,1,1) > MMAT(m,2,2))
|
|
|
|
|
{
|
|
|
|
|
const float s = 2.0f * Math::Sqrt( 1.0f + MMAT(m,1,1) - MMAT(m,0,0) - MMAT(m,2,2));
|
|
|
|
|
const float oneOverS = 1.0f / s;
|
|
|
|
|
result.x = (MMAT(m,1,0) + MMAT(m,0,1) ) * oneOverS;
|
|
|
|
|
result.y = 0.25f * s;
|
|
|
|
|
result.z = (MMAT(m,2,1) + MMAT(m,1,2) ) * oneOverS;
|
|
|
|
|
result.w = (MMAT(m,2,0) - MMAT(m,0,2) ) * oneOverS;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
const float s = 2.0f * Math::Sqrt( 1.0f + MMAT(m,2,2) - MMAT(m,0,0) - MMAT(m,1,1) );
|
|
|
|
|
const float oneOverS = 1.0f / s;
|
|
|
|
|
result.x = (MMAT(m,2,0) + MMAT(m,0,2) ) * oneOverS;
|
|
|
|
|
result.y = (MMAT(m,2,1) + MMAT(m,1,2) ) * oneOverS;
|
|
|
|
|
result.z = 0.25f * s;
|
|
|
|
|
result.w = (MMAT(m,1,0) - MMAT(m,0,1) ) * oneOverS;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
} // namespace MCore
|
|
|
|
|
|