This commit is contained in:
hyunbin14
2025-12-28 10:39:09 +09:00
parent 6b83edfcd9
commit 5dac73abf2
6 changed files with 84 additions and 8 deletions
@@ -42,9 +42,9 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
int PlayHeadBone;
int HeadBoneIndex;
float HeadAimWeight;
float paddding1;
float3 TargetDir_Local;
float padding;
@@ -332,8 +332,45 @@ row_major float4x4 SampleBlendedLocal(uint bone)
T = 0;
R = RootInitRot;
}
float4x4 M = MakeAffine(S, R, T);
if (PlayHeadBone == 1)
{
if (bone == HeadBoneIndex && HeadAimWeight > 0.f)
{
float3 curFwd = normalize(float3(M._31, M._32, M._33));
float3 target = normalize(TargetDir_Local);
return MakeAffine(S, R, T);
float3 axis = cross(curFwd, target);
float axisLen = length(axis);
if (axisLen > EPS)
{
axis /= axisLen;
float angle = acos(saturate(dot(curFwd, target)));
angle *= HeadAimWeight;
float4 qAim = float4(axis * sin(angle * 0.5f), cos(angle * 0.5f));
qAim = QuatNormalize(qAim);
row_major float4x4 AimM =
MakeAffine(float3(1, 1, 1), qAim, float3(0, 0, 0));
M = mul(AimM, M);
}
}
}
return M;
//return MakeAffine(S, R, T);
}
[numthreads(256, 1, 1)]
@@ -24,9 +24,10 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
int PlayHeadBone;
int HeadBoneIndex;
float HeadAimWeight;
float paddding1;
float3 TargetDir_Local;
float padding;
@@ -42,9 +42,9 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
int PlayHeadBone;
int HeadBoneIndex;
float HeadAimWeight;
float paddding1;
float3 TargetDir_Local;
float padding;
@@ -333,9 +333,44 @@ row_major float4x4 SampleBlendedLocal(uint bone)
R = RootInitRot;
}
float4x4 M = MakeAffine(S, R, T);
if (PlayHeadBone == 1)
{
if (bone == HeadBoneIndex && HeadAimWeight > 0.f)
{
float3 curFwd = normalize(float3(M._31, M._32, M._33));
float3 target = normalize(TargetDir_Local);
float3 axis = cross(curFwd, target);
float axisLen = length(axis);
if (axisLen > EPS)
{
axis /= axisLen;
float angle = acos(saturate(dot(curFwd, target)));
angle *= HeadAimWeight;
float4 qAim = float4(axis * sin(angle * 0.5f), cos(angle * 0.5f));
qAim = QuatNormalize(qAim);
row_major float4x4 AimM =
MakeAffine(float3(1, 1, 1), qAim, float3(0, 0, 0));
M = mul(AimM, M);
}
}
}
return M;
return MakeAffine(S, R, T);
//return MakeAffine(S, R, T);
}
[numthreads(256, 1, 1)]
@@ -24,9 +24,10 @@ cbuffer AnimCB : register(b0)
float BlendRatio;
int RootBoneIndex;
int PlayHeadBone;
int HeadBoneIndex;
float HeadAimWeight;
float paddding1;
float3 TargetDir_Local;
float padding;
+1 -1
View File
@@ -1708,9 +1708,9 @@ void CModel::ComputeLocal(_uint AnimIndex, _uint MeshIndex)
pDesc->PrevTime = m_Animations[m_iPreAnimIndex]->Get_CurrentTrackPosition();
pDesc->BlendRatio = m_fRatio;
pDesc->RootBoneIndex = m_iRootBoneIndex;
pDesc->PlayHeadBone = m_bHeadBone;
pDesc->HeadBoneIndex = m_iBoneIndex[ENUM_CLASS(BLEND_BONE::HEAD)];
pDesc->HeadAimWeight = 1.f;
pDesc->paddding1 = 0.f;
if (m_iBoneIndex[ENUM_CLASS(BLEND_BONE::HEAD)] != -1)
{
_vector dirWS = XMVector3Normalize(m_vTargetPos - m_pTransform->Get_State(STATE::POSITION));
+3 -1
View File
@@ -20,9 +20,9 @@ class ENGINE_DLL CModel final : public CComponent
_float BlendRatio;
_int RootBoneIndex;
_int PlayHeadBone;
_int HeadBoneIndex;
_float HeadAimWeight;
_float paddding1;
_float3 TargetDir_Local;
_float padding;
@@ -50,6 +50,7 @@ class ENGINE_DLL CModel final : public CComponent
void Set_Temp(_bool Temp) { m_bTemp = Temp; }
void Set_TargetPos(_vector vTargetPos) { m_vTargetPos = vTargetPos; }
void Set_HeadPos(_vector vHeadPos) { m_vHeadPos = vHeadPos; }
void Play_HeadBone(_bool bPlay) { m_bHeadBone = bPlay; }
#pragma endregion
#pragma region Animation
_bool Play_Animation(_float fTimeDelta, class CTransform* pTransform = nullptr); // 애니메이션에 델타타임을 넣어줌
@@ -204,6 +205,7 @@ class ENGINE_DLL CModel final : public CComponent
_bool m_bTemp = {false};
_vector m_vTargetPos = XMVectorZero();
_vector m_vHeadPos = XMVectorZero();
_bool m_bHeadBone = { false };
private: