모델오류

This commit is contained in:
hyunbin14
2025-11-07 15:23:16 +09:00
parent aee047bf1e
commit 3c2519643b
88 changed files with 1850 additions and 48 deletions
@@ -42,7 +42,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v145</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
@@ -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("셰이더를(을) 로딩 중 입니다.");
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 113 B

@@ -42,7 +42,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v145</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
@@ -150,11 +150,13 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\Public\DebugCamera.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" />
@@ -164,8 +166,10 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Private\DebugCamera.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">
@@ -58,6 +58,9 @@
<Filter Include="02.GameObjects\Effect">
<UniqueIdentifier>{a9a30c22-af8f-421a-8901-edfb8146f59d}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Dummy_Goblin">
<UniqueIdentifier>{0ebb9c08-69b0-49b6-bac3-c827ca13319a}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Editor.h">
@@ -96,6 +99,12 @@
<ClInclude Include="..\Public\DebugCamera.h">
<Filter>02.GameObjects\Dummys\DebugCamera</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>
</ItemGroup>
<ItemGroup>
<Image Include="Editor.ico">
@@ -127,6 +136,12 @@
<ClCompile Include="..\Private\pch.cpp">
<Filter>99.Define\DEFAULT</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>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Editor.rc">
@@ -0,0 +1,159 @@
#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->Set_AnimationIndex(0);
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();
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_pShaderCom->Begin(0)))
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(ENUM_CLASS(LEVEL::OBJECT), TEXT("Prototype_Component_GoblinBody_Model"),
reinterpret_cast<CComponent**>(&m_pModelCom))))
return E_FAIL;
/* Com_Shader */
if (FAILED(__super::Add_Asset_Component(ENUM_CLASS(LEVEL::STATIC), FX_MESH,
reinterpret_cast<CComponent**>(&m_pShaderCom))))
return E_FAIL;
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;
CameraDesc.pFollowTarget = this;
CameraDesc.pLookTarget = this;
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CDebugCamera>(ENUM_CLASS(LEVEL::STATIC), ENUM_CLASS(LEVEL::OBJECT),
TEXT("Layer_Camera"), &CameraDesc)))
return E_FAIL;
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;
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) }
@@ -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;
@@ -22,10 +22,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,98 @@
#include "pch.h"
#include "Level_ObjectViewer.h"
#include "GameInstance.h"
#include "Level_Loading.h"
#include "Dummy_Goblin.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_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>(ENUM_CLASS(LEVEL::STATIC),ENUM_CLASS(LEVEL::OBJECT),
// strLayerTag, &CameraDesc)))
// 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>(ENUM_CLASS(LEVEL::OBJECT), ENUM_CLASS(LEVEL::OBJECT), TEXT("Layer_Dummy"))))
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();
}
+34 -3
View File
@@ -3,6 +3,7 @@
#include "DebugCamera.h"
#include "GameInstance.h"
#include "MainApp.h"
#include "Dummy_Goblin.h"
CLoader::CLoader(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: m_pDevice{ pDevice }
@@ -58,9 +59,9 @@ HRESULT CLoader::Loading()
//case LEVEL::MAP:
// hr = Loading_For_MapViewer();
// break;
//case LEVEL::OBJECT:
// hr = Loading_For_ObjectViewer();
// break;
case LEVEL::OBJECT:
hr = Loading_For_ObjectViewer();
break;
//case LEVEL::COMBINED:
// hr = Loading_For_CombinedViewer();
// break;
@@ -141,6 +142,36 @@ HRESULT CLoader::Loading_For_Logo()
return S_OK;
}
HRESULT CLoader::Loading_For_ObjectViewer()
{
m_strMessage = TEXT("텍스쳐를(을) 로딩 중 입니다.");
m_strMessage = TEXT("모델를(을) 로딩 중 입니다.");
/* For.Prototype_Component_GoblinBody_Model */
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::OBJECT), TEXT("Prototype_Component_GoblinBody_Model"),
CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/Sword/Sword.fbx"))))
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>(ENUM_CLASS(LEVEL::OBJECT), CDummy_Goblin::Create(m_pDevice, m_pContext))))
return E_FAIL;
m_strMessage = TEXT("정보를 불러오는 중입니다.");
m_strMessage = TEXT("로딩이 완료되었습니다..");
m_isFinished = true;
return S_OK;
}
CLoader* CLoader::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, LEVEL eNextLevelID)
{
CLoader* pInstance = new CLoader(pDevice, pContext);
@@ -0,0 +1,44 @@
#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 };
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,30 @@
#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_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
+1
View File
@@ -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);
+11 -1
View File
@@ -42,7 +42,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v145</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<EnableASAN>true</EnableASAN>
</PropertyGroup>
@@ -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" />
@@ -230,6 +233,8 @@
<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,6 +261,7 @@
<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" />
@@ -341,6 +347,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" />
@@ -358,6 +365,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" />
@@ -422,6 +430,8 @@
<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" />
@@ -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>
@@ -202,6 +172,39 @@
<Filter Include="02.Element\02.Component\02.VIBuffer\Terrain">
<UniqueIdentifier>{52994263-6339-4d57-97b3-7bb3c6dca479}</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>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Private\Base.cpp">
@@ -354,6 +357,21 @@
<ClCompile Include="..\Private\VIBuffer_Cell.cpp">
<Filter>02.Element\02.Component\02.VIBuffer\Cell</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>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\Public\Base.h">
@@ -872,6 +890,21 @@
<ClInclude Include="..\Public\VIBuffer_Cell.h">
<Filter>02.Element\02.Component\02.VIBuffer\Cell</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>
</ItemGroup>
<ItemGroup>
<None Include="..\Public\Assimp\color4.inl">
@@ -0,0 +1,152 @@
#include "pch.h"
#include "Animation.h"
#include "Channel.h"
#include "Model.h"
#include "Bone.h"
CAnimation::CAnimation()
{
}
CAnimation::CAnimation(const CAnimation& Prototype)
: m_fCurrentTrackPosition{ Prototype.m_fCurrentTrackPosition }
, m_fDuration{ Prototype.m_fDuration }
, m_fTickPerSecond{ Prototype.m_fTickPerSecond }
, m_iNumChannels{ Prototype.m_iNumChannels }
, m_Channels{ Prototype.m_Channels }
, m_CurrentKeyFrameIndices{ Prototype.m_CurrentKeyFrameIndices }
, m_pAIAnimation{ Prototype.m_pAIAnimation }
{
for (auto& pChannel : m_Channels)
Safe_AddRef(pChannel);
}
HRESULT CAnimation::Initialize(const CModel* pModel, const aiAnimation* pAIAnimation)
{
m_pAIAnimation = pAIAnimation;
m_fDuration = pAIAnimation->mDuration;
m_fTickPerSecond = (_float)pAIAnimation->mTicksPerSecond;
m_iNumChannels = pAIAnimation->mNumChannels;
m_CurrentKeyFrameIndices.resize(m_iNumChannels);
for (size_t i = 0; i < m_iNumChannels; i++)
{
CChannel* pChannel = CChannel::Create(pModel, pAIAnimation->mChannels[i]);
if (nullptr == pChannel)
return E_FAIL;
m_Channels.push_back(pChannel);
}
return S_OK;
}
_bool CAnimation::Update_TransformationMatrices(_float fTimeDelta, _bool isLoop, vector<CBone*>& Bones)
{
m_fCurrentTrackPosition += m_fTickPerSecond * fTimeDelta;
if (m_fCurrentTrackPosition >= m_fDuration)
{
if (isLoop)
m_fCurrentTrackPosition = 0.f;
else
return true;
}
_uint iIndex = {};
m_vBoneTransformationMatrix.clear();
for (auto& pChannel : m_Channels)
{
pChannel->Update_TransformationMatrix(m_fCurrentTrackPosition, Bones, &m_CurrentKeyFrameIndices[iIndex++]);
m_vBoneTransformationMatrix.push_back(pChannel->Get_BoneTransformationMatrix());
}
return false;
}
void CAnimation::InterpAnim(CAnimation* pPreAnim, vector<CBone*>& Bones, float fRatio)
{
for (size_t i = 0; i < m_Channels.size(); i++)
{
if (m_vBoneTransformationMatrix.size() > pPreAnim->m_vBoneTransformationMatrix.size())
{
for (size_t j = 0; j < pPreAnim->m_Channels.size(); j++)
{
if (strcmp(m_pAIAnimation->mChannels[i]->mNodeName.C_Str(), pPreAnim->m_pAIAnimation->mChannels[j]->mNodeName.C_Str()) == 0)
{
break;
}
else
{
if (j == pPreAnim->m_Channels.size() - 1)
{
pPreAnim->m_vBoneTransformationMatrix.push_back(m_vBoneTransformationMatrix[i]);
break;
}
}
}
}
}
for (size_t i = 0; i < m_Channels.size(); i++)
{
for (size_t j = 0; j < pPreAnim->m_pAIAnimation->mNumChannels; j++)
{
if (strcmp(m_pAIAnimation->mChannels[i]->mNodeName.C_Str(), pPreAnim->m_pAIAnimation->mChannels[j]->mNodeName.C_Str()) == 0)
{
_matrix CurMat = m_vBoneTransformationMatrix[i];
_matrix PreMat = pPreAnim->m_vBoneTransformationMatrix[j];
_vector CurScale, CurRot, CurPos;
_vector PreScale, PreRot, PrePos;
XMMatrixDecompose(&CurScale, &CurRot, &CurPos, CurMat);
XMMatrixDecompose(&PreScale, &PreRot, &PrePos, PreMat);
_vector FinalScale = XMVectorLerp(PreScale, CurScale, fRatio);
_vector FinalRot = XMQuaternionSlerp(PreRot, CurRot, fRatio);
_vector FinalPos = XMVectorLerp(PrePos, CurPos, fRatio);
m_vBoneTransformationMatrix[i] = XMMatrixAffineTransformation(FinalScale, XMVectorZero(), FinalRot, FinalPos);
_int BoneIndex = m_Channels[i]->Get_BoneIndex();
if (BoneIndex < Bones.size())
{
Bones[BoneIndex]->Set_Transformation(m_vBoneTransformationMatrix[i]);
}
}
}
}
}
CAnimation* CAnimation::Create(const CModel* pModel, const aiAnimation* pAIAnimation)
{
CAnimation* pInstance = new CAnimation();
if (FAILED(pInstance->Initialize(pModel, pAIAnimation)))
{
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();
}
+60
View File
@@ -0,0 +1,60 @@
#include "pch.h"
#include "Bone.h"
CBone::CBone()
{
}
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)));
XMStoreFloat4x4(&m_CombinedTransformationMatrix, XMMatrixIdentity());
return S_OK;
}
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_Transformation(_fmatrix BoneTransformationMatrix)
{
XMStoreFloat4x4(&m_TransformationMatrix, BoneTransformationMatrix);
}
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;
}
CBone* CBone::Clone()
{
return new CBone(*this);
}
void CBone::Free()
{
__super::Free();
}
+134
View File
@@ -0,0 +1,134 @@
#include "pch.h"
#include "Channel.h"
#include "Model.h"
#include "Bone.h"
CChannel::CChannel()
{
}
HRESULT CChannel::Initialize(const CModel* pModel, const aiNodeAnim* pAIChannel)
{
strcpy_s(m_szName, pAIChannel->mNodeName.data);
m_iBoneIndex = pModel->Get_BoneIndex(m_szName);
if (-1 == m_iBoneIndex)
return E_FAIL;
m_iNumKeyFrames = max(pAIChannel->mNumScalingKeys, pAIChannel->mNumRotationKeys);
m_iNumKeyFrames = max(m_iNumKeyFrames, 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;
}
void CChannel::Update_TransformationMatrix(_float fCurrentTrackPosition, vector<CBone*>& Bones, _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 vSourScale{}, vDestScale{};
_float4 vSourRotation{}, vDestRotation{};
_float3 vSourTranslation{}, vDestTranslation{};
vSourScale = m_KeyFrames[*pCurrentKeyFrameIndex].vScale;
vDestScale = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vScale;
vSourRotation = m_KeyFrames[*pCurrentKeyFrameIndex].vRotation;
vDestRotation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vRotation;
vSourTranslation = m_KeyFrames[*pCurrentKeyFrameIndex].vTranslation;
vDestTranslation = m_KeyFrames[*pCurrentKeyFrameIndex + 1].vTranslation;
_float fRatio = (fCurrentTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition) /
(m_KeyFrames[*pCurrentKeyFrameIndex + 1].fTrackPosition - m_KeyFrames[*pCurrentKeyFrameIndex].fTrackPosition);
vScale = XMVectorLerp(XMLoadFloat3(&vSourScale), XMLoadFloat3(&vDestScale), fRatio);
vRotation = XMQuaternionSlerp(XMLoadFloat4(&vSourRotation), XMLoadFloat4(&vDestRotation), fRatio);
vTranslation = XMVectorSetW(XMVectorLerp(XMLoadFloat3(&vSourTranslation), XMLoadFloat3(&vDestTranslation), fRatio), 1.f);
}
m_BoneTransformationMatrix = XMMatrixAffineTransformation(vScale, XMVectorSet(0.f, 0.f, 0.f, 1.f), vRotation, vTranslation);
Bones[m_iBoneIndex]->Set_Transformation(m_BoneTransformationMatrix);
}
CChannel* CChannel::Create(const CModel* pModel, const aiNodeAnim* pAIChannel)
{
CChannel* pInstance = new CChannel();
if (FAILED(pInstance->Initialize(pModel, pAIChannel)))
{
MSG_BOX("Failed to Created : CChannel");
Safe_Release(pInstance);
}
return pInstance;
}
void CChannel::Free()
{
__super::Free();
m_KeyFrames.clear();
}
+103
View File
@@ -0,0 +1,103 @@
#include "pch.h"
#include "Material.h"
#include "Shader.h"
CMaterial::CMaterial(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: m_pDevice{ pDevice }
, m_pContext{ pContext }
{
Safe_AddRef(m_pDevice);
Safe_AddRef(m_pContext);
}
HRESULT CMaterial::Initialize(const _char* pModelFilePath, const aiMaterial* pAIMaterial)
{
for (_uint i = 0; i < AI_TEXTURE_TYPE_MAX; i++)
{
m_iNumSRVs = pAIMaterial->GetTextureCount(static_cast<aiTextureType>(i));
m_SRVs[i].reserve(m_iNumSRVs);
for (_uint j = 0; j < m_iNumSRVs; j++)
{
aiString strTexturePath;
char szDrive[MAX_PATH] = {};
char szDir[MAX_PATH] = {};
char szFileName[MAX_PATH] = {};
char szEXT[MAX_PATH] = {};
if (FAILED(pAIMaterial->GetTexture(static_cast<aiTextureType>(i), j, &strTexturePath)))
continue;
_char szTextureFilePath[MAX_PATH] = {};
_splitpath_s(pModelFilePath, szDrive, MAX_PATH, szDir, MAX_PATH, nullptr, 0, nullptr, 0);
_splitpath_s(strTexturePath.data, nullptr, 0, nullptr, 0, szFileName, MAX_PATH, szEXT, MAX_PATH);
strcpy_s(szTextureFilePath, szDrive);
strcat_s(szTextureFilePath, szDir);
strcat_s(szTextureFilePath, szFileName);
strcat_s(szTextureFilePath, szEXT);
_tchar szPerfectPath[MAX_PATH] = {};
MultiByteToWideChar(CP_ACP, 0, szTextureFilePath, (_int)strlen(szTextureFilePath),
szPerfectPath, MAX_PATH);
ID3D11ShaderResourceView* pSRV = { nullptr };
HRESULT hr = {};
if (false == strcmp(".dds", szEXT))
hr = CreateDDSTextureFromFile(m_pDevice, szPerfectPath, nullptr, &pSRV);
else if (false == strcmp(".tga", szEXT))
hr = S_OK;
else
hr = CreateWICTextureFromFile(m_pDevice, szPerfectPath, nullptr, &pSRV);
if (FAILED(hr))
return E_FAIL;
m_SRVs[i].push_back(pSRV);
}
}
return S_OK;
}
HRESULT CMaterial::Bind_SRV(CShader* pShader, const _char* pConstantName, aiTextureType eType, _uint iTextureIndex)
{
if (m_SRVs[eType].empty())
{
return S_OK;
}
return pShader->Bind_SRV(pConstantName, m_SRVs[eType][iTextureIndex]);
}
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;
}
void CMaterial::Free()
{
__super::Free();
Safe_Release(m_pDevice);
Safe_Release(m_pContext);
for (auto& SRVs : m_SRVs)
{
for (auto& pSRV : SRVs)
Safe_Release(pSRV);
SRVs.clear();
}
}
+359
View File
@@ -0,0 +1,359 @@
#include "pch.h"
#include "Mesh.h"
#include "Bone.h"
#include "Model.h"
#include "Shader.h"
CMesh::CMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CVIBuffer( pDevice, pContext )
{
}
CMesh::CMesh(const CMesh& Prototype)
: CVIBuffer( Prototype )
{
}
HRESULT CMesh::Initialize_Prototype(MODEL eType, const class CModel* pModel, 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;
m_Indices.clear();
m_Indices.reserve(pAIMesh->mNumFaces * 3);
for (unsigned int f = 0; f < pAIMesh->mNumFaces; ++f)
{
const aiFace& face = pAIMesh->mFaces[f];
if (face.mNumIndices == 3)
{
m_Indices.push_back(face.mIndices[0]);
m_Indices.push_back(face.mIndices[1]);
m_Indices.push_back(face.mIndices[2]);
}
}
m_Vertices.clear();
m_Vertices.reserve(pAIMesh->mNumVertices);
XMMATRIX matPre = PreTransformMatrix;
for (size_t i = 0; i < pAIMesh->mNumVertices; ++i)
{
_float3 pos{ pAIMesh->mVertices[i].x,
pAIMesh->mVertices[i].y,
pAIMesh->mVertices[i].z };
XMVECTOR v = XMLoadFloat3(&pos);
v = XMVector3TransformCoord(v, matPre);
XMFLOAT3 tp;
XMStoreFloat3(&tp, v);
m_Vertices.push_back(tp);
}
#pragma region VERTEX_BUFFER
HRESULT hr = MODEL::NONANIM == eType ?
Ready_VertexBuffer_For_NonAnim(pAIMesh, PreTransformMatrix) :
Ready_VertexBuffer_For_Anim(pModel, pAIMesh);
if (FAILED(hr))
return E_FAIL;
#pragma endregion
#pragma region INDEX_BUFFER
D3D11_BUFFER_DESC IBDesc{};
IBDesc.ByteWidth = m_iIndexStride * m_iNumIndices;
IBDesc.Usage = D3D11_USAGE_DEFAULT;
IBDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
IBDesc.StructureByteStride = m_iIndexStride;
IBDesc.CPUAccessFlags = 0;
IBDesc.MiscFlags = 0;
_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;
}
HRESULT CMesh::Initialize(void* pArg)
{
return S_OK;
}
HRESULT CMesh::Bind_BoneMatrices(const vector<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::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));
if (pAIMesh->HasNormals())
{
memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3));
XMStoreFloat3(&pVertices[i].vNormal,
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vNormal), PreTransformMatrix)));
}
else
{
pVertices[i].vNormal = _float3(0.f, 1.f, 0.f);
}
if (pAIMesh->HasTangentsAndBitangents())
{
memcpy(&pVertices[i].vTangent, &pAIMesh->mTangents[i], sizeof(_float3));
XMStoreFloat3(&pVertices[i].vTangent,
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vTangent), PreTransformMatrix)));
}
else
{
pVertices[i].vTangent = _float3(1.f, 0.f, 0.f);
}
if (pAIMesh->HasTextureCoords(0))
{
memcpy(&pVertices[i].vTexcoord, &pAIMesh->mTextureCoords[0][i], sizeof(_float2));
}
else
{
pVertices[i].vTexcoord = _float2(0.f, 0.f);
}
}
D3D11_SUBRESOURCE_DATA InitialVBData{};
InitialVBData.pSysMem = pVertices;
if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB)))
return E_FAIL;
Safe_Delete_Array(pVertices);
return S_OK;
}
HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, 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));
if (pAIMesh->HasNormals())
{
memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3));
}
else
{
pVertices[i].vNormal = _float3(0.f, 1.f, 0.f);
}
if (pAIMesh->HasTangentsAndBitangents())
{
memcpy(&pVertices[i].vTangent, &pAIMesh->mTangents[i], sizeof(_float3));
}
else
{
pVertices[i].vTangent = _float3(1.f, 0.f, 0.f);
}
if (pAIMesh->HasTextureCoords(0))
{
memcpy(&pVertices[i].vTexcoord, &pAIMesh->mTextureCoords[0][i], sizeof(_float2));
}
else
{
pVertices[i].vTexcoord = _float2(0.f, 0.f);
}
}
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];
memcpy(&OffsetMatrix, &pAIBone->mOffsetMatrix, sizeof(_float4x4));
XMStoreFloat4x4(&OffsetMatrix, XMMatrixTranspose(XMLoadFloat4x4(&OffsetMatrix)));
_int iBoneIndex = pModel->Get_BoneIndex(pAIBone->mName.data);
if (-1 == iBoneIndex)
return E_FAIL;
m_OffsetMatrices.push_back(OffsetMatrix);
m_BoneIndices.push_back(iBoneIndex);
for (_uint j = 0; j < pAIBone->mNumWeights; 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(pModel->Get_BoneIndex(m_szName));
m_OffsetMatrices.push_back(OffsetMatrix);
}
D3D11_SUBRESOURCE_DATA InitialVBData{};
InitialVBData.pSysMem = pVertices;
if (FAILED(m_pDevice->CreateBuffer(&VBDesc, &InitialVBData, &m_pVB)))
return E_FAIL;
Safe_Delete_Array(pVertices);
return S_OK;
}
CMesh* CMesh::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const CModel* pModel, const aiMesh* pAIMesh, _fmatrix PreTransformMatrix)
{
CMesh* pInstance = new CMesh(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype(eType, pModel, pAIMesh, PreTransformMatrix)))
{
MSG_BOX("Failed to Created : CMesh");
Safe_Release(pInstance);
}
return pInstance;
}
CComponent* CMesh::Clone(void* pArg, CGameObject* pOwner)
{
CMesh* pInstance = new CMesh(*this);
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()
{
}
+300 -1
View File
@@ -1,2 +1,301 @@
#include "pch.h"
#include "Model.h"
#include "Model.h"
#include "Mesh.h"
#include "Shader.h"
#include "Material.h"
#include "Bone.h"
#include "Animation.h"
CModel::CModel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CComponent( pDevice, pContext )
{
}
CModel::CModel(const CModel& Prototype)
: CComponent( Prototype )
, m_eType{ Prototype.m_eType }
, m_iNumMeshes{ Prototype.m_iNumMeshes }
, m_Meshes{ Prototype.m_Meshes }
, m_iNumMaterials{ Prototype.m_iNumMaterials }
, m_Materials{ Prototype.m_Materials }
, m_PreTransformMatrix{ Prototype.m_PreTransformMatrix }
, m_iNumAnimations{ Prototype.m_iNumAnimations }
{
for (auto& pPrototypeBone : Prototype.m_Bones)
m_Bones.push_back(pPrototypeBone->Clone());
for (auto& pMesh : m_Meshes)
Safe_AddRef(pMesh);
for (auto& pMaterial : m_Materials)
Safe_AddRef(pMaterial);
for (auto& pPrototypeAnim : Prototype.m_Animations)
m_Animations.push_back(pPrototypeAnim->Clone());
}
_int CModel::Get_BoneIndex(const _char* pBoneName) const
{
_int iBoneIndex = {};
auto iter = find_if(m_Bones.begin(), m_Bones.end(), [&](CBone* pBone)->_bool
{
if (true == pBone->Compare_Name(pBoneName))
return true;
++iBoneIndex;
return false;
});
if (iter == m_Bones.end())
return -1;
return iBoneIndex;
}
const _float4x4* CModel::Get_BoneMatrixPtr(const _char* pBoneName) const
{
auto 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();
}
HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix)
{
_uint iFlag = {};
iFlag = aiProcess_ConvertToLeftHanded | aiProcessPreset_TargetRealtime_Fast;
if (MODEL::NONANIM == eType)
iFlag |= aiProcess_PreTransformVertices;
m_pAIScene = m_Importer.ReadFile(pModelFilePath, iFlag);
if (nullptr == m_pAIScene)
return E_FAIL;
m_eType = eType;
XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix);
Ready_Bones(m_pAIScene->mRootNode, -1);
if (FAILED(Ready_Meshes()))
return E_FAIL;
if (FAILED(Ready_Materials(pModelFilePath)))
return E_FAIL;
if (FAILED(Ready_Animations()))
return E_FAIL;
return S_OK;
}
HRESULT CModel::Initialize(void* pArg)
{
return S_OK;
}
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);
}
HRESULT CModel::Bind_Material(_uint iMeshIndex, CShader* pShader, const _char* pConstantName, aiTextureType eType, _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, eType, iTextureIndex);
}
_bool CModel::Play_Animation(_float fTimeDelta)
{
if (-1 == m_iCurrentAnimIndex ||
m_iCurrentAnimIndex >= m_iNumAnimations)
return false;
if (m_iPreAnimIndex != m_iCurrentAnimIndex)
{
m_fBlendTime += fTimeDelta;
_float fRatio = m_fBlendTime / m_fBlendDuration;
fRatio = min(fRatio, 1.f);
m_Animations[m_iPreAnimIndex]->Update_TransformationMatrices(fTimeDelta, m_isLoop, m_Bones);
m_isFinish = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(fTimeDelta, m_isLoop, m_Bones);
m_Animations[m_iCurrentAnimIndex]->InterpAnim(m_Animations[m_iPreAnimIndex], m_Bones, fRatio);
if (fRatio >= 1.f)
{
m_iPreAnimIndex = m_iCurrentAnimIndex;
m_fBlendTime = 0.f;
}
}
else
{
m_isFinish = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(fTimeDelta, m_isLoop, m_Bones);
}
for (auto& pBone : m_Bones)
{
pBone->Update_CombinedTransformationMatrix(m_Bones, XMLoadFloat4x4(&m_PreTransformMatrix));
}
return m_isFinish;
}
void CModel::Set_AnimationIndex(_int iIndex, _bool isLoop)
{
if (iIndex >= 0 && iIndex < m_iNumAnimations)
{
m_iCurrentAnimIndex = iIndex;
m_isLoop = isLoop;
}
else
m_iCurrentAnimIndex = -1;
}
HRESULT CModel::Render(_uint iMeshIndex)
{
m_Meshes[iMeshIndex]->Bind_Resources();
m_Meshes[iMeshIndex]->Render();
return S_OK;
}
HRESULT CModel::Ready_Meshes()
{
m_iNumMeshes = m_pAIScene->mNumMeshes;
for (size_t i = 0; i < m_iNumMeshes; i++)
{
CMesh* pMesh = CMesh::Create(m_pDevice, m_pContext, m_eType, this, m_pAIScene->mMeshes[i], XMLoadFloat4x4(&m_PreTransformMatrix));
if (nullptr == pMesh)
return E_FAIL;
m_Meshes.push_back(pMesh);
}
return S_OK;
}
HRESULT CModel::Ready_Materials(const _char* pModelFilePath)
{
m_iNumMaterials = m_pAIScene->mNumMaterials;
for (size_t i = 0; i < m_iNumMaterials; i++)
{
CMaterial* pMaterial = CMaterial::Create(m_pDevice, m_pContext, pModelFilePath, m_pAIScene->mMaterials[i]);
if (nullptr == pMaterial)
return E_FAIL;
m_Materials.push_back(pMaterial);
}
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 (_uint i = 0; i < pAINode->mNumChildren; i++)
{
Ready_Bones(pAINode->mChildren[i], iParent);
}
return S_OK;
}
HRESULT CModel::Ready_Animations()
{
m_iNumAnimations = m_pAIScene->mNumAnimations;
for (size_t i = 0; i < m_iNumAnimations; i++)
{
CAnimation* pAnimation = CAnimation::Create(this, m_pAIScene->mAnimations[i]);
if (nullptr == pAnimation)
return E_FAIL;
m_Animations.push_back(pAnimation);
}
return S_OK;
}
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix)
{
CModel* pInstance = new CModel(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype(eType, pModelFilePath, PreTransformMatrix)))
{
MSG_BOX("Failed to Created : CModel");
Safe_Release(pInstance);
}
return pInstance;
}
CComponent* CModel::Clone(void* pArg, CGameObject* pOwner)
{
CModel* pInstance = new CModel(*this);
if (FAILED(pInstance->Initialize(pArg)))
{
MSG_BOX("Failed to Cloned : CModel");
Safe_Release(pInstance);
}
return pInstance;
}
void CModel::Free()
{
__super::Free();
for (auto& pMaterial : m_Materials)
Safe_Release(pMaterial);
m_Materials.clear();
for (auto& pMesh : m_Meshes)
Safe_Release(pMesh);
m_Meshes.clear();
for (auto& pBone : m_Bones)
Safe_Release(pBone);
m_Bones.clear();
for (auto& pAnim : m_Animations)
Safe_Release(pAnim);
m_Animations.clear();
m_Importer.FreeScene();
}
void CModel::Describe_Entity()
{
}
+38
View File
@@ -0,0 +1,38 @@
#pragma once
#include "Base.h"
NS_BEGIN(Engine)
class CAnimation final : public CBase
{
private:
CAnimation();
CAnimation(const CAnimation& Prototype);
virtual ~CAnimation() = default;
public:
HRESULT Initialize(const class CModel* pModel, const aiAnimation* pAIAnimation);
_bool Update_TransformationMatrices(_float fTimeDelta, _bool isLoop, vector<class CBone*>& Bones);
void InterpAnim(CAnimation* pPreAnim, vector<CBone*>& Bones, float fRatio);
private:
const aiAnimation* m_pAIAnimation = { nullptr };
_float m_fCurrentTrackPosition = {};
_double m_fDuration = {};
_float m_fTickPerSecond = {};
vector<class CChannel*> m_Channels;
_uint m_iNumChannels = {};
vector<_uint> m_CurrentKeyFrameIndices;
vector<_matrix> m_vBoneTransformationMatrix = {};
public:
static CAnimation* Create(const class CModel* pModel, const aiAnimation* pAIAnimation);
CAnimation* Clone();
virtual void Free() override;
};
NS_END
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#include "Base.h"
NS_BEGIN(Engine)
class CBone final : public CBase
{
private:
CBone();
virtual ~CBone() = default;
public:
_matrix Get_CombinedTransformationMatrix() const {
return XMLoadFloat4x4(&m_CombinedTransformationMatrix);
}
const _float4x4* Get_CombinedTransformationMatrixPtr() const {
return &m_CombinedTransformationMatrix;
}
_bool Compare_Name(const _char* pBoneName) const {
return !strcmp(pBoneName, m_szName);
}
public:
HRESULT Initialize(const aiNode* pAINode, _int iParentIndex);
void Update_CombinedTransformationMatrix(const vector<CBone*>& Bones, _fmatrix PreTransformMatrix);
void Set_Transformation(_fmatrix BoneTransformationMatrix);
private:
_char m_szName[MAX_PATH] = {};
_float4x4 m_TransformationMatrix = {};
_float4x4 m_CombinedTransformationMatrix = {};
_int m_iParentBoneIndex = { -1 };
public:
static CBone* Create(const aiNode* pAINode, _int iParentIndex);
CBone* Clone();
virtual void Free() override;
};
NS_END
+33
View File
@@ -0,0 +1,33 @@
#pragma once
#include "Base.h"
NS_BEGIN(Engine)
class CChannel final : public CBase
{
private:
CChannel();
virtual ~CChannel() = default;
public:
HRESULT Initialize(const class CModel* pModel, const aiNodeAnim* pAIChannel);
void Update_TransformationMatrix(_float fCurrentTrackPosition, vector<class CBone*>& Bones, _uint* pCurrentKeyFrameIndex);
_matrix Get_BoneTransformationMatrix() { return m_BoneTransformationMatrix; }
_int Get_BoneIndex() { return m_iBoneIndex; }
private:
_char m_szName[MAX_PATH] = {};
_int m_iBoneIndex = { -1 };
_uint m_iNumKeyFrames = {};
vector<KEYFRAME> m_KeyFrames;
_uint m_iCurrentKeyFrameIndex = { 0 };
_matrix m_BoneTransformationMatrix = {};
public:
static CChannel* Create(const class CModel* pModel, const aiNodeAnim* pAIChannel);
virtual void Free() override;
};
NS_END
@@ -12,6 +12,15 @@ typedef struct tagEngineDesc
_uint iWinSizeX, iWinSizeY;
}ENGINE_DESC;
typedef struct tagKeyFrame
{
XMFLOAT3 vScale;
XMFLOAT4 vRotation;
XMFLOAT3 vTranslation;
float fTrackPosition;
}KEYFRAME;
typedef struct tagLightDesc
{
LIGHT eType;
+1 -1
View File
@@ -42,7 +42,7 @@ class ENGINE_DLL CGameObject abstract
const CGameObject* Get_Owner() const { return m_pOwner; }
public:
HRESULT Add_Asset_Component(_uint iTargetLevel, const _wstring strPrototypeTag, CComponent** ppOut, void* pArg);
HRESULT Add_Asset_Component(_uint iTargetLevel, const _wstring strPrototypeTag, CComponent** ppOut, void* pArg = nullptr);
template<typename T>
HRESULT Add_Component(_uint iPrototypeLevelIndex, T** ppOut, void* pArg = nullptr) {
T* pComponent = m_pGameInstance->Clone_Prototype<T>(iPrototypeLevelIndex, pArg, this);
+27
View File
@@ -0,0 +1,27 @@
#pragma once
#include "Base.h"
NS_BEGIN(Engine)
class CMaterial final : public CBase
{
private:
CMaterial(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual ~CMaterial() = default;
public:
HRESULT Initialize(const _char* pModelFilePath, const aiMaterial* pAIMaterial);
HRESULT Bind_SRV(class CShader* pShader, const _char* pConstantName, aiTextureType eType, _uint iTextureIndex);
private:
ID3D11Device* m_pDevice = { nullptr };
ID3D11DeviceContext* m_pContext = { nullptr };
_uint m_iNumSRVs = {};
vector<ID3D11ShaderResourceView*> m_SRVs[AI_TEXTURE_TYPE_MAX];
public:
static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const aiMaterial* pAIMaterial);
virtual void Free() override;
};
NS_END
+45
View File
@@ -0,0 +1,45 @@
#pragma once
#include "VIBuffer.h"
NS_BEGIN(Engine)
class ENGINE_DLL CMesh final : public CVIBuffer
{
private:
CMesh(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CMesh(const CMesh& Prototype);
virtual ~CMesh() = default;
public:
_uint Get_MaterialIndex() const {
return m_iMaterialIndex;
}
public:
virtual HRESULT Initialize_Prototype(MODEL eType, const class CModel* pModel, const aiMesh* pAIMesh, _fmatrix PreTransformMatrix);
virtual HRESULT Initialize(void* pArg) override;
HRESULT Bind_BoneMatrices(const vector<class CBone*>& Bones, class CShader* pShader, const _char* pConstantName);
private:
_char m_szName[MAX_PATH] = {};
_uint m_iMaterialIndex = {};
_uint m_iNumBones = { };
_float4x4* m_pBoneMatrices = { nullptr };
vector<_float4x4> m_OffsetMatrices;
vector<_int> m_BoneIndices;
vector<_uint> m_Indices;
vector<_float3> m_Vertices;
private:
HRESULT Ready_VertexBuffer_For_NonAnim(const aiMesh* pAIMesh, _fmatrix PreTransformMatrix);
HRESULT Ready_VertexBuffer_For_Anim(const class CModel* pModel, const aiMesh* pAIMesh);
public:
static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const class CModel* pModel, const aiMesh* pAIMesh, _fmatrix PreTransformMatrix);
virtual CComponent* Clone(void* pArg, CGameObject* pOwner = nullptr)override;
virtual void Free() override;
virtual void Describe_Entity() override;
};
NS_END
+63
View File
@@ -6,6 +6,69 @@ NS_BEGIN(Engine)
class ENGINE_DLL CModel final : public CComponent
{
private:
CModel(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CModel(const CModel& Prototype);
virtual ~CModel() = default;
public:
_uint Get_NumMeshes() const {
return m_iNumMeshes;
}
_int Get_BoneIndex(const _char* pBoneName) const;
const _float4x4* Get_BoneMatrixPtr(const _char* pBoneName) const;
const vector<class CMesh*>& Get_Meshes() const { return m_Meshes; }
public:
virtual HRESULT Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix);
virtual HRESULT Initialize(void* pArg) override;
HRESULT Bind_BoneMatrices(_uint iMeshIndex, class CShader* pShader, const _char* pConstantName);
HRESULT Bind_Material(_uint iMeshIndex, class CShader* pShader, const _char* pConstantName, aiTextureType eType, _uint iTextureIndex);
_bool Play_Animation(_float fTimeDelta);
void Set_AnimationIndex(_int iIndex, _bool isLoop = true);
HRESULT Render(_uint iMeshIndex);
private:
const aiScene* m_pAIScene = { nullptr };
Assimp::Importer m_Importer;
private:
MODEL m_eType = {};
_float4x4 m_PreTransformMatrix = {};
vector<class CMesh*> m_Meshes;
_uint m_iNumMeshes = {};
vector<class CMaterial*> m_Materials;
_uint m_iNumMaterials = {};
vector<class CBone*> m_Bones;
vector<class CAnimation*> m_Animations;
_int m_iCurrentAnimIndex = { -1 };
_int m_iPreAnimIndex = { 0 };
_int m_iNumAnimations = {};
_bool m_isLoop = { false };
_bool m_isFinish = { false };
_float m_fBlendTime = { 0.f };
_float m_fBlendDuration = { 0.3f };
private:
HRESULT Ready_Meshes();
HRESULT Ready_Materials(const _char* pModelFilePath);
HRESULT Ready_Bones(const aiNode* pAINode, _int iParentIndex);
HRESULT Ready_Animations();
public:
static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix = XMMatrixIdentity());
virtual CComponent* Clone(void* pArg, CGameObject* pOwner = nullptr)override;
virtual void Free();
#ifdef _DEBUG
virtual void Describe_Entity() override;
#endif
};
NS_END
+1 -1
View File
@@ -28,7 +28,7 @@ class ENGINE_DLL CTexture final :
HRESULT ParseTexturePathToSRVs(const _tchar* pTextureFolderPath);
private:
vector<ID3D11ShaderResourceView*> m_pSRVs = { nullptr };
vector<ID3D11ShaderResourceView*> m_pSRVs = { };
public:
static CTexture* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, const _wstring& wstrTextureKey, _uint iNumTextures);