*
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#ifndef BoneTransform_h__
|
||||
#define BoneTransform_h__
|
||||
#include "math/LifeMath.h"
|
||||
|
||||
namespace LifeGraphics
|
||||
{
|
||||
struct BoneTransform
|
||||
{
|
||||
public:
|
||||
int boneId;
|
||||
LifeMath::float3 Translation;
|
||||
LifeMath::Quaternion Rotation;
|
||||
|
||||
BoneTransform()
|
||||
:boneId(0)
|
||||
{
|
||||
}
|
||||
|
||||
BoneTransform operator =(const BoneTransform& right)
|
||||
{
|
||||
boneId = right.boneId;
|
||||
Translation = right.Translation;
|
||||
Rotation = right.Rotation;
|
||||
return *this;
|
||||
}
|
||||
|
||||
BoneTransform operator *(const BoneTransform& right)
|
||||
{
|
||||
BoneTransform bt;
|
||||
bt.Translation = Translation + right.Translation;
|
||||
bt.Rotation = Rotation * right.Rotation;
|
||||
return bt;
|
||||
}
|
||||
|
||||
LifeMath::float4x4 GetMatrix()
|
||||
{
|
||||
LifeMath::float4x4 rot;
|
||||
LifeMath::float4x4 trans;
|
||||
LifeMath::Mat4x4RotationQuaternion(Rotation, rot);
|
||||
LifeMath::Mat4x4Translation(Translation, trans);
|
||||
return rot*trans;
|
||||
}
|
||||
|
||||
LifeMath::float4x4 GetMatrixInvert()
|
||||
{
|
||||
LifeMath::float4x4 rot;
|
||||
LifeMath::float4x4 trans;
|
||||
LifeMath::Mat4x4RotationQuaternion(Rotation, rot);
|
||||
LifeMath::Mat4x4Translation(Translation, trans);
|
||||
LifeMath::float4x4 transform = rot * trans;
|
||||
transform = LifeMath::Mat4x4Invert(&transform);
|
||||
return transform;
|
||||
}
|
||||
|
||||
BoneTransform GetInverted()
|
||||
{
|
||||
BoneTransform tr;
|
||||
tr.Translation = -this->Translation;
|
||||
tr.Rotation = this->Rotation;
|
||||
QuatInvert(tr.Rotation);
|
||||
return tr;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // BoneTransform_h__
|
||||
Reference in New Issue
Block a user