Merge branch 'Develope' into UI
@@ -85,6 +85,7 @@ HRESULT CLevel_GamePlay::Ready_Layer_Sound()
|
||||
|
||||
HRESULT CLevel_GamePlay::Ready_Markers()
|
||||
{
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ HRESULT CLoader::Loading_For_GamePlay()
|
||||
{
|
||||
m_strMessage = TEXT("텍스쳐를(을) 로딩 중 입니다.");
|
||||
|
||||
|
||||
m_strMessage = TEXT("모델를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다.");
|
||||
|
||||
|
After Width: | Height: | Size: 296 B |
|
After Width: | Height: | Size: 285 B |
|
After Width: | Height: | Size: 245 B |
|
After Width: | Height: | Size: 136 B |
|
After Width: | Height: | Size: 239 B |
|
After Width: | Height: | Size: 278 B |
|
After Width: | Height: | Size: 97 B |
|
After Width: | Height: | Size: 114 B |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 189 KiB |
|
After Width: | Height: | Size: 96 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 244 B |
|
After Width: | Height: | Size: 53 KiB |
|
After Width: | Height: | Size: 149 B |
|
After Width: | Height: | Size: 68 KiB |
|
After Width: | Height: | Size: 228 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 55 KiB |
|
After Width: | Height: | Size: 34 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
|
After Width: | Height: | Size: 244 B |
|
After Width: | Height: | Size: 246 B |
|
After Width: | Height: | Size: 167 B |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 42 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 106 B |
|
After Width: | Height: | Size: 114 B |
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 138 B |
|
After Width: | Height: | Size: 142 B |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 128 B |
|
After Width: | Height: | Size: 210 B |
|
After Width: | Height: | Size: 116 B |
|
After Width: | Height: | Size: 113 B |
|
After Width: | Height: | Size: 79 KiB |
|
After Width: | Height: | Size: 2.6 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 |
|
After Width: | Height: | Size: 367 B |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 113 B |
@@ -334,8 +334,8 @@ technique11 MeshTechnique11
|
||||
|
||||
pass SkyBoxPass // 2
|
||||
{
|
||||
SetRasterizerState(RS_Nocull);
|
||||
SetDepthStencilState(DSS_None, 0);
|
||||
SetRasterizerState(RS_Default);
|
||||
SetDepthStencilState(DSS_Default, 0);
|
||||
SetBlendState(BS_None, float4(0.f, 0.f, 0.f, 0.f), 0xffffffff);
|
||||
VertexShader = compile vs_5_0 VS_MAIN();
|
||||
GeometryShader = NULL;
|
||||
|
||||
@@ -151,11 +151,14 @@
|
||||
<ItemGroup>
|
||||
<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\Editor_Define.h" />
|
||||
<ClInclude Include="..\Public\Editor_Macro.h" />
|
||||
<ClInclude Include="..\Public\Editor_Struct.h" />
|
||||
<ClInclude Include="..\Public\Level_Loading.h" />
|
||||
<ClInclude Include="..\Public\Level_Logo.h" />
|
||||
<ClInclude Include="..\Public\Level_ObjectViewer.h" />
|
||||
<ClInclude Include="..\Public\Loader.h" />
|
||||
<ClInclude Include="..\Public\MainApp.h" />
|
||||
<ClInclude Include="Editor.h" />
|
||||
@@ -166,8 +169,11 @@
|
||||
<ItemGroup>
|
||||
<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\Level_Loading.cpp" />
|
||||
<ClCompile Include="..\Private\Level_Logo.cpp" />
|
||||
<ClCompile Include="..\Private\Level_ObjectViewer.cpp" />
|
||||
<ClCompile Include="..\Private\Loader.cpp" />
|
||||
<ClCompile Include="..\Private\MainApp.cpp" />
|
||||
<ClCompile Include="..\Private\pch.cpp">
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
<Filter Include="02.GameObjects\Dummys\DummyRect">
|
||||
<UniqueIdentifier>{130c848e-6ab6-4b45-b12c-56db07e2c2f4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.GameObjects\Dummy_Goblin">
|
||||
<UniqueIdentifier>{0ebb9c08-69b0-49b6-bac3-c827ca13319a}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Editor.h">
|
||||
@@ -102,6 +105,15 @@
|
||||
<ClInclude Include="..\Public\DummyRect.h">
|
||||
<Filter>02.GameObjects\Dummys\DummyRect</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Dummy_Goblin.h">
|
||||
<Filter>02.GameObjects\Dummy_Goblin</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Level_ObjectViewer.h">
|
||||
<Filter>01.Level\20.ObjectViewer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Dummy_Cube.h">
|
||||
<Filter>02.GameObjects\Dummys\DummyCube</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Editor.ico">
|
||||
@@ -136,6 +148,15 @@
|
||||
<ClCompile Include="..\Private\DummyRect.cpp">
|
||||
<Filter>02.GameObjects\Dummys\DummyRect</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Dummy_Goblin.cpp">
|
||||
<Filter>02.GameObjects\Dummy_Goblin</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Level_ObjectViewer.cpp">
|
||||
<Filter>01.Level\20.ObjectViewer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Dummy_Cube.cpp">
|
||||
<Filter>02.GameObjects\Dummys\DummyCube</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Editor.rc">
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
#include "pch.h"
|
||||
#include "Dummy_Cube.h"
|
||||
|
||||
#include "GameInstance.h"
|
||||
|
||||
|
||||
CDummy_Cube::CDummy_Cube(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CGameObject{ pDevice, pContext }
|
||||
{
|
||||
}
|
||||
|
||||
CDummy_Cube::CDummy_Cube(const CDummy_Cube& rhs)
|
||||
: CGameObject(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CDummy_Cube::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_Cube::Initialize(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Initialize(pArg)))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(Ready_Components(pArg)))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CDummy_Cube::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CDummy_Cube::Update(_float fTimeDelta)
|
||||
{
|
||||
}
|
||||
|
||||
void CDummy_Cube::Late_Update(_float fTimeDelta)
|
||||
{
|
||||
_float4* vPos = (_float4*)(m_pTransformCom->Get_WorldMatrixPtr()->m[3]);
|
||||
m_pGameInstance->Add_RenderGroup(RENDER::NONBLEND, this, *vPos, m_pTransformCom->Get_Radius());
|
||||
}
|
||||
|
||||
HRESULT CDummy_Cube::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_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_MESH::SKYBOX)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (FAILED(m_pModelCom->Render(i))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_Cube::Ready_Components(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Ready_Components(pArg))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
///* Com_Model */
|
||||
//if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_GoblinBody_Model"),
|
||||
// reinterpret_cast<CComponent**>(&m_pModelCom))))
|
||||
// return E_FAIL;
|
||||
|
||||
/* Com_Model */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Desc_Box"),
|
||||
reinterpret_cast<CComponent**>(&m_pModelCom))))
|
||||
return E_FAIL;
|
||||
|
||||
/* Com_Shader */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH,
|
||||
reinterpret_cast<CComponent**>(&m_pShaderCom))))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_Cube::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;
|
||||
}
|
||||
|
||||
CDummy_Cube* CDummy_Cube::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CDummy_Cube* pInstance = new CDummy_Cube(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CDummy_Cube");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CGameObject* CDummy_Cube::Clone(void* pArg, CGameObject* pOwner)
|
||||
{
|
||||
CDummy_Cube* pInstance = new CDummy_Cube(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CDummy_Cube");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CDummy_Cube::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
SAFE_RELEASE(m_pModelCom);
|
||||
SAFE_RELEASE(m_pShaderCom);
|
||||
}
|
||||
|
||||
void CDummy_Cube::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
#include "pch.h"
|
||||
#include "Dummy_Goblin.h"
|
||||
|
||||
#include "GameInstance.h"
|
||||
#include "DebugCamera.h"
|
||||
|
||||
CDummy_Goblin::CDummy_Goblin(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CGameObject( pDevice, pContext )
|
||||
{
|
||||
}
|
||||
|
||||
CDummy_Goblin::CDummy_Goblin(const CDummy_Goblin& Prototype)
|
||||
: CGameObject( Prototype )
|
||||
{
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin::Initialize(void* pArg)
|
||||
{
|
||||
if (FAILED(__super::Initialize(pArg)))
|
||||
return E_FAIL;
|
||||
|
||||
|
||||
if (FAILED(Ready_Components()))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CDummy_Goblin::Priority_Update(_float fTimeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CDummy_Goblin::Update(_float fTimeDelta)
|
||||
{
|
||||
m_pModelCom->Play_Animation(fTimeDelta);
|
||||
}
|
||||
|
||||
void CDummy_Goblin::Late_Update(_float fTimeDelta)
|
||||
{
|
||||
_float4 vPos;
|
||||
XMStoreFloat4(&vPos, Get_WorldPostion());
|
||||
m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this, vPos, 20.f);
|
||||
}
|
||||
|
||||
HRESULT CDummy_Goblin::Render()
|
||||
{
|
||||
if (FAILED(Bind_ShaderResources())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_uint iNumMeshes = m_pModelCom->Get_NumMeshes();
|
||||
|
||||
//m_pShaderCom->Bind_SRV("g_NormalTexture", nullptr);
|
||||
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::Ready_Components()
|
||||
{
|
||||
__super::Ready_Components(nullptr);
|
||||
|
||||
/* Com_Model */
|
||||
if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_GoblinBody_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::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* CDummy_Goblin::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CDummy_Goblin* pInstance = new CDummy_Goblin(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CDummy_Goblin");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CGameObject* CDummy_Goblin::Clone(void* pArg, CGameObject* pOwner)
|
||||
{
|
||||
CDummy_Goblin* pInstance = new CDummy_Goblin(*this);
|
||||
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CDummy_Goblin");
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CDummy_Goblin::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
Safe_Release(m_pShaderCom);
|
||||
Safe_Release(m_pModelCom);
|
||||
}
|
||||
|
||||
void CDummy_Goblin::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "GameInstance.h"
|
||||
|
||||
#include "Level_Logo.h"
|
||||
#include "Level_ObjectViewer.h"
|
||||
|
||||
CLevel_Loading::CLevel_Loading(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID)
|
||||
: CLevel{ pDevice, pContext, ENUM_CLASS(eLevelID) }
|
||||
@@ -29,7 +30,7 @@ HRESULT CLevel_Loading::Initialize(LEVEL eNextLevelID)
|
||||
void CLevel_Loading::Update(_float fTimeDelta)
|
||||
{
|
||||
if (true == m_pLoader->isFinished() &&
|
||||
m_pGameInstance->Key_Down(DIK_RETURN))
|
||||
m_pGameInstance->Key_Down(DIK_F1))
|
||||
{
|
||||
CLevel* pNewLevel = { nullptr };
|
||||
|
||||
@@ -41,9 +42,9 @@ void CLevel_Loading::Update(_float fTimeDelta)
|
||||
//case LEVEL::MAP:
|
||||
// pNewLevel = CLevel_MapViewer::Create(m_pDevice, m_pContext, m_eNextLevelID);
|
||||
// break;
|
||||
//case LEVEL::OBJECT:
|
||||
// pNewLevel = CLevel_ObjectViewer::Create(m_pDevice, m_pContext, m_eNextLevelID);
|
||||
// break;
|
||||
case LEVEL::OBJECT:
|
||||
pNewLevel = CLevel_ObjectViewer::Create(m_pDevice, m_pContext, m_eNextLevelID);
|
||||
break;
|
||||
//case LEVEL::COMBINED:
|
||||
// pNewLevel = CLevel_LevelViewer::Create(m_pDevice, m_pContext, m_eNextLevelID);
|
||||
// break;
|
||||
|
||||
@@ -26,10 +26,10 @@ void CLevel_Logo::Update(_float fTimeDelta)
|
||||
// if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::MAP))))
|
||||
// return;
|
||||
//}
|
||||
//else if (GUI::Button("Object Editor", { 100, 100 })) {
|
||||
// if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::OBJECT))))
|
||||
// return;
|
||||
//}
|
||||
/*else */if (GUI::Button("Object Editor", { 100, 100 })) {
|
||||
if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::OBJECT))))
|
||||
return;
|
||||
}
|
||||
//else if (GUI::Button("Combined Editor", { 100, 100 })) {
|
||||
// if (FAILED(m_pGameInstance->Change_Level(CLevel_Loading::Create(m_pDevice, m_pContext, LEVEL::LOADING, LEVEL::COMBINED))))
|
||||
// return;
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
#include "pch.h"
|
||||
#include "Level_ObjectViewer.h"
|
||||
#include "GameInstance.h"
|
||||
#include "Level_Loading.h"
|
||||
#include "Dummy_Goblin.h"
|
||||
#include "Dummy_Cube.h"
|
||||
#include "DebugCamera.h"
|
||||
|
||||
CLevel_ObjectViewer::CLevel_ObjectViewer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID)
|
||||
: CLevel{ pDevice, pContext, ENUM_CLASS(eLevelID) }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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"))))
|
||||
{
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CLevel_ObjectViewer::Update(_float fTimeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HRESULT CLevel_ObjectViewer::Render()
|
||||
{
|
||||
SetWindowText(g_hWnd, TEXT("¿ÀºêÁ§Æ® ·¹º§ÀÔ´Ï´Ù"));
|
||||
GUI::ShowDemoWindow();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT CLevel_ObjectViewer::Ready_Layer_Camera(const _wstring& strLayerTag)
|
||||
{
|
||||
CDebugCamera::CAMERA_DEBUG_DESC CameraDesc{};
|
||||
CameraDesc.fFovy = XMConvertToRadians(60.0f);
|
||||
CameraDesc.fNear = 0.1f;
|
||||
CameraDesc.fFar = 500.f;
|
||||
CameraDesc.vEye = _float3(0.f, 10.f, -10.f);
|
||||
CameraDesc.vAt = _float3(0.f, 0.f, 0.f);
|
||||
CameraDesc.fSpeedPerSec = 5.f;
|
||||
CameraDesc.fRotationPerSec = XMConvertToRadians(90.0f);
|
||||
CameraDesc.fMouseSensor = 0.1f;
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CDebugCamera>(g_iStaticLevel, NEXT_LEVEL,
|
||||
strLayerTag, &CameraDesc)))
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CLevel_ObjectViewer::Ready_Layer_Light()
|
||||
{
|
||||
LIGHT_DESC LightDesc{};
|
||||
|
||||
LightDesc.eType = LIGHT::DIRECTIONAL;
|
||||
LightDesc.vDiffuse = _float4(0.8f, 0.8f, 0.8f, 0.f);
|
||||
LightDesc.vAmbient = _float4(0.2f, 0.2f, 0.2f, 0.f);
|
||||
LightDesc.vSpecular = _float4(0.f, 0.f, 0.f, 0.f);
|
||||
LightDesc.vDirection = _float4(1.f, -1.f, 1.f, 0.f);
|
||||
|
||||
if (FAILED(m_pGameInstance->On_Light(NEXT_LEVEL, TEXT("Main_Light"), LightDesc, nullptr))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CLevel_ObjectViewer::Ready_Layer_UI(const _wstring& strLayerTag)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CLevel_ObjectViewer* CLevel_ObjectViewer::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID)
|
||||
{
|
||||
CLevel_ObjectViewer* pInstance = new CLevel_ObjectViewer(pDevice, pContext, eLevelID);
|
||||
|
||||
if (FAILED(pInstance->Initialize()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CLevel_ObjectViewer");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CLevel_ObjectViewer::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "GameInstance.h"
|
||||
#include "DummyRect.h"
|
||||
#include "MainApp.h"
|
||||
#include "Dummy_Goblin.h"
|
||||
#include "Dummy_Cube.h"
|
||||
|
||||
CLoader::CLoader(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: m_pDevice{ pDevice }
|
||||
@@ -56,24 +58,24 @@ HRESULT CLoader::Loading()
|
||||
case LEVEL::LOGO:
|
||||
hr = Loading_For_Logo();
|
||||
break;
|
||||
//case LEVEL::MAP:
|
||||
// hr = Loading_For_MapViewer();
|
||||
// break;
|
||||
//case LEVEL::OBJECT:
|
||||
// hr = Loading_For_ObjectViewer();
|
||||
// break;
|
||||
//case LEVEL::COMBINED:
|
||||
// hr = Loading_For_CombinedViewer();
|
||||
// break;
|
||||
//case LEVEL::EFFECT:
|
||||
// hr = Loading_For_Effect();
|
||||
// break;
|
||||
//case LEVEL::SKIllSTUDIO:
|
||||
// hr = Loading_For_SkillStudio();
|
||||
// break;
|
||||
//case LEVEL::PARTICLE:
|
||||
// hr = Loading_For_Particle();
|
||||
// break;
|
||||
//case LEVEL::MAP:
|
||||
// hr = Loading_For_MapViewer();
|
||||
// break;
|
||||
case LEVEL::OBJECT:
|
||||
hr = Loading_For_ObjectViewer();
|
||||
break;
|
||||
//case LEVEL::COMBINED:
|
||||
// hr = Loading_For_CombinedViewer();
|
||||
// break;
|
||||
//case LEVEL::EFFECT:
|
||||
// hr = Loading_For_Effect();
|
||||
// break;
|
||||
//case LEVEL::SKIllSTUDIO:
|
||||
// hr = Loading_For_SkillStudio();
|
||||
// break;
|
||||
//case LEVEL::PARTICLE:
|
||||
// hr = Loading_For_Particle();
|
||||
// break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
@@ -94,16 +96,16 @@ 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("모델를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다.");
|
||||
m_strMessage = TEXT("셰이더를(을) 로딩 중 입니다.");
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, FX_POSTEX,
|
||||
CShader::Create(m_pDevice, m_pContext, TEXT("../Bin/Resources/ShaderFiles/Shader_VtxPosTex.hlsl"),
|
||||
@@ -141,7 +143,7 @@ HRESULT CLoader::Loading_For_Logo()
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_strMessage = TEXT("객체원형를(을) 로딩 중 입니다.");
|
||||
m_strMessage = TEXT("객체원형를(을) 로딩 중 입니다.");
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Prototype<CDummyRect>(g_iStaticLevel, CDummyRect::Create(m_pDevice, m_pContext)))) {
|
||||
return E_FAIL;
|
||||
@@ -150,7 +152,44 @@ HRESULT CLoader::Loading_For_Logo()
|
||||
if (FAILED(m_pGameInstance->Add_Prototype<CDebugCamera>(g_iStaticLevel, CDebugCamera::Create(m_pDevice, m_pContext)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_strMessage = TEXT("로딩이 완료되었습니다..");
|
||||
m_strMessage = TEXT("로딩이 완료되었습니다..");
|
||||
|
||||
m_isFinished = true;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CLoader::Loading_For_ObjectViewer()
|
||||
{
|
||||
m_strMessage = TEXT("텍스쳐를(을) 로딩 중 입니다.");
|
||||
|
||||
m_strMessage = TEXT("모델를(을) 로딩 중 입니다.");
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, 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"),
|
||||
CModel::Create(m_pDevice, m_pContext, "../Bin/Resources/Models/Box/Box.fbx", MODEL::NONANIM, XMMatrixIdentity(), 0))))
|
||||
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))))
|
||||
return E_FAIL;
|
||||
|
||||
/* For.Prototype_GameObject_Dummy_Cube */
|
||||
if (FAILED(m_pGameInstance->Add_Prototype<CDummy_Cube>(g_iStaticLevel, CDummy_Cube::Create(m_pDevice, m_pContext))))
|
||||
return E_FAIL;
|
||||
|
||||
m_strMessage = TEXT("정보를 불러오는 중입니다.");
|
||||
|
||||
m_strMessage = TEXT("로딩이 완료되었습니다..");
|
||||
|
||||
m_isFinished = true;
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "Editor_Define.h"
|
||||
#include "GameObject.h"
|
||||
|
||||
NS_BEGIN(Engine)
|
||||
class CModel;
|
||||
class CShader;
|
||||
NS_END
|
||||
|
||||
NS_BEGIN(Editor)
|
||||
|
||||
class CDummy_Cube final : public CGameObject
|
||||
{
|
||||
private:
|
||||
CDummy_Cube(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CDummy_Cube(const CDummy_Cube& rhs);
|
||||
virtual ~CDummy_Cube() = default;
|
||||
|
||||
public:
|
||||
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:
|
||||
CModel* m_pModelCom = { nullptr };
|
||||
CShader* m_pShaderCom = { nullptr };
|
||||
|
||||
|
||||
private:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
virtual HRESULT Ready_Components(void* pArg) override;
|
||||
virtual HRESULT Bind_ShaderResources() override;
|
||||
|
||||
public:
|
||||
static CDummy_Cube* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
virtual CGameObject* Clone(void* pArg, class CGameObject* pOwner) override;
|
||||
virtual void Free() override;
|
||||
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 final : public CGameObject
|
||||
{
|
||||
private:
|
||||
CDummy_Goblin(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
|
||||
CDummy_Goblin(const CDummy_Goblin& Prototype);
|
||||
virtual ~CDummy_Goblin() = 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* 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
|
||||
@@ -11,7 +11,7 @@ namespace Editor
|
||||
const unsigned int g_iWinSizeX = 1920;
|
||||
const unsigned int g_iWinSizeY = 1080;
|
||||
|
||||
enum class LEVEL { STATIC, LOADING, LOGO, LOBY, GAMEPLAY, RESTART, END };
|
||||
enum class LEVEL { STATIC, LOADING, LOGO, LOBY, GAMEPLAY, RESTART, OBJECT,END };
|
||||
enum class COLLIDABLEOBJECT { PLAYER, MONSTER, HOSTILE_HITBOX, ALLY_HITBOX, NEUTRAL_HITBOX, ENVIRIONMENT, NPC, ITEM, TRIGGERBOX, REGION, NOCOLLIDE, END };
|
||||
|
||||
enum class SHADER_PASS_ANIM { DEFAULT, SHADOW, CAPTURE, BLUR, END };
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "Editor_Define.h"
|
||||
#include "Level.h"
|
||||
|
||||
NS_BEGIN(Editor)
|
||||
|
||||
class CLevel_ObjectViewer final : public CLevel
|
||||
{
|
||||
private:
|
||||
CLevel_ObjectViewer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eLevelID);
|
||||
virtual ~CLevel_ObjectViewer() = default;
|
||||
|
||||
public:
|
||||
virtual void Update(_float fTimeDelta) override;
|
||||
virtual HRESULT Render() override;
|
||||
|
||||
private:
|
||||
/* 이 레벨에서 쓰기위한 객체들을 생성한다. */
|
||||
virtual HRESULT Initialize() override;
|
||||
HRESULT Ready_Layer_Camera(const _wstring& strLayerTag);
|
||||
HRESULT Ready_Layer_Light();
|
||||
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;
|
||||
};
|
||||
|
||||
NS_END
|
||||
@@ -41,6 +41,7 @@ class CLoader final : public CBase
|
||||
private:
|
||||
HRESULT Initialize(LEVEL eNextLevelID);
|
||||
HRESULT Loading_For_Logo();
|
||||
HRESULT Loading_For_ObjectViewer();
|
||||
|
||||
public:
|
||||
static CLoader* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eNextLevelID);
|
||||
|
||||
@@ -151,7 +151,9 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Private\Animation.cpp" />
|
||||
<ClCompile Include="..\Private\Base.cpp" />
|
||||
<ClCompile Include="..\Private\Bone.cpp" />
|
||||
<ClCompile Include="..\Private\Bounding.cpp" />
|
||||
<ClCompile Include="..\Private\Bounding_AABB.cpp" />
|
||||
<ClCompile Include="..\Private\Bounding_OBB.cpp" />
|
||||
@@ -169,6 +171,7 @@
|
||||
</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Cell.cpp" />
|
||||
<ClCompile Include="..\Private\Channel.cpp" />
|
||||
<ClCompile Include="..\Private\Collider.cpp" />
|
||||
<ClCompile Include="..\Private\Component.cpp" />
|
||||
<ClCompile Include="..\Private\ContainerObject.cpp" />
|
||||
@@ -226,10 +229,13 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Key_Manager.cpp" />
|
||||
<ClCompile Include="..\Private\Layer.cpp" />
|
||||
<ClCompile Include="..\Private\LerpAnim.cpp" />
|
||||
<ClCompile Include="..\Private\Level.cpp" />
|
||||
<ClCompile Include="..\Private\Level_Manager.cpp" />
|
||||
<ClCompile Include="..\Private\Light.cpp" />
|
||||
<ClCompile Include="..\Private\Light_Manager.cpp" />
|
||||
<ClCompile Include="..\Private\Material.cpp" />
|
||||
<ClCompile Include="..\Private\Mesh.cpp" />
|
||||
<ClCompile Include="..\Private\Model.cpp" />
|
||||
<ClCompile Include="..\Private\Mouse_Manager.cpp" />
|
||||
<ClCompile Include="..\Private\MyTools.cpp" />
|
||||
@@ -256,9 +262,11 @@
|
||||
<ClCompile Include="..\Private\Transform.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer_Cell.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer_Cube.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer_Rect.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Public\Animation.h" />
|
||||
<ClInclude Include="..\Public\Assimp\aabb.h" />
|
||||
<ClInclude Include="..\Public\Assimp\ai_assert.h" />
|
||||
<ClInclude Include="..\Public\Assimp\anim.h" />
|
||||
@@ -344,6 +352,7 @@
|
||||
<ClInclude Include="..\Public\Assimp\XMLTools.h" />
|
||||
<ClInclude Include="..\Public\Assimp\ZipArchiveIOSystem.h" />
|
||||
<ClInclude Include="..\Public\Base.h" />
|
||||
<ClInclude Include="..\Public\Bone.h" />
|
||||
<ClInclude Include="..\Public\Bounding.h" />
|
||||
<ClInclude Include="..\Public\Bounding_AABB.h" />
|
||||
<ClInclude Include="..\Public\Bounding_OBB.h" />
|
||||
@@ -361,6 +370,7 @@
|
||||
</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Cell.h" />
|
||||
<ClInclude Include="..\Public\Channel.h" />
|
||||
<ClInclude Include="..\Public\Collider.h" />
|
||||
<ClInclude Include="..\Public\Component.h" />
|
||||
<ClInclude Include="..\Public\ContainerObject.h" />
|
||||
@@ -421,10 +431,13 @@
|
||||
<ClInclude Include="..\Public\IMGUI\imstb_truetype.h" />
|
||||
<ClInclude Include="..\Public\Key_Manager.h" />
|
||||
<ClInclude Include="..\Public\Layer.h" />
|
||||
<ClInclude Include="..\Public\LerpAnim.h" />
|
||||
<ClInclude Include="..\Public\Level.h" />
|
||||
<ClInclude Include="..\Public\Level_Manager.h" />
|
||||
<ClInclude Include="..\Public\Light.h" />
|
||||
<ClInclude Include="..\Public\Light_Manager.h" />
|
||||
<ClInclude Include="..\Public\Material.h" />
|
||||
<ClInclude Include="..\Public\Mesh.h" />
|
||||
<ClInclude Include="..\Public\Model.h" />
|
||||
<ClInclude Include="..\Public\Mouse_Manager.h" />
|
||||
<ClInclude Include="..\Public\MyTools.h" />
|
||||
@@ -446,6 +459,7 @@
|
||||
<ClInclude Include="..\Public\Transform.h" />
|
||||
<ClInclude Include="..\Public\VIBuffer.h" />
|
||||
<ClInclude Include="..\Public\VIBuffer_Cell.h" />
|
||||
<ClInclude Include="..\Public\VIBuffer_Cube.h" />
|
||||
<ClInclude Include="..\Public\VIBuffer_Rect.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -7,36 +7,6 @@
|
||||
<Filter Include="00.System\99.Base">
|
||||
<UniqueIdentifier>{0c9df74d-79e3-4ca1-87cd-22b0789afc1c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define">
|
||||
<UniqueIdentifier>{2cb454c9-e390-4f2e-8cf5-b5c6325543ed}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\00.DEFAULT">
|
||||
<UniqueIdentifier>{0e35cd1b-88f6-46b9-b72e-b46eeaacd4e0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY">
|
||||
<UniqueIdentifier>{32ca0c26-d3e2-49c5-8dc6-cc67e5291214}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\IMGUI">
|
||||
<UniqueIdentifier>{17dcadfe-e4cd-46c6-8122-e5e02bb73e57}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\FX11">
|
||||
<UniqueIdentifier>{c3e7b75b-ec8b-4071-8b52-e5c356febfa6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\FMOD">
|
||||
<UniqueIdentifier>{57dd171f-f788-4918-aae2-85c20794b3cb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\DXTK">
|
||||
<UniqueIdentifier>{40758cb1-0f91-4db9-bad7-7c77eb8002da}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\ASSIMP">
|
||||
<UniqueIdentifier>{bbf3ec67-56f5-4e67-b6cf-8eb1eb4400ff}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\01.SHADER">
|
||||
<UniqueIdentifier>{30c382b4-2ac9-4355-b3a5-c1b3622c2982}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\70.NS_SOUND">
|
||||
<UniqueIdentifier>{1622af23-8aca-43cd-8250-b289e363e613}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="00.System\01.Timer">
|
||||
<UniqueIdentifier>{de88c47e-55e3-4c50-8b4c-7dd94c0c837f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -205,6 +175,45 @@
|
||||
<Filter Include="99.Define\TINYXML2">
|
||||
<UniqueIdentifier>{d93660eb-4bf9-43d2-902e-8ecbefd02481}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define">
|
||||
<UniqueIdentifier>{2cb454c9-e390-4f2e-8cf5-b5c6325543ed}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\00.DEFAULT">
|
||||
<UniqueIdentifier>{0e35cd1b-88f6-46b9-b72e-b46eeaacd4e0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY">
|
||||
<UniqueIdentifier>{32ca0c26-d3e2-49c5-8dc6-cc67e5291214}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\IMGUI">
|
||||
<UniqueIdentifier>{17dcadfe-e4cd-46c6-8122-e5e02bb73e57}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\FX11">
|
||||
<UniqueIdentifier>{c3e7b75b-ec8b-4071-8b52-e5c356febfa6}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\FMOD">
|
||||
<UniqueIdentifier>{57dd171f-f788-4918-aae2-85c20794b3cb}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\DXTK">
|
||||
<UniqueIdentifier>{40758cb1-0f91-4db9-bad7-7c77eb8002da}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\99.THIRDPARTY\ASSIMP">
|
||||
<UniqueIdentifier>{bbf3ec67-56f5-4e67-b6cf-8eb1eb4400ff}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\01.SHADER">
|
||||
<UniqueIdentifier>{30c382b4-2ac9-4355-b3a5-c1b3622c2982}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="99.Define\70.NS_SOUND">
|
||||
<UniqueIdentifier>{1622af23-8aca-43cd-8250-b289e363e613}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\06.Model\Animation\Channel">
|
||||
<UniqueIdentifier>{3625aad6-89b2-490e-bd9c-3cff284605e4}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\06.Model\LerpAnim">
|
||||
<UniqueIdentifier>{92ec7ae6-14ee-455c-a3ad-378e46f3b1f0}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\02.VIBuffer\Cube">
|
||||
<UniqueIdentifier>{be0d499e-e4cf-4dde-92a0-a0904e713045}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Private\Base.cpp">
|
||||
@@ -360,6 +369,27 @@
|
||||
<ClCompile Include="..\Private\tinyxml2.cpp">
|
||||
<Filter>99.Define\TINYXML2</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Mesh.cpp">
|
||||
<Filter>02.Element\02.Component\06.Model\Mesh</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Material.cpp">
|
||||
<Filter>02.Element\02.Component\06.Model\Material</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Bone.cpp">
|
||||
<Filter>02.Element\02.Component\06.Model\Bone</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Animation.cpp">
|
||||
<Filter>02.Element\02.Component\06.Model\Animation</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Channel.cpp">
|
||||
<Filter>02.Element\02.Component\06.Model\Animation\Channel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\LerpAnim.cpp">
|
||||
<Filter>02.Element\02.Component\06.Model\LerpAnim</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\VIBuffer_Cube.cpp">
|
||||
<Filter>02.Element\02.Component\02.VIBuffer\Cube</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Public\Base.h">
|
||||
@@ -881,6 +911,27 @@
|
||||
<ClInclude Include="..\Public\tinyxml2.h">
|
||||
<Filter>99.Define\TINYXML2</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Mesh.h">
|
||||
<Filter>02.Element\02.Component\06.Model\Mesh</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Material.h">
|
||||
<Filter>02.Element\02.Component\06.Model\Material</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Bone.h">
|
||||
<Filter>02.Element\02.Component\06.Model\Bone</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Animation.h">
|
||||
<Filter>02.Element\02.Component\06.Model\Animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Channel.h">
|
||||
<Filter>02.Element\02.Component\06.Model\Animation\Channel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\LerpAnim.h">
|
||||
<Filter>02.Element\02.Component\06.Model\LerpAnim</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\VIBuffer_Cube.h">
|
||||
<Filter>02.Element\02.Component\02.VIBuffer\Cube</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Public\Assimp\color4.inl">
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "Animation.h"
|
||||
#include "Channel.h"
|
||||
|
||||
CAnimation::CAnimation()
|
||||
{
|
||||
/*XMMatrixDecompose();*/
|
||||
}
|
||||
|
||||
CAnimation::CAnimation(const CAnimation& rhs)
|
||||
: m_fCurrentTrackPosition{ rhs.m_fCurrentTrackPosition }
|
||||
, m_fDuration{ rhs.m_fDuration }
|
||||
, m_iNumChannels{ rhs.m_iNumChannels }
|
||||
, m_Channels{ rhs.m_Channels }
|
||||
, m_CurrentKeyFrameIndices{ rhs.m_CurrentKeyFrameIndices }
|
||||
, m_StartKeyFrames{ rhs.m_StartKeyFrames }
|
||||
, m_DestBones{ rhs.m_DestBones }
|
||||
, m_strName{ rhs.m_strName }
|
||||
{
|
||||
memcpy_s(m_TickPerSeconds, sizeof(_float) * 2, rhs.m_TickPerSeconds, sizeof(_float) * 2);
|
||||
|
||||
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;
|
||||
|
||||
if (m_fCurrentTrackPosition >= m_fDuration) {
|
||||
m_fCurrentTrackPosition = 0.f; // ·çÇÁ
|
||||
if (false == bIsLoop) {
|
||||
m_fCurrentTrackPosition = m_fDuration;
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
Depart_Animation();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_uint iIndex = {};
|
||||
for (auto& pChannel : m_Channels) {
|
||||
pChannel->Update_TransformationMatirx(Bones, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex++]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CAnimation::Depart_Animation()
|
||||
{
|
||||
m_fCurrentTrackPosition = 0.f;
|
||||
fill(m_CurrentKeyFrameIndices.begin(), m_CurrentKeyFrameIndices.end(), 0);
|
||||
}
|
||||
_float CAnimation::Get_AnimProgressRatio()
|
||||
{
|
||||
return (m_fCurrentTrackPosition / m_fDuration);
|
||||
}
|
||||
_float CAnimation::Get_AnimEstimatedDuration()
|
||||
{
|
||||
return m_fDuration / m_TickPerSeconds[0];
|
||||
}
|
||||
_int CAnimation::Get_AnimProgressPostion(const _char* pAnimChannelName)
|
||||
{
|
||||
for (_int iIndex = 0; iIndex < m_Channels.size(); ++iIndex) {
|
||||
if (true == m_Channels[iIndex]->Compare_Name(pAnimChannelName)) {
|
||||
return m_CurrentKeyFrameIndices[iIndex];
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
void CAnimation::Set_AnimProgressPostion(const _char* pChannelName, _uint iPosition)
|
||||
{
|
||||
Depart_Animation();
|
||||
|
||||
for (_int iIndex = 0; iIndex < m_Channels.size(); ++iIndex) {
|
||||
if (true == m_Channels[iIndex]->Compare_Name(pChannelName)) {
|
||||
m_fCurrentTrackPosition = m_Channels[iIndex]->Get_Frame(iPosition)->fTrackPosition;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
vector<_int>* CAnimation::Capture_Bones()
|
||||
{
|
||||
if (m_DestBones.empty()) {
|
||||
m_DestBones.reserve(m_iNumChannels);
|
||||
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
||||
m_DestBones.push_back(m_Channels[i]->Get_BoneIndex());
|
||||
}
|
||||
}
|
||||
return &m_DestBones;
|
||||
}
|
||||
#ifdef EDITOR_PROJECT
|
||||
HRESULT CAnimation::Initialize(const vector<CBone*>& Bones, const aiAnimation* pAIAnimation)
|
||||
{
|
||||
m_strName = pAIAnimation->mName.data;
|
||||
size_t pos = m_strName.find_last_of('|');
|
||||
if (0 > pos) {
|
||||
pos = 0;
|
||||
}
|
||||
else {
|
||||
pos++;
|
||||
}
|
||||
m_strName = m_strName.substr(pos);
|
||||
m_fDuration = (_float)pAIAnimation->mDuration;
|
||||
m_TickPerSeconds[0] = (_float)pAIAnimation->mTicksPerSecond;
|
||||
m_iNumChannels = pAIAnimation->mNumChannels;
|
||||
m_CurrentKeyFrameIndices.resize(m_iNumChannels);
|
||||
|
||||
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
||||
CChannel* pChannel = CChannel::Create(Bones, pAIAnimation->mChannels[i]);
|
||||
if (nullptr == pChannel) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_Channels.push_back(pChannel);
|
||||
}
|
||||
|
||||
if (FAILED(Combined_Initialize())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CAnimation::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
size_t iNameLength = m_strName.length();
|
||||
WriteFile(hFile, &iNameLength, sizeof(size_t), &dwByte, nullptr);
|
||||
WriteFile(hFile, m_strName.data(), (DWORD)m_strName.length(), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_fDuration, sizeof(_float), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_TickPerSeconds, sizeof(_float) * 2, &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iNumChannels, sizeof(_uint), &dwByte, nullptr);
|
||||
|
||||
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
||||
m_Channels[i]->SaveAsBinary(hFile, dwByte);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CAnimation* CAnimation::Create(const vector<CBone*>& Bones, const aiAnimation* pAnimation)
|
||||
{
|
||||
CAnimation* pInstance = new CAnimation;
|
||||
if (FAILED(pInstance->Initialize(Bones, pAnimation))) {
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
return pInstance;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
HRESULT CAnimation::Initialize(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
size_t iNameLength = {};
|
||||
if (!ReadFile(hFile, &iNameLength, sizeof(size_t), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_strName.resize(iNameLength);
|
||||
if (!ReadFile(hFile, (void*)m_strName.data(), (DWORD)iNameLength, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_fDuration, sizeof(_float), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_TickPerSeconds, sizeof(_float) * 2, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iNumChannels, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_CurrentKeyFrameIndices.resize(m_iNumChannels);
|
||||
m_Channels.reserve(m_iNumChannels);
|
||||
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
||||
m_Channels.push_back(CChannel::Create(hFile, dwByte));
|
||||
}
|
||||
if (FAILED(Combined_Initialize())) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CAnimation::Combined_Initialize()
|
||||
{
|
||||
m_StartKeyFrames.reserve(m_iNumChannels);
|
||||
for (auto& pChannel : m_Channels) {
|
||||
LERPDESC desc = { pChannel->Get_BoneIndex(), *pChannel->Get_Frame(0) };
|
||||
m_StartKeyFrames.push_back(desc);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
_uint CAnimation::Get_BoneIndex(const char* pChannelName)
|
||||
{
|
||||
return _uint();
|
||||
}
|
||||
|
||||
CAnimation* CAnimation::Create(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
CAnimation* pInstance = new CAnimation();
|
||||
|
||||
if (FAILED(pInstance->Initialize(hFile, dwByte)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CAnimation");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CAnimation* CAnimation::Clone()
|
||||
{
|
||||
return new CAnimation(*this);
|
||||
}
|
||||
|
||||
void CAnimation::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
for (auto& pChannel : m_Channels) {
|
||||
SAFE_RELEASE(pChannel);
|
||||
}
|
||||
m_Channels.clear();
|
||||
|
||||
m_CurrentKeyFrameIndices.clear();
|
||||
}
|
||||
;
|
||||
void CAnimation::Describe_Entity()
|
||||
{
|
||||
//if (GUI::CollapsingHeader(m_strName.c_str())) {
|
||||
//
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
#include "pch.h"
|
||||
#include "Bone.h"
|
||||
|
||||
CBone::CBone()
|
||||
{
|
||||
}
|
||||
|
||||
void CBone::Get_KeyFrame(KEYFRAME& kf, _bool bIsCurrentFrame)
|
||||
{
|
||||
_vector vScale = {};
|
||||
_vector vRotation = {};
|
||||
_vector vTranspose = {};
|
||||
if (bIsCurrentFrame) {
|
||||
XMMatrixDecompose(&vScale, &vRotation, &vTranspose, XMLoadFloat4x4(&m_TransformationMatrix));
|
||||
}
|
||||
else {
|
||||
XMMatrixDecompose(&vScale, &vRotation, &vTranspose, XMLoadFloat4x4(&m_matInitial));
|
||||
}
|
||||
XMStoreFloat3(&kf.vScale, vScale);
|
||||
XMStoreFloat4(&kf.vRotation, vRotation);
|
||||
XMStoreFloat3(&kf.vTranslation, vTranspose);
|
||||
kf.fTrackPosition = 0.f;
|
||||
}
|
||||
|
||||
void CBone::Update_CombinedTransformationMatrix(const vector<CBone*>& Bones, _fmatrix PreTransformMatrix)
|
||||
{
|
||||
if (-1 == m_iParentBoneIndex) {
|
||||
XMStoreFloat4x4(&m_CombinedTransformationMatrix,
|
||||
XMLoadFloat4x4(&m_TransformationMatrix) * PreTransformMatrix);
|
||||
}
|
||||
else {
|
||||
XMStoreFloat4x4(&m_CombinedTransformationMatrix,
|
||||
XMLoadFloat4x4(&m_TransformationMatrix) * Bones[m_iParentBoneIndex]->Get_CombinedTransformationMatrix());
|
||||
}
|
||||
}
|
||||
void CBone::Set_TransformationMatrix(_fmatrix TransformationMatrix)
|
||||
{
|
||||
XMStoreFloat4x4(&m_TransformationMatrix, TransformationMatrix);
|
||||
}
|
||||
_float3 CBone::Get_LocalPosition()
|
||||
{
|
||||
_float3 vPos = { m_TransformationMatrix.m[3][0], m_TransformationMatrix.m[3][1], m_TransformationMatrix.m[3][2] };
|
||||
return vPos;
|
||||
}
|
||||
#ifdef EDITOR_PROJECT
|
||||
HRESULT CBone::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
string strName = m_szName;
|
||||
strName.shrink_to_fit();
|
||||
DWORD iLength = (DWORD)strName.length();
|
||||
WriteFile(hFile, &iLength, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, strName.data(), iLength, &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iParentBoneIndex, sizeof(_int), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_TransformationMatrix, sizeof(_float4x4), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_matInitial, sizeof(_float4x4), &dwByte, nullptr);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
CBone* CBone::Create(const aiNode* pAINode, _int iParentIndex)
|
||||
{
|
||||
CBone* pInstance = new CBone();
|
||||
|
||||
if (FAILED(pInstance->Initialize(pAINode, 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);
|
||||
|
||||
m_iParentBoneIndex = iParentIndex;
|
||||
|
||||
memcpy(&m_TransformationMatrix, &pAINode->mTransformation, sizeof(_float4x4));
|
||||
XMStoreFloat4x4(&m_TransformationMatrix, XMMatrixTranspose(XMLoadFloat4x4(&m_TransformationMatrix)));
|
||||
m_matInitial = m_TransformationMatrix;
|
||||
XMStoreFloat4x4(&m_CombinedTransformationMatrix, XMMatrixIdentity());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
HRESULT CBone::Initialize(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
_uint iLength = { 0 };
|
||||
if (!ReadFile(hFile, &iLength, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, m_szName, iLength, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iParentBoneIndex, sizeof(_int), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_TransformationMatrix, sizeof(_float4x4), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_matInitial, sizeof(_float4x4), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
XMStoreFloat4x4(&m_CombinedTransformationMatrix, XMMatrixIdentity());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CBone* CBone::Create(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
CBone* pInstance = new CBone();
|
||||
|
||||
if (FAILED(pInstance->Initialize(hFile, dwByte)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CBone");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CBone* CBone::Clone()
|
||||
{
|
||||
return new CBone(*this);
|
||||
}
|
||||
|
||||
void CBone::Free()
|
||||
{
|
||||
__super::Free();
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "Channel.h"
|
||||
#include "Model.h"
|
||||
#include "Bone.h"
|
||||
|
||||
CChannel::CChannel()
|
||||
{
|
||||
}
|
||||
#ifdef EDITOR_PROJECT
|
||||
HRESULT CChannel::Initialize(const vector<CBone*>& Bones, const aiNodeAnim* pAIChannel)
|
||||
{
|
||||
strcpy_s(m_szName, pAIChannel->mNodeName.data);
|
||||
|
||||
m_iBoneIndex = CModel::Get_BoneIndex(m_szName, Bones);
|
||||
if (-1 == m_iBoneIndex) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_iNumKeyFrames = max(pAIChannel->mNumScalingKeys, pAIChannel->mNumRotationKeys);
|
||||
m_iNumKeyFrames = max(m_iNumKeyFrames, (_uint)pAIChannel->mNumPositionKeys);
|
||||
|
||||
_float3 vScale = { };
|
||||
_float4 vRotation{};
|
||||
_float3 vTranslation{};
|
||||
for (size_t i = 0; i < m_iNumKeyFrames; i++)
|
||||
{
|
||||
KEYFRAME KeyFrame{};
|
||||
|
||||
if (i < pAIChannel->mNumScalingKeys)
|
||||
{
|
||||
memcpy(&vScale, &pAIChannel->mScalingKeys[i].mValue, sizeof(_float3));
|
||||
KeyFrame.fTrackPosition = (_float)pAIChannel->mScalingKeys[i].mTime;
|
||||
}
|
||||
|
||||
if (i < pAIChannel->mNumRotationKeys)
|
||||
{
|
||||
vRotation.x = pAIChannel->mRotationKeys[i].mValue.x;
|
||||
vRotation.y = pAIChannel->mRotationKeys[i].mValue.y;
|
||||
vRotation.z = pAIChannel->mRotationKeys[i].mValue.z;
|
||||
vRotation.w = pAIChannel->mRotationKeys[i].mValue.w;
|
||||
|
||||
KeyFrame.fTrackPosition = (_float)pAIChannel->mRotationKeys[i].mTime;
|
||||
}
|
||||
|
||||
if (i < pAIChannel->mNumPositionKeys)
|
||||
{
|
||||
memcpy(&vTranslation, &pAIChannel->mPositionKeys[i].mValue, sizeof(_float3));
|
||||
KeyFrame.fTrackPosition = (_float)pAIChannel->mPositionKeys[i].mTime;
|
||||
}
|
||||
|
||||
KeyFrame.vScale = vScale;
|
||||
KeyFrame.vRotation = vRotation;
|
||||
KeyFrame.vTranslation = vTranslation;
|
||||
|
||||
m_KeyFrames.push_back(KeyFrame);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CChannel::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
string strName = m_szName;
|
||||
strName.shrink_to_fit();
|
||||
DWORD iLength = (DWORD)strName.length();
|
||||
WriteFile(hFile, &iLength, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, strName.data(), iLength, &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iBoneIndex, sizeof(_int), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iNumKeyFrames, sizeof(_uint), &dwByte, nullptr);
|
||||
for (auto& keyFrame : m_KeyFrames) {
|
||||
WriteFile(hFile, &keyFrame, sizeof(KEYFRAME), &dwByte, nullptr);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CChannel* CChannel::Create(const vector<CBone*>& Bones, const aiNodeAnim* pAIChannel)
|
||||
{
|
||||
CChannel* pInstance = new CChannel();
|
||||
|
||||
if (FAILED(pInstance->Initialize(Bones, pAIChannel))) {
|
||||
MSG_BOX("Failed to Created : CChannel");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
HRESULT CChannel::Initialize(const vector<CBone*>& Bones, _uint iIndex)
|
||||
{
|
||||
m_iBoneIndex = iIndex;
|
||||
memcpy_s(m_szName, sizeof(_char) * MAX_PATH, Bones[iIndex]->Get_Name(), sizeof(_char) * MAX_PATH);
|
||||
|
||||
m_iNumKeyFrames = 2;
|
||||
m_KeyFrames.resize(m_iNumKeyFrames);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
void CChannel::Update_TransformationMatirx(const vector<CBone*>& Bones, _float fCurrentTrackPosition, _uint* pCurrentKeyFrameIndex)
|
||||
|
||||
{
|
||||
if (0.f == fCurrentTrackPosition) {
|
||||
*pCurrentKeyFrameIndex = 0;
|
||||
}
|
||||
KEYFRAME LastKeyFrame = m_KeyFrames.back();
|
||||
|
||||
_vector vScale = {};
|
||||
_vector vRotation = {};
|
||||
_vector vTranslation = {};
|
||||
|
||||
if (fCurrentTrackPosition >= LastKeyFrame.fTrackPosition)
|
||||
{
|
||||
vScale = XMLoadFloat3(&LastKeyFrame.vScale);
|
||||
vRotation = XMLoadFloat4(&LastKeyFrame.vRotation);
|
||||
vTranslation = XMVectorSetW(XMLoadFloat3(&LastKeyFrame.vTranslation), 1.f);
|
||||
}
|
||||
else {
|
||||
while (fCurrentTrackPosition >= m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition) {
|
||||
++*pCurrentKeyFrameIndex;
|
||||
}
|
||||
|
||||
_float3 vSrcScale = {}, vDstScale = {};
|
||||
_float4 vSrcRotation = {}, vDstRotation = {};
|
||||
_float3 vSrcTranslation = {}, vDstTranslation = {};
|
||||
|
||||
vSrcScale = m_KeyFrames[*pCurrentKeyFrameIndex].vScale;
|
||||
vDstScale = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vScale;
|
||||
|
||||
vSrcRotation = m_KeyFrames[*pCurrentKeyFrameIndex].vRotation;
|
||||
vDstRotation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vRotation;
|
||||
|
||||
vSrcTranslation = m_KeyFrames[*pCurrentKeyFrameIndex].vTranslation;
|
||||
vDstTranslation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vTranslation;
|
||||
|
||||
_float fRatio = (fCurrentTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition) /
|
||||
(m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition);
|
||||
|
||||
vScale = XMVectorLerp(XMLoadFloat3(&vSrcScale), XMLoadFloat3(&vDstScale), fRatio);
|
||||
vRotation = XMQuaternionSlerp(XMLoadFloat4(&vSrcRotation), XMLoadFloat4(&vDstRotation), fRatio);
|
||||
vTranslation = XMVectorSetW(XMVectorLerp(XMLoadFloat3(&vSrcTranslation), XMLoadFloat3(&vDstTranslation), fRatio), 1.f);
|
||||
}
|
||||
_matrix BoneTransformationMatrix = XMMatrixAffineTransformation(vScale, XMVectorSet(0.f, 0.f, 0.f, 1.f), vRotation, vTranslation);
|
||||
|
||||
Bones[m_iBoneIndex]->Set_TransformationMatrix(BoneTransformationMatrix);
|
||||
}
|
||||
|
||||
|
||||
KEYFRAME* CChannel::Get_Frame(_uint iIndex)
|
||||
{
|
||||
return &m_KeyFrames[iIndex];
|
||||
}
|
||||
|
||||
void CChannel::Set_Frame(_uint iIndex, KEYFRAME& kf)
|
||||
{
|
||||
m_KeyFrames[iIndex] = kf;
|
||||
}
|
||||
|
||||
|
||||
HRESULT CChannel::Initialize(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
_uint iLength = { 0 };
|
||||
if (!ReadFile(hFile, &iLength, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, m_szName, iLength, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iBoneIndex, sizeof(_int), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iNumKeyFrames, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_KeyFrames.resize(m_iNumKeyFrames);
|
||||
for (_uint i = 0; i < m_iNumKeyFrames; ++i) {
|
||||
if (!ReadFile(hFile, &m_KeyFrames[i], sizeof(KEYFRAME), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CChannel* CChannel::Create(const vector<CBone*>& Bones, _uint iIndex)
|
||||
{
|
||||
CChannel* pInstance = new CChannel();
|
||||
|
||||
if (FAILED(pInstance->Initialize(Bones, iIndex)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CChannel");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CChannel* CChannel::Create(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
CChannel* pInstance = new CChannel();
|
||||
|
||||
if (FAILED(pInstance->Initialize(hFile, dwByte)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CChannel");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CChannel::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
m_KeyFrames.clear();
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
#include "pch.h"
|
||||
#include "LerpAnim.h"
|
||||
#include "Channel.h"
|
||||
#include "Bone.h"
|
||||
|
||||
CLerpAnim::CLerpAnim()
|
||||
{
|
||||
}
|
||||
|
||||
_bool CLerpAnim::Update_TransformationMatrices(const vector<CBone*>& Bones, _float fTimeDelta)
|
||||
{
|
||||
m_fCurrentTrackPosition += m_fTickPerSecond * fTimeDelta;
|
||||
|
||||
if (m_fCurrentTrackPosition >= m_fDuration) {
|
||||
m_fCurrentTrackPosition = m_fDuration;
|
||||
m_bLerping = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
_uint iIndex = {};
|
||||
for (auto& pChannel : m_Channels) {
|
||||
if (true == m_Movable[iIndex]) {
|
||||
pChannel->Update_TransformationMatirx(Bones, m_fCurrentTrackPosition, &m_CurrentKeyFrameIndices[iIndex]);
|
||||
}
|
||||
iIndex++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
HRESULT CLerpAnim::Initialize(_uint iNumBone, _float fTickPerSecond, const vector<CBone*>& Bones)
|
||||
{
|
||||
m_iNumChannels = iNumBone;
|
||||
m_fTickPerSecond = fTickPerSecond;
|
||||
m_CurrentKeyFrameIndices.resize(m_iNumChannels);
|
||||
m_Movable.resize(m_iNumChannels);
|
||||
m_InitialFrames.resize(m_iNumChannels);
|
||||
m_Channels.reserve(m_iNumChannels);
|
||||
|
||||
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
||||
CChannel* pChannel = CChannel::Create(Bones, i);
|
||||
if (nullptr == pChannel) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_Channels.push_back(pChannel);
|
||||
Bones[i]->Get_KeyFrame(m_InitialFrames[i], false);
|
||||
m_InitialFrames[i].fTrackPosition = m_fDuration;
|
||||
pChannel->Set_Frame(1, m_InitialFrames[i]);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
void CLerpAnim::Begin(const vector<class CBone*>& Bones, vector<LERPDESC>& StartFrames, vector<LERPDESC>& EndFrames, _float fDuration, _uint iRootBoneIndex)
|
||||
{
|
||||
{ // 초기화
|
||||
|
||||
//KEYFRAME kf = { // 항등행렬의 키프레임
|
||||
// { 1.f, 1.f, 1.f },
|
||||
// { 0.f, 0.f, 0.f, 1.f },
|
||||
// { 0.f, 0.f, 0.f},
|
||||
// m_fDuration };
|
||||
m_bLerping = true;
|
||||
m_fDuration = fDuration;
|
||||
m_fCurrentTrackPosition = 0.f;
|
||||
for (_uint i = 0; i < m_iNumChannels; ++i) {
|
||||
m_Channels[i]->Set_Frame(1, m_InitialFrames[i]); // 끝프레임을 초기 값으로 채우기
|
||||
}
|
||||
fill(m_CurrentKeyFrameIndices.begin(), m_CurrentKeyFrameIndices.end(), 0);
|
||||
fill(m_Movable.begin(), m_Movable.end(), false);
|
||||
}
|
||||
{ // 실제 값 채우기
|
||||
for (LERPDESC& Desc : EndFrames) // 끝프레임을 실제 값으로 채우기
|
||||
{
|
||||
_int iIndex = Desc.iSlot;
|
||||
Desc.tagKeyFrame.fTrackPosition = m_fDuration;
|
||||
m_Channels[iIndex]->Set_Frame(1, Desc.tagKeyFrame);
|
||||
}
|
||||
for (_uint i = 0; i < StartFrames.size(); ++i) { // 시작 프레임을 현재 본 상태 키프레임으로 채우기
|
||||
_int iIndex = StartFrames[i].iSlot;
|
||||
m_Movable[iIndex] = true;
|
||||
m_Channels[iIndex]->Set_Frame(0, StartFrames[i].tagKeyFrame);
|
||||
}
|
||||
//m_Movable[iRootBoneIndex] = false;
|
||||
}
|
||||
}
|
||||
CLerpAnim* CLerpAnim::Create(_uint iNumBone, _float fTickPerSecond, const vector<CBone*>& Bones)
|
||||
{
|
||||
CLerpAnim* pInstance = new CLerpAnim;
|
||||
if (FAILED(pInstance->Initialize(iNumBone, fTickPerSecond, Bones))) {
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
void CLerpAnim::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
for (auto& pChannel : m_Channels) {
|
||||
SAFE_RELEASE(pChannel);
|
||||
}
|
||||
m_Channels.clear();
|
||||
|
||||
m_CurrentKeyFrameIndices.clear();
|
||||
}
|
||||
;
|
||||
@@ -0,0 +1,243 @@
|
||||
#include "pch.h"
|
||||
#include "Material.h"
|
||||
#include "GameInstance.h"
|
||||
#include "Shader.h"
|
||||
|
||||
CMaterial::CMaterial(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: m_pDevice{ pDevice }
|
||||
, m_pContext{ pContext }
|
||||
, m_pGameInstance{ CGameInstance::GetInstance() }
|
||||
{
|
||||
SAFE_ADDREF(m_pDevice);
|
||||
SAFE_ADDREF(m_pContext);
|
||||
SAFE_ADDREF(m_pGameInstance);
|
||||
}
|
||||
#ifdef EDITOR_PROJECT
|
||||
HRESULT CMaterial::Initialize(const _char* pModelFilePath, const aiMaterial* pAIMaterial)
|
||||
{
|
||||
for (size_t i = 0; i < AI_TEXTURE_TYPE_MAX; i++)
|
||||
{
|
||||
_uint iNumSRVs = pAIMaterial->GetTextureCount(static_cast<aiTextureType>(i));
|
||||
|
||||
m_SRVs[i].reserve(iNumSRVs);
|
||||
|
||||
ID3D11ShaderResourceView* pSRV = { nullptr };
|
||||
|
||||
HRESULT hr = {};
|
||||
|
||||
for (size_t j = 0; j < iNumSRVs; j++)
|
||||
{
|
||||
aiString strTexturePath;
|
||||
|
||||
if (FAILED(pAIMaterial->GetTexture(static_cast<aiTextureType>(i), (_uint)j, &strTexturePath))) {
|
||||
continue;
|
||||
}
|
||||
_char szTextureDir[MAX_PATH] = {};
|
||||
_char szSaveDir[MAX_PATH] = {};
|
||||
_char szDrive[MAX_PATH] = {};
|
||||
_char szDir[MAX_PATH] = {};
|
||||
_char szName[MAX_PATH] = {};
|
||||
_char szExt[MAX_PATH] = {};
|
||||
_splitpath_s(pModelFilePath, szDrive, MAX_PATH, szDir, MAX_PATH, nullptr, 0, nullptr, 0);
|
||||
_splitpath_s(strTexturePath.C_Str(), nullptr, 0, nullptr, 0, szName, MAX_PATH, szExt, MAX_PATH);
|
||||
strcpy_s(szTextureDir, sizeof(_char) * MAX_PATH, szDrive);
|
||||
strcat_s(szTextureDir, sizeof(_char) * MAX_PATH, szDir);
|
||||
strcat_s(szTextureDir, sizeof(_char) * MAX_PATH, szName);
|
||||
strcat_s(szTextureDir, sizeof(_char) * MAX_PATH, szExt);
|
||||
|
||||
{
|
||||
_char szTextureFileName[MAX_PATH] = {};
|
||||
_char szTextureFilePath[MAX_PATH] = {};
|
||||
_char szDrive[MAX_PATH] = {};
|
||||
_char szDir[MAX_PATH] = {};
|
||||
_char szFileName[MAX_PATH] = {};
|
||||
_char szEXT[MAX_PATH] = {};
|
||||
_splitpath_s(szTextureDir, szDrive, MAX_PATH, szDir, MAX_PATH, szFileName, MAX_PATH, szEXT, MAX_PATH);
|
||||
strcpy_s(szTextureFileName, szDrive);
|
||||
strcat_s(szTextureFileName, szDir);
|
||||
strcat_s(szTextureFileName, szFileName);
|
||||
|
||||
strcat_s(szTextureFilePath, szTextureFileName);
|
||||
strcat_s(szTextureFilePath, ".dds");
|
||||
|
||||
hr = CreateDDSTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, &pSRV); // 일단 dds로 시도하고
|
||||
if (FAILED(hr)) {
|
||||
memset(szTextureFilePath, 0, sizeof(_char) * MAX_PATH); // 실패하면 원래 확장자로 다시 시도
|
||||
strcat_s(szTextureFilePath, szTextureFileName);
|
||||
strcat_s(szTextureFilePath, szEXT);
|
||||
|
||||
if (false == strcmp(".tga", szEXT)) {
|
||||
assert(false); // trying to Load TGA
|
||||
hr = S_OK;
|
||||
}
|
||||
else {
|
||||
hr = CreateWICTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, &pSRV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
strcpy_s(szSaveDir, sizeof(_char) * MAX_PATH, szName);
|
||||
strcat_s(szSaveDir, sizeof(_char) * MAX_PATH, szExt);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_strPath[i].push_back(szSaveDir);
|
||||
m_SRVs[i].push_back(pSRV);
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CMaterial::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
// 실제 값을 저장하지 않고 파일이름.확장자명의 문자열을 저장해서 수정하기 편하게 만들기
|
||||
// 대신 리소스를 공유해야함
|
||||
// 텍스쳐를 저장하지 않고
|
||||
// 텍스쳐 경로만 ( "이름.확장자" ) 만 저장함
|
||||
for (int i = 0; i < AI_TEXTURE_TYPE_MAX; ++i) {
|
||||
_uint iNumSrv = (_uint)m_strPath[i].size();
|
||||
WriteFile(hFile, &i, sizeof(_uint), &dwByte, nullptr); // 종류 저장
|
||||
WriteFile(hFile, &iNumSrv, sizeof(_uint), &dwByte, nullptr); // 종류의 갯수 저장
|
||||
for (_uint j = 0; j < iNumSrv; ++j) {
|
||||
m_strPath[i][j].shrink_to_fit();
|
||||
_uint strLength = (_uint)(sizeof(_char) * m_strPath[i][j].length());
|
||||
WriteFile(hFile, &strLength, sizeof(_uint), &dwByte, nullptr); // 사이즈 저장
|
||||
WriteFile(hFile, m_strPath[i][j].data(), strLength, &dwByte, nullptr); // 실제 값 저장
|
||||
}
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const aiMaterial* pAIMaterial)
|
||||
{
|
||||
CMaterial* pInstance = new CMaterial(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize(pModelFilePath, pAIMaterial)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CMaterial");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT CMaterial::Bind_SRV(CShader* pShader, const _char* pConstantName, _uint iType, _uint iTextureIndex)
|
||||
{
|
||||
if (m_SRVs[iType].empty()) {
|
||||
//assert(false);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
return pShader->Bind_SRV(pConstantName, m_SRVs[iType][iTextureIndex]);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CMaterial::Initialize(const _char* pModelFilePath, HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
for (int i = 0; i < AI_TEXTURE_TYPE_MAX; ++i) {
|
||||
_uint iNumSrv = { 0 };
|
||||
if (!ReadFile(hFile, &i, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &iNumSrv, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (iNumSrv == 0) {
|
||||
continue;
|
||||
}
|
||||
m_SRVs[i].reserve(iNumSrv);
|
||||
|
||||
ID3D11ShaderResourceView* pSRV = { nullptr };
|
||||
HRESULT hr = {};
|
||||
|
||||
for (_uint j = 0; j < iNumSrv; ++j) {
|
||||
_uint strLength = { 0 };
|
||||
if (!ReadFile(hFile, &strLength, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
_char szTextureName[MAX_PATH] = {};
|
||||
if (!ReadFile(hFile, szTextureName, strLength, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_char szTextureDir[MAX_PATH] = {};
|
||||
_char szDrive[MAX_PATH] = {};
|
||||
_char szDir[MAX_PATH] = {};
|
||||
_splitpath_s(pModelFilePath, szDrive, MAX_PATH, szDir, MAX_PATH, nullptr, 0, nullptr, 0);
|
||||
strcpy_s(szTextureDir, sizeof(_char) * MAX_PATH, szDrive);
|
||||
strcat_s(szTextureDir, sizeof(_char) * MAX_PATH, szDir);
|
||||
strcat_s(szTextureDir, sizeof(_char) * MAX_PATH, szTextureName);
|
||||
|
||||
{
|
||||
_char szTextureFileName[MAX_PATH] = {};
|
||||
_char szTextureFilePath[MAX_PATH] = {};
|
||||
_char szDrive[MAX_PATH] = {};
|
||||
_char szDir[MAX_PATH] = {};
|
||||
_char szFileName[MAX_PATH] = {};
|
||||
_char szEXT[MAX_PATH] = {};
|
||||
_splitpath_s(szTextureDir, szDrive, MAX_PATH, szDir, MAX_PATH, szFileName, MAX_PATH, szEXT, MAX_PATH);
|
||||
strcpy_s(szTextureFileName, szDrive);
|
||||
strcat_s(szTextureFileName, szDir);
|
||||
strcat_s(szTextureFileName, szFileName);
|
||||
|
||||
strcat_s(szTextureFilePath, szTextureFileName);
|
||||
strcat_s(szTextureFilePath, ".dds");
|
||||
|
||||
hr = CreateDDSTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, &pSRV); // 일단 dds로 시도하고
|
||||
if (FAILED(hr)) {
|
||||
memset(szTextureFilePath, 0, sizeof(_char) * MAX_PATH); // 실패하면 원래 확장자로 다시 시도
|
||||
strcat_s(szTextureFilePath, szTextureFileName);
|
||||
strcat_s(szTextureFilePath, szEXT);
|
||||
|
||||
if (false == strcmp(".tga", szEXT)) {
|
||||
assert(false); // trying to Load TGA
|
||||
hr = S_OK;
|
||||
}
|
||||
else {
|
||||
hr = CreateWICTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, &pSRV);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (FAILED(hr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_SRVs[i].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);
|
||||
|
||||
if (FAILED(pInstance->Initialize(pModelFilePath, hFile, dwByte)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CMaterial");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
|
||||
void CMaterial::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
SAFE_RELEASE(m_pGameInstance);
|
||||
SAFE_RELEASE(m_pDevice);
|
||||
SAFE_RELEASE(m_pContext);
|
||||
|
||||
for (auto& SRVs : m_SRVs)
|
||||
{
|
||||
for (auto& pSRV : SRVs) {
|
||||
SAFE_RELEASE(pSRV);
|
||||
}
|
||||
SRVs.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,515 @@
|
||||
#include "pch.h"
|
||||
#include "Mesh.h"
|
||||
#include "Model.h"
|
||||
#include "Bone.h"
|
||||
#include "Shader.h"
|
||||
|
||||
CMesh::CMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CVIBuffer{ pDevice, pContext }
|
||||
{
|
||||
}
|
||||
|
||||
CMesh::CMesh(const CMesh& rhs)
|
||||
: CVIBuffer(rhs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HRESULT CMesh::Bind_BoneMatrices(const vector<class CBone*>& Bones, CShader* pShader, const _char* pConstantName)
|
||||
{
|
||||
if (m_iNumBones >= 512) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_iNumBones; ++i) {
|
||||
XMStoreFloat4x4(&m_pBoneMatrices[i],
|
||||
XMLoadFloat4x4(&m_offsetMatrices[i]) * Bones[m_BoneIndices[i]]->Get_CombinedTransformationMatrix());
|
||||
}
|
||||
if (0 == m_iNumBones) {
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return pShader->Bind_Matrices(pConstantName, m_pBoneMatrices, m_iNumBones);
|
||||
}
|
||||
|
||||
HRESULT CMesh::Bind_BoneMatrices(_float4x4* pCombinedMatrices, CShader* pShader, const _char* pConstantName)
|
||||
{
|
||||
if (m_iNumBones >= 512) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_iNumBones; ++i) {
|
||||
XMStoreFloat4x4(&m_pBoneMatrices[i],
|
||||
XMLoadFloat4x4(&m_offsetMatrices[i]) * XMLoadFloat4x4(&pCombinedMatrices[m_BoneIndices[i]]));
|
||||
}
|
||||
if (0 == m_iNumBones) {
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
return pShader->Bind_Matrices(pConstantName, m_pBoneMatrices, m_iNumBones);
|
||||
}
|
||||
|
||||
HRESULT CMesh::Render_Indexed(_uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation)
|
||||
{
|
||||
m_pContext->DrawIndexed(IndexCount, StartIndexLocation, BaseVertexLocation);
|
||||
return S_OK;
|
||||
}
|
||||
#ifdef EDITOR_PROJECT
|
||||
HRESULT CMesh::Initialize_Prototype(MODEL eType, vector<class CBone*>& Bones, const aiMesh* pAIMesh, _fmatrix& PreTransformMatrix)
|
||||
{
|
||||
strcpy_s(m_szName, pAIMesh->mName.data);
|
||||
|
||||
m_iMaterialIndex = pAIMesh->mMaterialIndex;
|
||||
m_iNumVertexBuffers = 1;
|
||||
m_iNumVertices = pAIMesh->mNumVertices;
|
||||
|
||||
m_iNumIndices = pAIMesh->mNumFaces * 3;
|
||||
m_iIndexStride = 4;
|
||||
|
||||
m_eIndexFormat = DXGI_FORMAT_R32_UINT;
|
||||
m_ePrimitive = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||
|
||||
#pragma region VERTEX_BUFFER
|
||||
|
||||
HRESULT hr = (eType == MODEL::NONANIM) ?
|
||||
Ready_VertexBuffer_For_NonAnim(pAIMesh, PreTransformMatrix) :
|
||||
Ready_VertexBuffer_For_Anim(Bones, pAIMesh);
|
||||
|
||||
#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;
|
||||
|
||||
|
||||
_uint* pIndices = new _uint[m_iNumIndices];
|
||||
ZeroMemory(pIndices, sizeof(_uint) * m_iNumIndices);
|
||||
|
||||
_uint iNumIndices = {};
|
||||
|
||||
for (size_t i = 0; i < pAIMesh->mNumFaces; i++)
|
||||
{
|
||||
|
||||
pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[0];
|
||||
pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[1];
|
||||
pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[2];
|
||||
}
|
||||
|
||||
|
||||
D3D11_SUBRESOURCE_DATA InitialIBData{};
|
||||
InitialIBData.pSysMem = pIndices;
|
||||
|
||||
if (FAILED(m_pDevice->CreateBuffer(&IBDesc, &InitialIBData, &m_pIB)))
|
||||
return E_FAIL;
|
||||
|
||||
Safe_Delete_Array(pIndices);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif
|
||||
HRESULT CMesh::Initialize_Prototype(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
{ // 멤버변수
|
||||
if (!ReadFile(hFile, &m_iMaterialIndex, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iNumVertexBuffers, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iNumVertices, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iVertexStride, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iNumIndices, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iIndexStride, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_iNumBones, sizeof(_uint), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_eIndexFormat, sizeof(DXGI_FORMAT), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &m_ePrimitive, sizeof(D3D_PRIMITIVE_TOPOLOGY), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
DWORD iSize = {};
|
||||
if (!ReadFile(hFile, &iSize, sizeof(DWORD), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_BoneIndices.resize(iSize / sizeof(_int));
|
||||
if (!ReadFile(hFile, m_BoneIndices.data(), iSize, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (!ReadFile(hFile, &iSize, sizeof(DWORD), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_offsetMatrices.resize(iSize / sizeof(_float4x4));
|
||||
if (!ReadFile(hFile, m_offsetMatrices.data(), iSize, &dwByte, nullptr)) {
|
||||
DWORD err = GetLastError();
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_pBoneMatrices = new _float4x4[0 == m_iNumBones ? 1 : m_iNumBones];
|
||||
ZeroMemory(m_pBoneMatrices, sizeof(_float4x4) * m_iNumBones);
|
||||
}
|
||||
{ // Vertex Buffer
|
||||
HRESULT hr = (m_iVertexStride == sizeof(VTXMESH)) ?
|
||||
Ready_VertexBuffer_For_NonAnim(hFile, dwByte) :
|
||||
Ready_VertexBuffer_For_Anim(hFile, dwByte);
|
||||
}
|
||||
{ // Index Buffer
|
||||
D3D11_BUFFER_DESC IBDesc{};
|
||||
if (!ReadFile(hFile, &IBDesc, sizeof(D3D11_BUFFER_DESC), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_uint* pIndices = new _uint[m_iNumIndices];
|
||||
ZeroMemory(pIndices, sizeof(_uint) * m_iNumIndices);
|
||||
|
||||
if (!ReadFile(hFile, pIndices, IBDesc.ByteWidth, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
D3D11_SUBRESOURCE_DATA InitialIBData{};
|
||||
InitialIBData.pSysMem = pIndices;
|
||||
|
||||
if (FAILED(m_pDevice->CreateBuffer(&IBDesc, &InitialIBData, &m_pIB))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
Safe_Delete_Array(pIndices);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
D3D11_BUFFER_DESC VBDesc{};
|
||||
if (!ReadFile(hFile, &VBDesc, sizeof(D3D11_BUFFER_DESC), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
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);
|
||||
if (!ReadFile(hFile, pVertices, VBDesc.ByteWidth, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
for (_uint i = 0; i < m_iNumVertices; ++i) {
|
||||
m_pVertexPositions[i] = pVertices[i].vPosition;
|
||||
}
|
||||
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(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
D3D11_BUFFER_DESC VBDesc{};
|
||||
if (!ReadFile(hFile, &VBDesc, sizeof(D3D11_BUFFER_DESC), &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
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);
|
||||
if (!ReadFile(hFile, pVertices, VBDesc.ByteWidth, &dwByte, nullptr)) {
|
||||
return E_FAIL;
|
||||
}
|
||||
for (_uint i = 0; i < m_iNumVertices; ++i) {
|
||||
m_pVertexPositions[i] = pVertices[i].vPosition;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
#ifdef EDITOR_PROJECT
|
||||
CMesh* CMesh::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, vector<class CBone*>& Bones, const aiMesh* pAIMesh, _fmatrix& PreTransformMatrix)
|
||||
{
|
||||
CMesh* pInstance = new CMesh(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype(eType, Bones, pAIMesh, PreTransformMatrix)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CMesh");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
HRESULT CMesh::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
{ // 멤버변수
|
||||
WriteFile(hFile, &m_iMaterialIndex, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iNumVertexBuffers, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iNumVertices, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iVertexStride, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iNumIndices, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iIndexStride, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_iNumBones, sizeof(_uint), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_eIndexFormat, sizeof(DXGI_FORMAT), &dwByte, nullptr);
|
||||
WriteFile(hFile, &m_ePrimitive, sizeof(D3D_PRIMITIVE_TOPOLOGY), &dwByte, nullptr);
|
||||
|
||||
DWORD iSize = (DWORD)(sizeof(_int) * m_BoneIndices.size());
|
||||
WriteFile(hFile, &iSize, sizeof(DWORD), &dwByte, nullptr);
|
||||
WriteFile(hFile, m_BoneIndices.data(), iSize, &dwByte, nullptr);
|
||||
|
||||
iSize = (DWORD)(sizeof(_float4x4) * m_offsetMatrices.size());
|
||||
WriteFile(hFile, &iSize, sizeof(DWORD), &dwByte, nullptr);
|
||||
WriteFile(hFile, m_offsetMatrices.data(), iSize, &dwByte, nullptr);
|
||||
}
|
||||
{ // Vertex Buffer
|
||||
D3D11_BUFFER_DESC VBDesc{};
|
||||
m_pVB->GetDesc(&VBDesc); // 버퍼 디스크립션 저장
|
||||
WriteFile(hFile, &VBDesc, sizeof(D3D11_BUFFER_DESC), &dwByte, nullptr);
|
||||
|
||||
D3D11_BUFFER_DESC StagingDesc{};
|
||||
StagingDesc.Usage = D3D11_USAGE_STAGING;
|
||||
StagingDesc.ByteWidth = VBDesc.ByteWidth;
|
||||
StagingDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
StagingDesc.BindFlags = 0;
|
||||
StagingDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Buffer* pStaging = nullptr;
|
||||
if (FAILED(m_pDevice->CreateBuffer(&StagingDesc, nullptr, &pStaging)) || nullptr == pStaging) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_pContext->CopyResource(pStaging, m_pVB); // 버퍼 복사
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mapped{};
|
||||
m_pContext->Map(pStaging, 0, D3D11_MAP_READ, 0, &mapped);
|
||||
WriteFile(hFile, mapped.pData, VBDesc.ByteWidth, &dwByte, nullptr);
|
||||
|
||||
m_pContext->Unmap(pStaging, 0);
|
||||
pStaging->Release();
|
||||
}
|
||||
{ // Index Buffer
|
||||
D3D11_BUFFER_DESC IBDesc{};
|
||||
m_pIB->GetDesc(&IBDesc);
|
||||
WriteFile(hFile, &IBDesc, sizeof(D3D11_BUFFER_DESC), &dwByte, nullptr);
|
||||
|
||||
D3D11_BUFFER_DESC StagingDesc{};
|
||||
StagingDesc.Usage = D3D11_USAGE_STAGING;
|
||||
StagingDesc.ByteWidth = IBDesc.ByteWidth;
|
||||
StagingDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
StagingDesc.BindFlags = 0;
|
||||
StagingDesc.MiscFlags = 0;
|
||||
|
||||
ID3D11Buffer* pStaging = nullptr;
|
||||
if (FAILED(m_pDevice->CreateBuffer(&StagingDesc, nullptr, &pStaging)) || nullptr == pStaging) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_pContext->CopyResource(pStaging, m_pIB);
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mapped{};
|
||||
m_pContext->Map(pStaging, 0, D3D11_MAP_READ, 0, &mapped);
|
||||
WriteFile(hFile, mapped.pData, IBDesc.ByteWidth, &dwByte, nullptr);
|
||||
|
||||
m_pContext->Unmap(pStaging, 0);
|
||||
pStaging->Release();
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(const aiMesh* pAIMesh, _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, &pAIMesh->mVertices[i], sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vPosition, XMVector3TransformCoord(XMLoadFloat3(&pVertices[i].vPosition), PreTransformMatrix));
|
||||
memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vNormal, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vNormal), PreTransformMatrix)));
|
||||
memcpy(&pVertices[i].vTangent, &pAIMesh->mTangents[i], sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vTangent, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vTangent), PreTransformMatrix)));
|
||||
memcpy(&pVertices[i].vBinormal, &pAIMesh->mBitangents[i], sizeof(_float3));
|
||||
XMStoreFloat3(&pVertices[i].vBinormal, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vBinormal), PreTransformMatrix)));
|
||||
memcpy(&pVertices[i].vTexcoord, &pAIMesh->mTextureCoords[0][i], sizeof(_float2));
|
||||
}
|
||||
|
||||
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(vector<class CBone*>& Bones, const aiMesh* pAIMesh)
|
||||
{
|
||||
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, &pAIMesh->mVertices[i], sizeof(_float3));
|
||||
memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3));
|
||||
memcpy(&pVertices[i].vTangent, &pAIMesh->mTangents[i], sizeof(_float3));
|
||||
memcpy(&pVertices[i].vBinormal, &pAIMesh->mBitangents[i], sizeof(_float3));
|
||||
memcpy(&pVertices[i].vTexcoord, &pAIMesh->mTextureCoords[0][i], sizeof(_float2));
|
||||
}
|
||||
|
||||
m_iNumBones = pAIMesh->mNumBones;
|
||||
|
||||
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) {
|
||||
aiBone* pAIBone = pAIMesh->mBones[i];
|
||||
_uint iNumWeight = pAIBone->mNumWeights;
|
||||
|
||||
memcpy(&OffSetMatrix, &pAIBone->mOffsetMatrix, sizeof(_float4x4));
|
||||
XMStoreFloat4x4(&OffSetMatrix, XMMatrixTranspose(XMLoadFloat4x4(&OffSetMatrix)));
|
||||
|
||||
_int iBoneIndex = CModel::Get_BoneIndex(pAIBone->mName.data, Bones);
|
||||
|
||||
if (-1 == iBoneIndex) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_offsetMatrices.push_back(OffSetMatrix);
|
||||
m_BoneIndices.push_back(iBoneIndex);
|
||||
|
||||
for (_uint j = 0; j < iNumWeight; ++j) {
|
||||
aiVertexWeight AIWeight = pAIBone->mWeights[j];
|
||||
if (0.f == pVertices[AIWeight.mVertexId].vBlendWeight.x) {
|
||||
pVertices[AIWeight.mVertexId].vBlendIndex.x = i;
|
||||
pVertices[AIWeight.mVertexId].vBlendWeight.x = AIWeight.mWeight;
|
||||
}
|
||||
else if (0.f == pVertices[AIWeight.mVertexId].vBlendWeight.y) {
|
||||
pVertices[AIWeight.mVertexId].vBlendIndex.y = i;
|
||||
pVertices[AIWeight.mVertexId].vBlendWeight.y = AIWeight.mWeight;
|
||||
}
|
||||
else if (0.f == pVertices[AIWeight.mVertexId].vBlendWeight.z) {
|
||||
pVertices[AIWeight.mVertexId].vBlendIndex.z = i;
|
||||
pVertices[AIWeight.mVertexId].vBlendWeight.z = AIWeight.mWeight;
|
||||
}
|
||||
else {
|
||||
pVertices[AIWeight.mVertexId].vBlendIndex.w = i;
|
||||
pVertices[AIWeight.mVertexId].vBlendWeight.w = AIWeight.mWeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (0 == m_iNumBones) {
|
||||
m_iNumBones = 1;
|
||||
m_BoneIndices.push_back(CModel::Get_BoneIndex(m_szName, Bones));
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
CMesh* CMesh::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, HANDLE hFile, DWORD& dwByte)
|
||||
{
|
||||
CMesh* pInstance = new CMesh(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype(hFile, dwByte)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CMesh");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CMesh* CMesh::Clone(void* pArg, class CGameObject* pOwner)
|
||||
{
|
||||
CMesh* pInstance = new CMesh(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CMesh");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
void CMesh::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
Safe_Delete_Array(m_pBoneMatrices);
|
||||
}
|
||||
|
||||
void CMesh::Describe_Entity()
|
||||
{
|
||||
}
|
||||
@@ -1,2 +1,510 @@
|
||||
#include "pch.h"
|
||||
#include "Model.h"
|
||||
#include "Model.h"
|
||||
#include "Bone.h"
|
||||
#include "Mesh.h"
|
||||
#include "Material.h"
|
||||
#include "Animation.h"
|
||||
#include "LerpAnim.h"
|
||||
#include "GameObject.h"
|
||||
|
||||
CModel::CModel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
: CComponent{ pDevice, pContext }
|
||||
{
|
||||
}
|
||||
|
||||
CModel::CModel(const CModel& rhs)
|
||||
: CComponent(rhs),
|
||||
m_eType(rhs.m_eType),
|
||||
m_PreTransformMatrix(rhs.m_PreTransformMatrix),
|
||||
m_iRootBoneIndex(rhs.m_iRootBoneIndex),
|
||||
m_Meshes(rhs.m_Meshes),
|
||||
m_iNumMeshes(rhs.m_iNumMeshes),
|
||||
m_Materials(rhs.m_Materials),
|
||||
m_iNumMaterials(rhs.m_iNumMaterials),
|
||||
m_iNumAnimations(rhs.m_iNumAnimations),
|
||||
m_pLerpAnim(rhs.m_pLerpAnim)
|
||||
{
|
||||
_uint iNumBones = (_uint)(rhs.m_Bones.size());
|
||||
m_Bones.reserve(iNumBones);
|
||||
for (_uint i = 0; i < iNumBones; ++i) {
|
||||
m_Bones.push_back(rhs.m_Bones[i]->Clone());
|
||||
}
|
||||
for (auto& pMesh : m_Meshes) {
|
||||
SAFE_ADDREF(pMesh);
|
||||
}
|
||||
for (auto& pMat : m_Materials) {
|
||||
SAFE_ADDREF(pMat);
|
||||
}
|
||||
m_Animations.reserve(m_iNumAnimations);
|
||||
for (_uint i = 0; i < m_iNumAnimations; ++i) {
|
||||
m_Animations.push_back(rhs.m_Animations[i]->Clone()); // 멤버 전부 얕은복사.
|
||||
}
|
||||
}
|
||||
|
||||
_int CModel::Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones)
|
||||
{
|
||||
_int iBoneIndex = {};
|
||||
vector<CBone*>::const_iterator iter = find_if(Bones.begin(), Bones.end(), [&](CBone* pBone)->_bool {
|
||||
if (true == pBone->Compare_Name(pBoneName)) {
|
||||
return true;
|
||||
}
|
||||
++iBoneIndex;
|
||||
return false;
|
||||
});
|
||||
if (iter == 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; }
|
||||
m_iCurrentAnimIndex = iAnimationIndex;
|
||||
m_bIsLoop = bIsLoop;
|
||||
RefreshAnim();
|
||||
|
||||
m_PrevAnimationMatrix = Get_BoneMatrix(m_iRootBoneIndex);
|
||||
|
||||
|
||||
m_Animations[m_iCurrentAnimIndex]->Depart_Animation(); // 애니메이션 종료 이벤트 ( 럴프애님은 자체적으로 불림 )
|
||||
vector<_int>* BeforeAnimIndex = m_Animations[m_iCurrentAnimIndex]->Capture_Bones(); // 영향을 받는 본 인덱스 추출 1
|
||||
vector<_int>* AfterAnimIndex = m_Animations[iAnimationIndex]->Capture_Bones(); // 영향을 받는 본 인덱스 추출 2
|
||||
unordered_set<_int> UnionAnimIndex = {};
|
||||
|
||||
vector<LERPDESC> LerpStartFrames;
|
||||
for (_int i : *BeforeAnimIndex) {
|
||||
UnionAnimIndex.insert(i);
|
||||
}
|
||||
for (_int i : *AfterAnimIndex) {
|
||||
UnionAnimIndex.insert(i);
|
||||
}
|
||||
LerpStartFrames.reserve(UnionAnimIndex.size()); // 영향을 받는 모든 현재 본을 가져옴
|
||||
|
||||
// 스타팅 키프레임 채우기 pair < 본 인덱스, 키프레임 >
|
||||
for (auto iter = UnionAnimIndex.begin(); iter != UnionAnimIndex.end(); ++iter) {
|
||||
LERPDESC desc = {};
|
||||
desc.iSlot = *iter;
|
||||
m_Bones[desc.iSlot]->Get_KeyFrame(desc.tagKeyFrame, true); // 스타팅 키프레임 채우기
|
||||
LerpStartFrames.emplace_back(desc);
|
||||
}
|
||||
|
||||
// 엔딩 키프레임 채우기 pair < 본인덱스, 키프레임 >
|
||||
vector<LERPDESC> LerpEndFrames = m_Animations[iAnimationIndex]->Get_StartFrameInformations();
|
||||
|
||||
// 럴프 애니메이션 시작
|
||||
m_pLerpAnim->Begin(m_Bones, LerpStartFrames, LerpEndFrames, fLerpDuration, m_iRootBoneIndex);
|
||||
|
||||
}
|
||||
HRESULT CModel::Bind_Material(_uint iMeshIndex, CShader* pShader, const _char* pConstantName, _uint iType, _uint iTextureIndex)
|
||||
{
|
||||
if (iMeshIndex >= m_iNumMeshes) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_uint iMaterialIndex = m_Meshes[iMeshIndex]->Get_MaterialIndex();
|
||||
|
||||
if (iMaterialIndex >= m_iNumMaterials) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return m_Materials[iMaterialIndex]->Bind_SRV(pShader, pConstantName, iType, iTextureIndex);
|
||||
}
|
||||
|
||||
HRESULT CModel::Bind_BoneMatrices(_uint iMeshIndex, CShader* pShader, const _char* pConstantName)
|
||||
{
|
||||
if (iMeshIndex >= m_iNumMeshes) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return m_Meshes[iMeshIndex]->Bind_BoneMatrices(m_Bones, pShader, pConstantName);
|
||||
}
|
||||
|
||||
_bool CModel::Play_Animation(_float fTimeDelta)
|
||||
{
|
||||
if (-1 == m_iCurrentAnimIndex // 정지 혹은 시작을 안시켜준 애님
|
||||
|| m_iCurrentAnimIndex >= (_int)m_iNumAnimations) // 애님 인덱스 초과됨
|
||||
{
|
||||
return false; // 잘못된 초기화
|
||||
}
|
||||
|
||||
if (true == m_pLerpAnim->IsLerping()) { // 럴프중이면 자동으로 럴프 Update를 부름
|
||||
m_bIsFinishedLerp = m_pLerpAnim->Update_TransformationMatrices(m_Bones, fTimeDelta);
|
||||
}
|
||||
else { // 럴프중이지 않다면 실제 애니메이션 재생을 시작함
|
||||
m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_bIsLoop, fTimeDelta);
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_Bones.size(); ++i)
|
||||
{
|
||||
m_Bones[i]->Update_CombinedTransformationMatrix(m_Bones, XMLoadFloat4x4(&m_PreTransformMatrix));
|
||||
|
||||
if (i == m_iRootBoneIndex) { // 루트본의 매트릭스를 갱신했다면 애니메이션에 맞게 이동량을 루트본에서 트랜스폼으로 보정시킴
|
||||
if (true == m_pLerpAnim->IsLerping()) { // 럴프중이었으면 이동량 반영 x
|
||||
_matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex);
|
||||
currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f);
|
||||
m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix);
|
||||
}
|
||||
else {
|
||||
_matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex); // 현재 루트본의 컴바인드 트랜스폼을 꺼내오고
|
||||
_matrix deltaAnimMatrix = XMMatrixMultiply(XMMatrixInverse(nullptr, m_PrevAnimationMatrix), currAnimMatrix); // 이전 트랜스폼이랑 비교해서 델타매트릭스를 꺼냄
|
||||
_vector momentum = XMMatrixMultiply(deltaAnimMatrix, XMMatrixRotationQuaternion(m_pTransform->Get_QuarternionVector())).r[3];
|
||||
deltaAnimMatrix.r[3] = XMVectorSetW(momentum, 0.f);
|
||||
|
||||
m_pTransform->AccumulateMomentum(deltaAnimMatrix.r[3]); // 모체 트랜스폼에 이동량 반영
|
||||
//m_pTransform->Set_State(STATE::POSITION, m_pTransform->Get_State(STATE::POSITION) + deltaAnimMatrix.r[3]);
|
||||
|
||||
m_PrevAnimationMatrix = currAnimMatrix;
|
||||
currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f);
|
||||
m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix); // 루트본의 이동량 소거
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_bIsFinishedAnim;
|
||||
}
|
||||
|
||||
void CModel::Stop_Animation()
|
||||
{
|
||||
if (-1 == m_iCurrentAnimIndex // 정지 혹은 시작을 안시켜준 애님
|
||||
|| m_iCurrentAnimIndex >= (_int)m_iNumAnimations) // 애님 인덱스 초과됨
|
||||
{
|
||||
return; // 잘못된 초기화
|
||||
}
|
||||
|
||||
m_Animations[m_iCurrentAnimIndex]->Depart_Animation(); // 애님이 퇴근할 때 불리는 함수를 부르면서 초기상태로 되돌림
|
||||
}
|
||||
|
||||
void CModel::RefreshAnim()
|
||||
{
|
||||
m_bIsFinishedAnim = false;
|
||||
m_bIsFinishedLerp = false;
|
||||
}
|
||||
_float CModel::Get_AnimProgressRatio()
|
||||
{
|
||||
return m_Animations[m_iCurrentAnimIndex]->Get_AnimProgressRatio();
|
||||
}
|
||||
_int CModel::Get_AnimProgressPostion(const char* pAnimChannelName)
|
||||
{
|
||||
return m_Animations[m_iCurrentAnimIndex]->Get_AnimProgressPostion(pAnimChannelName);
|
||||
}
|
||||
_float CModel::Get_AnimEstimatedDuration()
|
||||
{
|
||||
if (MODEL::ANIM == m_eType) {
|
||||
return m_Animations[m_iCurrentAnimIndex]->Get_AnimEstimatedDuration();
|
||||
}
|
||||
else {
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
}
|
||||
void CModel::Set_AnimProgressPostion(const _char* pChannelName, _uint iPosition)
|
||||
{
|
||||
return m_Animations[m_iCurrentAnimIndex]->Set_AnimProgressPostion(pChannelName, iPosition);
|
||||
}
|
||||
void CModel::Set_AnimPauseState(_bool bValue) {
|
||||
m_Animations[m_iCurrentAnimIndex]->Set_AnimPause(bValue);
|
||||
}
|
||||
|
||||
void CModel::ReallocateResources(CTransform* pTransform)
|
||||
{
|
||||
SAFE_RELEASE(m_pTransform);
|
||||
m_pTransform = pTransform;
|
||||
SAFE_ADDREF(m_pTransform);
|
||||
}
|
||||
|
||||
const _float4x4* CModel::Get_BoneMatrixPtr(const _char* pBoneName) const
|
||||
{
|
||||
vector<CBone*>::const_iterator iter = find_if(m_Bones.begin(), m_Bones.end(), [&](CBone* pBone)->_bool
|
||||
{
|
||||
if (true == pBone->Compare_Name(pBoneName))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
return (*iter)->Get_CombinedTransformationMatrixPtr();
|
||||
}
|
||||
|
||||
|
||||
_matrix CModel::Get_BoneMatrix(_uint iBoneIndex)
|
||||
{
|
||||
return m_Bones[iBoneIndex]->Get_CombinedTransformationMatrix();
|
||||
}
|
||||
|
||||
void CModel::Get_BoneMatrices(_float4x4* pOut)
|
||||
{
|
||||
if (0 == m_Bones.size()) {
|
||||
return;
|
||||
}
|
||||
for (_uint i = 0; i < m_Bones.size(); ++i) {
|
||||
pOut[i] = *m_Bones[i]->Get_CombinedTransformationMatrixPtr();
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT CModel::Render(_uint iMeshIndex)
|
||||
{
|
||||
m_Meshes[iMeshIndex]->Bind_Resources();
|
||||
m_Meshes[iMeshIndex]->Render();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Render_Indexed(_uint iMeshIndex, _uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation)
|
||||
{
|
||||
m_Meshes[iMeshIndex]->Bind_Resources();
|
||||
m_Meshes[iMeshIndex]->Render_Indexed(IndexCount, StartIndexLocation, BaseVertexLocation);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#ifdef EDITOR_PROJECT
|
||||
|
||||
HRESULT CModel::Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& PreTransformMatrix)
|
||||
{
|
||||
XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix);
|
||||
m_iNumMeshes = pAIScene->mNumMeshes;
|
||||
|
||||
m_Meshes.reserve(m_iNumMeshes);
|
||||
|
||||
for (size_t i = 0; i < m_iNumMeshes; ++i)
|
||||
{
|
||||
CMesh* pMesh = CMesh::Create(m_pDevice, m_pContext, eType, m_Bones, pAIScene->mMeshes[i], PreTransformMatrix);
|
||||
if (nullptr == pMesh) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_Meshes.push_back(pMesh);
|
||||
}
|
||||
m_Meshes.shrink_to_fit();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_Materials(const aiScene* pAIScene, const _char* pModelFilePath)
|
||||
{
|
||||
m_iNumMaterials = pAIScene->mNumMaterials;
|
||||
m_Materials.reserve(m_iNumMaterials);
|
||||
for (size_t i = 0; i < m_iNumMaterials; ++i) {
|
||||
CMaterial* pMaterial = CMaterial::Create(m_pDevice, m_pContext, pModelFilePath, pAIScene->mMaterials[i]);
|
||||
if (nullptr == pMaterial) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_Materials.push_back(pMaterial);
|
||||
}
|
||||
m_Materials.shrink_to_fit();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_Animations(const aiScene* pAIScene)
|
||||
{
|
||||
m_iNumAnimations = pAIScene->mNumAnimations;
|
||||
m_Animations.reserve(m_iNumAnimations);
|
||||
for (size_t i = 0; i < m_iNumAnimations; i++)
|
||||
{
|
||||
CAnimation* pAnimation = CAnimation::Create(m_Bones, pAIScene->mAnimations[i]);
|
||||
if (nullptr == pAnimation)
|
||||
return E_FAIL;
|
||||
|
||||
m_Animations.push_back(pAnimation);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_Bones(const aiNode* pAINode, _int iParentIndex)
|
||||
{
|
||||
CBone* pBone = CBone::Create(pAINode, iParentIndex);
|
||||
if (nullptr == pBone) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_Bones.push_back(pBone);
|
||||
|
||||
_int iParent = (_int)(m_Bones.size() - 1);
|
||||
|
||||
for (size_t i = 0; i < pAINode->mNumChildren; i++)
|
||||
{
|
||||
Ready_Bones(pAINode->mChildren[i], iParent);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
#endif // EDITOR_PROJECT
|
||||
|
||||
HRESULT CModel::Initialize_Prototype()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Initialize_Prototype(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
|
||||
{
|
||||
return Assimp_Model_Load(pModelFilePath, eType, PreTransformMatrix, iRootBoneIndex);
|
||||
}
|
||||
|
||||
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
|
||||
{
|
||||
CModel* pInstance = new CModel(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype(pModelFilePath, eType, PreTransformMatrix, iRootBoneIndex)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CModel");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
|
||||
{
|
||||
_uint iFlag = {};
|
||||
iFlag = aiProcess_ConvertToLeftHanded | aiProcessPreset_TargetRealtime_Fast;
|
||||
|
||||
if (MODEL::NONANIM == eType) {
|
||||
iFlag |= aiProcess_PreTransformVertices;
|
||||
}
|
||||
m_iRootBoneIndex = iRootBoneIndex;
|
||||
|
||||
Assimp::Importer Importer = {};
|
||||
const aiScene* pAIScene = { nullptr };
|
||||
|
||||
pAIScene = Importer.ReadFile(pModelFilePath, iFlag);
|
||||
if (nullptr == pAIScene) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#pragma region Bone
|
||||
if (FAILED(Ready_Bones(pAIScene->mRootNode, -1))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Mesh
|
||||
if (FAILED(Ready_Meshes(eType, pAIScene, PreTransformMatrix))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Material
|
||||
if (FAILED(Ready_Materials(pAIScene, pModelFilePath))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
#pragma region Animation
|
||||
if (FAILED(Ready_Animations(pAIScene))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
#pragma endregion
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Initialize(void* pArg)
|
||||
{
|
||||
m_pLerpAnim = CLerpAnim::Create((_uint)m_Bones.size(), 1.f, m_Bones);
|
||||
if (nullptr == m_pLerpAnim) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_pTransform = m_pOwner->Get_Component<CTransform>();
|
||||
SAFE_ADDREF(m_pTransform);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
{
|
||||
CModel* pInstance = new CModel(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize_Prototype()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CModel");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CComponent* CModel::Clone(void* pArg, class CGameObject* pOwner)
|
||||
{
|
||||
CModel* pInstance = new CModel(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CModel");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
|
||||
void CModel::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
for (auto& pAnimation : m_Animations) {
|
||||
SAFE_RELEASE(pAnimation);
|
||||
}
|
||||
m_Animations.clear();
|
||||
|
||||
for (auto& pMesh : m_Meshes) {
|
||||
SAFE_RELEASE(pMesh);
|
||||
}
|
||||
m_Meshes.clear();
|
||||
for (auto& pMaterial : m_Materials) {
|
||||
SAFE_RELEASE(pMaterial);
|
||||
}
|
||||
m_Materials.clear();
|
||||
for (auto& pBone : m_Bones) {
|
||||
SAFE_RELEASE(pBone);
|
||||
}
|
||||
m_Bones.clear();
|
||||
|
||||
SAFE_RELEASE(m_pTransform);
|
||||
SAFE_RELEASE(m_pLerpAnim);
|
||||
}
|
||||
|
||||
void CModel::Describe_Entity()
|
||||
{
|
||||
//GUI::Begin("Model_Desc");
|
||||
//GUI::Text("Lerping : %d\nAnim : %d", m_pLerpAnim->IsLerping(), m_bIsFinishedAnim);
|
||||
//for (_uint i = 0; i < m_iNumAnimations; ++i) {
|
||||
// if (GUI::Button(m_Animations[i]->Get_Name().c_str())) {
|
||||
// Change_AnimationIndex(i, false, 0.25f);
|
||||
// }
|
||||
//}
|
||||
//if (GUI::Button("SaveAnimIndexWithName")) {
|
||||
// _wstring wstrPath = TEXT("../Bin/AnimIndex.txt");
|
||||
// HANDLE hFile = CreateFile(wstrPath.c_str(),
|
||||
// GENERIC_WRITE, NULL,
|
||||
// NULL, CREATE_ALWAYS,
|
||||
// FILE_ATTRIBUTE_NORMAL, NULL
|
||||
// );
|
||||
|
||||
// if (hFile == INVALID_HANDLE_VALUE)
|
||||
// {
|
||||
// GUI::End();
|
||||
// CloseHandle(hFile);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// _string name = {};
|
||||
// for (_uint i = 0; i < m_iNumAnimations; ++i) {
|
||||
//
|
||||
// name.clear();
|
||||
// name.append(to_string(i) + '\t' + m_Animations[i]->Get_Name() + "\n");
|
||||
// name.shrink_to_fit();
|
||||
// WriteFile(hFile, name.data(),(DWORD) name.length(), nullptr, nullptr);
|
||||
// }
|
||||
|
||||
// CloseHandle(hFile);
|
||||
|
||||
//}
|
||||
//GUI::End();
|
||||
//
|
||||
//GUI::Begin("Bone_Desc");
|
||||
//_uint iNumBones = (_uint)m_Bones.size();
|
||||
//for (_uint i = 0; i < iNumBones; ++i){
|
||||
// _float3 vPos = m_Bones[i]->Get_LocalPosition();
|
||||
// GUI::PushID(i);
|
||||
// GUI::DragFloat3(m_Bones[i]->Get_Name(), (_float*)&vPos, 1.f, 0.f, 0.f, "%.3f", ImGuiSliderFlags_NoInput);
|
||||
// GUI::PopID();
|
||||
//}
|
||||
//GUI::End();
|
||||
}
|
||||
|
||||
@@ -92,6 +92,9 @@ HRESULT CPrototype_Manager::Ready_StaticComponents()
|
||||
if (FAILED(Add_Prototype(g_iStaticLevel, CVIBuffer_Rect::Create(m_pDevice, m_pContext)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(Add_Prototype(g_iStaticLevel, CVIBuffer_Cube::Create(m_pDevice, m_pContext)))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ void CRenderer::Refresh_Renderer()
|
||||
XMStoreFloat3(&m_CubeViewFrustum[i], XMVector3TransformCoord(XMVectorSet(m_CubeViewFrustum[i].x, m_CubeViewFrustum[i].y, m_CubeViewFrustum[i].z, 1.f), matProjInv));
|
||||
XMStoreFloat3(&m_CubeViewFrustum[i], XMVector3TransformCoord(XMVectorSet(m_CubeViewFrustum[i].x, m_CubeViewFrustum[i].y, m_CubeViewFrustum[i].z, 1.f), matViewInv));
|
||||
}
|
||||
// 0(1, 3, 4), 6(2, 5, 7) ( 법선벡터 후보 )
|
||||
// 0, 6( 한 점 후보)
|
||||
// 0(1, 3, 4), 6(2, 5, 7) ( 법선벡터 후보 )
|
||||
// 0, 6( 한 점 후보)
|
||||
//_float3 m_CubeNDC[8] = {
|
||||
// 근 좌하 우하 우상 좌상
|
||||
// 원 좌하 우하 우상 좌상
|
||||
// 근 좌하 우하 우상 좌상
|
||||
// 원 좌하 우하 우상 좌상
|
||||
// 0, 1, 2, 3
|
||||
// 4, 5, 6, 7
|
||||
//{ -1.f, -1.f, 0.f }, { 1.f, -1.f, 0.f }, { 1.f, 1.f, 0.f }, { -1.f, 1.f, 0.f },
|
||||
@@ -58,22 +58,22 @@ HRESULT CRenderer::Add_RenderGroup(RENDER eRenderGroup, CGameObject* pRenderObje
|
||||
return E_FAIL;
|
||||
|
||||
_bool bPossible = { true };
|
||||
if (pRenderObject->isDead()) {
|
||||
return E_FAIL;
|
||||
}
|
||||
// 프러스텀컬링 예외 추가
|
||||
if (RENDER::UI == eRenderGroup || RENDER::PRIORITY == eRenderGroup /* || RENDER::SHADOW == eRenderGroup*/ || RENDER::BLUR == eRenderGroup) {
|
||||
m_RenderObjects[ENUM_CLASS(eRenderGroup)].push_back(pRenderObject);
|
||||
SAFE_ADDREF(pRenderObject);
|
||||
return S_OK;
|
||||
}
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
if (XMVectorGetX(XMVector4Dot(XMLoadFloat4(&m_vPlanes[i]),
|
||||
XMLoadFloat4(&vPos))) + fCullRadius < 0) {
|
||||
bPossible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//if (pRenderObject->isDead()) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
//// 프러스텀컬링 예외 추가
|
||||
//if (RENDER::UI == eRenderGroup || RENDER::PRIORITY == eRenderGroup /* || RENDER::SHADOW == eRenderGroup*/ || RENDER::BLUR == eRenderGroup) {
|
||||
// m_RenderObjects[ENUM_CLASS(eRenderGroup)].push_back(pRenderObject);
|
||||
// SAFE_ADDREF(pRenderObject);
|
||||
// return S_OK;
|
||||
//}
|
||||
//for (int i = 0; i < 6; ++i) {
|
||||
// if (XMVectorGetX(XMVector4Dot(XMLoadFloat4(&m_vPlanes[i]),
|
||||
// XMLoadFloat4(&vPos))) + fCullRadius < 0) {
|
||||
// bPossible = false;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
if (bPossible) {
|
||||
m_RenderObjects[ENUM_CLASS(eRenderGroup)].push_back(pRenderObject);
|
||||
SAFE_ADDREF(pRenderObject);
|
||||
@@ -112,7 +112,7 @@ void CRenderer::Render()
|
||||
Render_NonLight();
|
||||
Render_Blend();
|
||||
Render_UI();
|
||||
//
|
||||
|
||||
//#ifdef _DEBUG
|
||||
// Render_Debug();
|
||||
//#endif
|
||||
@@ -388,7 +388,7 @@ void CRenderer::Render_UI()
|
||||
XMStoreFloat3(&vSrcPos, pSrc->Get_WorldPostion());
|
||||
|
||||
return vDstPos.z > vSrcPos.z;
|
||||
}); // z 소팅
|
||||
}); // z 소팅
|
||||
|
||||
for (auto& pRenderObject : m_RenderObjects[ENUM_CLASS(RENDER::UI)])
|
||||
{
|
||||
@@ -463,7 +463,7 @@ void CRenderer::Render_Debug()
|
||||
return;
|
||||
}
|
||||
|
||||
/* 렌더타겟을 디버그로 직교투영을 통해 그려라. */
|
||||
/* 렌더타겟을 디버그로 직교투영을 통해 그려라. */
|
||||
if (FAILED(m_pGameInstance->Render_RenderTarget_Debug(TEXT("MRT_GameObjects"), m_pShader, m_pVIBuffer))) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2,29 +2,87 @@
|
||||
#include "Shader.h"
|
||||
|
||||
CShader::CShader(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
:CComponent(pDevice, pContext)
|
||||
: CComponent{ pDevice, pContext }
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CShader::CShader(const CShader& rhs)
|
||||
: CComponent(rhs)
|
||||
, m_pEffect{ rhs.m_pEffect }
|
||||
, m_iNumPasses{ rhs.m_iNumPasses }
|
||||
, m_pLayouts{ rhs.m_pLayouts }
|
||||
, m_InputLayouts{ rhs.m_InputLayouts }
|
||||
{
|
||||
SAFE_ADDREF(m_pEffect);
|
||||
Safe_AddRef(m_pEffect);
|
||||
|
||||
for (auto& pInputLayout : m_pLayouts){
|
||||
SAFE_ADDREF(pInputLayout);
|
||||
}
|
||||
for (auto& pInputLayout : m_InputLayouts)
|
||||
Safe_AddRef(pInputLayout);
|
||||
}
|
||||
|
||||
HRESULT CShader::Initialize_Prototype(const _tchar* pShaderFilePath, const D3D11_INPUT_ELEMENT_DESC* pElements, _uint iNumElements)
|
||||
{
|
||||
_uint iHlslFlag = {};
|
||||
|
||||
#ifdef _DEBUG
|
||||
iHlslFlag = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
|
||||
#else
|
||||
iHlslFlag = D3DCOMPILE_OPTIMIZATION_LEVEL1;
|
||||
#endif
|
||||
|
||||
/*ID3DBlob* pBlob;*/
|
||||
|
||||
if (FAILED(D3DX11CompileEffectFromFile(pShaderFilePath, nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, iHlslFlag, 0, m_pDevice, &m_pEffect, nullptr)))
|
||||
return E_FAIL;
|
||||
|
||||
ID3DX11EffectTechnique* pTechnique = m_pEffect->GetTechniqueByIndex(0);
|
||||
if (nullptr == pTechnique)
|
||||
return E_FAIL;
|
||||
|
||||
D3DX11_TECHNIQUE_DESC TechniqueDesc{};
|
||||
|
||||
if (FAILED(pTechnique->GetDesc(&TechniqueDesc)))
|
||||
return E_FAIL;
|
||||
|
||||
m_iNumPasses = TechniqueDesc.Passes;
|
||||
|
||||
for (_uint i = 0; i < m_iNumPasses; i++)
|
||||
{
|
||||
ID3D11InputLayout* pInputLayout = { nullptr };
|
||||
|
||||
ID3DX11EffectPass* pPass = pTechnique->GetPassByIndex(i);
|
||||
if (nullptr == pPass)
|
||||
return E_FAIL;
|
||||
|
||||
D3DX11_PASS_DESC PassDesc{};
|
||||
if (FAILED(pPass->GetDesc(&PassDesc)))
|
||||
return E_FAIL;
|
||||
|
||||
if (FAILED(m_pDevice->CreateInputLayout(
|
||||
pElements,
|
||||
iNumElements,
|
||||
PassDesc.pIAInputSignature/*쉐이더에서 받아줄수 있는 정점의 정보*/,
|
||||
PassDesc.IAInputSignatureSize/*쉐이더에서 받아줄수 있는 정점의 멤버변수갯수*/,
|
||||
&pInputLayout)))
|
||||
return E_FAIL;
|
||||
|
||||
m_InputLayouts.push_back(pInputLayout);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CShader::Initialize(void* pArg)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HRESULT CShader::Bind_RawValue(const _char* pConstantName, const void* pData, _uint iLength)
|
||||
{
|
||||
ID3DX11EffectVariable* pVariable = m_pEffect->GetVariableByName(pConstantName);
|
||||
if (nullptr == pVariable){
|
||||
if (nullptr == pVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return pVariable->SetRawValue(pData, 0, iLength);
|
||||
}
|
||||
@@ -32,137 +90,69 @@ HRESULT CShader::Bind_RawValue(const _char* pConstantName, const void* pData, _u
|
||||
HRESULT CShader::Bind_Matrix(const _char* pConstantName, const _float4x4* pMatrix)
|
||||
{
|
||||
ID3DX11EffectVariable* pVariable = m_pEffect->GetVariableByName(pConstantName);
|
||||
if (nullptr == pVariable) {
|
||||
if (nullptr == pVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ID3DX11EffectMatrixVariable* pMatrixVariable = pVariable->AsMatrix();
|
||||
if (nullptr == pMatrixVariable) {
|
||||
if (nullptr == pMatrixVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return pMatrixVariable->SetMatrix(reinterpret_cast<const _float*>(pMatrix));
|
||||
}
|
||||
|
||||
HRESULT CShader::Bind_Matrices(const _char* pConstantName, const _float4x4* pMatrices, _uint iNumMatrices)
|
||||
HRESULT CShader::Bind_Matrices(const _char* pConstantName, const _float4x4* pMatrix, _uint iNumMatrices)
|
||||
{
|
||||
ID3DX11EffectVariable* pVariable = m_pEffect->GetVariableByName(pConstantName);
|
||||
if (nullptr == pVariable) {
|
||||
if (nullptr == pVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ID3DX11EffectMatrixVariable* pMatrixVariable = pVariable->AsMatrix();
|
||||
if (nullptr == pMatrixVariable) {
|
||||
if (nullptr == pMatrixVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return pMatrixVariable->SetMatrixArray(reinterpret_cast<const _float*>(pMatrices), 0, iNumMatrices);
|
||||
return pMatrixVariable->SetMatrixArray(reinterpret_cast<const _float*>(pMatrix), 0, iNumMatrices);
|
||||
}
|
||||
|
||||
HRESULT CShader::Bind_SRV(const _char* pConstantName, ID3D11ShaderResourceView* pSRV)
|
||||
{
|
||||
ID3DX11EffectVariable* pVariable = m_pEffect->GetVariableByName(pConstantName);
|
||||
if (nullptr == pVariable) {
|
||||
if (nullptr == pVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ID3DX11EffectShaderResourceVariable* pSRVariable = pVariable->AsShaderResource();
|
||||
if (nullptr == pSRVariable) {
|
||||
if (nullptr == pSRVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return pSRVariable->SetResource(pSRV);
|
||||
}
|
||||
|
||||
HRESULT CShader::Bind_SRVs(const _char* pConstantName, ID3D11ShaderResourceView** pSRVs, _uint iOffset, _uint iCount)
|
||||
HRESULT CShader::Bind_SRVs(const _char* pConstantName, ID3D11ShaderResourceView** ppSRV, _uint iNumSRVs)
|
||||
{
|
||||
ID3DX11EffectVariable* pVariable = m_pEffect->GetVariableByName(pConstantName);
|
||||
if (nullptr == pVariable) {
|
||||
if (nullptr == pVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ID3DX11EffectShaderResourceVariable* pSRVariable = pVariable->AsShaderResource();
|
||||
if (nullptr == pSRVariable) {
|
||||
if (nullptr == pSRVariable)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return pSRVariable->SetResourceArray(pSRVs, iOffset, iCount);
|
||||
return pSRVariable->SetResourceArray(ppSRV, 0, iNumSRVs);
|
||||
}
|
||||
|
||||
HRESULT CShader::Begin(_uint iPassIndex)
|
||||
{
|
||||
if (iPassIndex >= m_iNumPasses) {
|
||||
if (iPassIndex >= m_iNumPasses)
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_pContext->IASetInputLayout(m_pLayouts[iPassIndex]);
|
||||
m_pContext->IASetInputLayout(m_InputLayouts[iPassIndex]);
|
||||
|
||||
/* Apply를 반드시 호출해야만 쉐이더로 그려진다. */
|
||||
/* Apply이전에 쉐이더에 전달할 모든 데이터들을 다 던져놓아야한다. */
|
||||
m_pEffect->GetTechniqueByIndex(0)->GetPassByIndex(iPassIndex)->Apply(0, m_pContext);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CShader::Initialize_Prototype(const _tchar* pShaderFilePath, const D3D11_INPUT_ELEMENT_DESC* pElements, _uint iNumElements)
|
||||
{
|
||||
UINT HLSLFlags = 0;
|
||||
|
||||
#ifdef _DEBUG
|
||||
HLSLFlags = D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
|
||||
#else
|
||||
HLSLFlags = D3DCOMPILE_OPTIMIZATION_LEVEL1;
|
||||
#endif
|
||||
|
||||
ID3DBlob* pErrorBlob = { nullptr };
|
||||
if (FAILED(D3DX11CompileEffectFromFile(pShaderFilePath,
|
||||
nullptr, D3D_COMPILE_STANDARD_FILE_INCLUDE, HLSLFlags,
|
||||
0, m_pDevice, &m_pEffect, &pErrorBlob))) {
|
||||
|
||||
if (pErrorBlob) {
|
||||
OutputDebugStringA((char*)pErrorBlob->GetBufferPointer());
|
||||
pErrorBlob->Release();
|
||||
}
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ID3DX11EffectTechnique* pTechnique = m_pEffect->GetTechniqueByIndex(0);
|
||||
if (nullptr == pTechnique) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
D3DX11_TECHNIQUE_DESC TechniqueDesc = {};
|
||||
if (FAILED(pTechnique->GetDesc(&TechniqueDesc))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
m_iNumPasses = TechniqueDesc.Passes;
|
||||
for (_uint i = 0; i < m_iNumPasses; ++i) {
|
||||
ID3D11InputLayout* pInputLayout = { nullptr };
|
||||
ID3DX11EffectPass* pPass = pTechnique->GetPassByIndex(i);
|
||||
if (nullptr == pPass) {
|
||||
return E_FAIL;
|
||||
}
|
||||
D3DX11_PASS_DESC PassDesc = {};
|
||||
if (FAILED(pPass->GetDesc(&PassDesc))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(m_pDevice->CreateInputLayout(
|
||||
pElements, iNumElements,
|
||||
PassDesc.pIAInputSignature, PassDesc.IAInputSignatureSize,
|
||||
&pInputLayout
|
||||
))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
m_pLayouts.push_back(pInputLayout);
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CShader::Initialize(void* pArg)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CShader* CShader::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const D3D11_INPUT_ELEMENT_DESC* pElements, _uint iNumElements)
|
||||
{
|
||||
CShader* pInstance = new CShader(pDevice, pContext);
|
||||
@@ -170,21 +160,20 @@ CShader* CShader::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, c
|
||||
if (FAILED(pInstance->Initialize_Prototype(pShaderFilePath, pElements, iNumElements)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CShader");
|
||||
SAFE_RELEASE(pInstance);
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
|
||||
CComponent* CShader::Clone(void* pArg, CGameObject* pOwner)
|
||||
CComponent* CShader::Clone(void* pArg, class CGameObject* pOwner)
|
||||
{
|
||||
CShader* pInstance = new CShader(*this);
|
||||
pInstance->m_pOwner = pOwner;
|
||||
|
||||
if (FAILED(pInstance->Initialize(pArg)))
|
||||
{
|
||||
MSG_BOX("Failed to Cloned : CShader");
|
||||
SAFE_RELEASE(pInstance);
|
||||
Safe_Release(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
@@ -194,11 +183,12 @@ void CShader::Free()
|
||||
{
|
||||
__super::Free();
|
||||
|
||||
SAFE_RELEASE(m_pEffect);
|
||||
for (auto& iter : m_pLayouts) {
|
||||
SAFE_RELEASE(iter);
|
||||
}
|
||||
m_pLayouts.clear();
|
||||
Safe_Release(m_pEffect);
|
||||
|
||||
for (auto& pInputLayout : m_InputLayouts)
|
||||
Safe_Release(pInputLayout);
|
||||
|
||||
m_InputLayouts.clear();
|
||||
}
|
||||
|
||||
void CShader::Describe_Entity()
|
||||
|
||||
@@ -25,8 +25,8 @@ HRESULT CTexture::Bind_ShaderResource(CShader* pShader, const _char* pConstantNa
|
||||
HRESULT CTexture::Bind_ShaderResources(CShader* pShader, const _char* pConstantName, _uint iOffset, _uint iCount)
|
||||
{
|
||||
|
||||
_uint iCnt = (iCount == UINT_MAX) ? (_uint)m_SRVs.size() : iCount;
|
||||
return pShader->Bind_SRVs(pConstantName, m_SRVs.data(), 0, iCnt);
|
||||
_uint iCnt = (iCount == UINT_MAX) ? (_uint)m_pSRVs.size() : iCount;
|
||||
return pShader->Bind_SRVs(pConstantName, m_pSRVs.data(), iCnt);
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView* CTexture::Get_SRV(_uint iTextureIndex)
|
||||
@@ -92,9 +92,9 @@ HRESULT CTexture::Load_SRV(const _char* szPath, ID3D11ShaderResourceView** ppSRV
|
||||
|
||||
HRESULT hr = {};
|
||||
|
||||
hr = CreateDDSTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, ppSRV); // 일단 dds로 시도하고
|
||||
hr = CreateDDSTextureFromFile(m_pDevice, CMyTools::ToWstring(szTextureFilePath).c_str(), nullptr, ppSRV); // 일단 dds로 시도하고
|
||||
if (FAILED(hr)) {
|
||||
memset(szTextureFilePath, 0, sizeof(_char) * MAX_PATH); // 실패하면 원래 확장자로 다시 시도
|
||||
memset(szTextureFilePath, 0, sizeof(_char) * MAX_PATH); // 실패하면 원래 확장자로 다시 시도
|
||||
strcat_s(szTextureFilePath, szTextureFileName);
|
||||
strcat_s(szTextureFilePath, szEXT);
|
||||
|
||||
@@ -148,7 +148,7 @@ HRESULT CTexture::ParseTexturePathToSRVs(const _tchar* pTextureFolderPath)
|
||||
files.reserve(128);
|
||||
do {
|
||||
if (fileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||
continue; // ..폴더 무시
|
||||
continue; // ..폴더 무시
|
||||
}
|
||||
_wstring wstrName = fileData.cFileName;
|
||||
_wstring wstrFull = wstrFolder + L"\\" + wstrName;
|
||||
|
||||