Files

65 lines
1.4 KiB
C++
Raw Permalink Normal View History

2025-05-13 02:46:21 +03:00
#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__