[Add] 상태 추가

[Add] 루트본 회전 추가
This commit is contained in:
hyunbin14
2025-11-18 22:02:45 +09:00
parent 6b5a37d74c
commit 4c681017ab
41 changed files with 826 additions and 83 deletions
+1 -1
View File
@@ -169,7 +169,7 @@ void CAnimation::InterpAnim(CAnimation* pPreAnim, vector<CBone*>& Bones, float f
if (BoneName == "Reference")
{
FinalPos = XMVectorZero();
//FinalPos = XMVectorZero();
}
_matrix FinalMat = XMMatrixAffineTransformation(FinalScale, XMVectorZero(), FinalRot, FinalPos);
+40 -2
View File
@@ -164,7 +164,7 @@ void CChannel::Update_TransformationMatirx(const vector<CBone*>& Bones, _float f
_float dy = XMVectorGetY(vDeltaAdjusted);
_float dz = XMVectorGetZ(vDeltaAdjusted);
_vector vDeltaWorld = vRight * dx + (-vUp * dz) + vLook * dy;
_vector vDeltaWorld = vRight * dx + (-vUp * dz) + vLook * dy;
vDeltaWorld *= 0.01f;
@@ -175,6 +175,45 @@ void CChannel::Update_TransformationMatirx(const vector<CBone*>& Bones, _float f
m_vPrevRootPos = vCurRootPos;
vTranslation = XMVectorZero();
/////////////////////////////////////
_float4 curRotF4;
XMStoreFloat4(&curRotF4, vRotation);
_vector qCur = XMLoadFloat4(&curRotF4);
if (!m_bInitialRootRotSaved)
{
m_vInitialRootRot = curRotF4;
m_vPrevRootRot = curRotF4;
m_bInitialRootRotSaved = true;
}
else
{
_vector qPrev = XMLoadFloat4(&m_vPrevRootRot);
_vector qInvPrev = XMQuaternionInverse(qPrev);
_vector qDelta = XMQuaternionMultiply(qInvPrev, qCur);
_vector axisLocal;
_float angle = 0.f;
XMQuaternionToAxisAngle(&axisLocal, &angle, qDelta);
_vector axisWorld = XMVector3TransformNormal(axisLocal, pre);
axisWorld = XMVector3Normalize(axisWorld);
_float4 axis;
XMStoreFloat4(&axis, axisWorld);
swap(axis.z, axis.y);
if (angle > 0 )
pTransform->TurnAngle(XMLoadFloat4(&axis), -angle);
}
XMStoreFloat4(&m_vPrevRootRot, qCur);
vRotation = XMLoadFloat4(&m_vInitialRootRot);
}
m_BoneTransformationMatrix = XMMatrixAffineTransformation(vScale, XMVectorSet(0.f, 0.f, 0.f, 1.f), vRotation, vTranslation);
@@ -182,7 +221,6 @@ void CChannel::Update_TransformationMatirx(const vector<CBone*>& Bones, _float f
Bones[m_iBoneIndex]->Set_TransformationMatrix(m_BoneTransformationMatrix);
}
KEYFRAME* CChannel::Get_Frame(_uint iIndex)
{
return &m_KeyFrames[iIndex];
+3 -1
View File
@@ -69,7 +69,9 @@ _uint CFSM::Get_CurrState()
_uint CFSM::Get_PrevState()
{
return m_pPrevious->Get_State();
if (m_pPrevious)
return m_pPrevious->Get_State();
return 0;
}
void CFSM::Set_Parent(FSMSTATE::ESTATE Child, FSMSTATE::ESTATE Parent)
@@ -225,6 +225,32 @@ void CTransform::Turn(_fvector vAxis, _float fTimeDelta)
Set_State(STATE::LOOK, vLook);
}
void CTransform::TurnAngle(_vector vAxis, _float fAngle)
{
_vector vRight = Get_State(STATE::RIGHT);
_vector vUp = Get_State(STATE::UP);
_vector vLook = Get_State(STATE::LOOK);
if (vAxis.m128_f32[0] == 0)
return;
if (vAxis.m128_f32[1] == 0)
return;
if (vAxis.m128_f32[2] == 0)
return;
vAxis = XMVector3Normalize(vAxis);
_matrix TurnMatrix = XMMatrixRotationAxis(vAxis, fAngle);
vRight = XMVector3TransformNormal(vRight, TurnMatrix);
vUp = XMVector3TransformNormal(vUp, TurnMatrix);
vLook = XMVector3TransformNormal(vLook, TurnMatrix);
Set_State(STATE::RIGHT, vRight);
Set_State(STATE::UP, vUp);
Set_State(STATE::LOOK, vLook);
}
void CTransform::Rotation(_fvector vAxis, _float fRadian)
{
_float3 vScale = Get_Scale();
+1 -1
View File
@@ -23,7 +23,7 @@ HRESULT CUnit::Initialize(void* pArg)
if (FAILED(__super::Initialize(pArg)))
return E_FAIL;
m_Animation.resize(FSMSTATE::END);
m_Animation.resize(STATEANIM::END);
return S_OK;
}
+9 -2
View File
@@ -22,7 +22,11 @@ class ENGINE_DLL CChannel : public CBase
void Update_TransformationMatirx(const vector<class CBone*>& Bones, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex,class CTransform* pTransform=nullptr);
_int Get_BoneIndex() { return { m_iBoneIndex }; }
void Set_BoneIndex(_int iBoneIndex) { m_iBoneIndex = iBoneIndex; }
void ResetRootMotion() { m_vPrevRootPos = { 0.f, 0.f, 0.f }; }
void ResetRootMotion() {
m_vPrevRootPos = { 0.f, 0.f, 0.f };
m_vPrevRootRot = { 0.f,0.f,0.f,0.f };
m_bInitialRootRotSaved = false;
}
_matrix Get_BoneTransformationMatrix() { return m_BoneTransformationMatrix; }
KEYFRAME* Get_Frame(_uint iIndex);
@@ -38,7 +42,6 @@ class ENGINE_DLL CChannel : public CBase
//
HRESULT Initialize(const vector<class CBone*>& Bones, _uint iIndex);
private:
_char m_szName[MAX_PATH] = {}; // 영향을 받을 본의 이름
_int m_iBoneIndex = { -1 }; // 본 벡터에서 본의 인덱스
@@ -46,7 +49,11 @@ class ENGINE_DLL CChannel : public CBase
_float4x4 m_PreTransformMatrix = {};
vector<KEYFRAME> m_KeyFrames; // 키프레임 벡터
_float3 m_vPrevRootPos = { 0.f, 0.f, 0.f };
_float4 m_vPrevRootRot = { 0.f, 0.f, 0.f,0.f };
_matrix m_BoneTransformationMatrix = {};
_float m_fPrevYaw = 0.f;
_bool m_bInitialRootRotSaved = {false};
_float4 m_vInitialRootRot = {};
public:
static CChannel* Create(const vector<class CBone*>& Bones, _uint iIndex); // 럴프전용
static CChannel* Create(HANDLE hFile, DWORD& dwByte);
+2 -3
View File
@@ -3,17 +3,16 @@
NS_BEGIN(FSMSTATE)
enum ESTATE
{
IDLE,
IDLE,IDLE_TURN,
MOVE, WALK, WALK_FWD, WALK_BWD, JOG, SPRINT,
JUMP,
LAND,
DODGE,
COMBAT, LIGHT_ATTACK, CAST, SKILL,
COMBAT, LIGHT_ATTACK, CAST, SKILL,SKILL2,
END
};
NS_END
NS_BEGIN(Engine)
class CState;
+16
View File
@@ -1,6 +1,22 @@
#pragma once
#include "Base.h"
NS_BEGIN(STATEANIM)
enum ESTATE
{
IDLE, IDLE_TURN_L, IDLE_TURN_R, IDLE_TURN_BWD,
MOVE,
WALK, WALK_FWD, WALK_BWD, WALK_STOP,
JOG,
SPRINT,
JUMP,JUMP_WALK,JUMP_SPRINT,
LAND,
DODGE,
COMBAT, LIGHT_ATTACK, CAST, SKILL, SKILL2,
END
};
NS_END
NS_BEGIN(Engine)
class CUnit;
class CModel;
@@ -57,6 +57,7 @@ class ENGINE_DLL CTransform final :
void BookMomentum(_fvector vMomentum);
void Turn(_fvector vAxis, _float fTimeDelta);
void TurnAngle(_vector vAxis, _float fAngle);
void Rotation(_fvector vAxis, _float fRadian);
void Rotation(_float fRadianX, _float fRadianY, _float fRadianZ);
void Rotation(_float3& vRadian);
+1
View File
@@ -39,6 +39,7 @@ class ENGINE_DLL CUnit abstract : public CGameObject
void Set_LightCombo(_uint LightCombo) { m_iLightCombo = LightCombo; }
_float Get_KeyFrame(_string FrameName);
_bool IsCurrentKeyFrame(_string FrameName);
virtual void Reset_Sprint() {};
#pragma endregion
protected: