|
After Width: | Height: | Size: 8.3 MiB |
|
After Width: | Height: | Size: 749 KiB |
|
After Width: | Height: | Size: 2.3 MiB |
|
After Width: | Height: | Size: 4.1 MiB |
|
After Width: | Height: | Size: 8.3 MiB |
|
After Width: | Height: | Size: 873 KiB |
|
After Width: | Height: | Size: 2.4 MiB |
|
After Width: | Height: | Size: 4.3 MiB |
|
After Width: | Height: | Size: 24 MiB |
|
After Width: | Height: | Size: 854 KiB |
|
After Width: | Height: | Size: 3.0 MiB |
|
After Width: | Height: | Size: 6.6 MiB |
|
After Width: | Height: | Size: 2.2 MiB |
|
After Width: | Height: | Size: 4.1 MiB |
|
After Width: | Height: | Size: 5.7 MiB |
|
After Width: | Height: | Size: 2.7 MiB |
|
After Width: | Height: | Size: 4.1 MiB |
|
After Width: | Height: | Size: 6.1 MiB |
|
After Width: | Height: | Size: 16 MiB |
|
After Width: | Height: | Size: 14 MiB |
|
After Width: | Height: | Size: 249 KiB |
|
After Width: | Height: | Size: 3.0 MiB |
|
After Width: | Height: | Size: 2.1 MiB |
@@ -149,20 +149,24 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Public\Body.h" />
|
||||
<ClInclude Include="..\Public\DebugCamera.h" />
|
||||
<ClInclude Include="..\Public\DummyRect.h" />
|
||||
<ClInclude Include="..\Public\Dummy_Cube.h" />
|
||||
<ClInclude Include="..\Public\Dummy_Goblin.h" />
|
||||
<ClInclude Include="..\Public\Dummy_Goblin_Head.h" />
|
||||
<ClInclude Include="..\Public\Editor_Define.h" />
|
||||
<ClInclude Include="..\Public\Editor_Macro.h" />
|
||||
<ClInclude Include="..\Public\Editor_Struct.h" />
|
||||
<ClInclude Include="..\public\Mission.h" />
|
||||
<ClInclude Include="..\Public\Head.h" />
|
||||
<ClInclude Include="..\Public\Level_Loading.h" />
|
||||
<ClInclude Include="..\Public\Level_Logo.h" />
|
||||
<ClInclude Include="..\public\Level_UI.h" />
|
||||
<ClInclude Include="..\Public\Level_ObjectViewer.h" />
|
||||
<ClInclude Include="..\Public\Loader.h" />
|
||||
<ClInclude Include="..\Public\MainApp.h" />
|
||||
<ClInclude Include="..\Public\ModelParts.h" />
|
||||
<ClInclude Include="..\public\Mouse_Cursor.h" />
|
||||
<ClInclude Include="Editor.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
@@ -170,17 +174,21 @@
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Private\Body.cpp" />
|
||||
<ClCompile Include="..\Private\DebugCamera.cpp" />
|
||||
<ClCompile Include="..\Private\DummyRect.cpp" />
|
||||
<ClCompile Include="..\Private\Dummy_Cube.cpp" />
|
||||
<ClCompile Include="..\Private\Dummy_Goblin.cpp" />
|
||||
<ClCompile Include="..\Private\Loader.cpp" />
|
||||
<ClCompile Include="..\private\Mission.cpp" />
|
||||
<ClCompile Include="..\Private\Dummy_Goblin_Head.cpp" />
|
||||
<ClCompile Include="..\Private\Head.cpp" />
|
||||
<ClCompile Include="..\Private\Level_Loading.cpp" />
|
||||
<ClCompile Include="..\Private\Level_Logo.cpp" />
|
||||
<ClCompile Include="..\private\Level_UI.cpp" />
|
||||
<ClCompile Include="..\Private\Level_ObjectViewer.cpp" />
|
||||
<ClCompile Include="..\Private\Loader.cpp" />
|
||||
<ClCompile Include="..\Private\MainApp.cpp" />
|
||||
<ClCompile Include="..\Private\ModelParts.cpp" />
|
||||
<ClCompile Include="..\private\Mouse_Cursor.cpp" />
|
||||
<ClCompile Include="..\Private\pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
|
||||
@@ -76,6 +76,21 @@
|
||||
<Filter Include="02.GameObjects\Dummy_Goblin">
|
||||
<UniqueIdentifier>{0ebb9c08-69b0-49b6-bac3-c827ca13319a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.GameObjects\Dummy_Goblin\Dummy_Goblin_Head">
|
||||
<UniqueIdentifier>{69af10ea-e8f1-4455-9435-93857b7eb198}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.GameObjects\ModelParts">
|
||||
<UniqueIdentifier>{a04e88c3-dabb-4a91-8b9f-ce7f5562def6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.GameObjects\ModelParts\Head">
|
||||
<UniqueIdentifier>{a483f296-1312-4b29-8b8f-ce47654cd09e}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.GameObjects\ModelParts\Body">
|
||||
<UniqueIdentifier>{763765ed-6960-4837-946e-20ff88d8e350}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.GameObjects\ModelParts\Hair">
|
||||
<UniqueIdentifier>{7ac7ca7b-7e52-498b-adfe-3a8e602b0904}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Editor.h">
|
||||
@@ -135,6 +150,18 @@
|
||||
<ClInclude Include="..\Public\Dummy_Cube.h">
|
||||
<Filter>02.GameObjects\Dummys\DummyCube</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Dummy_Goblin_Head.h">
|
||||
<Filter>02.GameObjects\Dummy_Goblin\Dummy_Goblin_Head</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Body.h">
|
||||
<Filter>02.GameObjects\ModelParts\Body</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\ModelParts.h">
|
||||
<Filter>02.GameObjects\ModelParts</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Head.h">
|
||||
<Filter>02.GameObjects\ModelParts\Head</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Editor.ico">
|
||||
@@ -154,9 +181,6 @@
|
||||
<ClCompile Include="..\Private\Level_Loading.cpp">
|
||||
<Filter>01.Level\00.Loading</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Loader.cpp">
|
||||
<Filter>01.Level\00.Loading\Loader</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Level_Logo.cpp">
|
||||
<Filter>01.Level\01.Logo</Filter>
|
||||
</ClCompile>
|
||||
@@ -187,6 +211,21 @@
|
||||
<ClCompile Include="..\Private\Dummy_Cube.cpp">
|
||||
<Filter>02.GameObjects\Dummys\DummyCube</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Dummy_Goblin_Head.cpp">
|
||||
<Filter>02.GameObjects\Dummy_Goblin\Dummy_Goblin_Head</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Body.cpp">
|
||||
<Filter>02.GameObjects\ModelParts\Body</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\ModelParts.cpp">
|
||||
<Filter>02.GameObjects\ModelParts</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Head.cpp">
|
||||
<Filter>02.GameObjects\ModelParts\Head</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Loader.cpp">
|
||||
<Filter>01.Level\00.Loading\Loader</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Editor.rc">
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
#include "pch.h"
|
||||
#include "Body.h"
|
||||
|
||||
#include "GameInstance.h"
|
||||
|
||||
CBody::CBody(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CModelParts(pDevice, pContext)
|
||||
{
|
||||
}
|
||||
|
||||
CBody::CBody(const CBody& Prototype)
|
||||
: CModelParts(Prototype)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CBody::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CBody::Initialize(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Initialize(pArg)))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
if (FAILED(Ready_Components()))
|
||||
return E_FAIL;
|
||||
|
||||
m_pModelCom->Set_AnimationIndex(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CBody::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CBody::Update(_float fTimeDelta)
|
||||
{
|
||||
m_pModelCom->Play_Animation(fTimeDelta);
|
||||
}
|
||||
|
||||
void CBody::Late_Update(_float fTimeDelta)
|
||||
{
|
||||
_float4 vPos;
|
||||
XMStoreFloat4(&vPos, Get_WorldPostion());
|
||||
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this, vPos, 20.f);
|
||||
}
|
||||
|
||||
HRESULT CBody::Render()
|
||||
{
|
||||
if (FAILED(Bind_ShaderResources())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_uint iNumMeshes = m_pModelCom->Get_NumMeshes();
|
||||
|
||||
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, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_NormalTexture", aiTextureType_NORMALS, 0))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pModelCom->Render(i))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CBody::Ready_Components()
|
||||
{
|
||||
/* Com_Model */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Steve_Model"),
|
||||
reinterpret_cast<CComponent**>(&m_pModelCom))))
|
||||
return E_FAIL;
|
||||
|
||||
/*m_pModelCom->Change_AnimationIndex(0, true, 0.4f, true);*/
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CBody* CBody::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CBody* pInstance = new CBody(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CBody");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CGameObject* CBody::Clone(void* pArg, CGameObject* pOwner)
|
||||
{
|
||||
CBody* pInstance = new CBody(*this);
|
||||
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CBody");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CBody::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
}
|
||||
|
||||
void CBody::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -38,7 +38,7 @@ void CDummy_Goblin::Priority_Update(_float fTimeDelta)
|
||||
|
||||
void CDummy_Goblin::Update(_float fTimeDelta)
|
||||
{
|
||||
m_pModelCom->Play_Animation(fTimeDelta);
|
||||
//m_pModelCom->Play_Animation(fTimeDelta);
|
||||
}
|
||||
|
||||
void CDummy_Goblin::Late_Update(_float fTimeDelta)
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
#include "pch.h"
|
||||
#include "Dummy_Goblin_Head.h"
|
||||
|
||||
#include "GameInstance.h"
|
||||
#include "DebugCamera.h"
|
||||
|
||||
CDummy_Goblin_Head::CDummy_Goblin_Head(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CGameObject(pDevice, pContext)
|
||||
{
|
||||
}
|
||||
|
||||
CDummy_Goblin_Head::CDummy_Goblin_Head(const CDummy_Goblin_Head& Prototype)
|
||||
: CGameObject(Prototype)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin_Head::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin_Head::Initialize(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Initialize(pArg)))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(Ready_Components()))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CDummy_Goblin_Head::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CDummy_Goblin_Head::Update(_float fTimeDelta)
|
||||
{
|
||||
m_pOwner->Get_Component<CModel>()->Play_Animation(fTimeDelta);
|
||||
m_pModelCom->Play_Animation(fTimeDelta);
|
||||
}
|
||||
|
||||
void CDummy_Goblin_Head::Late_Update(_float fTimeDelta)
|
||||
{
|
||||
_float4 vPos;
|
||||
XMStoreFloat4(&vPos, Get_WorldPostion());
|
||||
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this, vPos, 20.f);
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin_Head::Render()
|
||||
{
|
||||
if (FAILED(Bind_ShaderResources())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_uint iNumMeshes = m_pModelCom->Get_NumMeshes();
|
||||
|
||||
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, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_NormalTexture", aiTextureType_NORMALS, 0))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pModelCom->Render(i))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin_Head::Ready_Components()
|
||||
{
|
||||
__super::Ready_Components(nullptr);
|
||||
|
||||
/* Com_Model */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_GoblinHead_Model"),
|
||||
reinterpret_cast<CComponent**>(&m_pModelCom))))
|
||||
return E_FAIL;
|
||||
|
||||
/* Com_Shader */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_ANIMMESH,
|
||||
reinterpret_cast<CComponent**>(&m_pShaderCom))))
|
||||
return E_FAIL;
|
||||
|
||||
m_pModelCom->Change_AnimationIndex(0, true, 0.4f, true);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin_Head::Bind_ShaderResources()
|
||||
{
|
||||
if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
//if (FAILED(m_pShaderCom->Bind_RawValue("g_vCamPosition", m_pGameInstance->Get_CamPosition(), sizeof(_float4)))) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
//if (FAILED(m_pShaderCom->Bind_RawValue("g_bRimLight", &m_bRimLight, sizeof(_bool)))) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
//if (FAILED(m_pShaderCom->Bind_RawValue("g_fRimStrength", &m_fRimLightStrength, sizeof(_float)))) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
//if (FAILED(m_pShaderCom->Bind_RawValue("g_fRimPower", &m_fRimLightPower, sizeof(_float)))) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
//if (FAILED(m_pShaderCom->Bind_RawValue("g_vRimColor", &m_vRimLightColor, sizeof(_float3)))) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CDummy_Goblin_Head* CDummy_Goblin_Head::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CDummy_Goblin_Head* pInstance = new CDummy_Goblin_Head(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CDummy_Goblin_Head");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CGameObject* CDummy_Goblin_Head::Clone(void* pArg, CGameObject* pOwner)
|
||||
{
|
||||
CDummy_Goblin_Head* pInstance = new CDummy_Goblin_Head(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CDummy_Goblin_Head");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CDummy_Goblin_Head::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
Safe_Release(m_pShaderCom);
|
||||
Safe_Release(m_pModelCom);
|
||||
}
|
||||
|
||||
void CDummy_Goblin_Head::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
#include "pch.h"
|
||||
#include "Head.h"
|
||||
|
||||
#include "GameInstance.h"
|
||||
|
||||
CHead::CHead(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CModelParts(pDevice, pContext)
|
||||
{
|
||||
}
|
||||
|
||||
CHead::CHead(const CHead& Prototype)
|
||||
: CModelParts(Prototype)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CHead::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CHead::Initialize(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Initialize(pArg)))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
if (FAILED(Ready_Components()))
|
||||
return E_FAIL;
|
||||
|
||||
m_pModelCom->Set_AnimationIndex(0);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CHead::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CHead::Update(_float fTimeDelta)
|
||||
{
|
||||
m_pModelCom->Play_Animation(fTimeDelta);
|
||||
}
|
||||
|
||||
void CHead::Late_Update(_float fTimeDelta)
|
||||
{
|
||||
_float4 vPos;
|
||||
XMStoreFloat4(&vPos, Get_WorldPostion());
|
||||
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this, vPos, 20.f);
|
||||
}
|
||||
|
||||
HRESULT CHead::Render()
|
||||
{
|
||||
if (FAILED(Bind_ShaderResources())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_uint iNumMeshes = m_pModelCom->Get_NumMeshes();
|
||||
|
||||
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, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pModelCom->Bind_Material(i, m_pShaderCom, "g_NormalTexture", aiTextureType_NORMALS, 0))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_ANIM::DEFAULT)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pModelCom->Render(i))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CHead::Ready_Components()
|
||||
{
|
||||
/* Com_Model */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_GoblinBody_Model"),
|
||||
reinterpret_cast<CComponent**>(&m_pModelCom))))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CHead* CHead::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CHead* pInstance = new CHead(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CHead");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CGameObject* CHead::Clone(void* pArg, CGameObject* pOwner)
|
||||
{
|
||||
CHead* pInstance = new CHead(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CHead");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CHead::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
}
|
||||
|
||||
void CHead::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
#include "Level_ObjectViewer.h"
|
||||
#include "GameInstance.h"
|
||||
#include "Level_Loading.h"
|
||||
#include "Dummy_Goblin.h"
|
||||
#include "Body.h"
|
||||
#include "Head.h"
|
||||
#include "Dummy_Cube.h"
|
||||
#include "DebugCamera.h"
|
||||
#include "Layer.h"
|
||||
|
||||
CLevel_ObjectViewer::CLevel_ObjectViewer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID)
|
||||
: CLevel{ pDevice, pContext, ENUM_CLASS(eLevelID) }
|
||||
@@ -17,11 +19,11 @@ HRESULT CLevel_ObjectViewer::Initialize()
|
||||
if (FAILED(Ready_Layer_Light())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(Ready_Layer_Camera(TEXT("Layer_Camera"))))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
if (FAILED(Ready_Layer_Dummy(TEXT("Layer_Dummy"))))
|
||||
{
|
||||
@@ -34,17 +36,80 @@ HRESULT CLevel_ObjectViewer::Initialize()
|
||||
|
||||
void CLevel_ObjectViewer::Update(_float fTimeDelta)
|
||||
{
|
||||
Add_Object();
|
||||
|
||||
Show_ModelFilePath();
|
||||
}
|
||||
|
||||
HRESULT CLevel_ObjectViewer::Render()
|
||||
{
|
||||
SetWindowText(g_hWnd, TEXT("¿ÀºêÁ§Æ® ·¹º§ÀÔ´Ï´Ù"));
|
||||
GUI::ShowDemoWindow();
|
||||
//GUI::ShowDemoWindow();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CLevel_ObjectViewer::Add_Object()
|
||||
{
|
||||
GUI::Begin("Add Object");
|
||||
|
||||
if (GUI::BeginTabBar("ObjectTabs"))
|
||||
{
|
||||
if (ImGui::BeginTabItem("Creatures"))
|
||||
{
|
||||
GUI::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Human"))
|
||||
{
|
||||
if (GUI::CollapsingHeader("Body"))
|
||||
{
|
||||
if (GUI::Button("Add"))
|
||||
{
|
||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CBody>(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, TEXT("Layer_Body"))))
|
||||
return;
|
||||
CBody* pBody = m_pGameInstance->Get_Layer(NEXT_LEVEL, TEXT("Layer_Body"))->Get_Object<CBody>();
|
||||
}
|
||||
if (GUI::Button("Delete"))
|
||||
{
|
||||
m_pGameInstance->Get_Layer(NEXT_LEVEL, TEXT("Layer_Body"))->Clear_Layer();
|
||||
}
|
||||
}
|
||||
if (GUI::CollapsingHeader("Head"))
|
||||
{
|
||||
if (GUI::Button("Add"))
|
||||
{
|
||||
CGameObject* pOwner = m_pGameInstance->Get_Layer(NEXT_LEVEL, TEXT("Layer_Body"))->Get_Object<CBody>();
|
||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CHead>(ENUM_CLASS(LEVEL::STATIC), NEXT_LEVEL, TEXT("Layer_Head"), nullptr, pOwner)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (GUI::CollapsingHeader("Hair"))
|
||||
{
|
||||
}
|
||||
GUI::EndTabItem();
|
||||
}
|
||||
|
||||
GUI::EndTabBar();
|
||||
|
||||
GUI::End();
|
||||
}
|
||||
}
|
||||
|
||||
void CLevel_ObjectViewer::Show_ModelFilePath()
|
||||
{
|
||||
GUI::Begin("Model_List");
|
||||
for (_uint i = 0; i < m_pGameInstance->ModelFilePathCount(); i++)
|
||||
{
|
||||
/*GUI::Text(m_pGameInstance->Load_BinaryModelFilePath(i));*/
|
||||
GUI::SameLine();
|
||||
|
||||
std::string label = "Binary##" + std::to_string(i);
|
||||
if (GUI::Button(label.c_str()))
|
||||
{
|
||||
m_pGameInstance->SaveAssimpModel(m_pGameInstance->Load_ModelFilePath(i));
|
||||
}
|
||||
}
|
||||
GUI::End();
|
||||
}
|
||||
|
||||
HRESULT CLevel_ObjectViewer::Ready_Layer_Camera(const _wstring& strLayerTag)
|
||||
{
|
||||
@@ -88,11 +153,8 @@ HRESULT CLevel_ObjectViewer::Ready_Layer_UI(const _wstring& strLayerTag)
|
||||
|
||||
HRESULT CLevel_ObjectViewer::Ready_Layer_Dummy(const _wstring& strLayerTag)
|
||||
{
|
||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CDummy_Goblin>(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER)))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CDummy_Cube>(g_iStaticLevel, NEXT_LEVEL, LAYER_CUBE)))
|
||||
return E_FAIL;
|
||||
/*if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CDummy_Cube>(g_iStaticLevel, NEXT_LEVEL, LAYER_CUBE)))
|
||||
return E_FAIL;*/
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "pch.h"
|
||||
#include "pch.h"
|
||||
#include "Loader.h"
|
||||
#include "DebugCamera.h"
|
||||
#include "GameInstance.h"
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "MainApp.h"
|
||||
#include "Mission.h"
|
||||
#include "Mouse_Cursor.h"
|
||||
#include "Head.h"
|
||||
#include "Body.h"
|
||||
#include "Dummy_Goblin.h"
|
||||
#include "Dummy_Cube.h"
|
||||
|
||||
@@ -105,13 +107,12 @@ void CLoader::Output()
|
||||
HRESULT CLoader::Loading_For_Logo()
|
||||
{
|
||||
m_strMessage = TEXT("텍스쳐를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("모델를(을) 로딩 중 입니다.");
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Dororong"),
|
||||
CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::SINGLE, TEXT("../Bin/Resources/Textures/DororongDoro.png"), TEXT("Dororong"), 0)))){
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_strMessage = TEXT("¸ðµ¨¸¦(À») ·Îµù Áß ÀÔ´Ï´Ù.");
|
||||
|
||||
m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다.");
|
||||
|
||||
@@ -170,7 +171,6 @@ HRESULT CLoader::Loading_For_Logo()
|
||||
HRESULT CLoader::Loading_For_UI()
|
||||
{
|
||||
m_strMessage = TEXT("텍스쳐를(을) 로딩 중 입니다.");
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Keyboard"),
|
||||
CTexture::Create(m_pDevice, m_pContext, TEXTURE_LOAD_TYPE::INCREMENTAL, TEXT("../Bin/Resources/Textures/Keyboard/Keyboard_%d.png"), TEXT("Keyboard"), 10)))) {
|
||||
return E_FAIL;
|
||||
@@ -185,6 +185,8 @@ HRESULT CLoader::Loading_For_UI()
|
||||
|
||||
m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("이펙트를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("객체원형를(을) 로딩 중 입니다.");
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Prototype<CMission>(g_iStaticLevel, CMission::Create(m_pDevice, m_pContext))))
|
||||
@@ -197,6 +199,8 @@ HRESULT CLoader::Loading_For_UI()
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_strMessage = TEXT("정보를 불러오는 중입니다.");
|
||||
|
||||
m_strMessage = TEXT("로딩이 완료되었습니다..");
|
||||
|
||||
m_isFinished = true;
|
||||
@@ -210,22 +214,52 @@ HRESULT CLoader::Loading_For_ObjectViewer()
|
||||
|
||||
m_strMessage = TEXT("모델를(을) 로딩 중 입니다.");
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_GoblinBody_Model"),
|
||||
/*if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_GoblinBody_Model"),
|
||||
CModel::Create(m_pDevice, m_pContext, "../Bin/Resources/Models/Goblin/GoblinBody.fbx", MODEL::ANIM, XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixIdentity(), 0))))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Desc_Box"),
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_GoblinHead_Model"),
|
||||
CModel::Create(m_pDevice, m_pContext, "../Bin/Resources/Models/Goblin/GoblinHead.fbx", MODEL::ANIM, XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixIdentity(), 0))))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Desc_Box"),
|
||||
CModel::Create(m_pDevice, m_pContext, "../Bin/Resources/Models/Box/Box.fbx", MODEL::NONANIM, XMMatrixIdentity(), 0))))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Steve_Model"),
|
||||
CModel::Create(m_pDevice, m_pContext, "../Bin/Resources/Models/Steve/Steve.fbx", MODEL::ANIM, XMMatrixIdentity(), 0))))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_TombProtector_Model"),
|
||||
CModel::Create(m_pDevice, m_pContext, "../Bin/Resources/Models/TombProtector/TombProtector.fbx", MODEL::ANIM,XMMatrixIdentity(), 0))))
|
||||
return E_FAIL;*/
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_GoblinBody_Model"),
|
||||
CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/SaveFile/GoblinBody", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity()))))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Steve_Model"),
|
||||
CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/SaveFile/Steve",XMMatrixScaling(0.01f,0.01f,0.01f)* XMMatrixIdentity()))))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_TombProtector_Model"),
|
||||
CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/SaveFile/TombProtector", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity()))))
|
||||
return E_FAIL;
|
||||
|
||||
m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("이펙트를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("객체원형를(을) 로딩 중 입니다.");
|
||||
|
||||
/* For.Prototype_GameObject_Dummy_Goblin */
|
||||
if (FAILED(m_pGameInstance->Add_Prototype<CDummy_Goblin>(g_iStaticLevel, CDummy_Goblin::Create(m_pDevice, m_pContext))))
|
||||
/* For.Prototype_GameObject_Body */
|
||||
if (FAILED(m_pGameInstance->Add_Prototype<CBody>(g_iStaticLevel, CBody::Create(m_pDevice, m_pContext))))
|
||||
return E_FAIL;
|
||||
|
||||
/* For.Prototype_GameObject_Head */
|
||||
if (FAILED(m_pGameInstance->Add_Prototype<CHead>(g_iStaticLevel, CHead::Create(m_pDevice, m_pContext))))
|
||||
return E_FAIL;
|
||||
|
||||
/* For.Prototype_GameObject_Dummy_Cube */
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
#include "pch.h"
|
||||
#include "Body.h"
|
||||
|
||||
#include "GameInstance.h"
|
||||
|
||||
CModelParts::CModelParts(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CGameObject(pDevice, pContext)
|
||||
{
|
||||
}
|
||||
|
||||
CModelParts::CModelParts(const CModelParts& Prototype)
|
||||
: CGameObject(Prototype)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CModelParts::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModelParts::Initialize(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Initialize(pArg)))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
if (FAILED(Ready_Components()))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CModelParts::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
}
|
||||
|
||||
void CModelParts::Update(_float fTimeDelta)
|
||||
{
|
||||
}
|
||||
|
||||
void CModelParts::Late_Update(_float fTimeDelta)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CModelParts::Render()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModelParts::Ready_Components()
|
||||
{
|
||||
__super::Ready_Components(nullptr);
|
||||
|
||||
/* Com_Shader */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_ANIMMESH,
|
||||
reinterpret_cast<CComponent**>(&m_pShaderCom))))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModelParts::Bind_ShaderResources()
|
||||
{
|
||||
if (FAILED(m_pTransformCom->Bind_ShaderResource(m_pShaderCom, "g_WorldMatrix"))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pShaderCom->Bind_Matrix("g_ViewMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pShaderCom->Bind_Matrix("g_ProjMatrix", m_pGameInstance->Get_Transform_Float4x4(D3DTS::PROJ)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pShaderCom->Bind_RawValue("g_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CModelParts::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
Safe_Release(m_pShaderCom);
|
||||
Safe_Release(m_pModelCom);
|
||||
}
|
||||
|
||||
void CModelParts::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "Editor_Define.h"
|
||||
#include "ModelParts.h"
|
||||
|
||||
NS_BEGIN(Editor)
|
||||
|
||||
class CBody final : public CModelParts
|
||||
{
|
||||
private:
|
||||
CBody(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CBody(const CBody& Prototype);
|
||||
virtual ~CBody() = default;
|
||||
|
||||
public:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
virtual void Priority_Update(_float fTimeDelta) override;
|
||||
virtual void Update(_float fTimeDelta) override;
|
||||
virtual void Late_Update(_float fTimeDelta) override;
|
||||
virtual HRESULT Render() override;
|
||||
|
||||
private:
|
||||
HRESULT Ready_Components();
|
||||
|
||||
public:
|
||||
static CBody* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override;
|
||||
virtual void Free() override;
|
||||
virtual void Describe_Entity() override;
|
||||
};
|
||||
|
||||
NS_END
|
||||
@@ -0,0 +1,47 @@
|
||||
#pragma once
|
||||
|
||||
#include "Editor_Define.h"
|
||||
#include "GameObject.h"
|
||||
|
||||
NS_BEGIN(Engine)
|
||||
class CShader;
|
||||
class CModel;
|
||||
NS_END
|
||||
|
||||
NS_BEGIN(Editor)
|
||||
|
||||
class CDummy_Goblin_Head final : public CGameObject
|
||||
{
|
||||
private:
|
||||
CDummy_Goblin_Head(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CDummy_Goblin_Head(const CDummy_Goblin_Head& Prototype);
|
||||
virtual ~CDummy_Goblin_Head() = default;
|
||||
|
||||
public:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
virtual void Priority_Update(_float fTimeDelta) override;
|
||||
virtual void Update(_float fTimeDelta) override;
|
||||
virtual void Late_Update(_float fTimeDelta) override;
|
||||
virtual HRESULT Render() override;
|
||||
|
||||
private:
|
||||
CShader* m_pShaderCom = { nullptr };
|
||||
CModel* m_pModelCom = { nullptr };
|
||||
_bool m_bRimLight = { true };
|
||||
_float m_fRimLightPower = { 3.2f };
|
||||
_float m_fRimLightStrength = { 3.04f };
|
||||
_float3 m_vRimLightColor = { 69.f / 255.f, 5.f / 255.f, 10.f / 255.f };
|
||||
|
||||
private:
|
||||
HRESULT Ready_Components();
|
||||
HRESULT Bind_ShaderResources();
|
||||
|
||||
public:
|
||||
static CDummy_Goblin_Head* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override;
|
||||
virtual void Free() override;
|
||||
virtual void Describe_Entity() override;
|
||||
};
|
||||
|
||||
NS_END
|
||||
@@ -0,0 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
#include "Editor_Define.h"
|
||||
#include "ModelParts.h"
|
||||
|
||||
NS_BEGIN(Editor)
|
||||
|
||||
class CHead final : public CModelParts
|
||||
{
|
||||
private:
|
||||
CHead(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CHead(const CHead& Prototype);
|
||||
virtual ~CHead() = default;
|
||||
|
||||
public:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
virtual void Priority_Update(_float fTimeDelta) override;
|
||||
virtual void Update(_float fTimeDelta) override;
|
||||
virtual void Late_Update(_float fTimeDelta) override;
|
||||
virtual HRESULT Render() override;
|
||||
|
||||
private:
|
||||
HRESULT Ready_Components();
|
||||
|
||||
public:
|
||||
static CHead* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr) override;
|
||||
virtual void Free() override;
|
||||
virtual void Describe_Entity() override;
|
||||
};
|
||||
|
||||
NS_END
|
||||
@@ -14,6 +14,8 @@ class CLevel_ObjectViewer final : public CLevel
|
||||
public:
|
||||
virtual void Update(_float fTimeDelta) override;
|
||||
virtual HRESULT Render() override;
|
||||
void Add_Object();
|
||||
void Show_ModelFilePath();
|
||||
|
||||
private:
|
||||
/* 이 레벨에서 쓰기위한 객체들을 생성한다. */
|
||||
@@ -23,6 +25,7 @@ class CLevel_ObjectViewer final : public CLevel
|
||||
HRESULT Ready_Layer_UI(const _wstring& strLayerTag);
|
||||
HRESULT Ready_Layer_Dummy(const _wstring& strLayerTag);
|
||||
|
||||
|
||||
public:
|
||||
static CLevel_ObjectViewer* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID);
|
||||
virtual void Free() override;
|
||||
|
||||
@@ -38,6 +38,8 @@ class CLoader final : public CBase
|
||||
|
||||
CGameInstance* m_pGameInstance = { nullptr };
|
||||
|
||||
//list<SaveModel> m_SaveModel;
|
||||
|
||||
private:
|
||||
HRESULT Initialize(LEVEL eNextLevelID);
|
||||
HRESULT Loading_For_Logo();
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "Editor_Define.h"
|
||||
#include "GameObject.h"
|
||||
|
||||
NS_BEGIN(Engine)
|
||||
class CShader;
|
||||
class CModel;
|
||||
NS_END
|
||||
|
||||
NS_BEGIN(Editor)
|
||||
|
||||
class CModelParts abstract : public CGameObject
|
||||
{
|
||||
protected:
|
||||
CModelParts(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CModelParts(const CModelParts& Prototype);
|
||||
virtual ~CModelParts() = default;
|
||||
|
||||
public:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
virtual void Priority_Update(_float fTimeDelta) override;
|
||||
virtual void Update(_float fTimeDelta) override;
|
||||
virtual void Late_Update(_float fTimeDelta) override;
|
||||
virtual HRESULT Render() override;
|
||||
|
||||
protected:
|
||||
CShader* m_pShaderCom = { nullptr };
|
||||
CModel* m_pModelCom = { nullptr };
|
||||
_bool m_bRimLight = { true };
|
||||
_float m_fRimLightPower = { 3.2f };
|
||||
_float m_fRimLightStrength = { 3.04f };
|
||||
_float3 m_vRimLightColor = { 69.f / 255.f, 5.f / 255.f, 10.f / 255.f };
|
||||
|
||||
protected:
|
||||
HRESULT Ready_Components();
|
||||
HRESULT Bind_ShaderResources();
|
||||
|
||||
public:
|
||||
virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr)PURE;
|
||||
virtual void Free() override;
|
||||
virtual void Describe_Entity() override;
|
||||
};
|
||||
|
||||
NS_END
|
||||
@@ -17,17 +17,21 @@ CAnimation::CAnimation(const CAnimation& rhs)
|
||||
, m_StartKeyFrames{ rhs.m_StartKeyFrames }
|
||||
, m_DestBones{ rhs.m_DestBones }
|
||||
, m_strName{ rhs.m_strName }
|
||||
, m_fTickPerSecond{ rhs.m_fTickPerSecond }
|
||||
, m_pSaveAnim{ rhs.m_pSaveAnim }
|
||||
{
|
||||
memcpy_s(m_TickPerSeconds, sizeof(_float) * 2, rhs.m_TickPerSeconds, sizeof(_float) * 2);
|
||||
|
||||
strcpy_s(m_szName, sizeof(m_szName), rhs.m_szName);
|
||||
|
||||
for (auto& pChannel : m_Channels) {
|
||||
SAFE_ADDREF(pChannel);
|
||||
}
|
||||
}
|
||||
_bool CAnimation::Update_TransformationMatrices(const vector<class CBone*>& Bones, _bool bIsLoop, _float fTimeDelta)
|
||||
{
|
||||
m_fCurrentTrackPosition += m_TickPerSeconds[m_bPause] * fTimeDelta;
|
||||
|
||||
//m_fCurrentTrackPosition += m_TickPerSeconds[m_bPause] * fTimeDelta;
|
||||
m_fCurrentTrackPosition += m_fTickPerSecond * fTimeDelta;
|
||||
if (m_fCurrentTrackPosition >= m_fDuration) {
|
||||
m_fCurrentTrackPosition = 0.f; // ·çÇÁ
|
||||
if (false == bIsLoop) {
|
||||
@@ -48,6 +52,7 @@ _bool CAnimation::Update_TransformationMatrices(const vector<class CBone*>& Bone
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CAnimation::Depart_Animation()
|
||||
{
|
||||
m_fCurrentTrackPosition = 0.f;
|
||||
@@ -177,6 +182,30 @@ HRESULT CAnimation::Initialize(HANDLE hFile, DWORD& dwByte)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CAnimation::Initialize(const CModel* pModel, SaveAnimation* pSaveAnimation)
|
||||
{
|
||||
m_pSaveAnim = pSaveAnimation;
|
||||
|
||||
strcpy_s(m_szName, pSaveAnimation->Name);
|
||||
m_fDuration = pSaveAnimation->mDuration;
|
||||
m_fTickPerSecond = pSaveAnimation->mTicksPerSecond;
|
||||
|
||||
m_iNumChannels = pSaveAnimation->ChannelCount;
|
||||
|
||||
m_CurrentKeyFrameIndices.resize(m_iNumChannels);
|
||||
|
||||
for (size_t i = 0; i < m_iNumChannels; i++)
|
||||
{
|
||||
CChannel* pChannel = CChannel::Create(pModel, &pSaveAnimation->Channels[i]);
|
||||
if (nullptr == pChannel)
|
||||
return E_FAIL;
|
||||
|
||||
m_Channels.push_back(pChannel);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CAnimation::Combined_Initialize()
|
||||
{
|
||||
m_StartKeyFrames.reserve(m_iNumChannels);
|
||||
@@ -205,6 +234,19 @@ CAnimation* CAnimation::Create(HANDLE hFile, DWORD& dwByte)
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CAnimation* CAnimation::Create(const CModel* pModel, SaveAnimation* pSaveAnimation)
|
||||
{
|
||||
CAnimation* pInstance = new CAnimation();
|
||||
|
||||
if (FAILED(pInstance->Initialize(pModel, pSaveAnimation)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CAnimation");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CAnimation* CAnimation::Clone()
|
||||
{
|
||||
return new CAnimation(*this);
|
||||
|
||||
@@ -69,6 +69,19 @@ CBone* CBone::Create(const aiNode* pAINode, _int iParentIndex)
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CBone* CBone::Create(const SaveNode& _SaveNode, _int iParentIndex)
|
||||
{
|
||||
CBone* pInstance = new CBone();
|
||||
|
||||
if (FAILED(pInstance->Initialize(_SaveNode, iParentIndex)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CBone");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
HRESULT CBone::Initialize(const aiNode* pAINode, _int iParentIndex)
|
||||
{
|
||||
strcpy_s(m_szName, pAINode->mName.data);
|
||||
@@ -109,6 +122,19 @@ HRESULT CBone::Initialize(HANDLE hFile, DWORD& dwByte)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CBone::Initialize(const SaveNode& _SaveNode, _int iParentIndex)
|
||||
{
|
||||
strcpy_s(m_szName, _SaveNode.Name);
|
||||
|
||||
m_iParentBoneIndex = iParentIndex;
|
||||
|
||||
memcpy(&m_TransformationMatrix, &_SaveNode.Transformation, sizeof(_float4x4));
|
||||
|
||||
XMStoreFloat4x4(&m_CombinedTransformationMatrix, XMMatrixIdentity());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CBone* CBone::Create(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
CBone* pInstance = new CBone();
|
||||
|
||||
@@ -183,6 +183,56 @@ HRESULT CChannel::Initialize(HANDLE hFile, DWORD& dwByte)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CChannel::Initialize(const CModel* pModel, SaveChannel* pSaveChannel)
|
||||
{
|
||||
strcpy_s(m_szName, pSaveChannel->Name);
|
||||
|
||||
m_iBoneIndex = pModel->Get_BoneIndex(m_szName);
|
||||
m_PreTransformMatrix = pModel->Get_PreTransformMatrix();
|
||||
|
||||
m_iNumKeyFrames = max(pSaveChannel->ScalingKeyCount, pSaveChannel->RotationKeyCount);
|
||||
m_iNumKeyFrames = max(m_iNumKeyFrames, pSaveChannel->PositionKeyCount);
|
||||
|
||||
_float3 vScale{};
|
||||
_float4 vRotation{};
|
||||
_float3 vTranslation{};
|
||||
|
||||
for (size_t i = 0; i < m_iNumKeyFrames; i++)
|
||||
{
|
||||
KEYFRAME KeyFrame{};
|
||||
|
||||
if (i < pSaveChannel->ScalingKeyCount)
|
||||
{
|
||||
memcpy(&vScale, &pSaveChannel->ScalingKeys[i].Value, sizeof(_float3));
|
||||
KeyFrame.fTrackPosition = pSaveChannel->ScalingKeys[i].Time;
|
||||
}
|
||||
|
||||
if (i < pSaveChannel->RotationKeyCount)
|
||||
{
|
||||
vRotation.x = pSaveChannel->RotationKeys[i].Value.x;
|
||||
vRotation.y = pSaveChannel->RotationKeys[i].Value.y;
|
||||
vRotation.z = pSaveChannel->RotationKeys[i].Value.z;
|
||||
vRotation.w = pSaveChannel->RotationKeys[i].Value.w;
|
||||
|
||||
KeyFrame.fTrackPosition = pSaveChannel->RotationKeys[i].Time;
|
||||
}
|
||||
|
||||
if (i < pSaveChannel->PositionKeyCount)
|
||||
{
|
||||
memcpy(&vTranslation, &pSaveChannel->PositionKeys[i].Value, sizeof(_float3));
|
||||
KeyFrame.fTrackPosition = pSaveChannel->PositionKeys[i].Time;
|
||||
}
|
||||
|
||||
KeyFrame.vScale = vScale;
|
||||
KeyFrame.vRotation = vRotation;
|
||||
KeyFrame.vTranslation = vTranslation;
|
||||
|
||||
m_KeyFrames.push_back(KeyFrame);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CChannel* CChannel::Create(const vector<CBone*>& Bones, _uint iIndex)
|
||||
{
|
||||
CChannel* pInstance = new CChannel();
|
||||
@@ -209,6 +259,19 @@ CChannel* CChannel::Create(HANDLE hFile, DWORD& dwByte)
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CChannel* CChannel::Create(const CModel* pModel, SaveChannel* pSaveChannel)
|
||||
{
|
||||
CChannel* pInstance = new CChannel();
|
||||
|
||||
if (FAILED(pInstance->Initialize(pModel, pSaveChannel)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CChannel");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CChannel::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
@@ -146,6 +146,29 @@ _int CGameInstance::Random_Int(_int iMin, _int iMax)
|
||||
return iMin + (_int)(Random_Normal() * (iMax - iMin));
|
||||
}
|
||||
|
||||
void CGameInstance::Save_ModelFilePath(const _char* FilePath)
|
||||
{
|
||||
m_FilePaths.push_back(FilePath);
|
||||
}
|
||||
|
||||
const _char* CGameInstance::Load_ModelFilePath(_uint iIndex)
|
||||
{
|
||||
return m_FilePaths[iIndex];
|
||||
}
|
||||
|
||||
const _char* CGameInstance::Load_BinaryModelFilePath(_uint iIndex)
|
||||
{
|
||||
auto iter = m_sModelMap.begin();
|
||||
std::advance(iter, iIndex);
|
||||
return iter->first;
|
||||
}
|
||||
|
||||
|
||||
size_t CGameInstance::ModelFilePathCount()
|
||||
{
|
||||
return m_FilePaths.size();
|
||||
}
|
||||
|
||||
void CGameInstance::Render_Begin(const _float4* pClearColor)
|
||||
{
|
||||
m_pGraphic_Device->Clear_BackBuffer_View(pClearColor);
|
||||
@@ -474,6 +497,16 @@ const SHADOW_LIGHT_DESC* CGameInstance::Get_ShadowDesc()
|
||||
{
|
||||
return m_pShadow->Get_ShadowDesc();
|
||||
}
|
||||
SaveModel* CGameInstance::Load_SaveModel(const _char* filePath)
|
||||
{
|
||||
auto iter = m_sModelMap.find(filePath);
|
||||
return &iter->second;
|
||||
}
|
||||
_bool CGameInstance::SaveAssimpModel(const _char* filename)
|
||||
{
|
||||
auto iter = m_ModelMap.find(filename);
|
||||
return iter->second->SaveAssimpModel(filename);
|
||||
}
|
||||
bool CGameInstance::Key_Pressing(int _iKey)
|
||||
{
|
||||
if (false == (GUI::IsWindowFocused(ImGuiFocusedFlags_AnyWindow))) {
|
||||
|
||||
@@ -74,9 +74,9 @@ HRESULT CMaterial::Initialize(const _char* pModelFilePath, const aiMaterial* pAI
|
||||
hr = CreateWICTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, &pSRV);
|
||||
}
|
||||
}
|
||||
m_SaveMaterial.Path[i].push_back(szTextureFilePath);
|
||||
}
|
||||
|
||||
|
||||
strcpy_s(szSaveDir, sizeof(_char) * MAX_PATH, szName);
|
||||
strcat_s(szSaveDir, sizeof(_char) * MAX_PATH, szExt);
|
||||
|
||||
@@ -171,6 +171,7 @@ HRESULT CMaterial::Initialize(const _char* pModelFilePath, HANDLE hFile, DWORD&
|
||||
strcat_s(szTextureDir, sizeof(_char) * MAX_PATH, szDir);
|
||||
strcat_s(szTextureDir, sizeof(_char) * MAX_PATH, szTextureName);
|
||||
|
||||
|
||||
{
|
||||
_char szTextureFileName[MAX_PATH] = {};
|
||||
_char szTextureFilePath[MAX_PATH] = {};
|
||||
@@ -200,6 +201,7 @@ HRESULT CMaterial::Initialize(const _char* pModelFilePath, HANDLE hFile, DWORD&
|
||||
hr = CreateWICTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, &pSRV);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (FAILED(hr)) {
|
||||
return E_FAIL;
|
||||
@@ -211,6 +213,46 @@ HRESULT CMaterial::Initialize(const _char* pModelFilePath, HANDLE hFile, DWORD&
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMaterial::Initialize(const _char* pModelFilePath, const SaveMaterial& _SaveMaterial)
|
||||
{
|
||||
for (size_t type = 0; type < 27; type++)
|
||||
{
|
||||
for (const auto& path : _SaveMaterial.Path[type])
|
||||
{
|
||||
char szDrive[MAX_PATH] = {};
|
||||
char szDir[MAX_PATH] = {};
|
||||
_splitpath_s(pModelFilePath, szDrive, MAX_PATH, szDir, MAX_PATH, nullptr, 0, nullptr, 0);
|
||||
|
||||
char szFullPath[MAX_PATH] = {};
|
||||
strcpy_s(szFullPath, szDrive);
|
||||
strcat_s(szFullPath, path.c_str());
|
||||
|
||||
_tchar szPerfectPath[MAX_PATH] = {};
|
||||
MultiByteToWideChar(CP_ACP, 0, szFullPath, -1, szPerfectPath, MAX_PATH);
|
||||
|
||||
ID3D11ShaderResourceView* pSRV = nullptr;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
const char* ext = strrchr(szFullPath, '.');
|
||||
if (ext)
|
||||
{
|
||||
if (strcmp(ext, ".dds") == 0)
|
||||
hr = CreateDDSTextureFromFile(m_pDevice, szPerfectPath, nullptr, &pSRV);
|
||||
else if (strcmp(ext, ".tga") == 0)
|
||||
hr = S_OK;
|
||||
else
|
||||
hr = CreateWICTextureFromFile(m_pDevice, szPerfectPath, nullptr, &pSRV);
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
return E_FAIL;
|
||||
|
||||
m_SRVs[type].push_back(pSRV);
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, HANDLE hFile, DWORD& dwByte) {
|
||||
CMaterial* pInstance = new CMaterial(pDevice, pContext);
|
||||
@@ -224,6 +266,19 @@ CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContex
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const SaveMaterial& _SaveMaterial)
|
||||
{
|
||||
CMaterial* pInstance = new CMaterial(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize(pModelFilePath, _SaveMaterial)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CMaterial");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
|
||||
void CMaterial::Free()
|
||||
{
|
||||
|
||||
@@ -196,6 +196,70 @@ HRESULT CMesh::Initialize_Prototype(HANDLE hFile, DWORD& dwByte)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMesh::Initialize_Prototype(MODEL eType, const CModel* pModel, SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix)
|
||||
{
|
||||
strcpy_s(m_szName, _SaveMesh->Name);
|
||||
|
||||
m_iMaterialIndex = _SaveMesh->MaterialIndex;
|
||||
m_iNumVertexBuffers = 1;
|
||||
m_iNumVertices = _SaveMesh->VertexCount;
|
||||
|
||||
m_iNumIndices = _SaveMesh->IndexCount;
|
||||
m_iIndexStride = 4;
|
||||
|
||||
m_eIndexFormat = DXGI_FORMAT_R32_UINT;
|
||||
m_ePrimitive = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||
|
||||
m_Indices = _SaveMesh->Indices;
|
||||
|
||||
m_Vertices.clear();
|
||||
m_Vertices.reserve(_SaveMesh->Vertices.size());
|
||||
|
||||
XMMATRIX matPre = PreTransformMatrix;
|
||||
for (size_t i = 0; i < _SaveMesh->Vertices.size(); ++i)
|
||||
{
|
||||
_float3 pos = _SaveMesh->Vertices[i].Pos;
|
||||
XMVECTOR v = XMLoadFloat3(&pos);
|
||||
v = XMVector3TransformCoord(v, matPre);
|
||||
XMFLOAT3 tp;
|
||||
XMStoreFloat3(&tp, v);
|
||||
m_Vertices.push_back(tp);
|
||||
}
|
||||
|
||||
#pragma region VERTEX_BUFFER
|
||||
|
||||
HRESULT hr = MODEL::NONANIM == eType ?
|
||||
Ready_VertexBuffer_For_NonAnim(_SaveMesh, PreTransformMatrix) :
|
||||
Ready_VertexBuffer_For_Anim(pModel, _SaveMesh);
|
||||
|
||||
if (FAILED(hr))
|
||||
return E_FAIL;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region INDEX_BUFFER
|
||||
D3D11_BUFFER_DESC IBDesc{};
|
||||
IBDesc.ByteWidth = m_iIndexStride * m_iNumIndices;
|
||||
IBDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
IBDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
IBDesc.StructureByteStride = m_iIndexStride;
|
||||
IBDesc.CPUAccessFlags = 0;
|
||||
IBDesc.MiscFlags = 0;
|
||||
|
||||
|
||||
D3D11_SUBRESOURCE_DATA InitialIBData{};
|
||||
InitialIBData.pSysMem = _SaveMesh->Indices.data();
|
||||
|
||||
if (FAILED(m_pDevice->CreateBuffer(&IBDesc, &InitialIBData, &m_pIB)))
|
||||
return E_FAIL;
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
D3D11_BUFFER_DESC VBDesc{};
|
||||
@@ -254,6 +318,165 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(HANDLE hFile, DWORD& dwByte)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix)
|
||||
{
|
||||
m_iVertexStride = sizeof(VTXMESH);
|
||||
D3D11_BUFFER_DESC VBDesc{};
|
||||
VBDesc.ByteWidth = m_iVertexStride * m_iNumVertices;
|
||||
VBDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
VBDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
VBDesc.StructureByteStride = m_iVertexStride;
|
||||
VBDesc.CPUAccessFlags = 0;
|
||||
VBDesc.MiscFlags = 0;
|
||||
|
||||
VTXMESH* pVertices = new VTXMESH[m_iNumVertices];
|
||||
ZeroMemory(pVertices, sizeof(VTXMESH) * m_iNumVertices);
|
||||
|
||||
m_pVertexPositions = new _float3[m_iNumVertices];
|
||||
ZeroMemory(m_pVertexPositions, sizeof(_float3) * m_iNumVertices);
|
||||
|
||||
for (_uint i = 0; i < m_iNumVertices; ++i)
|
||||
{
|
||||
memcpy(&pVertices[i].vPosition, &_SaveMesh->Vertices[i].Pos, sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vPosition,
|
||||
XMVector3TransformCoord(XMLoadFloat3(&pVertices[i].vPosition), PreTransformMatrix));
|
||||
|
||||
memcpy(&pVertices[i].vNormal, &_SaveMesh->Vertices[i].Normal, sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vNormal,
|
||||
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vNormal), PreTransformMatrix)));
|
||||
|
||||
memcpy(&pVertices[i].vTangent, &_SaveMesh->Vertices[i].Tan, sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vTangent,
|
||||
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vTangent), PreTransformMatrix)));
|
||||
|
||||
memcpy(&pVertices[i].vBinormal, &_SaveMesh->Vertices[i].BiNoraml, sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vBinormal,
|
||||
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vBinormal), PreTransformMatrix)));
|
||||
|
||||
pVertices[i].vTexcoord = _SaveMesh->Vertices[i].UV;
|
||||
}
|
||||
|
||||
D3D11_SUBRESOURCE_DATA InitialVBData{};
|
||||
InitialVBData.pSysMem = pVertices;
|
||||
|
||||
if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB)))
|
||||
return E_FAIL;
|
||||
|
||||
Safe_Delete_Array(pVertices);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _SaveMesh)
|
||||
{
|
||||
m_iVertexStride = sizeof(VTXANIMMESH);
|
||||
D3D11_BUFFER_DESC VBDesc{};
|
||||
VBDesc.ByteWidth = m_iVertexStride * m_iNumVertices;
|
||||
VBDesc.Usage = D3D11_USAGE_DEFAULT;
|
||||
VBDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
VBDesc.StructureByteStride = m_iVertexStride;
|
||||
VBDesc.CPUAccessFlags = 0;
|
||||
VBDesc.MiscFlags = 0;
|
||||
|
||||
VTXANIMMESH* pVertices = new VTXANIMMESH[m_iNumVertices];
|
||||
ZeroMemory(pVertices, sizeof(VTXANIMMESH) * m_iNumVertices);
|
||||
|
||||
m_pVertexPositions = new _float3[m_iNumVertices];
|
||||
ZeroMemory(m_pVertexPositions, sizeof(_float3) * m_iNumVertices);
|
||||
|
||||
for (_uint i = 0; i < m_iNumVertices; ++i)
|
||||
{
|
||||
memcpy(&pVertices[i].vPosition, &_SaveMesh->Vertices[i].Pos, sizeof(_float3));
|
||||
if (_SaveMesh->Vertices[i].bHasNormal)
|
||||
memcpy(&pVertices[i].vNormal, &_SaveMesh->Vertices[i].Normal, sizeof(_float3));
|
||||
else
|
||||
pVertices[i].vNormal = _float3(0.f, 1.f, 0.f);
|
||||
if (_SaveMesh->Vertices[i].bHasTan)
|
||||
memcpy(&pVertices[i].vTangent, &_SaveMesh->Vertices[i].Tan, sizeof(_float3));
|
||||
else
|
||||
pVertices[i].vTangent = _float3(1.f, 0.f, 0.f);
|
||||
|
||||
memcpy(&pVertices[i].vBinormal, &_SaveMesh->Vertices[i].BiNoraml, sizeof(_float3));
|
||||
|
||||
if (_SaveMesh->Vertices[i].bHasUV)
|
||||
memcpy(&pVertices[i].vTexcoord, &_SaveMesh->Vertices[i].UV, sizeof(_float2));
|
||||
else
|
||||
pVertices[i].vTexcoord = _float2(0.f, 0.f);
|
||||
}
|
||||
|
||||
m_iNumBones = (_uint)_SaveMesh->Bones.size();
|
||||
|
||||
m_offsetMatrices.reserve(m_iNumBones);
|
||||
|
||||
m_pBoneMatrices = new _float4x4[0 == m_iNumBones ? 1 : m_iNumBones];
|
||||
ZeroMemory(m_pBoneMatrices, sizeof(_float4x4) * m_iNumBones);
|
||||
|
||||
_float4x4 OffsetMatrix;
|
||||
XMStoreFloat4x4(&OffsetMatrix, XMMatrixIdentity());
|
||||
|
||||
for (_uint i = 0; i < m_iNumBones; i++)
|
||||
{
|
||||
SaveBone _SaveBone = _SaveMesh->Bones[i];
|
||||
strcpy_s(m_szName, _SaveBone.Name);
|
||||
|
||||
memcpy(&OffsetMatrix, &_SaveBone.OffsetMatrix, sizeof(_float4x4));
|
||||
|
||||
_int iBoneIndex = pModel->Get_BoneIndex(_SaveBone.Name);
|
||||
|
||||
if (-1 == iBoneIndex)
|
||||
return E_FAIL;
|
||||
|
||||
m_BoneIndices.push_back(iBoneIndex);
|
||||
m_offsetMatrices.push_back(OffsetMatrix);
|
||||
|
||||
|
||||
for (_uint j = 0; j < _SaveBone.Weights.size(); j++)
|
||||
{
|
||||
SaveBoneWeight _SaveBoneWeight = _SaveBone.Weights[j];
|
||||
|
||||
if (0.f == pVertices[_SaveBoneWeight.VertexId].vBlendWeight.x)
|
||||
{
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendIndex.x = i;
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendWeight.x = _SaveBoneWeight.Weight;
|
||||
}
|
||||
else if (0.f == pVertices[_SaveBoneWeight.VertexId].vBlendWeight.y)
|
||||
{
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendIndex.y = i;
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendWeight.y = _SaveBoneWeight.Weight;
|
||||
}
|
||||
else if (0.f == pVertices[_SaveBoneWeight.VertexId].vBlendWeight.z)
|
||||
{
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendIndex.z = i;
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendWeight.z = _SaveBoneWeight.Weight;
|
||||
}
|
||||
else
|
||||
{
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendIndex.w = i;
|
||||
pVertices[_SaveBoneWeight.VertexId].vBlendWeight.w = _SaveBoneWeight.Weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == m_iNumBones)
|
||||
{
|
||||
m_iNumBones = 1;
|
||||
|
||||
m_BoneIndices.push_back(pModel->Get_BoneIndex(m_szName));
|
||||
|
||||
m_offsetMatrices.push_back(OffsetMatrix);
|
||||
}
|
||||
|
||||
D3D11_SUBRESOURCE_DATA InitialVBData{};
|
||||
InitialVBData.pSysMem = pVertices;
|
||||
|
||||
if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB)))
|
||||
return E_FAIL;
|
||||
|
||||
Safe_Delete_Array(pVertices);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMesh::Initialize(void* pArg)
|
||||
{
|
||||
return S_OK;
|
||||
@@ -491,6 +714,19 @@ CMesh* CMesh::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, HANDL
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CMesh* CMesh::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const CModel* pModel, SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix)
|
||||
{
|
||||
CMesh* pInstance = new CMesh(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype(eType, pModel, _SaveMesh, PreTransformMatrix)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CMesh");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CMesh* CMesh::Clone(void* pArg, class CGameObject* pOwner)
|
||||
{
|
||||
CMesh* pInstance = new CMesh(*this);
|
||||
|
||||
@@ -59,6 +59,26 @@ _int CModel::Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones)
|
||||
return iBoneIndex;
|
||||
}
|
||||
|
||||
_int CModel::Get_BoneIndex(const _char* pBoneName) const
|
||||
{
|
||||
_int iBoneIndex = {};
|
||||
|
||||
auto iter = find_if(m_Bones.begin(), m_Bones.end(), [&](CBone* pBone)->_bool
|
||||
{
|
||||
if (true == pBone->Compare_Name(pBoneName))
|
||||
return true;
|
||||
|
||||
++iBoneIndex;
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (iter == m_Bones.end())
|
||||
return -1;
|
||||
|
||||
return iBoneIndex;
|
||||
}
|
||||
|
||||
void CModel::Change_AnimationIndex(_int iAnimationIndex, _bool bIsLoop, _float fLerpDuration, _bool bIgnoreCurrentIndex)
|
||||
{
|
||||
if (false == bIgnoreCurrentIndex && m_iCurrentAnimIndex == iAnimationIndex) { return; }
|
||||
@@ -164,6 +184,19 @@ _bool CModel::Play_Animation(_float fTimeDelta)
|
||||
return m_bIsFinishedAnim;
|
||||
}
|
||||
|
||||
void CModel::Set_AnimationIndex(_uint iIndex, _bool isLoop)
|
||||
{
|
||||
if (m_iCurrentAnimIndex == iIndex)
|
||||
return;
|
||||
if (iIndex >= 0 && iIndex < m_iNumAnimations)
|
||||
{
|
||||
m_iCurrentAnimIndex = iIndex;
|
||||
m_bIsLoop = isLoop;
|
||||
}
|
||||
else
|
||||
m_iCurrentAnimIndex = -1;
|
||||
}
|
||||
|
||||
void CModel::Stop_Animation()
|
||||
{
|
||||
if (-1 == m_iCurrentAnimIndex // 정지 혹은 시작을 안시켜준 애님
|
||||
@@ -329,6 +362,296 @@ HRESULT CModel::Ready_Bones(const aiNode* pAINode, _int iParentIndex)
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
bool CModel::SaveAssimpModel(const _char* filename)
|
||||
{
|
||||
if (!m_pAIScene) return false;
|
||||
|
||||
_char szModel[MAX_PATH] = {};
|
||||
_char szName[MAX_PATH] = {};
|
||||
_splitpath_s(filename, nullptr, 0, nullptr, 0, szName, MAX_PATH, nullptr, 0);
|
||||
strcat_s(szModel, sizeof(_char) * MAX_PATH, szName);
|
||||
|
||||
_string savePath = string("../Bin/Resources/SaveFile/") + szModel;
|
||||
|
||||
SaveModel modelData;
|
||||
modelData.MeshCount = m_pAIScene->mNumMeshes;
|
||||
modelData.MaterialCount = m_pAIScene->mNumMaterials;
|
||||
|
||||
for (unsigned int i = 0; i < m_pAIScene->mNumMeshes; i++)
|
||||
{
|
||||
aiMesh* mesh = m_pAIScene->mMeshes[i];
|
||||
SaveMesh saveMesh{};
|
||||
strcpy_s(saveMesh.Name, mesh->mName.C_Str());
|
||||
saveMesh.VertexCount = mesh->mNumVertices;
|
||||
saveMesh.IndexCount = mesh->mNumFaces * 3;
|
||||
saveMesh.MaterialIndex = mesh->mMaterialIndex;
|
||||
|
||||
saveMesh.Vertices.resize(saveMesh.VertexCount);
|
||||
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
|
||||
{
|
||||
saveMesh.Vertices[i].Pos = XMFLOAT3{ mesh->mVertices[i].x , mesh->mVertices[i].y,mesh->mVertices[i].z };
|
||||
|
||||
if (mesh->HasNormals())
|
||||
{
|
||||
saveMesh.Vertices[i].Normal = XMFLOAT3{
|
||||
mesh->mNormals[i].x,
|
||||
mesh->mNormals[i].y,
|
||||
mesh->mNormals[i].z
|
||||
};
|
||||
saveMesh.Vertices[i].bHasNormal = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveMesh.Vertices[i].Normal = XMFLOAT3(0.f, 1.f, 0.f);
|
||||
saveMesh.Vertices[i].bHasNormal = false;
|
||||
}
|
||||
|
||||
if (mesh->HasTangentsAndBitangents())
|
||||
{
|
||||
saveMesh.Vertices[i].Tan = XMFLOAT3{
|
||||
mesh->mTangents[i].x,
|
||||
mesh->mTangents[i].y,
|
||||
mesh->mTangents[i].z
|
||||
};
|
||||
saveMesh.Vertices[i].bHasTan = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveMesh.Vertices[i].Tan = XMFLOAT3(1.f, 0.f, 0.f);
|
||||
saveMesh.Vertices[i].bHasTan = false;
|
||||
}
|
||||
|
||||
saveMesh.Vertices[i].BiNoraml = XMFLOAT3{
|
||||
mesh->mBitangents[i].x,
|
||||
mesh->mBitangents[i].y,
|
||||
mesh->mBitangents[i].z
|
||||
};
|
||||
|
||||
if (mesh->HasTextureCoords(0))
|
||||
{
|
||||
saveMesh.Vertices[i].UV = XMFLOAT2{
|
||||
mesh->mTextureCoords[0][i].x,
|
||||
mesh->mTextureCoords[0][i].y
|
||||
};
|
||||
saveMesh.Vertices[i].bHasUV = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
saveMesh.Vertices[i].UV = XMFLOAT2(0.f, 0.f);
|
||||
saveMesh.Vertices[i].bHasUV = false;
|
||||
}
|
||||
saveMesh.Vertices[i].BlendIndex = XMUINT4(0, 0, 0, 0);
|
||||
saveMesh.Vertices[i].BlendWeight = XMFLOAT4(0.f, 0.f, 0.f, 0.f);
|
||||
}
|
||||
saveMesh.BoneCount = mesh->mNumBones;
|
||||
saveMesh.Bones.resize(mesh->mNumBones);
|
||||
for (size_t j = 0; j < mesh->mNumBones; j++)
|
||||
{
|
||||
strcpy_s(saveMesh.Bones[j].Name, sizeof(saveMesh.Bones[j].Name), mesh->mBones[j]->mName.C_Str());
|
||||
|
||||
memcpy(&saveMesh.Bones[j].OffsetMatrix, &mesh->mBones[j]->mOffsetMatrix, sizeof(_float4x4));
|
||||
XMStoreFloat4x4(&saveMesh.Bones[j].OffsetMatrix, XMMatrixTranspose(XMLoadFloat4x4(&saveMesh.Bones[j].OffsetMatrix)));
|
||||
saveMesh.Bones[j].WeightsCount = mesh->mBones[j]->mNumWeights;
|
||||
saveMesh.Bones[j].Weights.resize(mesh->mBones[j]->mNumWeights);
|
||||
for (size_t k = 0; k < saveMesh.Bones[j].WeightsCount; k++)
|
||||
{
|
||||
saveMesh.Bones[j].Weights[k].VertexId = mesh->mBones[j]->mWeights[k].mVertexId;
|
||||
saveMesh.Bones[j].Weights[k].Weight = mesh->mBones[j]->mWeights[k].mWeight;
|
||||
}
|
||||
}
|
||||
|
||||
saveMesh.Indices.reserve(saveMesh.IndexCount);
|
||||
for (unsigned int i = 0; i < mesh->mNumFaces; i++)
|
||||
{
|
||||
aiFace& face = mesh->mFaces[i];
|
||||
for (unsigned int idx = 0; idx < face.mNumIndices; idx++)
|
||||
saveMesh.Indices.push_back(face.mIndices[idx]);
|
||||
}
|
||||
|
||||
modelData.Meshes.push_back(saveMesh);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_Materials.size(); i++)
|
||||
{
|
||||
modelData.Materials.push_back(m_Materials[i]->Get_SaveMaterial());
|
||||
}
|
||||
|
||||
std::vector<SaveNode> allNodes;
|
||||
SaveNodeRecursive(m_pAIScene->mRootNode, allNodes, -1);
|
||||
|
||||
modelData.AnimationCount = m_pAIScene->mNumAnimations;
|
||||
for (unsigned int i = 0; i < modelData.AnimationCount; i++)
|
||||
{
|
||||
aiAnimation* Anim = m_pAIScene->mAnimations[i];
|
||||
SaveAnimation saveAnim{};
|
||||
strcpy_s(saveAnim.Name, Anim->mName.C_Str());
|
||||
saveAnim.mDuration = (_float)Anim->mDuration;
|
||||
saveAnim.mTicksPerSecond = (_float)Anim->mTicksPerSecond;
|
||||
saveAnim.ChannelCount = Anim->mNumChannels;
|
||||
|
||||
saveAnim.Channels.resize(Anim->mNumChannels);
|
||||
for (size_t j = 0; j < saveAnim.ChannelCount; j++)
|
||||
{
|
||||
strcpy_s(saveAnim.Channels[j].Name, sizeof(saveAnim.Channels[j].Name),
|
||||
Anim->mChannels[j]->mNodeName.C_Str());
|
||||
|
||||
saveAnim.Channels[j].ScalingKeyCount = Anim->mChannels[j]->mNumScalingKeys;
|
||||
saveAnim.Channels[j].RotationKeyCount = Anim->mChannels[j]->mNumRotationKeys;
|
||||
saveAnim.Channels[j].PositionKeyCount = Anim->mChannels[j]->mNumPositionKeys;
|
||||
for (size_t k = 0; k < saveAnim.Channels[j].ScalingKeyCount; k++)
|
||||
{
|
||||
SaveKeyFrameVec Key;
|
||||
Key.Time = (_float)Anim->mChannels[j]->mScalingKeys[k].mTime;
|
||||
Key.Value = XMFLOAT3(
|
||||
Anim->mChannels[j]->mScalingKeys[k].mValue.x,
|
||||
Anim->mChannels[j]->mScalingKeys[k].mValue.y,
|
||||
Anim->mChannels[j]->mScalingKeys[k].mValue.z);
|
||||
saveAnim.Channels[j].ScalingKeys.push_back(Key);
|
||||
}
|
||||
for (size_t k = 0; k < saveAnim.Channels[j].RotationKeyCount; k++)
|
||||
{
|
||||
SaveKeyFrameRotation Key;
|
||||
Key.Time = (_float)Anim->mChannels[j]->mRotationKeys[k].mTime;
|
||||
Key.Value = XMFLOAT4(
|
||||
Anim->mChannels[j]->mRotationKeys[k].mValue.x,
|
||||
Anim->mChannels[j]->mRotationKeys[k].mValue.y,
|
||||
Anim->mChannels[j]->mRotationKeys[k].mValue.z,
|
||||
Anim->mChannels[j]->mRotationKeys[k].mValue.w);
|
||||
saveAnim.Channels[j].RotationKeys.push_back(Key);
|
||||
}
|
||||
for (size_t k = 0; k < saveAnim.Channels[j].PositionKeyCount; k++)
|
||||
{
|
||||
SaveKeyFrameVec Key;
|
||||
Key.Time = (_float)Anim->mChannels[j]->mPositionKeys[k].mTime;
|
||||
Key.Value = XMFLOAT3(
|
||||
Anim->mChannels[j]->mPositionKeys[k].mValue.x,
|
||||
Anim->mChannels[j]->mPositionKeys[k].mValue.y,
|
||||
Anim->mChannels[j]->mPositionKeys[k].mValue.z);
|
||||
saveAnim.Channels[j].PositionKeys.push_back(Key);
|
||||
}
|
||||
}
|
||||
modelData.Animations.push_back(saveAnim);
|
||||
}
|
||||
|
||||
FILE* fp = nullptr;
|
||||
fopen_s(&fp, savePath.c_str(), "wb");
|
||||
if (!fp) return false;
|
||||
|
||||
fwrite(&modelData.MeshCount, sizeof(_uint), 1, fp);
|
||||
fwrite(&modelData.MaterialCount, sizeof(_uint), 1, fp);
|
||||
fwrite(&modelData.AnimationCount, sizeof(_uint), 1, fp);
|
||||
modelData.NodeCount = (_uint)allNodes.size();
|
||||
fwrite(&modelData.NodeCount, sizeof(_uint), 1, fp);
|
||||
|
||||
for (auto& mesh : modelData.Meshes)
|
||||
{
|
||||
fwrite(&mesh.Name, sizeof(mesh.Name), 1, fp);
|
||||
fwrite(&mesh.VertexCount, sizeof(_uint), 1, fp);
|
||||
fwrite(&mesh.IndexCount, sizeof(_uint), 1, fp);
|
||||
fwrite(&mesh.MaterialIndex, sizeof(_uint), 1, fp);
|
||||
fwrite(&mesh.BoneCount, sizeof(_uint), 1, fp);
|
||||
|
||||
fwrite(mesh.Vertices.data(), sizeof(SaveVertex), mesh.VertexCount, fp);
|
||||
fwrite(mesh.Indices.data(), sizeof(_uint), mesh.IndexCount, fp);
|
||||
for (auto& bone : mesh.Bones)
|
||||
{
|
||||
fwrite(&bone.Name, sizeof(bone.Name), 1, fp);
|
||||
fwrite(&bone.OffsetMatrix, sizeof(XMFLOAT4X4), 1, fp);
|
||||
fwrite(&bone.WeightsCount, sizeof(_uint), 1, fp);
|
||||
for (auto& Weights : bone.Weights)
|
||||
{
|
||||
fwrite(&Weights.VertexId, sizeof(_uint), 1, fp);
|
||||
fwrite(&Weights.Weight, sizeof(float), 1, fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (auto& node : allNodes)
|
||||
{
|
||||
fwrite(node.Name, sizeof(node.Name), 1, fp);
|
||||
fwrite(&node.ParentIndex, sizeof(int), 1, fp);
|
||||
fwrite(&node.Transformation, sizeof(XMFLOAT4X4), 1, fp);
|
||||
fwrite(&node.ChildrenCount, sizeof(_uint), 1, fp);
|
||||
|
||||
for (auto child : node.ChildrenIndices)
|
||||
{
|
||||
fwrite(&child, sizeof(int), 1, fp);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& Anim : modelData.Animations)
|
||||
{
|
||||
fwrite(Anim.Name, sizeof(Anim.Name), 1, fp);
|
||||
fwrite(&Anim.mDuration, sizeof(_float), 1, fp);
|
||||
fwrite(&Anim.mTicksPerSecond, sizeof(_float), 1, fp);
|
||||
fwrite(&Anim.ChannelCount, sizeof(_uint), 1, fp);
|
||||
for (size_t i = 0; i < Anim.ChannelCount; i++)
|
||||
{
|
||||
fwrite(Anim.Channels[i].Name, sizeof(Anim.Channels[i].Name), 1, fp);
|
||||
|
||||
fwrite(&Anim.Channels[i].ScalingKeyCount, sizeof(_uint), 1, fp);
|
||||
fwrite(Anim.Channels[i].ScalingKeys.data(), sizeof(SaveKeyFrameVec), Anim.Channels[i].ScalingKeyCount, fp);
|
||||
|
||||
fwrite(&Anim.Channels[i].RotationKeyCount, sizeof(_uint), 1, fp);
|
||||
fwrite(Anim.Channels[i].RotationKeys.data(), sizeof(SaveKeyFrameRotation), Anim.Channels[i].RotationKeyCount, fp);
|
||||
|
||||
fwrite(&Anim.Channels[i].PositionKeyCount, sizeof(_uint), 1, fp);
|
||||
fwrite(Anim.Channels[i].PositionKeys.data(), sizeof(SaveKeyFrameVec), Anim.Channels[i].PositionKeyCount, fp);
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& mat : modelData.Materials)
|
||||
{
|
||||
for (_uint i = 0; i < AI_TEXTURE_TYPE_MAX; i++)
|
||||
{
|
||||
_uint MaterialCount = static_cast<_uint>(mat.Path[i].size());
|
||||
fwrite(&MaterialCount, sizeof(_uint), 1, fp);
|
||||
for (const auto& path : mat.Path[i])
|
||||
{
|
||||
_uint len = static_cast<_uint>(path.size());
|
||||
fwrite(&len, sizeof(_uint), 1, fp);
|
||||
fwrite(path.c_str(), sizeof(char), len, fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
MSG_BOX("Save Succeed");
|
||||
|
||||
return true;
|
||||
}
|
||||
_int CModel::SaveNodeRecursive(const aiNode* pAINode, std::vector<SaveNode>& outNodes, _int parentIndex)
|
||||
{
|
||||
SaveNode node{};
|
||||
strcpy_s(node.Name, sizeof(node.Name), pAINode->mName.C_Str());
|
||||
node.ParentIndex = parentIndex;
|
||||
|
||||
const aiMatrix4x4& m = pAINode->mTransformation;
|
||||
node.Transformation = XMFLOAT4X4(
|
||||
m.a1, m.a2, m.a3, m.a4,
|
||||
m.b1, m.b2, m.b3, m.b4,
|
||||
m.c1, m.c2, m.c3, m.c4,
|
||||
m.d1, m.d2, m.d3, m.d4
|
||||
);
|
||||
|
||||
XMStoreFloat4x4(&node.Transformation, XMMatrixTranspose(XMLoadFloat4x4(&node.Transformation)));
|
||||
|
||||
node.ChildrenCount = pAINode->mNumChildren;
|
||||
node.ChildrenIndices.resize(node.ChildrenCount);
|
||||
|
||||
int currentIndex = static_cast<int>(outNodes.size());
|
||||
outNodes.push_back(node);
|
||||
|
||||
for (size_t i = 0; i < pAINode->mNumChildren; i++)
|
||||
{
|
||||
int childIndex = SaveNodeRecursive(pAINode->mChildren[i], outNodes, currentIndex);
|
||||
outNodes[currentIndex].ChildrenIndices[i] = childIndex;
|
||||
}
|
||||
|
||||
return currentIndex;
|
||||
}
|
||||
#endif // EDITOR_PROJECT
|
||||
|
||||
HRESULT CModel::Initialize_Prototype()
|
||||
@@ -336,11 +659,195 @@ HRESULT CModel::Initialize_Prototype()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix)
|
||||
{
|
||||
LoadData(pModelFilePath);
|
||||
m_pSaveModel = m_pGameInstance->Load_SaveModel(pModelFilePath);
|
||||
|
||||
m_eType = eType;
|
||||
XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix);
|
||||
|
||||
Ready_Bones(m_pSaveModel->Nodes, 0, -1);
|
||||
|
||||
if (FAILED(Ready_Meshes()))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(Ready_Materials(pModelFilePath)))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(Ready_Animations()))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CModel::Initialize_Prototype(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
|
||||
{
|
||||
return Assimp_Model_Load(pModelFilePath, eType, PreTransformMatrix, iRootBoneIndex);
|
||||
}
|
||||
|
||||
bool CModel::LoadData(const _char* filename)
|
||||
{
|
||||
FILE* fp = nullptr;
|
||||
fopen_s(&fp, filename, "rb");
|
||||
if (!fp) return false;
|
||||
|
||||
SaveModel NewModel = {};
|
||||
|
||||
fread(&NewModel.MeshCount, sizeof(_uint), 1, fp);
|
||||
fread(&NewModel.MaterialCount, sizeof(_uint), 1, fp);
|
||||
fread(&NewModel.AnimationCount, sizeof(_uint), 1, fp);
|
||||
fread(&NewModel.NodeCount, sizeof(_uint), 1, fp);
|
||||
|
||||
for (_uint i = 0; i < NewModel.MeshCount; i++)
|
||||
{
|
||||
SaveMesh mesh{};
|
||||
fread(&mesh.Name, sizeof(mesh.Name), 1, fp);
|
||||
fread(&mesh.VertexCount, sizeof(_uint), 1, fp);
|
||||
fread(&mesh.IndexCount, sizeof(_uint), 1, fp);
|
||||
fread(&mesh.MaterialIndex, sizeof(_uint), 1, fp);
|
||||
fread(&mesh.BoneCount, sizeof(_uint), 1, fp);
|
||||
|
||||
mesh.Vertices.resize(mesh.VertexCount);
|
||||
fread(mesh.Vertices.data(), sizeof(SaveVertex), mesh.VertexCount, fp);
|
||||
|
||||
mesh.Indices.resize(mesh.IndexCount);
|
||||
fread(mesh.Indices.data(), sizeof(_uint), mesh.IndexCount, fp);
|
||||
|
||||
mesh.Bones.resize(mesh.BoneCount);
|
||||
for (size_t i = 0; i < mesh.BoneCount; i++)
|
||||
{
|
||||
fread(&mesh.Bones[i].Name, sizeof(mesh.Bones[i].Name), 1, fp);
|
||||
fread(&mesh.Bones[i].OffsetMatrix, sizeof(XMFLOAT4X4), 1, fp);
|
||||
fread(&mesh.Bones[i].WeightsCount, sizeof(_uint), 1, fp);
|
||||
mesh.Bones[i].Weights.resize(mesh.Bones[i].WeightsCount);
|
||||
for (size_t j = 0;j < mesh.Bones[i].WeightsCount; j++)
|
||||
{
|
||||
fread(&mesh.Bones[i].Weights[j].VertexId, sizeof(_uint), 1, fp);
|
||||
fread(&mesh.Bones[i].Weights[j].Weight, sizeof(_float), 1, fp);
|
||||
}
|
||||
}
|
||||
NewModel.Meshes.push_back(mesh);
|
||||
}
|
||||
|
||||
NewModel.Nodes.resize(NewModel.NodeCount);
|
||||
for (size_t i = 0; i < NewModel.NodeCount; i++)
|
||||
{
|
||||
fread(NewModel.Nodes[i].Name, sizeof(NewModel.Nodes[i].Name), 1, fp);
|
||||
fread(&NewModel.Nodes[i].ParentIndex, sizeof(int), 1, fp);
|
||||
fread(&NewModel.Nodes[i].Transformation, sizeof(XMFLOAT4X4), 1, fp);
|
||||
fread(&NewModel.Nodes[i].ChildrenCount, sizeof(_uint), 1, fp);
|
||||
NewModel.Nodes[i].ChildrenIndices.resize(NewModel.Nodes[i].ChildrenCount);
|
||||
for (size_t j = 0; j < NewModel.Nodes[i].ChildrenCount; j++)
|
||||
{
|
||||
fread(&NewModel.Nodes[i].ChildrenIndices[j], sizeof(int), 1, fp);
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < NewModel.AnimationCount; i++)
|
||||
{
|
||||
SaveAnimation saveAnim = {};
|
||||
fread(&saveAnim.Name, sizeof(saveAnim.Name), 1, fp);
|
||||
fread(&saveAnim.mDuration, sizeof(_float), 1, fp);
|
||||
fread(&saveAnim.mTicksPerSecond, sizeof(_float), 1, fp);
|
||||
fread(&saveAnim.ChannelCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels.resize(saveAnim.ChannelCount);
|
||||
for (size_t j = 0; j < saveAnim.ChannelCount; j++)
|
||||
{
|
||||
fread(&saveAnim.Channels[j].Name, sizeof(saveAnim.Channels[j].Name), 1, fp);
|
||||
|
||||
fread(&saveAnim.Channels[j].ScalingKeyCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels[j].ScalingKeys.resize(saveAnim.Channels[j].ScalingKeyCount);
|
||||
fread(saveAnim.Channels[j].ScalingKeys.data(), sizeof(SaveKeyFrameVec), saveAnim.Channels[j].ScalingKeyCount, fp);
|
||||
|
||||
fread(&saveAnim.Channels[j].RotationKeyCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels[j].RotationKeys.resize(saveAnim.Channels[j].RotationKeyCount);
|
||||
fread(saveAnim.Channels[j].RotationKeys.data(), sizeof(SaveKeyFrameRotation), saveAnim.Channels[j].RotationKeyCount, fp);
|
||||
|
||||
fread(&saveAnim.Channels[j].PositionKeyCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels[j].PositionKeys.resize(saveAnim.Channels[j].PositionKeyCount);
|
||||
fread(saveAnim.Channels[j].PositionKeys.data(), sizeof(SaveKeyFrameVec), saveAnim.Channels[j].PositionKeyCount, fp);
|
||||
}
|
||||
NewModel.Animations.push_back(saveAnim);
|
||||
}
|
||||
|
||||
NewModel.Materials.clear();
|
||||
for (_uint i = 0; i < NewModel.MaterialCount; i++)
|
||||
{
|
||||
SaveMaterial mat;
|
||||
|
||||
for (_uint k = 0; k < AI_TEXTURE_TYPE_MAX; k++)
|
||||
{
|
||||
_uint MaterialCount = 0;
|
||||
fread(&MaterialCount, sizeof(_uint), 1, fp);
|
||||
mat.Path[k].resize(MaterialCount);
|
||||
for (_uint j = 0; j < MaterialCount; j++)
|
||||
{
|
||||
_uint len = 0;
|
||||
fread(&len, sizeof(_uint), 1, fp);
|
||||
std::string temp;
|
||||
temp.resize(len);
|
||||
fread(&temp[0], sizeof(char), len, fp);
|
||||
mat.Path[k][j] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*_uint diffuseCount = 0;
|
||||
fread(&diffuseCount, sizeof(_uint), 1, fp);
|
||||
mat.DiffusePath.resize(diffuseCount);
|
||||
for (_uint j = 0; j < diffuseCount; j++)
|
||||
{
|
||||
_uint len = 0;
|
||||
fread(&len, sizeof(_uint), 1, fp);
|
||||
std::string temp;
|
||||
temp.resize(len);
|
||||
fread(&temp[0], sizeof(char), len, fp);
|
||||
mat.DiffusePath[j] = temp;
|
||||
}
|
||||
|
||||
_uint normalCount = 0;
|
||||
fread(&normalCount, sizeof(_uint), 1, fp);
|
||||
mat.NormalPath.resize(normalCount);
|
||||
for (_uint j = 0; j < normalCount; j++)
|
||||
{
|
||||
_uint len = 0;
|
||||
fread(&len, sizeof(_uint), 1, fp);
|
||||
std::string temp;
|
||||
temp.resize(len);
|
||||
fread(&temp[0], sizeof(char), len, fp);
|
||||
mat.NormalPath[j] = temp;
|
||||
}
|
||||
|
||||
_uint specularCount = 0;
|
||||
fread(&specularCount, sizeof(_uint), 1, fp);
|
||||
mat.SpecularPath.resize(specularCount);
|
||||
for (_uint j = 0; j < specularCount; j++)
|
||||
{
|
||||
_uint len = 0;
|
||||
fread(&len, sizeof(_uint), 1, fp);
|
||||
std::string temp;
|
||||
temp.resize(len);
|
||||
fread(&temp[0], sizeof(char), len, fp);
|
||||
mat.SpecularPath[j] = temp;
|
||||
}*/
|
||||
|
||||
NewModel.Materials.push_back(mat);
|
||||
}
|
||||
|
||||
|
||||
fclose(fp);
|
||||
|
||||
m_SaveModel.push_back(NewModel);
|
||||
|
||||
m_pGameInstance->Add_SaveModel(filename, m_SaveModel.back());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
|
||||
{
|
||||
CModel* pInstance = new CModel(pDevice, pContext);
|
||||
@@ -364,34 +871,36 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma
|
||||
}
|
||||
m_iRootBoneIndex = iRootBoneIndex;
|
||||
|
||||
Assimp::Importer Importer = {};
|
||||
const aiScene* pAIScene = { nullptr };
|
||||
|
||||
pAIScene = Importer.ReadFile(pModelFilePath, iFlag);
|
||||
if (nullptr == pAIScene) {
|
||||
m_pAIScene = m_Importer.ReadFile(pModelFilePath, iFlag);
|
||||
if (nullptr == m_pAIScene)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
#pragma region Bone
|
||||
if (FAILED(Ready_Bones(pAIScene->mRootNode, -1))) {
|
||||
if (FAILED(Ready_Bones(m_pAIScene->mRootNode, -1))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Mesh
|
||||
if (FAILED(Ready_Meshes(eType, pAIScene, PreTransformMatrix))) {
|
||||
if (FAILED(Ready_Meshes(eType, m_pAIScene, PreTransformMatrix))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Material
|
||||
if (FAILED(Ready_Materials(pAIScene, pModelFilePath))) {
|
||||
if (FAILED(Ready_Materials(m_pAIScene, pModelFilePath))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Animation
|
||||
if (FAILED(Ready_Animations(pAIScene))) {
|
||||
if (FAILED(Ready_Animations(m_pAIScene))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
m_pGameInstance->Save_ModelFilePath(pModelFilePath);
|
||||
|
||||
m_pGameInstance->Add_ModelToMap(pModelFilePath, this);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -407,6 +916,73 @@ HRESULT CModel::Initialize(void* pArg)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_Meshes()
|
||||
{
|
||||
m_iNumMeshes = m_pSaveModel->MeshCount;
|
||||
|
||||
for (size_t i = 0; i < m_iNumMeshes; i++)
|
||||
{
|
||||
CMesh* pMesh = CMesh::Create(m_pDevice, m_pContext, m_eType, this, &m_pSaveModel->Meshes[i], XMLoadFloat4x4(&m_PreTransformMatrix));
|
||||
if (nullptr == pMesh)
|
||||
return E_FAIL;
|
||||
|
||||
m_Meshes.push_back(pMesh);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_Materials(const _char* pModelFilePath)
|
||||
{
|
||||
m_iNumMaterials = m_pSaveModel->MaterialCount;
|
||||
|
||||
for (size_t i = 0; i < m_iNumMaterials; i++)
|
||||
{
|
||||
CMaterial* pMaterial = CMaterial::Create(m_pDevice, m_pContext, pModelFilePath, m_pSaveModel->Materials[i]);
|
||||
if (nullptr == pMaterial)
|
||||
return E_FAIL;
|
||||
|
||||
m_Materials.push_back(pMaterial);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_Bones(const std::vector<SaveNode>& allNodes, _int currentIndex, _int parentIndex)
|
||||
{
|
||||
const SaveNode& saveNode = allNodes[currentIndex];
|
||||
|
||||
CBone* pBone = CBone::Create(saveNode, parentIndex);
|
||||
|
||||
if (!pBone) return E_FAIL;
|
||||
|
||||
m_Bones.push_back(pBone);
|
||||
|
||||
_int myIndex = _int(m_Bones.size() - 1);
|
||||
|
||||
for (size_t i = 0; i < saveNode.ChildrenIndices.size(); i++)
|
||||
{
|
||||
Ready_Bones(allNodes, saveNode.ChildrenIndices[i], myIndex);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_Animations()
|
||||
{
|
||||
m_iNumAnimations = m_pSaveModel->AnimationCount;
|
||||
|
||||
for (size_t i = 0; i < m_iNumAnimations; i++)
|
||||
{
|
||||
CAnimation* pAnimation = CAnimation::Create(this, &m_pSaveModel->Animations[i]);
|
||||
if (nullptr == pAnimation)
|
||||
return E_FAIL;
|
||||
|
||||
m_Animations.push_back(pAnimation);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CModel* pInstance = new CModel(pDevice, pContext);
|
||||
@@ -420,6 +996,19 @@ CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath,_fmatrix PreTransformMatrix)
|
||||
{
|
||||
CModel* pInstance = new CModel(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype(eType, pModelFilePath, PreTransformMatrix)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CModel");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CComponent* CModel::Clone(void* pArg, class CGameObject* pOwner)
|
||||
{
|
||||
CModel* pInstance = new CModel(*this);
|
||||
@@ -458,6 +1047,8 @@ void CModel::Free()
|
||||
|
||||
SAFE_RELEASE(m_pTransform);
|
||||
SAFE_RELEASE(m_pLerpAnim);
|
||||
|
||||
m_SaveModel.clear();
|
||||
}
|
||||
|
||||
void CModel::Describe_Entity()
|
||||
|
||||
@@ -33,10 +33,17 @@ class ENGINE_DLL CAnimation : public CBase
|
||||
|
||||
private:
|
||||
HRESULT Initialize(HANDLE hFile, DWORD& dwByte);
|
||||
// 바이너리
|
||||
HRESULT Initialize(const class CModel* pModel,SaveAnimation* pSaveAnimation);
|
||||
//
|
||||
HRESULT Combined_Initialize();
|
||||
_uint Get_BoneIndex(const char* pChannelName);
|
||||
|
||||
private:
|
||||
SaveAnimation* m_pSaveAnim = { nullptr };
|
||||
_char m_szName[MAX_PATH] = {};
|
||||
_float m_fTickPerSecond = {};
|
||||
|
||||
_bool m_bPause = { FALSE }; // 애님퍼즈 인덱스
|
||||
_string m_strName = {}; // 애님 이름
|
||||
_float m_fCurrentTrackPosition = {}; // 현재 트랙 위치
|
||||
@@ -52,6 +59,9 @@ class ENGINE_DLL CAnimation : public CBase
|
||||
|
||||
public:
|
||||
static CAnimation* Create(HANDLE hFile, DWORD& dwByte);
|
||||
// 바이너리
|
||||
static CAnimation* Create(const class CModel* pModel, SaveAnimation* pSaveAnimation);
|
||||
//
|
||||
CAnimation* Clone();
|
||||
virtual void Free() override;
|
||||
void Describe_Entity();
|
||||
|
||||
@@ -37,6 +37,9 @@ class ENGINE_DLL CBone final : public CBase
|
||||
|
||||
private:
|
||||
HRESULT Initialize(HANDLE hFile, DWORD& dwByte);
|
||||
// 바이너리
|
||||
HRESULT Initialize(const SaveNode& _SaveNode, _int iParentIndex);
|
||||
//
|
||||
|
||||
public:
|
||||
static CBone* Create(HANDLE hFile, DWORD& dwByte);
|
||||
@@ -47,6 +50,9 @@ class ENGINE_DLL CBone final : public CBase
|
||||
public:
|
||||
HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte);
|
||||
static CBone* Create(const aiNode* pAINode, _int iParentIndex);
|
||||
// 바이너리
|
||||
static CBone* Create(const SaveNode& _SaveNode, _int iParentIndex);
|
||||
//
|
||||
private:
|
||||
HRESULT Initialize(const aiNode* pAINode, _int iParentIndex);
|
||||
#endif // EDITOR_PROJECT
|
||||
|
||||
@@ -30,18 +30,25 @@ class ENGINE_DLL CChannel : public CBase
|
||||
}
|
||||
private:
|
||||
HRESULT Initialize(HANDLE hFile, DWORD& dwByte);
|
||||
// 바이너리
|
||||
HRESULT Initialize(const class CModel* pModel, SaveChannel* pSaveChannel);
|
||||
//
|
||||
HRESULT Initialize(const vector<class CBone*>& Bones, _uint iIndex);
|
||||
|
||||
|
||||
private:
|
||||
_char m_szName[MAX_PATH] = {}; // 영향을 받을 본의 이름
|
||||
_int m_iBoneIndex = { -1 }; // 본 벡터에서 본의 인덱스
|
||||
_uint m_iNumKeyFrames = {}; // Animation의 m_fDuration동안 이 본이 취해야할 키프레임의 갯수
|
||||
vector<KEYFRAME> m_KeyFrames; // 키프레임 벡터
|
||||
_char m_szName[MAX_PATH] = {}; // 영향을 받을 본의 이름
|
||||
_int m_iBoneIndex = { -1 }; // 본 벡터에서 본의 인덱스
|
||||
_uint m_iNumKeyFrames = {}; // Animation의 m_fDuration동안 이 본이 취해야할 키프레임의 갯수
|
||||
_float4x4 m_PreTransformMatrix = {};
|
||||
vector<KEYFRAME> m_KeyFrames; // 키프레임 벡터
|
||||
|
||||
public:
|
||||
static CChannel* Create(const vector<class CBone*>& Bones, _uint iIndex); // 럴프전용
|
||||
static CChannel* Create(HANDLE hFile, DWORD& dwByte);
|
||||
// 바이너리
|
||||
static CChannel* Create(const class CModel* pModel, SaveChannel* pSaveChannel);
|
||||
//
|
||||
virtual void Free() override;
|
||||
};
|
||||
|
||||
|
||||
@@ -55,6 +55,111 @@ typedef struct tagShadowLight
|
||||
_float fWidth, fHeight, fNear, fFar;
|
||||
}SHADOW_LIGHT_DESC;
|
||||
|
||||
struct SaveVertex
|
||||
{
|
||||
XMFLOAT3 Pos;
|
||||
XMFLOAT3 Normal;
|
||||
XMFLOAT3 Tan;
|
||||
XMFLOAT3 BiNoraml;
|
||||
XMFLOAT2 UV;
|
||||
|
||||
bool bHasNormal;
|
||||
bool bHasTan;
|
||||
bool bHasUV;
|
||||
|
||||
XMUINT4 BlendIndex;
|
||||
XMFLOAT4 BlendWeight;
|
||||
};
|
||||
|
||||
struct SaveBoneWeight
|
||||
{
|
||||
unsigned int VertexId;
|
||||
float Weight;
|
||||
};
|
||||
|
||||
struct SaveBone
|
||||
{
|
||||
char Name[64];
|
||||
XMFLOAT4X4 OffsetMatrix;
|
||||
int BoneIndex;
|
||||
unsigned int WeightsCount;
|
||||
vector<SaveBoneWeight>Weights;
|
||||
};
|
||||
|
||||
struct SaveNode
|
||||
{
|
||||
char Name[64];
|
||||
int ParentIndex;
|
||||
unsigned int ChildrenCount;
|
||||
XMFLOAT4X4 Transformation;
|
||||
vector<int> ChildrenIndices;
|
||||
};
|
||||
|
||||
struct SaveMesh
|
||||
{
|
||||
char Name[64];
|
||||
unsigned int VertexCount;
|
||||
unsigned int IndexCount;
|
||||
unsigned int MaterialIndex;
|
||||
unsigned int BoneCount;
|
||||
|
||||
vector<SaveVertex> Vertices;
|
||||
vector<unsigned int> Indices;
|
||||
|
||||
vector<SaveBone> Bones;
|
||||
};
|
||||
|
||||
struct SaveMaterial
|
||||
{
|
||||
vector<string> Path[27];
|
||||
|
||||
};
|
||||
|
||||
struct SaveKeyFrameVec
|
||||
{
|
||||
float Time;
|
||||
XMFLOAT3 Value;
|
||||
};
|
||||
|
||||
struct SaveKeyFrameRotation
|
||||
{
|
||||
float Time;
|
||||
XMFLOAT4 Value;
|
||||
};
|
||||
|
||||
struct SaveChannel
|
||||
{
|
||||
char Name[64];
|
||||
unsigned int ScalingKeyCount;
|
||||
unsigned int RotationKeyCount;
|
||||
unsigned int PositionKeyCount;
|
||||
|
||||
vector<SaveKeyFrameVec> ScalingKeys;
|
||||
vector<SaveKeyFrameRotation> RotationKeys;
|
||||
vector<SaveKeyFrameVec> PositionKeys;
|
||||
};
|
||||
|
||||
struct SaveAnimation
|
||||
{
|
||||
char Name[128];
|
||||
float mDuration;
|
||||
float mTicksPerSecond;
|
||||
unsigned int ChannelCount;
|
||||
vector<SaveChannel> Channels;
|
||||
};
|
||||
|
||||
struct SaveModel
|
||||
{
|
||||
unsigned int MeshCount;
|
||||
unsigned int MaterialCount;
|
||||
unsigned int AnimationCount;
|
||||
unsigned int NodeCount;
|
||||
vector<SaveMesh> Meshes;
|
||||
vector<SaveMaterial> Materials;
|
||||
vector<SaveAnimation> Animations;
|
||||
vector<SaveNode>Nodes;
|
||||
};
|
||||
|
||||
typedef struct tagVertexInstance_Particle
|
||||
{
|
||||
_float4 vRight;
|
||||
|
||||
@@ -165,6 +165,24 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
#pragma region SOUND_MANAGER
|
||||
#pragma endregion
|
||||
|
||||
public:
|
||||
void Add_ModelToMap(const _char* filePath, CModel* pModel)
|
||||
{
|
||||
m_ModelMap[filePath] = pModel;
|
||||
}
|
||||
|
||||
void Add_SaveModel(const _char* filePath, SaveModel sModel)
|
||||
{
|
||||
m_sModelMap[filePath] = sModel;
|
||||
}
|
||||
|
||||
SaveModel* Load_SaveModel(const _char* filePath);
|
||||
_bool SaveAssimpModel(const _char* filename);
|
||||
void Save_ModelFilePath(const _char* FilePath);
|
||||
const _char* Load_ModelFilePath(_uint iIndex);
|
||||
const _char* Load_BinaryModelFilePath(_uint iIndex);
|
||||
size_t ModelFilePathCount();
|
||||
|
||||
private:
|
||||
class CGraphic_Device* m_pGraphic_Device = { nullptr };
|
||||
class CTimer_Manager* m_pTimer_Manager = { nullptr };
|
||||
@@ -189,6 +207,10 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
_float m_fTimer_DrawCall = { 0.f };
|
||||
_float m_fTimer_Present = { 0.f };
|
||||
_float m_fTimer_FrameCount = { 0.f };
|
||||
|
||||
vector<const _char*> m_FilePaths = {};
|
||||
map<const _char*, CModel*> m_ModelMap;
|
||||
map<const _char*, SaveModel> m_sModelMap;
|
||||
#endif // _DEBUG
|
||||
|
||||
public:
|
||||
|
||||
@@ -12,13 +12,14 @@ class ENGINE_DLL CMaterial final : public CBase
|
||||
|
||||
public:
|
||||
HRESULT Bind_SRV(class CShader* pShader, const _char* pConstantName, _uint iType, _uint iTextureIndex);
|
||||
|
||||
SaveMaterial Get_SaveMaterial() { return m_SaveMaterial; }
|
||||
private:
|
||||
class CGameInstance* m_pGameInstance = { nullptr };
|
||||
ID3D11Device* m_pDevice = { nullptr };
|
||||
ID3D11DeviceContext* m_pContext = { nullptr };
|
||||
|
||||
vector<ID3D11ShaderResourceView*> m_SRVs[AI_TEXTURE_TYPE_MAX];
|
||||
SaveMaterial m_SaveMaterial;
|
||||
|
||||
#ifdef EDITOR_PROJECT
|
||||
public:
|
||||
@@ -30,10 +31,15 @@ class ENGINE_DLL CMaterial final : public CBase
|
||||
#endif // EDITOR_PROJECT
|
||||
|
||||
virtual HRESULT Initialize(const _char* pModelFilePath, HANDLE hFile, DWORD& dwByte);
|
||||
|
||||
// 바이너리
|
||||
HRESULT Initialize(const _char* pModelFilePath, const SaveMaterial& _SaveMaterial);
|
||||
//
|
||||
|
||||
public:
|
||||
static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, HANDLE hFile, DWORD& dwByte);
|
||||
// 바이너리
|
||||
static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePathconst, const SaveMaterial& _SaveMaterial);
|
||||
//
|
||||
virtual void Free() override;
|
||||
};
|
||||
|
||||
|
||||
@@ -34,7 +34,11 @@ class ENGINE_DLL CMesh final : public CVIBuffer
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
HRESULT Ready_VertexBuffer_For_NonAnim(HANDLE hFile, DWORD& dwByte);
|
||||
HRESULT Ready_VertexBuffer_For_Anim(HANDLE hFile, DWORD& dwByte);
|
||||
|
||||
// 바이너리
|
||||
virtual HRESULT Initialize_Prototype(MODEL eType, const class CModel* pModel, SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix);
|
||||
HRESULT Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix);
|
||||
HRESULT Ready_VertexBuffer_For_Anim(const class CModel* pModel, SaveMesh* _SaveMesh);
|
||||
//
|
||||
private:
|
||||
_char m_szName[MAX_PATH] = {};
|
||||
_uint m_iMaterialIndex = {};
|
||||
@@ -43,9 +47,16 @@ class ENGINE_DLL CMesh final : public CVIBuffer
|
||||
vector<_int> m_BoneIndices;
|
||||
_float4x4* m_pBoneMatrices = { nullptr };
|
||||
vector<_float4x4> m_offsetMatrices;
|
||||
// 바이너리
|
||||
std::vector<_uint> m_Indices;
|
||||
std::vector<_float3> m_Vertices;
|
||||
//
|
||||
|
||||
public:
|
||||
static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, HANDLE hFile, DWORD& dwByte);
|
||||
// 바이너리
|
||||
static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const class CModel* pModel, SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix);
|
||||
//
|
||||
virtual CMesh* Clone(void* pArg, class CGameObject* pOwner = nullptr) override;
|
||||
virtual void Free() override;
|
||||
void Describe_Entity() override;
|
||||
|
||||
@@ -13,11 +13,12 @@ class ENGINE_DLL CModel final : public CComponent
|
||||
|
||||
public:
|
||||
static _int Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones); // 본의 벡터와 이름을 넘겨주면 인덱스를 넘겨줌 ( n 순회 )
|
||||
_int Get_BoneIndex(const _char* pBoneName) const;
|
||||
void Set_RootBoneIndex(_int iIndex) { m_iRootBoneIndex = iIndex; }
|
||||
void Change_AnimationIndex(_int iAnimationIndex, _bool bIsLoop, _float fLerpDuration, _bool bIgnoreCurrentIndex = false); // 애니메이션을 다른 인덱스로 변경함
|
||||
_bool Play_Animation(_float fTimeDelta); // 애니메이션에 델타타임을 넣어줌
|
||||
void Set_AnimationIndex(_uint iIndex, _bool isLoop = true);
|
||||
void Stop_Animation(); // 애니메이션을 정지 (초기상태로)
|
||||
void Get_CurrentAnimationState();
|
||||
_bool IsFinishedAnim() const { return m_bIsFinishedAnim; }
|
||||
_bool IsFinishedLerp() const { return m_bIsFinishedLerp; }
|
||||
void RefreshAnim(); // 애님을 현재 애님의 초기상태로 되돌림
|
||||
@@ -34,6 +35,7 @@ class ENGINE_DLL CModel final : public CComponent
|
||||
_matrix Get_BoneMatrix(_uint iBoneIndex);
|
||||
|
||||
_float4x4* Get_PreTransformMatrixPtr() { return &m_PreTransformMatrix; }
|
||||
_float4x4 Get_PreTransformMatrix() const { return m_PreTransformMatrix; };
|
||||
void Get_BoneMatrices(_float4x4* pOut);
|
||||
_uint Get_BonesNum() const { return (_uint)m_Bones.size(); }
|
||||
|
||||
@@ -51,9 +53,18 @@ class ENGINE_DLL CModel final : public CComponent
|
||||
HRESULT Ready_Materials(const aiScene* pAIScene, const _char* pModelFilePath);
|
||||
HRESULT Ready_Animations(const aiScene* pAIScene);
|
||||
HRESULT Ready_Bones(const aiNode* pAINode, _int iParentIndex);
|
||||
// 바이너리
|
||||
bool SaveAssimpModel(const _char* filename);
|
||||
_int SaveNodeRecursive(const aiNode* pAINode, std::vector<SaveNode>& outNodes, _int parentIndex);
|
||||
//
|
||||
#endif // EDITOR_PROJECT
|
||||
|
||||
|
||||
private:
|
||||
const aiScene* m_pAIScene = { nullptr };
|
||||
Assimp::Importer m_Importer;
|
||||
|
||||
|
||||
private:
|
||||
MODEL m_eType = {}; // 모델의 타입
|
||||
_float4x4 m_PreTransformMatrix = {}; // 사전에 루트본에 곱해줄 매트릭스
|
||||
@@ -81,12 +92,32 @@ class ENGINE_DLL CModel final : public CComponent
|
||||
class CTransform* m_pTransform = { nullptr }; // 모델 대상의 트랜스폼
|
||||
|
||||
|
||||
// 바이너리
|
||||
SaveModel* m_pSaveModel = { nullptr };
|
||||
list<SaveModel> m_SaveModel;
|
||||
//
|
||||
|
||||
private:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
// 바이너리
|
||||
virtual HRESULT Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix);
|
||||
bool LoadData(const _char* filename);
|
||||
//
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
|
||||
private:
|
||||
// 바이너리
|
||||
HRESULT Ready_Meshes();
|
||||
HRESULT Ready_Materials(const _char* pModelFilePath);
|
||||
HRESULT Ready_Bones(const std::vector<SaveNode>& allNodes, _int currentIndex, _int parentIndex);
|
||||
HRESULT Ready_Animations();
|
||||
//
|
||||
|
||||
public:
|
||||
static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
// 바이너리
|
||||
static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix = XMMatrixIdentity());
|
||||
//
|
||||
virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr);
|
||||
virtual void Free(); public:
|
||||
void Describe_Entity() override;
|
||||
|
||||