[merge commit]
This commit is contained in:
@@ -38,9 +38,19 @@ void CBroom::Priority_Update(_float fTimeDelta)
|
|||||||
|
|
||||||
void CBroom::Update(_float fTimeDelta)
|
void CBroom::Update(_float fTimeDelta)
|
||||||
{
|
{
|
||||||
m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom);
|
m_pModelCom->ComputeAnimation();
|
||||||
|
|
||||||
//m_pModelCom->ComputeSkinning();
|
static _uint m_iIndex = 0;
|
||||||
|
|
||||||
|
if (m_pGameInstance->Key_Down(DIK_1))
|
||||||
|
m_iIndex++;
|
||||||
|
if (m_pGameInstance->Key_Down(DIK_2))
|
||||||
|
m_iIndex--;
|
||||||
|
|
||||||
|
m_pModelCom->Set_AnimationIndex(m_iIndex);
|
||||||
|
|
||||||
|
|
||||||
|
m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBroom::Late_Update(_float fTimeDelta)
|
void CBroom::Late_Update(_float fTimeDelta)
|
||||||
@@ -61,6 +71,9 @@ HRESULT CBroom::Render()
|
|||||||
|
|
||||||
for (_uint i = 0; i < iNumMeshes; i++)
|
for (_uint i = 0; i < iNumMeshes; i++)
|
||||||
{
|
{
|
||||||
|
if (FAILED(m_pModelCom->Bind_BoneMatrices(i, m_pShaderCom, "g_BoneMatrices"))) {
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) {
|
if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
@@ -69,9 +82,6 @@ HRESULT CBroom::Render()
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (FAILED(m_pModelCom->Bind_CS_Output(5, i)))
|
|
||||||
// return E_FAIL;
|
|
||||||
|
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Render(i))) {
|
if (FAILED(m_pModelCom->Render(i))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|||||||
@@ -140,8 +140,8 @@ HRESULT CLevel_GamePlay::Ready_Layer_Player(const _wstring& strLayerTag)
|
|||||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CPlayer>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CPlayer>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CBroom>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
/*if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CBroom>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
||||||
return E_FAIL;
|
return E_FAIL;*/
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,13 +71,14 @@ HRESULT CPlayer::Initialize(void* pArg)
|
|||||||
void CPlayer::Priority_Update(_float fTimeDelta)
|
void CPlayer::Priority_Update(_float fTimeDelta)
|
||||||
{
|
{
|
||||||
m_pTransformCom->RewindMomentum();
|
m_pTransformCom->RewindMomentum();
|
||||||
m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position());
|
|
||||||
__super::Priority_Update(fTimeDelta);
|
__super::Priority_Update(fTimeDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPlayer::Update(_float fTimeDelta)
|
void CPlayer::Update(_float fTimeDelta)
|
||||||
{
|
{
|
||||||
//m_pModelCom->ComputeSkinning();
|
m_pModelCom->ComputeAnimation();
|
||||||
|
|
||||||
|
|
||||||
IsSprint();
|
IsSprint();
|
||||||
IsWalk();
|
IsWalk();
|
||||||
@@ -87,6 +88,8 @@ void CPlayer::Update(_float fTimeDelta)
|
|||||||
|
|
||||||
m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom);
|
m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__super::Update(fTimeDelta);
|
__super::Update(fTimeDelta);
|
||||||
Describe_Entity();
|
Describe_Entity();
|
||||||
m_pCharacter_Controller->Move(fTimeDelta);
|
m_pCharacter_Controller->Move(fTimeDelta);
|
||||||
@@ -94,6 +97,9 @@ void CPlayer::Update(_float fTimeDelta)
|
|||||||
|
|
||||||
void CPlayer::Late_Update(_float fTimeDelta)
|
void CPlayer::Late_Update(_float fTimeDelta)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position());
|
||||||
|
|
||||||
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this);
|
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this);
|
||||||
|
|
||||||
__super::Late_Update(fTimeDelta);
|
__super::Late_Update(fTimeDelta);
|
||||||
@@ -120,9 +126,6 @@ HRESULT CPlayer::Render()
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (FAILED(m_pModelCom->Bind_CS_Output(5, i)))
|
|
||||||
// return E_FAIL;
|
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Render(i))) {
|
if (FAILED(m_pModelCom->Render(i))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +1,151 @@
|
|||||||
float PI = 3.141592;
|
float PI = 3.141592;
|
||||||
|
|
||||||
struct Mesh
|
struct KeyFrame
|
||||||
{
|
{
|
||||||
float3 vPosition;
|
float3 vScale;
|
||||||
float3 vNormal;
|
float4 vRotation;
|
||||||
float3 vTangent;
|
float3 vTranslation;
|
||||||
float3 vBinormal;
|
float fTrackPosition;
|
||||||
float2 vTexcoord;
|
|
||||||
|
|
||||||
uint4 vBlendIndex;
|
|
||||||
float4 vBlendWeight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SkinngMesh
|
struct Channel
|
||||||
{
|
{
|
||||||
float3 vPosition;
|
uint StartIndex;
|
||||||
float3 vNormal;
|
uint KeyCount;
|
||||||
float3 vTangent;
|
uint BoneIndex;
|
||||||
float3 vBinormal;
|
|
||||||
float2 vTexcoord;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
StructuredBuffer<Mesh> g_MeshBufferInput : register(t0);
|
struct LocalPos
|
||||||
RWStructuredBuffer<SkinngMesh> gSkinngMeshOutput : register(u0);
|
|
||||||
|
|
||||||
cbuffer g_ConstantBuffer : register(b0)
|
|
||||||
{
|
{
|
||||||
row_major float4x4 BoneMatrix[512];
|
float3 Scale;
|
||||||
|
float pad0;
|
||||||
|
|
||||||
|
float4 Rotation;
|
||||||
|
|
||||||
|
float3 Translation;
|
||||||
|
float pad1;
|
||||||
};
|
};
|
||||||
|
|
||||||
//[numthreads(256, 1, 1)]
|
|
||||||
[numthreads(256, 1, 1)]
|
StructuredBuffer<KeyFrame> g_KeyFrameBuffer : register(t0);
|
||||||
void CS_MAIN(uint3 DispatchThreadID : SV_DispatchThreadID)
|
StructuredBuffer<Channel> g_ChannelBuffer : register(t1);
|
||||||
|
|
||||||
|
RWStructuredBuffer<LocalPos> g_LocalPosOutput : register(u0);
|
||||||
|
|
||||||
|
|
||||||
|
cbuffer AnimCB : register(b0)
|
||||||
{
|
{
|
||||||
uint iIndex = DispatchThreadID.x;
|
float CurrentTime;
|
||||||
|
float Duration;
|
||||||
|
float Speed;
|
||||||
|
int BoneCount;
|
||||||
|
|
||||||
|
row_major float4x4 PreTransformMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
Mesh mesh = g_MeshBufferInput[iIndex];
|
float4 quatSlerp(float4 q1, float4 q2, float t)
|
||||||
|
{
|
||||||
|
float cosTheta = dot(q1, q2);
|
||||||
|
|
||||||
float fWeightW = 1.f -
|
if (cosTheta < 0.0f)
|
||||||
(mesh.vBlendWeight.x + mesh.vBlendWeight.y + mesh.vBlendWeight.z);
|
{
|
||||||
|
q2 = -q2;
|
||||||
|
cosTheta = -cosTheta;
|
||||||
|
}
|
||||||
|
|
||||||
matrix SkinMatrix =
|
if (cosTheta > 0.9995f)
|
||||||
BoneMatrix[mesh.vBlendIndex.x] * mesh.vBlendWeight.x +
|
return normalize(lerp(q1, q2, t));
|
||||||
BoneMatrix[mesh.vBlendIndex.y] * mesh.vBlendWeight.y +
|
|
||||||
BoneMatrix[mesh.vBlendIndex.z] * mesh.vBlendWeight.z +
|
|
||||||
BoneMatrix[mesh.vBlendIndex.w] * fWeightW;
|
|
||||||
|
|
||||||
float4 vPosition = mul(float4(mesh.vPosition, 1), SkinMatrix);
|
float theta = acos(cosTheta);
|
||||||
float4 vNormal = mul(float4(mesh.vNormal, 0), SkinMatrix);
|
float sinTheta = sin(theta);
|
||||||
float4 vBinormal = mul(float4(mesh.vBinormal, 0), SkinMatrix);
|
|
||||||
float4 vTangent = mul(float4(mesh.vTangent, 0), SkinMatrix);
|
|
||||||
|
|
||||||
|
float w1 = sin((1.0f - t) * theta) / sinTheta;
|
||||||
|
float w2 = sin(t * theta) / sinTheta;
|
||||||
|
|
||||||
SkinngMesh outv;
|
return q1 * w1 + q2 * w2;
|
||||||
outv.vPosition = vPosition.xyz;
|
}
|
||||||
outv.vNormal = vNormal.xyz;
|
|
||||||
outv.vTangent = vTangent.xyz;
|
|
||||||
outv.vBinormal = vBinormal.xyz;
|
[numthreads(256, 1, 1)]
|
||||||
outv.vTexcoord = mesh.vTexcoord;
|
void CS_LocalSRT(uint3 DTID : SV_DispatchThreadID)
|
||||||
|
{
|
||||||
gSkinngMeshOutput[iIndex] = outv;
|
uint boneIndex = DTID.x;
|
||||||
|
if (boneIndex >= (uint) BoneCount)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float time = CurrentTime;
|
||||||
|
if (Duration > 0)
|
||||||
|
time = min(time, Duration);
|
||||||
|
|
||||||
|
Channel channel = g_ChannelBuffer[boneIndex];
|
||||||
|
|
||||||
|
LocalPos result;
|
||||||
|
|
||||||
|
if (channel.KeyCount == 0)
|
||||||
|
{
|
||||||
|
result.Scale = float3(1, 1, 1);
|
||||||
|
result.Rotation = float4(0, 0, 0, 1);
|
||||||
|
result.Translation = float3(0, 0, 0);
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint firstIndex = channel.StartIndex;
|
||||||
|
uint lastIndex = channel.StartIndex + channel.KeyCount - 1;
|
||||||
|
|
||||||
|
KeyFrame keyframe1 = g_KeyFrameBuffer[firstIndex];
|
||||||
|
KeyFrame keyframe2 = g_KeyFrameBuffer[lastIndex];
|
||||||
|
|
||||||
|
if (time <= keyframe1.fTrackPosition)
|
||||||
|
{
|
||||||
|
result.Scale = keyframe1.vScale;
|
||||||
|
result.Rotation = keyframe1.vRotation;
|
||||||
|
result.Translation = keyframe1.vTranslation;
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time >= keyframe2.fTrackPosition)
|
||||||
|
{
|
||||||
|
result.Scale = keyframe2.vScale;
|
||||||
|
result.Rotation = keyframe2.vRotation;
|
||||||
|
result.Translation = keyframe2.vTranslation;
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint i = 0; i < channel.KeyCount - 1; ++i)
|
||||||
|
{
|
||||||
|
uint A = channel.StartIndex + i;
|
||||||
|
uint B = channel.StartIndex + i + 1;
|
||||||
|
|
||||||
|
KeyFrame ka = g_KeyFrameBuffer[A];
|
||||||
|
KeyFrame kb = g_KeyFrameBuffer[B];
|
||||||
|
|
||||||
|
if (time >= ka.fTrackPosition && time <= kb.fTrackPosition)
|
||||||
|
{
|
||||||
|
float t = (time - ka.fTrackPosition) / (kb.fTrackPosition - ka.fTrackPosition);
|
||||||
|
|
||||||
|
result.Scale = lerp(ka.vScale, kb.vScale, t);
|
||||||
|
result.Rotation = quatSlerp(ka.vRotation, kb.vRotation, t);
|
||||||
|
result.Translation = lerp(ka.vTranslation, kb.vTranslation, t);
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Scale = keyframe2.vScale;
|
||||||
|
result.Rotation = keyframe2.vRotation;
|
||||||
|
result.Translation = keyframe2.vTranslation;
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
#include "Engine_Shader_Defines.hlsli"
|
#include "Engine_Shader_Defines.hlsli"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
matrix g_WorldMatrix, g_ViewMatrix, g_ProjMatrix;
|
matrix g_WorldMatrix, g_ViewMatrix, g_ProjMatrix;
|
||||||
|
|
||||||
@@ -16,11 +14,11 @@ float3 g_vRimColor;
|
|||||||
float4 g_TestColor;
|
float4 g_TestColor;
|
||||||
vector g_vCamPosition;
|
vector g_vCamPosition;
|
||||||
|
|
||||||
Texture2D g_DiffuseTexture : register(t0);
|
Texture2D g_DiffuseTexture;
|
||||||
Texture2D g_NormalTexture : register(t1);
|
Texture2D g_NormalTexture;
|
||||||
Texture2D g_DAOTexture : register(t2);
|
Texture2D g_DAOTexture;
|
||||||
Texture2D g_THVTexture : register(t3);
|
Texture2D g_THVTexture;
|
||||||
Texture2D g_SurfaceParamsTexture : register(t4);
|
Texture2D g_SurfaceParamsTexture;
|
||||||
|
|
||||||
|
|
||||||
float3 g_RootColor;
|
float3 g_RootColor;
|
||||||
@@ -57,23 +55,26 @@ struct VS_OUT
|
|||||||
float4 vWorldPos : TEXCOORD1;
|
float4 vWorldPos : TEXCOORD1;
|
||||||
float4 vProjPos : TEXCOORD2;
|
float4 vProjPos : TEXCOORD2;
|
||||||
};
|
};
|
||||||
|
|
||||||
VS_OUT VS_MAIN(VS_IN In)
|
VS_OUT VS_MAIN(VS_IN In)
|
||||||
{
|
{
|
||||||
VS_OUT Out;
|
VS_OUT Out;
|
||||||
|
|
||||||
float fWeightW = 1.f - (In.vBlendWeight.x + In.vBlendWeight.y + In.vBlendWeight.z);
|
float fWeightW = 1.f - (In.vBlendWeight.x + In.vBlendWeight.y + In.vBlendWeight.z);
|
||||||
|
|
||||||
matrix BoneMatrix =
|
matrix BoneMatrix =
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x) +
|
mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x) +
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y) +
|
mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y) +
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z) +
|
mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z) +
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.w], fWeightW);
|
mul(g_BoneMatrices[In.vBlendIndex.w], fWeightW);
|
||||||
|
|
||||||
vector vPosition = mul(vector(In.vPosition, 1.f), BoneMatrix);
|
vector vPosition = mul(vector(In.vPosition, 1.f), BoneMatrix);
|
||||||
vector vNormal = mul(vector(In.vNormal, 0.f), BoneMatrix);
|
vector vNormal = mul(vector(In.vNormal, 0.f), BoneMatrix);
|
||||||
vector vBinormal = mul(vector(In.vBinormal, 0.f), BoneMatrix);
|
vector vBinormal = mul(vector(In.vBinormal, 0.f), BoneMatrix);
|
||||||
vector vTangent = mul(vector(In.vTangent, 0.f), BoneMatrix);
|
vector vTangent = mul(vector(In.vTangent, 0.f), BoneMatrix);
|
||||||
|
|
||||||
|
|
||||||
matrix matWV, matWVP;
|
matrix matWV, matWVP;
|
||||||
|
|
||||||
matWV = mul(g_WorldMatrix, g_ViewMatrix);
|
matWV = mul(g_WorldMatrix, g_ViewMatrix);
|
||||||
matWVP = mul(matWV, g_ProjMatrix);
|
matWVP = mul(matWV, g_ProjMatrix);
|
||||||
|
|
||||||
@@ -82,7 +83,6 @@ VS_OUT VS_MAIN(VS_IN In)
|
|||||||
Out.vBinormal = normalize(mul(vBinormal, g_WorldMatrix)).xyz;
|
Out.vBinormal = normalize(mul(vBinormal, g_WorldMatrix)).xyz;
|
||||||
Out.vTangent = normalize(mul(vTangent, g_WorldMatrix)).xyz;
|
Out.vTangent = normalize(mul(vTangent, g_WorldMatrix)).xyz;
|
||||||
Out.vTexcoord = In.vTexcoord;
|
Out.vTexcoord = In.vTexcoord;
|
||||||
//In.vTexcoord;
|
|
||||||
Out.vWorldPos = mul(vPosition, g_WorldMatrix);
|
Out.vWorldPos = mul(vPosition, g_WorldMatrix);
|
||||||
Out.vProjPos = Out.vPosition;
|
Out.vProjPos = Out.vPosition;
|
||||||
return Out;
|
return Out;
|
||||||
@@ -106,10 +106,10 @@ VS_OUT_CAPTUREDMODEL VS_CAPTUREDMODEL(VS_IN In)
|
|||||||
|
|
||||||
float fWeightW = 1.f - (In.vBlendWeight.x + In.vBlendWeight.y + In.vBlendWeight.z);
|
float fWeightW = 1.f - (In.vBlendWeight.x + In.vBlendWeight.y + In.vBlendWeight.z);
|
||||||
|
|
||||||
matrix BoneMatrix =
|
matrix BoneMatrix =
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x ) +
|
mul(g_BoneMatrices[In.vBlendIndex.x], In.vBlendWeight.x) +
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y ) +
|
mul(g_BoneMatrices[In.vBlendIndex.y], In.vBlendWeight.y) +
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z ) +
|
mul(g_BoneMatrices[In.vBlendIndex.z], In.vBlendWeight.z) +
|
||||||
mul(g_BoneMatrices[In.vBlendIndex.w], fWeightW);
|
mul(g_BoneMatrices[In.vBlendIndex.w], fWeightW);
|
||||||
|
|
||||||
vector vPosition = mul(vector(In.vPosition, 1.f), BoneMatrix);
|
vector vPosition = mul(vector(In.vPosition, 1.f), BoneMatrix);
|
||||||
@@ -201,10 +201,13 @@ struct PS_OUT
|
|||||||
PS_OUT PS_MAIN(PS_IN In)
|
PS_OUT PS_MAIN(PS_IN In)
|
||||||
{
|
{
|
||||||
PS_OUT Out;
|
PS_OUT Out;
|
||||||
|
|
||||||
vector vMtrlDiffuse = g_DiffuseTexture.Sample(DefaultSampler, In.vTexcoord);
|
vector vMtrlDiffuse = g_DiffuseTexture.Sample(DefaultSampler, In.vTexcoord);
|
||||||
vector vSurface = g_SurfaceParamsTexture.Sample(DefaultSampler, In.vTexcoord);
|
vector vSurface = g_SurfaceParamsTexture.Sample(DefaultSampler, In.vTexcoord);
|
||||||
if (vMtrlDiffuse.a < 0.2f) { discard; }
|
if (vMtrlDiffuse.a < 0.2f)
|
||||||
|
{
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
|
||||||
float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, DefaultSampler, In.vTexcoord);
|
float3 vNormalDecoded = DecodeNormalFromRG(g_NormalTexture, DefaultSampler, In.vTexcoord);
|
||||||
float3x3 WorldMatrix = float3x3(In.vTangent, In.vBinormal * -1.f, In.vNormal);
|
float3x3 WorldMatrix = float3x3(In.vTangent, In.vBinormal * -1.f, In.vNormal);
|
||||||
|
|||||||
@@ -66,9 +66,6 @@ HRESULT CBroom::Render()
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Bind_CS_Output(5, i)))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Render(i))) {
|
if (FAILED(m_pModelCom->Render(i))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ void CDummyObject::Priority_Update(_float fTimeDelta)
|
|||||||
|
|
||||||
void CDummyObject::Update(_float fTimeDelta)
|
void CDummyObject::Update(_float fTimeDelta)
|
||||||
{
|
{
|
||||||
m_pModelCom->ComputeSkinning();
|
m_pModelCom->ComputeAnimation();
|
||||||
|
|
||||||
m_pModelCom->Play_Animation(fTimeDelta,m_pTransformCom);
|
m_pModelCom->Play_Animation(fTimeDelta,m_pTransformCom);
|
||||||
|
|
||||||
@@ -77,9 +77,6 @@ HRESULT CDummyObject::Render()
|
|||||||
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) {
|
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Bind_CS_Output(5, i)))
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Render(i))) {
|
if (FAILED(m_pModelCom->Render(i))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ void CGoblin::Update(_float fTimeDelta)
|
|||||||
{
|
{
|
||||||
m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom);
|
m_pModelCom->Play_Animation(fTimeDelta, m_pTransformCom);
|
||||||
|
|
||||||
//m_pModelCom->ComputeSkinning();
|
m_pModelCom->ComputeAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGoblin::Late_Update(_float fTimeDelta)
|
void CGoblin::Late_Update(_float fTimeDelta)
|
||||||
@@ -71,9 +71,6 @@ HRESULT CGoblin::Render()
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (FAILED(m_pModelCom->Bind_CS_Output(5, 0)))
|
|
||||||
// return E_FAIL;
|
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Render(i))) {
|
if (FAILED(m_pModelCom->Render(i))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ HRESULT CLevel_ObjectViewer::Initialize()
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if (FAILED(Ready_Layer_Camera(TEXT("Layer_Camera"))))
|
if (FAILED(Ready_Layer_Camera(TEXT("Layer_Camera"))))
|
||||||
{
|
{
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (FAILED(Ready_Layer_Dummy(TEXT("Layer_Dummy"))))
|
if (FAILED(Ready_Layer_Dummy(TEXT("Layer_Dummy"))))
|
||||||
{
|
{
|
||||||
@@ -58,7 +58,7 @@ void CLevel_ObjectViewer::Update(_float fTimeDelta)
|
|||||||
|
|
||||||
Find_Anim();
|
Find_Anim();
|
||||||
|
|
||||||
m_Test->Describe_Entity();
|
//m_Test->Describe_Entity();
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CLevel_ObjectViewer::Render()
|
HRESULT CLevel_ObjectViewer::Render()
|
||||||
@@ -702,8 +702,8 @@ HRESULT CLevel_ObjectViewer::Ready_Layer_Dummy(const _wstring& strLayerTag)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CGoblin>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
//if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CGoblin>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
||||||
return E_FAIL;
|
// return E_FAIL;
|
||||||
|
|
||||||
/*if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CBroom>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
/*if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CBroom>(g_iStaticLevel, NEXT_LEVEL, strLayerTag)))
|
||||||
return E_FAIL;*/
|
return E_FAIL;*/
|
||||||
|
|||||||
@@ -69,10 +69,7 @@ void CPlayer::Priority_Update(_float fTimeDelta)
|
|||||||
|
|
||||||
void CPlayer::Update(_float fTimeDelta)
|
void CPlayer::Update(_float fTimeDelta)
|
||||||
{
|
{
|
||||||
//m_pModelCom->ComputeSkinning();
|
m_pModelCom->ComputeAnimation();
|
||||||
|
|
||||||
IsSprint();
|
|
||||||
IsWalk();
|
|
||||||
|
|
||||||
m_pFSM->Update_State(fTimeDelta);
|
m_pFSM->Update_State(fTimeDelta);
|
||||||
|
|
||||||
@@ -109,8 +106,6 @@ HRESULT CPlayer::Render()
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (FAILED(m_pModelCom->Bind_CS_Output(5, i)))
|
|
||||||
// return E_FAIL;
|
|
||||||
|
|
||||||
if (FAILED(m_pModelCom->Render(i))) {
|
if (FAILED(m_pModelCom->Render(i))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ void CRootModelPart::Update_Anim(_float fTimeDelta)
|
|||||||
{
|
{
|
||||||
pModel->Set_PlayAnim(m_pMainModel->Get_PlayAnim());
|
pModel->Set_PlayAnim(m_pMainModel->Get_PlayAnim());
|
||||||
pModel->Set_AnimSpeed(m_pMainModel->Get_AnimSpeed());
|
pModel->Set_AnimSpeed(m_pMainModel->Get_AnimSpeed());
|
||||||
|
pModel->ComputeAnimation();
|
||||||
pModel->Play_Animation(fTimeDelta,m_pTransformCom);
|
pModel->Play_Animation(fTimeDelta,m_pTransformCom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +99,8 @@ void CRootModelPart::Change_Model(_uint iIndex)
|
|||||||
CModel* pModel = m_ModelParts[iIndex]->Get_Component<CModel>();
|
CModel* pModel = m_ModelParts[iIndex]->Get_Component<CModel>();
|
||||||
|
|
||||||
pModel->Set_AnimationIndex(m_iAnimIndex);
|
pModel->Set_AnimationIndex(m_iAnimIndex);
|
||||||
pModel->Set_CurrentTrackPosition(m_fTrackPosition);
|
pModel->Set_CurrentTrackPosition(m_fTrackPosition);
|
||||||
|
pModel->ComputeAnimation();
|
||||||
pModel->Play_Animation(0.f, m_pTransformCom);
|
pModel->Play_Animation(0.f, m_pTransformCom);
|
||||||
|
|
||||||
if (iIndex == ENUM_CLASS(PARTSTYPE::BODY))
|
if (iIndex == ENUM_CLASS(PARTSTYPE::BODY))
|
||||||
@@ -112,6 +114,7 @@ void CRootModelPart::Set_Animation(_uint iAnimIndex)
|
|||||||
{
|
{
|
||||||
m_pMainModel->Set_AnimationIndex(iAnimIndex);
|
m_pMainModel->Set_AnimationIndex(iAnimIndex);
|
||||||
m_pMainModel->Set_CurrentTrackPosition(0.f);
|
m_pMainModel->Set_CurrentTrackPosition(0.f);
|
||||||
|
m_pMainModel->ComputeAnimation();
|
||||||
m_pMainModel->Play_Animation(0.f, m_pTransformCom);
|
m_pMainModel->Play_Animation(0.f, m_pTransformCom);
|
||||||
for (auto& PartObject : m_ModelParts)
|
for (auto& PartObject : m_ModelParts)
|
||||||
{
|
{
|
||||||
@@ -120,6 +123,7 @@ void CRootModelPart::Set_Animation(_uint iAnimIndex)
|
|||||||
{
|
{
|
||||||
pModel->Set_AnimationIndex(m_pMainModel->Get_AnimIndex());
|
pModel->Set_AnimationIndex(m_pMainModel->Get_AnimIndex());
|
||||||
pModel->Set_CurrentTrackPosition(m_pMainModel->Get_CurrentTrackPosition());
|
pModel->Set_CurrentTrackPosition(m_pMainModel->Get_CurrentTrackPosition());
|
||||||
|
pModel->ComputeAnimation();
|
||||||
pModel->Play_Animation(0.f, m_pTransformCom);
|
pModel->Play_Animation(0.f, m_pTransformCom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,64 +1,151 @@
|
|||||||
float PI = 3.141592;
|
float PI = 3.141592;
|
||||||
|
|
||||||
struct Mesh
|
struct KeyFrame
|
||||||
{
|
{
|
||||||
float3 vPosition;
|
float3 vScale;
|
||||||
float3 vNormal;
|
float4 vRotation;
|
||||||
float3 vTangent;
|
float3 vTranslation;
|
||||||
float3 vBinormal;
|
float fTrackPosition;
|
||||||
float2 vTexcoord;
|
|
||||||
|
|
||||||
uint4 vBlendIndex;
|
|
||||||
float4 vBlendWeight;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SkinngMesh
|
struct Channel
|
||||||
{
|
{
|
||||||
float3 vPosition;
|
uint StartIndex;
|
||||||
float3 vNormal;
|
uint KeyCount;
|
||||||
float3 vTangent;
|
uint BoneIndex;
|
||||||
float3 vBinormal;
|
|
||||||
float2 vTexcoord;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
StructuredBuffer<Mesh> g_MeshBufferInput : register(t0);
|
struct LocalPos
|
||||||
RWStructuredBuffer<SkinngMesh> gSkinngMeshOutput : register(u0);
|
|
||||||
|
|
||||||
cbuffer g_ConstantBuffer : register(b0)
|
|
||||||
{
|
{
|
||||||
row_major float4x4 BoneMatrix[512];
|
float3 Scale;
|
||||||
|
float pad0;
|
||||||
|
|
||||||
|
float4 Rotation;
|
||||||
|
|
||||||
|
float3 Translation;
|
||||||
|
float pad1;
|
||||||
};
|
};
|
||||||
|
|
||||||
//[numthreads(256, 1, 1)]
|
|
||||||
[numthreads(256, 1, 1)]
|
StructuredBuffer<KeyFrame> g_KeyFrameBuffer : register(t0);
|
||||||
void CS_MAIN(uint3 DispatchThreadID : SV_DispatchThreadID)
|
StructuredBuffer<Channel> g_ChannelBuffer : register(t1);
|
||||||
|
|
||||||
|
RWStructuredBuffer<LocalPos> g_LocalPosOutput : register(u0);
|
||||||
|
|
||||||
|
|
||||||
|
cbuffer AnimCB : register(b0)
|
||||||
{
|
{
|
||||||
uint iIndex = DispatchThreadID.x;
|
float CurrentTime;
|
||||||
|
float Duration;
|
||||||
|
float Speed;
|
||||||
|
int BoneCount;
|
||||||
|
|
||||||
|
row_major float4x4 PreTransformMatrix;
|
||||||
|
};
|
||||||
|
|
||||||
Mesh mesh = g_MeshBufferInput[iIndex];
|
float4 quatSlerp(float4 q1, float4 q2, float t)
|
||||||
|
{
|
||||||
|
float cosTheta = dot(q1, q2);
|
||||||
|
|
||||||
float fWeightW = 1.f -
|
if (cosTheta < 0.0f)
|
||||||
(mesh.vBlendWeight.x + mesh.vBlendWeight.y + mesh.vBlendWeight.z);
|
{
|
||||||
|
q2 = -q2;
|
||||||
|
cosTheta = -cosTheta;
|
||||||
|
}
|
||||||
|
|
||||||
matrix SkinMatrix =
|
if (cosTheta > 0.9995f)
|
||||||
BoneMatrix[mesh.vBlendIndex.x] * mesh.vBlendWeight.x +
|
return normalize(lerp(q1, q2, t));
|
||||||
BoneMatrix[mesh.vBlendIndex.y] * mesh.vBlendWeight.y +
|
|
||||||
BoneMatrix[mesh.vBlendIndex.z] * mesh.vBlendWeight.z +
|
|
||||||
BoneMatrix[mesh.vBlendIndex.w] * fWeightW;
|
|
||||||
|
|
||||||
float4 vPosition = mul(float4(mesh.vPosition, 1), SkinMatrix);
|
float theta = acos(cosTheta);
|
||||||
float4 vNormal = mul(float4(mesh.vNormal, 0), SkinMatrix);
|
float sinTheta = sin(theta);
|
||||||
float4 vBinormal = mul(float4(mesh.vBinormal, 0), SkinMatrix);
|
|
||||||
float4 vTangent = mul(float4(mesh.vTangent, 0), SkinMatrix);
|
|
||||||
|
|
||||||
|
float w1 = sin((1.0f - t) * theta) / sinTheta;
|
||||||
|
float w2 = sin(t * theta) / sinTheta;
|
||||||
|
|
||||||
SkinngMesh outv;
|
return q1 * w1 + q2 * w2;
|
||||||
outv.vPosition = vPosition.xyz;
|
}
|
||||||
outv.vNormal = vNormal.xyz;
|
|
||||||
outv.vTangent = vTangent.xyz;
|
|
||||||
outv.vBinormal = vBinormal.xyz;
|
[numthreads(256, 1, 1)]
|
||||||
outv.vTexcoord = mesh.vTexcoord;
|
void CS_LocalSRT(uint3 DTID : SV_DispatchThreadID)
|
||||||
|
{
|
||||||
gSkinngMeshOutput[iIndex] = outv;
|
uint boneIndex = DTID.x;
|
||||||
|
if (boneIndex >= (uint) BoneCount)
|
||||||
|
return;
|
||||||
|
|
||||||
|
float time = CurrentTime;
|
||||||
|
if (Duration > 0)
|
||||||
|
time = min(time, Duration);
|
||||||
|
|
||||||
|
Channel channel = g_ChannelBuffer[boneIndex];
|
||||||
|
|
||||||
|
LocalPos result;
|
||||||
|
|
||||||
|
if (channel.KeyCount == 0)
|
||||||
|
{
|
||||||
|
result.Scale = float3(1, 1, 1);
|
||||||
|
result.Rotation = float4(0, 0, 0, 1);
|
||||||
|
result.Translation = float3(0, 0, 0);
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint firstIndex = channel.StartIndex;
|
||||||
|
uint lastIndex = channel.StartIndex + channel.KeyCount - 1;
|
||||||
|
|
||||||
|
KeyFrame keyframe1 = g_KeyFrameBuffer[firstIndex];
|
||||||
|
KeyFrame keyframe2 = g_KeyFrameBuffer[lastIndex];
|
||||||
|
|
||||||
|
if (time <= keyframe1.fTrackPosition)
|
||||||
|
{
|
||||||
|
result.Scale = keyframe1.vScale;
|
||||||
|
result.Rotation = keyframe1.vRotation;
|
||||||
|
result.Translation = keyframe1.vTranslation;
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (time >= keyframe2.fTrackPosition)
|
||||||
|
{
|
||||||
|
result.Scale = keyframe2.vScale;
|
||||||
|
result.Rotation = keyframe2.vRotation;
|
||||||
|
result.Translation = keyframe2.vTranslation;
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (uint i = 0; i < channel.KeyCount - 1; ++i)
|
||||||
|
{
|
||||||
|
uint A = channel.StartIndex + i;
|
||||||
|
uint B = channel.StartIndex + i + 1;
|
||||||
|
|
||||||
|
KeyFrame ka = g_KeyFrameBuffer[A];
|
||||||
|
KeyFrame kb = g_KeyFrameBuffer[B];
|
||||||
|
|
||||||
|
if (time >= ka.fTrackPosition && time <= kb.fTrackPosition)
|
||||||
|
{
|
||||||
|
float t = (time - ka.fTrackPosition) / (kb.fTrackPosition - ka.fTrackPosition);
|
||||||
|
|
||||||
|
result.Scale = lerp(ka.vScale, kb.vScale, t);
|
||||||
|
result.Rotation = quatSlerp(ka.vRotation, kb.vRotation, t);
|
||||||
|
result.Translation = lerp(ka.vTranslation, kb.vTranslation, t);
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.Scale = keyframe2.vScale;
|
||||||
|
result.Rotation = keyframe2.vRotation;
|
||||||
|
result.Translation = keyframe2.vTranslation;
|
||||||
|
result.pad0 = result.pad1 = 0.0f;
|
||||||
|
|
||||||
|
g_LocalPosOutput[boneIndex] = result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ CAnimation::CAnimation(const CAnimation& rhs)
|
|||||||
, m_fTickPerSecond{ rhs.m_fTickPerSecond }
|
, m_fTickPerSecond{ rhs.m_fTickPerSecond }
|
||||||
, m_pSaveAnim{ rhs.m_pSaveAnim }
|
, m_pSaveAnim{ rhs.m_pSaveAnim }
|
||||||
, m_fAnimSpeed{rhs.m_fAnimSpeed }
|
, m_fAnimSpeed{rhs.m_fAnimSpeed }
|
||||||
|
,m_iBoneCount{rhs.m_iBoneCount}
|
||||||
{
|
{
|
||||||
memcpy_s(m_TickPerSeconds, sizeof(_float) * 2, rhs.m_TickPerSeconds, sizeof(_float) * 2);
|
memcpy_s(m_TickPerSeconds, sizeof(_float) * 2, rhs.m_TickPerSeconds, sizeof(_float) * 2);
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ CAnimation::CAnimation(const CAnimation& rhs)
|
|||||||
SAFE_ADDREF(pChannel);
|
SAFE_ADDREF(pChannel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_bool CAnimation::Update_TransformationMatrices(const vector<class CBone*>& Bones, _bool bIsLoop, _float fTimeDelta,CTransform*pTransform)
|
_bool CAnimation::Update_TransformationMatrices(const vector<class CBone*>& Bones, const LOCALPOS_DESC* pLocalPosArray, _bool bIsLoop, _float fTimeDelta,CTransform*pTransform)
|
||||||
{
|
{
|
||||||
//m_fCurrentTrackPosition += m_TickPerSeconds[m_bPause] * fTimeDelta;
|
//m_fCurrentTrackPosition += m_TickPerSeconds[m_bPause] * fTimeDelta;
|
||||||
m_fCurrentTrackPosition += m_fTickPerSecond * fTimeDelta * m_fAnimSpeed;
|
m_fCurrentTrackPosition += m_fTickPerSecond * fTimeDelta * m_fAnimSpeed;
|
||||||
@@ -52,7 +53,7 @@ _bool CAnimation::Update_TransformationMatrices(const vector<class CBone*>& Bone
|
|||||||
if (m_vBoneTransformationMatrix.size() > 0)
|
if (m_vBoneTransformationMatrix.size() > 0)
|
||||||
m_vBoneTransformationMatrix.clear();
|
m_vBoneTransformationMatrix.clear();
|
||||||
for (auto& pChannel : m_Channels) {
|
for (auto& pChannel : m_Channels) {
|
||||||
pChannel->Update_TransformationMatirx(Bones, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex++],pTransform);
|
pChannel->Update_TransformationMatirx(Bones, pLocalPosArray, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex++],pTransform);
|
||||||
m_vBoneTransformationMatrix.push_back(pChannel->Get_BoneTransformationMatrix());
|
m_vBoneTransformationMatrix.push_back(pChannel->Get_BoneTransformationMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,9 +185,36 @@ void CAnimation::InterpAnim(CAnimation* pPreAnim, vector<CBone*>& Bones, float f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CAnimation::CreateGPUData(ID3D11Device* pDevice)
|
||||||
|
{
|
||||||
|
vector<CHANNEL_DESC> channels;
|
||||||
|
vector<KEYFRAME_DESC> keyframes;
|
||||||
|
|
||||||
|
channels.resize(m_iBoneCount);
|
||||||
|
|
||||||
|
for (auto& pChannel : m_Channels)
|
||||||
|
{
|
||||||
|
CHANNEL_DESC desc = pChannel->Fill_GPU_ChannelDesc();
|
||||||
|
desc.StartIndex = (_uint)keyframes.size();
|
||||||
|
|
||||||
|
pChannel->Fill_GPU_Keyframes(keyframes);
|
||||||
|
|
||||||
|
channels[desc.BoneIndex] = desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_iChannelCount = (_uint)channels.size();
|
||||||
|
m_iKeyframeCount = (_uint)keyframes.size();
|
||||||
|
|
||||||
|
CreateKeyFrameBuffer(pDevice, keyframes);
|
||||||
|
CreateChannelBuffer(pDevice, channels);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef EDITOR_PROJECT
|
#ifdef EDITOR_PROJECT
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT CAnimation::Initialize(const vector<CBone*>& Bones, const aiAnimation* pAIAnimation)
|
HRESULT CAnimation::Initialize(const vector<CBone*>& Bones, const aiAnimation* pAIAnimation)
|
||||||
{
|
{
|
||||||
m_strName = pAIAnimation->mName.data;
|
m_strName = pAIAnimation->mName.data;
|
||||||
@@ -216,6 +244,8 @@ HRESULT CAnimation::Initialize(const vector<CBone*>& Bones, const aiAnimation* p
|
|||||||
if (FAILED(Combined_Initialize())) {
|
if (FAILED(Combined_Initialize())) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
HRESULT CAnimation::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
HRESULT CAnimation::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||||
@@ -274,7 +304,7 @@ HRESULT CAnimation::Initialize(HANDLE hFile, DWORD& dwByte)
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CAnimation::Initialize(const CModel* pModel, SaveAnimation* pSaveAnimation)
|
HRESULT CAnimation::Initialize(const vector<CBone*>& Bones, const CModel* pModel, SaveAnimation* pSaveAnimation)
|
||||||
{
|
{
|
||||||
m_pSaveAnim = pSaveAnimation;
|
m_pSaveAnim = pSaveAnimation;
|
||||||
|
|
||||||
@@ -286,6 +316,8 @@ HRESULT CAnimation::Initialize(const CModel* pModel, SaveAnimation* pSaveAnimati
|
|||||||
|
|
||||||
m_CurrentKeyFrameIndices.resize(m_iNumChannels);
|
m_CurrentKeyFrameIndices.resize(m_iNumChannels);
|
||||||
|
|
||||||
|
m_iBoneCount = (_uint)Bones.size();
|
||||||
|
|
||||||
for (size_t i = 0; i < m_iNumChannels; i++)
|
for (size_t i = 0; i < m_iNumChannels; i++)
|
||||||
{
|
{
|
||||||
CChannel* pChannel = CChannel::Create(pModel, &pSaveAnimation->Channels[i]);
|
CChannel* pChannel = CChannel::Create(pModel, &pSaveAnimation->Channels[i]);
|
||||||
@@ -313,6 +345,64 @@ _uint CAnimation::Get_BoneIndex(const char* pChannelName)
|
|||||||
return _uint();
|
return _uint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HRESULT CAnimation::CreateKeyFrameBuffer(ID3D11Device* pDevice,vector<KEYFRAME_DESC> keyframe)
|
||||||
|
{
|
||||||
|
D3D11_BUFFER_DESC desc{};
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.ByteWidth = (_int)sizeof(KEYFRAME_DESC) * m_iKeyframeCount;
|
||||||
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
desc.CPUAccessFlags = 0;
|
||||||
|
desc.StructureByteStride = (_int)sizeof(KEYFRAME_DESC);
|
||||||
|
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA init{};
|
||||||
|
init.pSysMem = keyframe.data();
|
||||||
|
|
||||||
|
pDevice->CreateBuffer(&desc, &init, &m_pKeyFrameBuffer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||||
|
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
|
||||||
|
srvDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||||
|
srvDesc.Buffer.FirstElement = 0;
|
||||||
|
srvDesc.Buffer.NumElements = m_iKeyframeCount;
|
||||||
|
|
||||||
|
if (FAILED(pDevice->CreateShaderResourceView(m_pKeyFrameBuffer, &srvDesc, &m_pKeyFrameSrv)))
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT CAnimation::CreateChannelBuffer(ID3D11Device* pDevice, vector<CHANNEL_DESC> channel)
|
||||||
|
{
|
||||||
|
D3D11_BUFFER_DESC desc{};
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.ByteWidth = (_int)sizeof(CHANNEL_DESC) * m_iChannelCount;
|
||||||
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
desc.CPUAccessFlags = 0;
|
||||||
|
desc.StructureByteStride = (_int)sizeof(CHANNEL_DESC);
|
||||||
|
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA init{};
|
||||||
|
init.pSysMem = channel.data();
|
||||||
|
|
||||||
|
pDevice->CreateBuffer(&desc, &init, &m_pChannelBuffer);
|
||||||
|
|
||||||
|
|
||||||
|
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||||
|
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
|
||||||
|
srvDesc.Format = DXGI_FORMAT_UNKNOWN;
|
||||||
|
srvDesc.Buffer.FirstElement = 0;
|
||||||
|
srvDesc.Buffer.NumElements = m_iChannelCount;
|
||||||
|
|
||||||
|
if (FAILED(pDevice->CreateShaderResourceView(m_pChannelBuffer, &srvDesc, &m_pChannelSrv)))
|
||||||
|
return E_FAIL;
|
||||||
|
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
CAnimation* CAnimation::Create(HANDLE hFile, DWORD& dwByte)
|
CAnimation* CAnimation::Create(HANDLE hFile, DWORD& dwByte)
|
||||||
{
|
{
|
||||||
CAnimation* pInstance = new CAnimation();
|
CAnimation* pInstance = new CAnimation();
|
||||||
@@ -326,11 +416,11 @@ CAnimation* CAnimation::Create(HANDLE hFile, DWORD& dwByte)
|
|||||||
return pInstance;
|
return pInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAnimation* CAnimation::Create(const CModel* pModel, SaveAnimation* pSaveAnimation)
|
CAnimation* CAnimation::Create(const vector<CBone*>& Bones, const CModel* pModel, SaveAnimation* pSaveAnimation)
|
||||||
{
|
{
|
||||||
CAnimation* pInstance = new CAnimation();
|
CAnimation* pInstance = new CAnimation();
|
||||||
|
|
||||||
if (FAILED(pInstance->Initialize(pModel, pSaveAnimation)))
|
if (FAILED(pInstance->Initialize(Bones,pModel, pSaveAnimation)))
|
||||||
{
|
{
|
||||||
MSG_BOX("Failed to Created : CAnimation");
|
MSG_BOX("Failed to Created : CAnimation");
|
||||||
SAFE_RELEASE(pInstance);
|
SAFE_RELEASE(pInstance);
|
||||||
@@ -354,6 +444,18 @@ void CAnimation::Free()
|
|||||||
m_Channels.clear();
|
m_Channels.clear();
|
||||||
|
|
||||||
m_CurrentKeyFrameIndices.clear();
|
m_CurrentKeyFrameIndices.clear();
|
||||||
|
|
||||||
|
m_KeyFrameDesc.clear();
|
||||||
|
m_ChannelDesc.clear();
|
||||||
|
|
||||||
|
if (m_pKeyFrameSrv&& m_pChannelSrv)
|
||||||
|
{
|
||||||
|
SAFE_RELEASE(m_pKeyFrameBuffer);
|
||||||
|
SAFE_RELEASE(m_pChannelBuffer);
|
||||||
|
SAFE_RELEASE(m_pKeyFrameSrv);
|
||||||
|
SAFE_RELEASE(m_pChannelSrv);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
void CAnimation::Describe_Entity()
|
void CAnimation::Describe_Entity()
|
||||||
|
|||||||
@@ -60,6 +60,34 @@ HRESULT CChannel::Initialize(const vector<CBone*>& Bones, const aiNodeAnim* pAIC
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CChannel::Fill_GPU_Keyframes(vector<KEYFRAME_DESC>& outKeyframes)
|
||||||
|
{
|
||||||
|
for (_uint i = 0; i < m_iNumKeyFrames; i++)
|
||||||
|
{
|
||||||
|
const KEYFRAME& src = m_KeyFrames[i];
|
||||||
|
|
||||||
|
KEYFRAME_DESC dst{};
|
||||||
|
dst.vScale = src.vScale;
|
||||||
|
dst.vRotation = src.vRotation;
|
||||||
|
dst.vTranslation = src.vTranslation;
|
||||||
|
dst.fTrackPosition = src.fTrackPosition;
|
||||||
|
|
||||||
|
outKeyframes.push_back(dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CHANNEL_DESC CChannel::Fill_GPU_ChannelDesc()
|
||||||
|
{
|
||||||
|
CHANNEL_DESC desc{};
|
||||||
|
desc.StartIndex = 0;
|
||||||
|
desc.KeyCount = m_iNumKeyFrames;
|
||||||
|
desc.BoneIndex = m_iBoneIndex;
|
||||||
|
|
||||||
|
return desc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT CChannel::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
HRESULT CChannel::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||||
{
|
{
|
||||||
string strName = m_szName;
|
string strName = m_szName;
|
||||||
@@ -100,84 +128,104 @@ HRESULT CChannel::Initialize(const vector<CBone*>& Bones, _uint iIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CChannel::Update_TransformationMatirx(const vector<CBone*>& Bones, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex, CTransform* pTransform)
|
void CChannel::Update_TransformationMatirx(const vector<CBone*>& Bones, const LOCALPOS_DESC* pLocalPosArray, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex, CTransform* pTransform)
|
||||||
|
|
||||||
{
|
{
|
||||||
if (0.f == fCurrentTrackPosition) {
|
|
||||||
*pCurrentKeyFrameIndex = 0;
|
|
||||||
}
|
|
||||||
KEYFRAME LastKeyFrame = m_KeyFrames.back();
|
|
||||||
|
|
||||||
_vector vScale = {};
|
|
||||||
_vector vRotation = {};
|
|
||||||
_vector vTranslation = {};
|
|
||||||
|
|
||||||
if (fCurrentTrackPosition >= LastKeyFrame.fTrackPosition)
|
|
||||||
{
|
|
||||||
vScale = XMLoadFloat3(&LastKeyFrame.vScale);
|
|
||||||
vRotation = XMLoadFloat4(&LastKeyFrame.vRotation);
|
|
||||||
vTranslation = XMVectorSetW(XMLoadFloat3(&LastKeyFrame.vTranslation), 1.f);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
while (fCurrentTrackPosition >= m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition) {
|
|
||||||
++*pCurrentKeyFrameIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
_float3 vSrcScale = {}, vDstScale = {};
|
|
||||||
_float4 vSrcRotation = {}, vDstRotation = {};
|
|
||||||
_float3 vSrcTranslation = {}, vDstTranslation = {};
|
|
||||||
|
|
||||||
vSrcScale = m_KeyFrames[*pCurrentKeyFrameIndex].vScale;
|
|
||||||
vDstScale = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vScale;
|
|
||||||
|
|
||||||
vSrcRotation = m_KeyFrames[*pCurrentKeyFrameIndex].vRotation;
|
|
||||||
vDstRotation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vRotation;
|
|
||||||
|
|
||||||
vSrcTranslation = m_KeyFrames[*pCurrentKeyFrameIndex].vTranslation;
|
|
||||||
vDstTranslation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vTranslation;
|
|
||||||
|
|
||||||
_float fRatio = (fCurrentTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition) /
|
|
||||||
(m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition);
|
|
||||||
|
|
||||||
vScale = XMVectorLerp(XMLoadFloat3(&vSrcScale), XMLoadFloat3(&vDstScale), fRatio);
|
|
||||||
vRotation = XMQuaternionSlerp(XMLoadFloat4(&vSrcRotation), XMLoadFloat4(&vDstRotation), fRatio);
|
|
||||||
vTranslation = XMVectorSetW(XMVectorLerp(XMLoadFloat3(&vSrcTranslation), XMLoadFloat3(&vDstTranslation), fRatio), 1.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//if (0.f == fCurrentTrackPosition) {
|
||||||
|
// *pCurrentKeyFrameIndex = 0;
|
||||||
|
//}
|
||||||
|
//KEYFRAME LastKeyFrame = m_KeyFrames.back();
|
||||||
|
|
||||||
|
//_vector vScale = {};
|
||||||
|
//_vector vRotation = {};
|
||||||
|
//_vector vTranslation = {};
|
||||||
|
|
||||||
|
//if (fCurrentTrackPosition >= LastKeyFrame.fTrackPosition)
|
||||||
|
//{
|
||||||
|
// vScale = XMLoadFloat3(&LastKeyFrame.vScale);
|
||||||
|
// vRotation = XMLoadFloat4(&LastKeyFrame.vRotation);
|
||||||
|
// vTranslation = XMVectorSetW(XMLoadFloat3(&LastKeyFrame.vTranslation), 1.f);
|
||||||
|
//}
|
||||||
|
//else {
|
||||||
|
// while (fCurrentTrackPosition >= m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition) {
|
||||||
|
// ++*pCurrentKeyFrameIndex;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _float3 vSrcScale = {}, vDstScale = {};
|
||||||
|
// _float4 vSrcRotation = {}, vDstRotation = {};
|
||||||
|
// _float3 vSrcTranslation = {}, vDstTranslation = {};
|
||||||
|
|
||||||
|
// vSrcScale = m_KeyFrames[*pCurrentKeyFrameIndex].vScale;
|
||||||
|
// vDstScale = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vScale;
|
||||||
|
|
||||||
|
// vSrcRotation = m_KeyFrames[*pCurrentKeyFrameIndex].vRotation;
|
||||||
|
// vDstRotation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vRotation;
|
||||||
|
|
||||||
|
// vSrcTranslation = m_KeyFrames[*pCurrentKeyFrameIndex].vTranslation;
|
||||||
|
// vDstTranslation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vTranslation;
|
||||||
|
|
||||||
|
// _float fRatio = (fCurrentTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition) /
|
||||||
|
// (m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition);
|
||||||
|
|
||||||
|
// vScale = XMVectorLerp(XMLoadFloat3(&vSrcScale), XMLoadFloat3(&vDstScale), fRatio);
|
||||||
|
// vRotation = XMQuaternionSlerp(XMLoadFloat4(&vSrcRotation), XMLoadFloat4(&vDstRotation), fRatio);
|
||||||
|
// vTranslation = XMVectorSetW(XMVectorLerp(XMLoadFloat3(&vSrcTranslation), XMLoadFloat3(&vDstTranslation), fRatio), 1.f);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const LOCALPOS_DESC& LocalPos = pLocalPosArray[m_iBoneIndex];
|
||||||
|
|
||||||
|
_vector vScale = XMLoadFloat3(&LocalPos.Scale);
|
||||||
|
_vector vRotation = XMLoadFloat4(&LocalPos.Rotation);
|
||||||
|
_vector vTranslation = XMVectorSet(
|
||||||
|
LocalPos.Translation.x,
|
||||||
|
LocalPos.Translation.y,
|
||||||
|
LocalPos.Translation.z,
|
||||||
|
1.f);
|
||||||
|
|
||||||
if (Bones[m_iBoneIndex]->Compare_Name("Reference") && pTransform != nullptr)
|
if (Bones[m_iBoneIndex]->Compare_Name("Reference") && pTransform != nullptr)
|
||||||
{
|
{
|
||||||
_float3 vCurRootPos;
|
_float3 vCurRootPos;
|
||||||
XMStoreFloat3(&vCurRootPos, vTranslation);
|
XMStoreFloat3(&vCurRootPos, vTranslation);
|
||||||
|
|
||||||
_vector vDeltaLocal = XMLoadFloat3(&vCurRootPos) - XMLoadFloat3(&m_vPrevRootPos);
|
|
||||||
|
|
||||||
_vector vDeltaAdjusted = {};
|
|
||||||
|
|
||||||
XMMATRIX pre = XMLoadFloat4x4(&m_PreTransformMatrix);
|
XMMATRIX pre = XMLoadFloat4x4(&m_PreTransformMatrix);
|
||||||
vDeltaAdjusted = XMVector3TransformNormal(vDeltaLocal, pre);
|
|
||||||
|
if (!m_bInitialRootPos)
|
||||||
|
{
|
||||||
|
m_bInitialRootPos = true;
|
||||||
|
vTranslation = XMVectorZero();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_vector vDeltaLocal = XMLoadFloat3(&vCurRootPos) - XMLoadFloat3(&m_vPrevRootPos);
|
||||||
|
|
||||||
_vector vRight = pTransform->Get_State(STATE::RIGHT);
|
_vector vDeltaAdjusted = {};
|
||||||
_vector vUp = pTransform->Get_State(STATE::UP);
|
|
||||||
_vector vLook = pTransform->Get_State(STATE::LOOK);
|
|
||||||
|
|
||||||
_float dx = XMVectorGetX(vDeltaAdjusted);
|
vDeltaAdjusted = XMVector3TransformNormal(vDeltaLocal, pre);
|
||||||
_float dy = XMVectorGetY(vDeltaAdjusted);
|
|
||||||
_float dz = XMVectorGetZ(vDeltaAdjusted);
|
|
||||||
|
|
||||||
_vector vDeltaWorld = vRight * dx + (-vUp * dz) + vLook * dy;
|
_vector vRight = pTransform->Get_State(STATE::RIGHT);
|
||||||
|
_vector vUp = pTransform->Get_State(STATE::UP);
|
||||||
|
_vector vLook = pTransform->Get_State(STATE::LOOK);
|
||||||
|
|
||||||
vDeltaWorld *= 0.01f;
|
_float dx = XMVectorGetX(vDeltaAdjusted);
|
||||||
|
_float dy = XMVectorGetY(vDeltaAdjusted);
|
||||||
|
_float dz = XMVectorGetZ(vDeltaAdjusted);
|
||||||
|
|
||||||
_vector vCurrentPos = pTransform->Get_State(STATE::POSITION);
|
_vector vDeltaWorld = vRight * dx + (-vUp * dz) + vLook * dy;
|
||||||
_vector vTargetPos = vCurrentPos + vDeltaWorld;
|
|
||||||
|
|
||||||
//pTransform->Set_State(STATE::POSITION, vTargetPos);
|
vDeltaWorld *= 0.01f;
|
||||||
pTransform->AccumulateMomentum(vDeltaWorld);
|
|
||||||
|
|
||||||
m_vPrevRootPos = vCurRootPos;
|
_vector vCurrentPos = pTransform->Get_State(STATE::POSITION);
|
||||||
vTranslation = XMVectorZero();
|
_vector vTargetPos = vCurrentPos + vDeltaWorld;
|
||||||
|
|
||||||
/////////////////////////////////////
|
pTransform->Set_State(STATE::POSITION, vTargetPos);
|
||||||
|
//pTransform->AccumulateMomentum(vDeltaWorld);
|
||||||
|
|
||||||
|
m_vPrevRootPos = vCurRootPos;
|
||||||
|
vTranslation = XMVectorZero();
|
||||||
|
}
|
||||||
|
///////////////////////////////////
|
||||||
|
|
||||||
_float4 curRotF4;
|
_float4 curRotF4;
|
||||||
XMStoreFloat4(&curRotF4, vRotation);
|
XMStoreFloat4(&curRotF4, vRotation);
|
||||||
@@ -301,6 +349,7 @@ HRESULT CChannel::Initialize(const CModel* pModel, SaveChannel* pSaveChannel)
|
|||||||
KeyFrame.vRotation = vRotation;
|
KeyFrame.vRotation = vRotation;
|
||||||
KeyFrame.vTranslation = vTranslation;
|
KeyFrame.vTranslation = vTranslation;
|
||||||
|
|
||||||
|
|
||||||
m_KeyFrames.push_back(KeyFrame);
|
m_KeyFrames.push_back(KeyFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,4 +400,6 @@ void CChannel::Free()
|
|||||||
__super::Free();
|
__super::Free();
|
||||||
|
|
||||||
m_KeyFrames.clear();
|
m_KeyFrames.clear();
|
||||||
|
|
||||||
|
m_KeyFrameDesc.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,9 +83,6 @@ vector<D3D11_MAPPED_SUBRESOURCE> CComputeShader::Dispatch(_uint iSRVIndex, _uint
|
|||||||
|
|
||||||
if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, D3D11_MAP_READ, 0, &StagingSubResource)))
|
if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, D3D11_MAP_READ, 0, &StagingSubResource)))
|
||||||
{
|
{
|
||||||
|
|
||||||
CInstance_Model::CS_PARTICLE_VALUE_DESC* pValueDesc = static_cast<CInstance_Model::CS_PARTICLE_VALUE_DESC*>(StagingSubResource.pData);
|
|
||||||
|
|
||||||
StagingSubResources.push_back(StagingSubResource);
|
StagingSubResources.push_back(StagingSubResource);
|
||||||
|
|
||||||
m_pContext->Unmap(m_pOutputStagingBuffer[i], 0);
|
m_pContext->Unmap(m_pOutputStagingBuffer[i], 0);
|
||||||
@@ -124,6 +121,37 @@ void CComputeShader::Bind_OutPut_SRV(_uint iIndex, _uint iBufferIndex)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ID3D11UnorderedAccessView* CComputeShader::GetOutputUAV(_uint iIndex) const
|
||||||
|
{
|
||||||
|
return m_pOutputUAV[iIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<D3D11_MAPPED_SUBRESOURCE> CComputeShader::ReadBackOutputs()
|
||||||
|
{
|
||||||
|
std::vector<D3D11_MAPPED_SUBRESOURCE> StagingSubResources;
|
||||||
|
StagingSubResources.reserve(m_iNumOutputBuffer);
|
||||||
|
|
||||||
|
for (_uint i = 0; i < m_iNumOutputBuffer; ++i)
|
||||||
|
{
|
||||||
|
if (m_pOutputStagingBuffer[i] == nullptr || m_pOutputBuffer[i] == nullptr)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
m_pContext->CopyResource(m_pOutputStagingBuffer[i], m_pOutputBuffer[i]);
|
||||||
|
|
||||||
|
D3D11_MAPPED_SUBRESOURCE mapped = {};
|
||||||
|
if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0,
|
||||||
|
D3D11_MAP_READ, 0, &mapped)))
|
||||||
|
{
|
||||||
|
StagingSubResources.push_back(mapped);
|
||||||
|
|
||||||
|
m_pContext->Unmap(m_pOutputStagingBuffer[i], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return StagingSubResources;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void CComputeShader::Reset()
|
void CComputeShader::Reset()
|
||||||
{
|
{
|
||||||
//다음 랜더링 패스에 연관되지 않도록 초기화
|
//다음 랜더링 패스에 연관되지 않도록 초기화
|
||||||
|
|||||||
@@ -126,11 +126,13 @@ void CGameInstance::Update_Engine(_float fTimeDelta)
|
|||||||
|
|
||||||
m_pObject_Manager->Update(fTimeDelta);
|
m_pObject_Manager->Update(fTimeDelta);
|
||||||
|
|
||||||
|
m_pPhysX_Manager->Update(fTimeDelta);
|
||||||
|
|
||||||
m_pObject_Manager->Late_Update(fTimeDelta);
|
m_pObject_Manager->Late_Update(fTimeDelta);
|
||||||
|
|
||||||
m_pLevel_Manager->Update(fTimeDelta);
|
m_pLevel_Manager->Update(fTimeDelta);
|
||||||
m_pObject_Manager->Clear_DeadObj();
|
m_pObject_Manager->Clear_DeadObj();
|
||||||
m_pPhysX_Manager->Update(fTimeDelta);
|
|
||||||
//m_pObstacle_Manager->Refresh_Region();
|
//m_pObstacle_Manager->Refresh_Region();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "LerpAnim.h"
|
#include "LerpAnim.h"
|
||||||
#include "Channel.h"
|
#include "Channel.h"
|
||||||
#include "Bone.h"
|
#include "Bone.h"
|
||||||
@@ -17,13 +17,13 @@ _bool CLerpAnim::Update_TransformationMatrices(const vector<CBone*>& Bones, _flo
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_uint iIndex = {};
|
/*_uint iIndex = {};
|
||||||
for (auto& pChannel : m_Channels) {
|
for (auto& pChannel : m_Channels) {
|
||||||
if (true == m_Movable[iIndex]) {
|
if (true == m_Movable[iIndex]) {
|
||||||
pChannel->Update_TransformationMatirx(Bones, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex]);
|
pChannel->Update_TransformationMatirx(Bones, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex]);
|
||||||
}
|
}
|
||||||
iIndex++;
|
iIndex++;
|
||||||
}
|
}*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,9 +50,9 @@ HRESULT CLerpAnim::Initialize(_uint iNumBone, _float fTickPerSecond, const vecto
|
|||||||
}
|
}
|
||||||
void CLerpAnim::Begin(const vector<class CBone*>& Bones, vector<LERPDESC>& StartFrames, vector<LERPDESC>& EndFrames, _float fDuration, _uint iRootBoneIndex)
|
void CLerpAnim::Begin(const vector<class CBone*>& Bones, vector<LERPDESC>& StartFrames, vector<LERPDESC>& EndFrames, _float fDuration, _uint iRootBoneIndex)
|
||||||
{
|
{
|
||||||
{ // 초기화
|
{ // 초기화
|
||||||
|
|
||||||
//KEYFRAME kf = { // 항등행렬의 키프레임
|
//KEYFRAME kf = { // 항등행렬의 키프레임
|
||||||
// { 1.f, 1.f, 1.f },
|
// { 1.f, 1.f, 1.f },
|
||||||
// { 0.f, 0.f, 0.f, 1.f },
|
// { 0.f, 0.f, 0.f, 1.f },
|
||||||
// { 0.f, 0.f, 0.f},
|
// { 0.f, 0.f, 0.f},
|
||||||
@@ -61,19 +61,19 @@ void CLerpAnim::Begin(const vector<class CBone*>& Bones, vector<LERPDESC>& Start
|
|||||||
m_fDuration = fDuration;
|
m_fDuration = fDuration;
|
||||||
m_fCurrentTrackPosition = 0.f;
|
m_fCurrentTrackPosition = 0.f;
|
||||||
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
||||||
m_Channels[i]->Set_Frame(1, m_InitialFrames[i]); // 끝프레임을 초기 값으로 채우기
|
m_Channels[i]->Set_Frame(1, m_InitialFrames[i]); // 끝프레임을 초기 값으로 채우기
|
||||||
}
|
}
|
||||||
fill(m_CurrentKeyFrameIndices.begin(), m_CurrentKeyFrameIndices.end(), 0);
|
fill(m_CurrentKeyFrameIndices.begin(), m_CurrentKeyFrameIndices.end(), 0);
|
||||||
fill(m_Movable.begin(), m_Movable.end(), false);
|
fill(m_Movable.begin(), m_Movable.end(), false);
|
||||||
}
|
}
|
||||||
{ // 실제 값 채우기
|
{ // 실제 값 채우기
|
||||||
for (LERPDESC& Desc : EndFrames) // 끝프레임을 실제 값으로 채우기
|
for (LERPDESC& Desc : EndFrames) // 끝프레임을 실제 값으로 채우기
|
||||||
{
|
{
|
||||||
_int iIndex = Desc.iSlot;
|
_int iIndex = Desc.iSlot;
|
||||||
Desc.tagKeyFrame.fTrackPosition = m_fDuration;
|
Desc.tagKeyFrame.fTrackPosition = m_fDuration;
|
||||||
m_Channels[iIndex]->Set_Frame(1, Desc.tagKeyFrame);
|
m_Channels[iIndex]->Set_Frame(1, Desc.tagKeyFrame);
|
||||||
}
|
}
|
||||||
for (_uint i = 0; i < StartFrames.size(); ++i) { // 시작 프레임을 현재 본 상태 키프레임으로 채우기
|
for (_uint i = 0; i < StartFrames.size(); ++i) { // 시작 프레임을 현재 본 상태 키프레임으로 채우기
|
||||||
_int iIndex = StartFrames[i].iSlot;
|
_int iIndex = StartFrames[i].iSlot;
|
||||||
m_Movable[iIndex] = true;
|
m_Movable[iIndex] = true;
|
||||||
m_Channels[iIndex]->Set_Frame(0, StartFrames[i].tagKeyFrame);
|
m_Channels[iIndex]->Set_Frame(0, StartFrames[i].tagKeyFrame);
|
||||||
@@ -101,4 +101,4 @@ void CLerpAnim::Free()
|
|||||||
|
|
||||||
m_CurrentKeyFrameIndices.clear();
|
m_CurrentKeyFrameIndices.clear();
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ HRESULT CMesh::Initialize_Prototype(MODEL eType, const CModel* pModel, SaveMesh*
|
|||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
Create_RawVB(m_RawVertices);
|
//Create_RawVB(m_RawVertices);
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@@ -507,20 +507,6 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save
|
|||||||
if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB)))
|
if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB)))
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
|
|
||||||
m_RawVertices.resize(m_iNumVertices);
|
|
||||||
|
|
||||||
for (_uint i = 0; i < m_iNumVertices; i++)
|
|
||||||
{
|
|
||||||
m_RawVertices[i].vPosition = pVertices[i].vPosition;
|
|
||||||
m_RawVertices[i].vNormal = pVertices[i].vNormal;
|
|
||||||
m_RawVertices[i].vTangent = pVertices[i].vTangent;
|
|
||||||
m_RawVertices[i].vBinormal = pVertices[i].vBinormal;
|
|
||||||
m_RawVertices[i].vTexcoord = pVertices[i].vTexcoord;
|
|
||||||
|
|
||||||
m_RawVertices[i].vBlendIndex = pVertices[i].vBlendIndex;
|
|
||||||
m_RawVertices[i].vBlendWeight = pVertices[i].vBlendWeight;
|
|
||||||
}
|
|
||||||
|
|
||||||
Safe_Delete_Array(pVertices);
|
Safe_Delete_Array(pVertices);
|
||||||
|
|
||||||
@@ -528,61 +514,6 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HRESULT CMesh::Create_RawVB(vector<MESH_DESC>& RawVertices)
|
|
||||||
{
|
|
||||||
m_iRawVertexStride = sizeof(MESH_DESC);
|
|
||||||
|
|
||||||
D3D11_BUFFER_DESC desc{};
|
|
||||||
desc.Usage = D3D11_USAGE_DEFAULT;
|
|
||||||
desc.ByteWidth = m_iRawVertexStride *m_iNumVertices;
|
|
||||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
|
||||||
desc.CPUAccessFlags = 0;
|
|
||||||
desc.StructureByteStride = m_iRawVertexStride;
|
|
||||||
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
|
||||||
|
|
||||||
D3D11_SUBRESOURCE_DATA init{};
|
|
||||||
init.pSysMem = RawVertices.data();
|
|
||||||
|
|
||||||
m_pDevice->CreateBuffer(&desc, &init, &m_pVBMesh);
|
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CMesh::ComputSkinning(CComputeShader* ComputeShader, ID3D11Buffer* ConstantBuffer)
|
|
||||||
{
|
|
||||||
if (ComputeShader == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_uint iGroupCountX = (m_iNumVertices + 255) / 256;
|
|
||||||
|
|
||||||
ID3D11Buffer* CSBuffers[] = {
|
|
||||||
m_pVBMesh
|
|
||||||
};
|
|
||||||
|
|
||||||
vector<D3D11_MAPPED_SUBRESOURCE> OutSubResources = {};
|
|
||||||
D3D11_MAPPED_SUBRESOURCE VBInstanceResource = {};
|
|
||||||
|
|
||||||
OutSubResources = ComputeShader->Dispatch(0, 0, _float3((_float)iGroupCountX, 1.f, 1.f), CSBuffers, ConstantBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMesh::FillBoneDesc(const vector<_float4x4>& CombinedMatrices, BONE_DESC* pOut)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < m_iNumBones; ++i)
|
|
||||||
{
|
|
||||||
const _float4x4& offset = m_offsetMatrices[i];
|
|
||||||
const _float4x4& combined = CombinedMatrices[m_BoneIndices[i]];
|
|
||||||
|
|
||||||
_matrix matOffset = XMLoadFloat4x4(&offset);
|
|
||||||
_matrix matCombined = XMLoadFloat4x4(&combined);
|
|
||||||
|
|
||||||
XMStoreFloat4x4(&pOut->BoneMatrix[i], matOffset * matCombined);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT CMesh::Initialize(void* pArg)
|
HRESULT CMesh::Initialize(void* pArg)
|
||||||
{
|
{
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -891,7 +822,6 @@ void CMesh::Free()
|
|||||||
__super::Free();
|
__super::Free();
|
||||||
|
|
||||||
Safe_Delete_Array(m_pBoneMatrices);
|
Safe_Delete_Array(m_pBoneMatrices);
|
||||||
SAFE_RELEASE(m_pVBMesh);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMesh::Describe_Entity()
|
void CMesh::Describe_Entity()
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ _bool CModel::Play_Animation(_float fTimeDelta,CTransform* pTransform)
|
|||||||
_float fRatio = m_fBlendTime / m_fBlendDuration;
|
_float fRatio = m_fBlendTime / m_fBlendDuration;
|
||||||
fRatio = min(fRatio, 1.f);
|
fRatio = min(fRatio, 1.f);
|
||||||
|
|
||||||
m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_bIsLoop, fTimeDelta, pTransform);
|
m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_pLocalPos, m_bIsLoop, fTimeDelta, pTransform);
|
||||||
m_Animations[m_iCurrentAnimIndex]->InterpAnim(m_Animations[m_iPreAnimIndex], m_Bones, fRatio);
|
m_Animations[m_iCurrentAnimIndex]->InterpAnim(m_Animations[m_iPreAnimIndex], m_Bones, fRatio);
|
||||||
|
|
||||||
if (fRatio >= 1.f)
|
if (fRatio >= 1.f)
|
||||||
@@ -171,38 +171,20 @@ _bool CModel::Play_Animation(_float fTimeDelta,CTransform* pTransform)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_bIsLoop, fTimeDelta, pTransform);
|
m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_pLocalPos, m_bIsLoop, fTimeDelta, pTransform);
|
||||||
m_iPreAnimIndex = m_iCurrentAnimIndex;
|
m_iPreAnimIndex = m_iCurrentAnimIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (_int i = 0; i < m_Bones.size(); ++i)
|
for (auto& pBone : m_Bones)
|
||||||
{
|
{
|
||||||
m_Bones[i]->Update_CombinedTransformationMatrix(m_Bones, XMLoadFloat4x4(&m_PreTransformMatrix));
|
pBone->Update_CombinedTransformationMatrix(m_Bones, XMLoadFloat4x4(&m_PreTransformMatrix));
|
||||||
|
|
||||||
if (i == m_iRootBoneIndex) { // 루트본의 매트릭스를 갱신했다면 애니메이션에 맞게 이동량을 루트본에서 트랜스폼으로 보정시킴
|
|
||||||
if (true == m_pLerpAnim->IsLerping()) { // 럴프중이었으면 이동량 반영 x
|
|
||||||
_matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex);
|
|
||||||
currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f);
|
|
||||||
m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex); // 현재 루트본의 컴바인드 트랜스폼을 꺼내오고
|
|
||||||
_matrix deltaAnimMatrix = XMMatrixMultiply(XMMatrixInverse(nullptr, m_PrevAnimationMatrix), currAnimMatrix); // 이전 트랜스폼이랑 비교해서 델타매트릭스를 꺼냄
|
|
||||||
_vector momentum = XMMatrixMultiply(deltaAnimMatrix, XMMatrixRotationQuaternion(m_pTransform->Get_QuarternionVector())).r[3];
|
|
||||||
deltaAnimMatrix.r[3] = XMVectorSetW(momentum, 0.f);
|
|
||||||
|
|
||||||
m_pTransform->AccumulateMomentum(deltaAnimMatrix.r[3]); // 모체 트랜스폼에 이동량 반영
|
|
||||||
//m_pTransform->Set_State(STATE::POSITION, m_pTransform->Get_State(STATE::POSITION) + deltaAnimMatrix.r[3]);
|
|
||||||
|
|
||||||
m_PrevAnimationMatrix = currAnimMatrix;
|
|
||||||
currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f);
|
|
||||||
m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix); // 루트본의 이동량 소거
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_bIsFinishedAnim)
|
if (m_bIsFinishedAnim)
|
||||||
|
{
|
||||||
m_Animations[m_iCurrentAnimIndex]->ResetRootMotion();
|
m_Animations[m_iCurrentAnimIndex]->ResetRootMotion();
|
||||||
|
m_Animations[m_iCurrentAnimIndex]->Depart_Animation();
|
||||||
|
}
|
||||||
|
|
||||||
return m_bIsFinishedAnim;
|
return m_bIsFinishedAnim;
|
||||||
}
|
}
|
||||||
@@ -902,79 +884,124 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma
|
|||||||
|
|
||||||
HRESULT CModel::Create_CS()
|
HRESULT CModel::Create_CS()
|
||||||
{
|
{
|
||||||
_uint vertexCount = 0;
|
_uint CS1_InputStrides[] = {
|
||||||
_uint MaxvertexCount = 0;
|
sizeof(KEYFRAME_DESC),
|
||||||
for (_uint i = 0; i < m_Meshes.size(); ++i)
|
sizeof(CHANNEL_DESC),
|
||||||
{
|
|
||||||
vertexCount = m_Meshes[i]->Get_Vertex();
|
|
||||||
if (MaxvertexCount < vertexCount)
|
|
||||||
MaxvertexCount = vertexCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
_uint CS_InputStrides[] = {
|
|
||||||
sizeof(MESH_DESC)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t meshCount = m_Meshes.size();
|
_uint CS1_OutputStrides[] = {
|
||||||
|
sizeof(LOCALPOS_DESC),
|
||||||
_uint* CS_OutputStrides = new _uint[meshCount];
|
};
|
||||||
|
|
||||||
for (size_t i = 0; i < meshCount; i++)
|
|
||||||
{
|
|
||||||
CS_OutputStrides[i] = sizeof(SKINNG_MESH_DESC)*(_uint)meshCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext,
|
m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext, L"../Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl",
|
||||||
L"../Bin/Resources/ShaderFiles/Shader_Mesh_Compute.hlsl", "CS_MAIN", MaxvertexCount, 1, (_uint)meshCount, CS_InputStrides,CS_OutputStrides);
|
"CS_LocalSRT", (_uint)m_Bones.size(), 0, 1, nullptr, CS1_OutputStrides
|
||||||
|
);
|
||||||
|
|
||||||
if (m_pComputeShader == nullptr)
|
if (!m_pComputeShader)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
Safe_Delete_Array(CS_OutputStrides);
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CModel::ComputeSkinning()
|
void CModel::Create_Temp()
|
||||||
{
|
{
|
||||||
Get_BoneMatrix();
|
for (auto& anim : m_Animations)
|
||||||
for (_uint i = 0; i < m_iNumMeshes; ++i)
|
|
||||||
{
|
{
|
||||||
D3D11_MAPPED_SUBRESOURCE ConstantSubResource{};
|
anim->CreateGPUData(m_pDevice);
|
||||||
if (SUCCEEDED(m_pContext->Map(m_pConstantBuffer, 0,
|
|
||||||
D3D11_MAP_WRITE_DISCARD, 0, &ConstantSubResource)))
|
|
||||||
{
|
|
||||||
CMesh::BONE_DESC* pDesc =
|
|
||||||
static_cast<CMesh::BONE_DESC*>(ConstantSubResource.pData);
|
|
||||||
|
|
||||||
m_Meshes[i]->FillBoneDesc(m_BoneMatrix,pDesc);
|
|
||||||
|
|
||||||
m_pContext->Unmap(m_pConstantBuffer, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Meshes[i]->ComputSkinning(m_pComputeShader, m_pConstantBuffer);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CModel::Create_LocalPosVB()
|
||||||
|
{
|
||||||
|
_uint iCount = (_uint)m_Bones.size();
|
||||||
|
_uint iStride = sizeof(LOCALPOS_DESC);
|
||||||
|
|
||||||
|
D3D11_BUFFER_DESC desc = {};
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.ByteWidth = iStride * iCount;
|
||||||
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
|
||||||
|
desc.CPUAccessFlags = 0;
|
||||||
|
desc.StructureByteStride = iStride;
|
||||||
|
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||||
|
|
||||||
|
HRESULT hr = m_pDevice->CreateBuffer(&desc, nullptr, &m_pLocalPosBuffer);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void CModel::Create_Con()
|
void CModel::Create_Con()
|
||||||
{
|
{
|
||||||
D3D11_BUFFER_DESC cbDesc = {};
|
D3D11_BUFFER_DESC cbDesc = {};
|
||||||
cbDesc.Usage = D3D11_USAGE_DYNAMIC;
|
cbDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
cbDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||||
cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
cbDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
cbDesc.ByteWidth = sizeof(BONE_DESC);
|
cbDesc.ByteWidth = sizeof(ANIMSTATE_DESC);
|
||||||
|
|
||||||
if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pConstantBuffer)))
|
if (FAILED(m_pDevice->CreateBuffer(&cbDesc, nullptr, &m_pConstantBuffer)))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CModel::Bind_CS_Output(_uint Index, _uint iBufferIndex)
|
|
||||||
{
|
|
||||||
if (m_pComputeShader == nullptr)
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
m_pComputeShader->Bind_OutPut_SRV(Index, iBufferIndex);
|
void CModel::UpdateAnimationCS()
|
||||||
|
{
|
||||||
|
D3D11_MAPPED_SUBRESOURCE sub{};
|
||||||
|
if (SUCCEEDED(m_pContext->Map(m_pConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &sub)))
|
||||||
|
{
|
||||||
|
ANIMSTATE_DESC* pDesc = (ANIMSTATE_DESC*)sub.pData;
|
||||||
|
|
||||||
|
CAnimation* pAnim = m_Animations[m_iCurrentAnimIndex];
|
||||||
|
pDesc->CurrentTime = pAnim->Get_CurrentTrackPosition();
|
||||||
|
pDesc->Duration = pAnim->Get_Duration();
|
||||||
|
pDesc->Speed = pAnim->Get_AnimSpeed();
|
||||||
|
pDesc->BoneCount = (_uint)m_Bones.size();
|
||||||
|
pDesc->PreTransformMatrix = m_PreTransformMatrix;
|
||||||
|
m_pContext->Unmap(m_pConstantBuffer, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModel::ComputeAnimation()
|
||||||
|
{
|
||||||
|
UpdateAnimationCS();
|
||||||
|
|
||||||
|
_uint iGroupCountX = ((_uint)m_Bones.size() + 255) / 256;
|
||||||
|
|
||||||
|
CAnimation* pAnim = m_Animations[m_iCurrentAnimIndex];
|
||||||
|
ID3D11ShaderResourceView* srvs[2] = {
|
||||||
|
pAnim->Get_KeyFrameSrv(),
|
||||||
|
pAnim->Get_ChannelSrv(),
|
||||||
|
};
|
||||||
|
|
||||||
|
m_pContext->CSSetShader(m_pComputeShader->Get_Compute(), nullptr, 0);
|
||||||
|
m_pContext->CSSetConstantBuffers(0, 1, &m_pConstantBuffer);
|
||||||
|
m_pContext->CSSetShaderResources(0, 2, srvs);
|
||||||
|
|
||||||
|
ID3D11UnorderedAccessView* uavs[1] = { m_pComputeShader->GetOutputUAV(0) };
|
||||||
|
m_pContext->CSSetUnorderedAccessViews(0, 1, uavs, nullptr);
|
||||||
|
|
||||||
|
m_pContext->Dispatch(iGroupCountX, 1, 1);
|
||||||
|
|
||||||
|
auto outSubs = m_pComputeShader->ReadBackOutputs();
|
||||||
|
m_pLocalPos = static_cast<LOCALPOS_DESC*>(outSubs[0].pData);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HRESULT CModel::Create_ParentVB()
|
||||||
|
{
|
||||||
|
D3D11_BUFFER_DESC desc{};
|
||||||
|
desc.Usage = D3D11_USAGE_DEFAULT;
|
||||||
|
desc.ByteWidth = (_int)sizeof(PARENT_DESC) * (_uint)m_Bones.size();
|
||||||
|
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||||
|
desc.CPUAccessFlags = 0;
|
||||||
|
desc.StructureByteStride = (_int)sizeof(PARENT_DESC);
|
||||||
|
desc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA init{};
|
||||||
|
init.pSysMem = m_Parent.data();
|
||||||
|
|
||||||
|
m_pDevice->CreateBuffer(&desc, &init, &m_pParentBuffer);
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@@ -988,8 +1015,6 @@ void CModel::Get_BoneMatrix()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix)
|
HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix)
|
||||||
{
|
{
|
||||||
m_eType = eType;
|
m_eType = eType;
|
||||||
@@ -1032,7 +1057,7 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
|||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(Ready_Animations())) {
|
if (FAILED(Ready_Animations(m_Bones))) {
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
@@ -1317,12 +1342,25 @@ HRESULT CModel::Initialize(void* pArg)
|
|||||||
m_pTransform = m_pOwner->Get_Component<CTransform>();
|
m_pTransform = m_pOwner->Get_Component<CTransform>();
|
||||||
SAFE_ADDREF(m_pTransform);
|
SAFE_ADDREF(m_pTransform);
|
||||||
|
|
||||||
/*Create_Con();
|
|
||||||
|
if (m_eType == MODEL::ANIM)
|
||||||
|
{
|
||||||
|
Create_Temp();
|
||||||
|
m_Parent.resize(m_Bones.size());
|
||||||
|
for (size_t i = 0; i < (_uint)m_Bones.size(); i++)
|
||||||
|
{
|
||||||
|
m_Parent[i].ParentIndex = m_Bones[i]->Get_ParentBoneIndex();
|
||||||
|
}
|
||||||
|
|
||||||
if (FAILED(Create_CS()))
|
if (FAILED(Create_CS()))
|
||||||
return E_FAIL;*/
|
return E_FAIL;
|
||||||
|
|
||||||
|
Create_Con();
|
||||||
|
Create_LocalPosVB();
|
||||||
|
Create_ParentVB();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@@ -1378,13 +1416,13 @@ HRESULT CModel::Ready_Bones(const std::vector<SaveNode>& allNodes, _int currentI
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT CModel::Ready_Animations()
|
HRESULT CModel::Ready_Animations(const vector<CBone*>& Bones)
|
||||||
{
|
{
|
||||||
m_iNumAnimations = m_pSaveModel->AnimationCount;
|
m_iNumAnimations = m_pSaveModel->AnimationCount;
|
||||||
|
|
||||||
for (size_t i = 0; i < m_iNumAnimations; i++)
|
for (size_t i = 0; i < m_iNumAnimations; i++)
|
||||||
{
|
{
|
||||||
CAnimation* pAnimation = CAnimation::Create(this, &m_pSaveModel->Animations[i]);
|
CAnimation* pAnimation = CAnimation::Create(Bones,this, &m_pSaveModel->Animations[i]);
|
||||||
if (nullptr == pAnimation)
|
if (nullptr == pAnimation)
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
|
|
||||||
@@ -1425,6 +1463,11 @@ void CModel::Free()
|
|||||||
{
|
{
|
||||||
__super::Free();
|
__super::Free();
|
||||||
|
|
||||||
|
|
||||||
|
SAFE_RELEASE(m_pComputeShader);
|
||||||
|
SAFE_RELEASE(m_pConstantBuffer);
|
||||||
|
SAFE_RELEASE(m_pParentBuffer);
|
||||||
|
SAFE_RELEASE(m_pLocalPosBuffer);
|
||||||
for (auto& pAnimation : m_Animations) {
|
for (auto& pAnimation : m_Animations) {
|
||||||
SAFE_RELEASE(pAnimation);
|
SAFE_RELEASE(pAnimation);
|
||||||
}
|
}
|
||||||
@@ -1448,8 +1491,8 @@ void CModel::Free()
|
|||||||
|
|
||||||
m_SaveModel.clear();
|
m_SaveModel.clear();
|
||||||
|
|
||||||
SAFE_RELEASE(m_pComputeShader);
|
m_Parent.clear();
|
||||||
SAFE_RELEASE(m_pConstantBuffer);
|
m_AnimRanges.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
void CModel::Describe_Entity()
|
void CModel::Describe_Entity()
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class ENGINE_DLL CAnimation : public CBase
|
|||||||
CAnimation(const CAnimation& rhs);
|
CAnimation(const CAnimation& rhs);
|
||||||
virtual ~CAnimation() = default;
|
virtual ~CAnimation() = default;
|
||||||
public:
|
public:
|
||||||
_bool Update_TransformationMatrices(const vector<class CBone*>& Bones, _bool bIsLoop, _float fTimeDelta, class CTransform* pTransform = nullptr);
|
_bool Update_TransformationMatrices(const vector<class CBone*>& Bones, const LOCALPOS_DESC* pLocalPosArray, _bool bIsLoop, _float fTimeDelta, class CTransform* pTransform = nullptr);
|
||||||
void ResetRootMotion();
|
void ResetRootMotion();
|
||||||
void Depart_Animation();
|
void Depart_Animation();
|
||||||
void Set_AnimPause(_bool bValue) { m_bPause = bValue; }
|
void Set_AnimPause(_bool bValue) { m_bPause = bValue; }
|
||||||
@@ -21,6 +21,7 @@ class ENGINE_DLL CAnimation : public CBase
|
|||||||
void Set_AnimProgressPostion(const _char* pChannelName, _uint iPosition);
|
void Set_AnimProgressPostion(const _char* pChannelName, _uint iPosition);
|
||||||
vector<_int>* Capture_Bones();
|
vector<_int>* Capture_Bones();
|
||||||
void InterpAnim(CAnimation* pPreAnim, vector<CBone*>& Bones, float fRatio);
|
void InterpAnim(CAnimation* pPreAnim, vector<CBone*>& Bones, float fRatio);
|
||||||
|
void CreateGPUData(ID3D11Device* pDevice);
|
||||||
vector<LERPDESC> Get_StartFrameInformations() { return m_StartKeyFrames; }
|
vector<LERPDESC> Get_StartFrameInformations() { return m_StartKeyFrames; }
|
||||||
const _string& Get_Name() const { return m_strName; }
|
const _string& Get_Name() const { return m_strName; }
|
||||||
|
|
||||||
@@ -29,6 +30,14 @@ class ENGINE_DLL CAnimation : public CBase
|
|||||||
_float Get_CurrentTrackPosition() { return m_fCurrentTrackPosition; }
|
_float Get_CurrentTrackPosition() { return m_fCurrentTrackPosition; }
|
||||||
void Set_AnimSpeed(_float fSpeed) { m_fAnimSpeed = fSpeed; }
|
void Set_AnimSpeed(_float fSpeed) { m_fAnimSpeed = fSpeed; }
|
||||||
_float Get_AnimSpeed() { return m_fAnimSpeed; }
|
_float Get_AnimSpeed() { return m_fAnimSpeed; }
|
||||||
|
|
||||||
|
_uint Get_ChannelCount() { return m_iNumChannels; }
|
||||||
|
_float Get_Duration() { return m_fDuration; }
|
||||||
|
|
||||||
|
ID3D11Buffer* Get_KeyFrameBuffer() { return m_pKeyFrameBuffer; }
|
||||||
|
ID3D11Buffer* Get_ChannelBuffer() { return m_pChannelBuffer; }
|
||||||
|
ID3D11ShaderResourceView* Get_KeyFrameSrv() { return m_pKeyFrameSrv; }
|
||||||
|
ID3D11ShaderResourceView* Get_ChannelSrv() { return m_pChannelSrv; }
|
||||||
#ifdef EDITOR_PROJECT
|
#ifdef EDITOR_PROJECT
|
||||||
private:
|
private:
|
||||||
HRESULT Initialize(const vector<class CBone*>& Bones, const aiAnimation* pAIAnimation);
|
HRESULT Initialize(const vector<class CBone*>& Bones, const aiAnimation* pAIAnimation);
|
||||||
@@ -40,11 +49,16 @@ class ENGINE_DLL CAnimation : public CBase
|
|||||||
private:
|
private:
|
||||||
HRESULT Initialize(HANDLE hFile, DWORD& dwByte);
|
HRESULT Initialize(HANDLE hFile, DWORD& dwByte);
|
||||||
// 바이너리
|
// 바이너리
|
||||||
HRESULT Initialize(const class CModel* pModel,SaveAnimation* pSaveAnimation);
|
HRESULT Initialize(const vector<CBone*>& Bones, const class CModel* pModel,SaveAnimation* pSaveAnimation);
|
||||||
//
|
//
|
||||||
HRESULT Combined_Initialize();
|
HRESULT Combined_Initialize();
|
||||||
_uint Get_BoneIndex(const char* pChannelName);
|
_uint Get_BoneIndex(const char* pChannelName);
|
||||||
|
|
||||||
|
HRESULT CreateKeyFrameBuffer(ID3D11Device* pDevice, vector<KEYFRAME_DESC> keyframe);
|
||||||
|
HRESULT CreateChannelBuffer(ID3D11Device* pDevice, vector<CHANNEL_DESC> channel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SaveAnimation* m_pSaveAnim = { nullptr };
|
SaveAnimation* m_pSaveAnim = { nullptr };
|
||||||
_char m_szName[MAX_PATH] = {};
|
_char m_szName[MAX_PATH] = {};
|
||||||
@@ -63,11 +77,22 @@ class ENGINE_DLL CAnimation : public CBase
|
|||||||
|
|
||||||
vector<_int> m_DestBones; // 이 애니메이션에서 영향을 받는 본들의 집합
|
vector<_int> m_DestBones; // 이 애니메이션에서 영향을 받는 본들의 집합
|
||||||
vector<LERPDESC> m_StartKeyFrames; // 이 애니메이션의 영향을 받는 본들의 초기값
|
vector<LERPDESC> m_StartKeyFrames; // 이 애니메이션의 영향을 받는 본들의 초기값
|
||||||
vector<_matrix> m_vBoneTransformationMatrix = {};
|
vector<_matrix> m_vBoneTransformationMatrix = {};
|
||||||
|
|
||||||
|
_uint m_iChannelCount;
|
||||||
|
_uint m_iKeyframeCount;
|
||||||
|
_uint m_iBoneCount;
|
||||||
|
vector<KEYFRAME_DESC> m_KeyFrameDesc;
|
||||||
|
vector<CHANNEL_DESC> m_ChannelDesc;
|
||||||
|
|
||||||
|
ID3D11Buffer* m_pKeyFrameBuffer;
|
||||||
|
ID3D11Buffer* m_pChannelBuffer;
|
||||||
|
ID3D11ShaderResourceView* m_pKeyFrameSrv = {};
|
||||||
|
ID3D11ShaderResourceView* m_pChannelSrv = {};
|
||||||
public:
|
public:
|
||||||
static CAnimation* Create(HANDLE hFile, DWORD& dwByte);
|
static CAnimation* Create(HANDLE hFile, DWORD& dwByte);
|
||||||
// 바이너리
|
// 바이너리
|
||||||
static CAnimation* Create(const class CModel* pModel, SaveAnimation* pSaveAnimation);
|
static CAnimation* Create(const vector<CBone*>& Bones, const class CModel* pModel, SaveAnimation* pSaveAnimation);
|
||||||
//
|
//
|
||||||
CAnimation* Clone();
|
CAnimation* Clone();
|
||||||
virtual void Free() override;
|
virtual void Free() override;
|
||||||
|
|||||||
@@ -28,14 +28,13 @@ class ENGINE_DLL CBone final : public CBase
|
|||||||
_float3 Get_LocalPosition();
|
_float3 Get_LocalPosition();
|
||||||
void Update_CombinedTransformationMatrix(const vector<CBone*>& Bones, _fmatrix PreTransformMatrix);
|
void Update_CombinedTransformationMatrix(const vector<CBone*>& Bones, _fmatrix PreTransformMatrix);
|
||||||
void Set_TransformationMatrix(_fmatrix TransformationMatrix); // 애니메이션에서 현재 로컬 매트릭스를 변경할 때 사용된다
|
void Set_TransformationMatrix(_fmatrix TransformationMatrix); // 애니메이션에서 현재 로컬 매트릭스를 변경할 때 사용된다
|
||||||
|
_int Get_ParentBoneIndex() { return m_iParentBoneIndex; }
|
||||||
private:
|
private:
|
||||||
_char m_szName[MAX_PATH] = {}; // 본의 이름
|
_char m_szName[MAX_PATH] = {}; // 본의 이름
|
||||||
_float4x4 m_TransformationMatrix = {}; // 본의 현재 로컬 매트릭스
|
_float4x4 m_TransformationMatrix = {}; // 본의 현재 로컬 매트릭스
|
||||||
_float4x4 m_CombinedTransformationMatrix = {}; // 본의 루트노드로부터 상대적인 복합매트릭스 ( 부모노드는 PreTranformMatrix와 월드좌표로부터 상대적임 )
|
_float4x4 m_CombinedTransformationMatrix = {}; // 본의 루트노드로부터 상대적인 복합매트릭스 ( 부모노드는 PreTranformMatrix와 월드좌표로부터 상대적임 )
|
||||||
_int m_iParentBoneIndex = { -1 }; // 부모본의 인덱스 ( 모델에 있는 본벡터의 인덱스 ) ( 부모는 인덱스 -1 고정 )
|
_int m_iParentBoneIndex = { -1 }; // 부모본의 인덱스 ( 모델에 있는 본벡터의 인덱스 ) ( 부모는 인덱스 -1 고정 )
|
||||||
_float4x4 m_matInitial = {};
|
_float4x4 m_matInitial = {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HRESULT Initialize(HANDLE hFile, DWORD& dwByte);
|
HRESULT Initialize(HANDLE hFile, DWORD& dwByte);
|
||||||
// 바이너리
|
// 바이너리
|
||||||
|
|||||||
@@ -13,19 +13,23 @@ class ENGINE_DLL CChannel : public CBase
|
|||||||
#ifdef EDITOR_PROJECT
|
#ifdef EDITOR_PROJECT
|
||||||
private:
|
private:
|
||||||
HRESULT Initialize(const vector<class CBone*>& Bones, const aiNodeAnim* pAIChannel);
|
HRESULT Initialize(const vector<class CBone*>& Bones, const aiNodeAnim* pAIChannel);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte);
|
HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte);
|
||||||
static CChannel* Create(const vector<class CBone*>& Bones, const aiNodeAnim* pAIChannel);
|
static CChannel* Create(const vector<class CBone*>& Bones, const aiNodeAnim* pAIChannel);
|
||||||
|
void Fill_GPU_Keyframes(vector<KEYFRAME_DESC>& outKeyframes);
|
||||||
|
CHANNEL_DESC Fill_GPU_ChannelDesc();
|
||||||
#endif // EDITOR_PROJECT
|
#endif // EDITOR_PROJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Update_TransformationMatirx(const vector<class CBone*>& Bones, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex,class CTransform* pTransform=nullptr);
|
void Update_TransformationMatirx(const vector<class CBone*>& Bones, const LOCALPOS_DESC* pLocalPosArray, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex,class CTransform* pTransform=nullptr);
|
||||||
_int Get_BoneIndex() { return { m_iBoneIndex }; }
|
_int Get_BoneIndex() { return { m_iBoneIndex }; }
|
||||||
void Set_BoneIndex(_int iBoneIndex) { m_iBoneIndex = iBoneIndex; }
|
void Set_BoneIndex(_int iBoneIndex) { m_iBoneIndex = iBoneIndex; }
|
||||||
void ResetRootMotion() {
|
void ResetRootMotion() {
|
||||||
m_vPrevRootPos = { 0.f, 0.f, 0.f };
|
m_vPrevRootPos = { 0.f, 0.f, 0.f };
|
||||||
m_vPrevRootRot = { 0.f,0.f,0.f,0.f };
|
m_vPrevRootRot = { 0.f,0.f,0.f,0.f };
|
||||||
m_bInitialRootRotSaved = false;
|
m_bInitialRootRotSaved = false;
|
||||||
|
m_bInitialRootPos = false;
|
||||||
}
|
}
|
||||||
_matrix Get_BoneTransformationMatrix() { return m_BoneTransformationMatrix; }
|
_matrix Get_BoneTransformationMatrix() { return m_BoneTransformationMatrix; }
|
||||||
|
|
||||||
@@ -53,7 +57,10 @@ class ENGINE_DLL CChannel : public CBase
|
|||||||
_matrix m_BoneTransformationMatrix = {};
|
_matrix m_BoneTransformationMatrix = {};
|
||||||
_float m_fPrevYaw = 0.f;
|
_float m_fPrevYaw = 0.f;
|
||||||
_bool m_bInitialRootRotSaved = {false};
|
_bool m_bInitialRootRotSaved = {false};
|
||||||
_float4 m_vInitialRootRot = {};
|
_bool m_bInitialRootPos = { false };
|
||||||
|
_float4 m_vInitialRootRot = {};
|
||||||
|
|
||||||
|
vector<KEYFRAME_DESC> m_KeyFrameDesc;
|
||||||
public:
|
public:
|
||||||
static CChannel* Create(const vector<class CBone*>& Bones, _uint iIndex); // 럴프전용
|
static CChannel* Create(const vector<class CBone*>& Bones, _uint iIndex); // 럴프전용
|
||||||
static CChannel* Create(HANDLE hFile, DWORD& dwByte);
|
static CChannel* Create(HANDLE hFile, DWORD& dwByte);
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ class ENGINE_DLL CComputeShader final : public CBase
|
|||||||
vector<D3D11_MAPPED_SUBRESOURCE> Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer = nullptr);
|
vector<D3D11_MAPPED_SUBRESOURCE> Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer = nullptr);
|
||||||
void Bind_OutPut_SRV(_uint iIndex, _uint iBufferIndex);
|
void Bind_OutPut_SRV(_uint iIndex, _uint iBufferIndex);
|
||||||
ID3D11ComputeShader* Get_Compute() { return m_pComputeShader; }
|
ID3D11ComputeShader* Get_Compute() { return m_pComputeShader; }
|
||||||
|
ID3D11UnorderedAccessView* GetOutputUAV(_uint iIndex) const;
|
||||||
|
vector<D3D11_MAPPED_SUBRESOURCE> ReadBackOutputs();
|
||||||
private:
|
private:
|
||||||
void Bind_SRV(_uint iIndex);
|
void Bind_SRV(_uint iIndex);
|
||||||
void Bind_UAV(_uint iIndex);
|
void Bind_UAV(_uint iIndex);
|
||||||
|
|||||||
@@ -362,4 +362,42 @@ typedef struct tagOnCollsionInfo
|
|||||||
|
|
||||||
}ON_COLLISION_INFO;
|
}ON_COLLISION_INFO;
|
||||||
|
|
||||||
|
typedef struct tagKeyFrameDesc
|
||||||
|
{
|
||||||
|
_float3 vScale;
|
||||||
|
_float4 vRotation;
|
||||||
|
_float3 vTranslation;
|
||||||
|
_float fTrackPosition;
|
||||||
|
|
||||||
|
}KEYFRAME_DESC;
|
||||||
|
|
||||||
|
typedef struct tagChannelDesc
|
||||||
|
{
|
||||||
|
_uint StartIndex;
|
||||||
|
_uint KeyCount;
|
||||||
|
_uint BoneIndex;
|
||||||
|
//_uint Padding;
|
||||||
|
}CHANNEL_DESC;
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct tagParentDesc
|
||||||
|
{
|
||||||
|
_int ParentIndex;
|
||||||
|
}PARENT_DESC;
|
||||||
|
|
||||||
|
typedef struct tagLocalPos
|
||||||
|
{
|
||||||
|
_float3 Scale;
|
||||||
|
_float pad0;
|
||||||
|
_float4 Rotation;
|
||||||
|
_float3 Translation;
|
||||||
|
_float pad1;
|
||||||
|
}LOCALPOS_DESC;
|
||||||
|
|
||||||
|
typedef struct tagBoneDesc
|
||||||
|
{
|
||||||
|
_float4x4 Combined;
|
||||||
|
}BONE_DESC;
|
||||||
|
|
||||||
|
|
||||||
NS_END
|
NS_END
|
||||||
|
|||||||
@@ -6,36 +6,6 @@ NS_BEGIN(Engine)
|
|||||||
|
|
||||||
class ENGINE_DLL CMesh final : public CVIBuffer
|
class ENGINE_DLL CMesh final : public CVIBuffer
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
typedef struct tagMeshDesc
|
|
||||||
{
|
|
||||||
_float3 vPosition = {};
|
|
||||||
_float3 vNormal = {};
|
|
||||||
_float3 vTangent = {};
|
|
||||||
_float3 vBinormal = {};
|
|
||||||
_float2 vTexcoord = {};
|
|
||||||
|
|
||||||
XMUINT4 vBlendIndex = {};
|
|
||||||
_float4 vBlendWeight = {};
|
|
||||||
|
|
||||||
}MESH_DESC;
|
|
||||||
|
|
||||||
typedef struct tagSkinngMeshDesc
|
|
||||||
{
|
|
||||||
_float3 vPosition = {};
|
|
||||||
_float3 vNormal = {};
|
|
||||||
_float3 vTangent = {};
|
|
||||||
_float3 vBinormal = {};
|
|
||||||
_float2 vTexcoord = {};
|
|
||||||
|
|
||||||
}SKINNG_MESH_DESC;
|
|
||||||
|
|
||||||
typedef struct tagBoneDesc
|
|
||||||
{
|
|
||||||
_float4x4 BoneMatrix[512];
|
|
||||||
}BONE_DESC;
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
CMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||||
CMesh(const CMesh& rhs);
|
CMesh(const CMesh& rhs);
|
||||||
@@ -66,10 +36,6 @@ class ENGINE_DLL CMesh final : public CVIBuffer
|
|||||||
virtual HRESULT Bind_Resources_Instance(ID3D11Buffer* pVBInstance, _uint iInstanceStride, _uint iBufferCount);
|
virtual HRESULT Bind_Resources_Instance(ID3D11Buffer* pVBInstance, _uint iInstanceStride, _uint iBufferCount);
|
||||||
virtual HRESULT Render_Instance(_uint iNumInstance);
|
virtual HRESULT Render_Instance(_uint iNumInstance);
|
||||||
|
|
||||||
void ComputSkinning(class CComputeShader* ComputeShader, ID3D11Buffer* ConstantBuffer);
|
|
||||||
|
|
||||||
void FillBoneDesc(const vector<_float4x4>& CombinedMatrices, BONE_DESC* pOut);
|
|
||||||
|
|
||||||
_uint Get_Vertex() { return m_iNumVertices; }
|
_uint Get_Vertex() { return m_iNumVertices; }
|
||||||
private:
|
private:
|
||||||
virtual HRESULT Initialize_Prototype(HANDLE hFile, DWORD& dwByte);
|
virtual HRESULT Initialize_Prototype(HANDLE hFile, DWORD& dwByte);
|
||||||
@@ -81,7 +47,7 @@ class ENGINE_DLL CMesh final : public CVIBuffer
|
|||||||
HRESULT Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix);
|
HRESULT Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix);
|
||||||
HRESULT Ready_VertexBuffer_For_Anim(const class CModel* pModel, SaveMesh* _SaveMesh);
|
HRESULT Ready_VertexBuffer_For_Anim(const class CModel* pModel, SaveMesh* _SaveMesh);
|
||||||
|
|
||||||
HRESULT Create_RawVB(vector<MESH_DESC>& RawVertices);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
private:
|
private:
|
||||||
@@ -99,16 +65,9 @@ class ENGINE_DLL CMesh final : public CVIBuffer
|
|||||||
//
|
//
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MESH_DESC m_MeshDesc = {};
|
|
||||||
BONE_DESC m_BoneDesc = {};
|
|
||||||
_uint m_iNumBuffer = {};
|
_uint m_iNumBuffer = {};
|
||||||
_uint m_iNumMeshes = {};
|
_uint m_iNumMeshes = {};
|
||||||
_int m_iRootBoneIndex = { -1 };
|
_int m_iRootBoneIndex = { -1 };
|
||||||
_int m_iRawVertexStride = {};
|
|
||||||
|
|
||||||
vector<MESH_DESC> m_RawVertices;
|
|
||||||
|
|
||||||
ID3D11Buffer* m_pVBMesh = { nullptr };
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, HANDLE hFile, DWORD& dwByte);
|
static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, HANDLE hFile, DWORD& dwByte);
|
||||||
|
|||||||
@@ -7,32 +7,15 @@ NS_BEGIN(Engine)
|
|||||||
class ENGINE_DLL CModel final : public CComponent
|
class ENGINE_DLL CModel final : public CComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef struct tagMeshDesc
|
typedef struct tagAnimStateDesc
|
||||||
{
|
{
|
||||||
_float3 vPosition = {};
|
_float CurrentTime;
|
||||||
_float3 vNormal = {};
|
_float Duration;
|
||||||
_float3 vTangent = {};
|
_float Speed;
|
||||||
_float3 vBinormal = {};
|
_int BoneCount;
|
||||||
_float2 vTexcoord = {};
|
_float4x4 PreTransformMatrix;
|
||||||
|
|
||||||
XMUINT4 vBlendIndex = {};
|
}ANIMSTATE_DESC;
|
||||||
_float4 vBlendWeight = {};
|
|
||||||
}MESH_DESC;
|
|
||||||
|
|
||||||
typedef struct tagSkinngMeshDesc
|
|
||||||
{
|
|
||||||
_float3 vPosition = {};
|
|
||||||
_float3 vNormal = {};
|
|
||||||
_float3 vTangent = {};
|
|
||||||
_float3 vBinormal = {};
|
|
||||||
_float2 vTexcoord = {};
|
|
||||||
|
|
||||||
}SKINNG_MESH_DESC;
|
|
||||||
|
|
||||||
typedef struct tagBoneDesc
|
|
||||||
{
|
|
||||||
_float4x4 BoneMatrix[512];
|
|
||||||
}BONE_DESC;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CModel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
CModel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||||
@@ -94,9 +77,11 @@ static _int Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones); /
|
|||||||
HRESULT Bind_Material(_uint iMeshIndex, class CShader* pShader);
|
HRESULT Bind_Material(_uint iMeshIndex, class CShader* pShader);
|
||||||
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
void ComputeSkinning();
|
|
||||||
void Create_Con();
|
void Create_Con();
|
||||||
HRESULT Bind_CS_Output(_uint Index, _uint iBufferIndex);
|
void UpdateAnimationCS();
|
||||||
|
void ComputeAnimation();
|
||||||
|
HRESULT Create_ParentVB();
|
||||||
void Get_BoneMatrix();
|
void Get_BoneMatrix();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -169,14 +154,23 @@ static _int Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones); /
|
|||||||
private:
|
private:
|
||||||
HRESULT Create_CS();
|
HRESULT Create_CS();
|
||||||
|
|
||||||
MESH_DESC m_MeshDesc = {};
|
void Create_Temp();
|
||||||
BONE_DESC m_BoneDesc = {};
|
|
||||||
|
void Create_LocalPosVB();
|
||||||
|
|
||||||
_uint m_iNumBuffer = {};
|
_uint m_iNumBuffer = {};
|
||||||
|
|
||||||
class CComputeShader* m_pComputeShader = {};
|
vector<PARENT_DESC> m_Parent = {};
|
||||||
ID3D11Buffer* m_pConstantBuffer = { nullptr };
|
vector<ANIMSTATE_DESC> m_AnimRanges;
|
||||||
_uint AccumulatedVertexCount = {};
|
|
||||||
|
|
||||||
|
LOCALPOS_DESC* m_pLocalPos = { nullptr };
|
||||||
|
|
||||||
|
class CComputeShader* m_pComputeShader = nullptr;
|
||||||
|
|
||||||
|
ID3D11Buffer* m_pConstantBuffer = { nullptr };
|
||||||
|
|
||||||
|
ID3D11Buffer* m_pParentBuffer = { nullptr };
|
||||||
|
ID3D11Buffer* m_pLocalPosBuffer = { nullptr };
|
||||||
private:
|
private:
|
||||||
// 바이너리
|
// 바이너리
|
||||||
virtual HRESULT Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix);
|
virtual HRESULT Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix);
|
||||||
@@ -191,7 +185,7 @@ static _int Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones); /
|
|||||||
HRESULT Ready_Meshes();
|
HRESULT Ready_Meshes();
|
||||||
HRESULT Ready_Materials(const _char* pModelFilePath);
|
HRESULT Ready_Materials(const _char* pModelFilePath);
|
||||||
HRESULT Ready_Bones(const std::vector<SaveNode>& allNodes, _int currentIndex, _int parentIndex);
|
HRESULT Ready_Bones(const std::vector<SaveNode>& allNodes, _int currentIndex, _int parentIndex);
|
||||||
HRESULT Ready_Animations();
|
HRESULT Ready_Animations(const vector<CBone*>& Bones);
|
||||||
//
|
//
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user