From 06b43e6e92f180156f5c6d9d9681613d20fda415 Mon Sep 17 00:00:00 2001 From: kimnuri Date: Thu, 13 Nov 2025 15:37:46 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20=ED=94=BC=EC=A7=81=EC=8A=A4=20=EB=A7=A4?= =?UTF-8?q?=ED=8A=B8=EB=A6=AD=EC=8A=A4=20=EC=84=B8=ED=8C=85=20[add]=20?= =?UTF-8?q?=EB=A8=B8=ED=85=8C=EB=A6=AC=EC=96=BC=20=ED=95=84=EC=9A=94?= =?UTF-8?q?=EC=97=86=EB=8A=94=EA=B1=B0=20=EC=A7=80=EC=9B=80=20[add]=20?= =?UTF-8?q?=EC=9E=90=EB=8F=99=EB=B9=8C=EB=93=9C=20=ED=81=B4=EB=A6=B0?= =?UTF-8?q?=EC=97=85=20=EC=A7=80=EC=9B=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Editor/Private/Dummy_PhysXBox.cpp | 78 ++++++++-------- .../Editor/Private/Dummy_PhysXPlayable.cpp | 81 ++++++++-------- .../Editor/Private/Level_PhysXLab.cpp | 34 +++---- Jusin154_Team3D/Editor/Private/Loader.cpp | 13 +-- .../Editor/Private/MapObject_LOD.cpp | 10 +- .../Editor/Private/MapObject_Manager.cpp | 4 +- .../Editor/Public/Dummy_PhysXBox.h | 4 +- .../Editor/Public/Dummy_PhysXPlayable.h | 4 +- Jusin154_Team3D/Engine/Default/Engine.vcxproj | 10 +- .../Engine/Private/Character_Controller.cpp | 64 +++++++++++++ Jusin154_Team3D/Engine/Private/Material.cpp | 92 ------------------- Jusin154_Team3D/Engine/Private/Mesh.cpp | 4 +- Jusin154_Team3D/Engine/Private/Model.cpp | 10 +- .../Engine/Private/PhysX_Manager.cpp | 80 +++++++++++----- Jusin154_Team3D/Engine/Private/PipeLine.cpp | 2 +- Jusin154_Team3D/Engine/Private/RigidBody.cpp | 6 +- .../Engine/Public/Character_Controller.h | 11 +++ Jusin154_Team3D/Engine/Public/Engine_Struct.h | 4 +- Jusin154_Team3D/Engine/Public/GameInstance.h | 2 +- Jusin154_Team3D/Engine/Public/Material.h | 2 - Jusin154_Team3D/Engine/Public/Mesh.h | 2 +- Jusin154_Team3D/Engine/Public/Model.h | 57 +++++++----- Jusin154_Team3D/Engine/Public/RigidBody.h | 4 +- Jusin154_Team3D/Engine/Public/pch.h | 2 + 24 files changed, 309 insertions(+), 271 deletions(-) diff --git a/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp b/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp index 748af56c8..72f8668cd 100644 --- a/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp +++ b/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp @@ -43,37 +43,27 @@ void CDummy_PhysXBox::Update(_float fTimeDelta) void CDummy_PhysXBox::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()); + _float4 vPos; + XMStoreFloat4(&vPos, Get_WorldPostion()); + m_pGameInstance->Add_RenderGroup(RENDER::BLEND, this, vPos, 20.f); } HRESULT CDummy_PhysXBox::Render() { - //if (FAILED(Bind_ShaderResources())) { - // return E_FAIL; - //} + if (FAILED(Bind_ShaderResources())) { + return E_FAIL; + } + if (FAILED(m_pModelCom->Bind_Material(0, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) { + return E_FAIL; + } + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) { + 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; - // } - //} - + if (FAILED(m_pModelCom->Render(0))) { + return E_FAIL; + } return S_OK; } @@ -106,24 +96,34 @@ HRESULT CDummy_PhysXBox::Ready_Components(void* pArg) } + /* Com_Shader */ + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, + reinterpret_cast(&m_pShaderCom)))) + return E_FAIL; + + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Box"), (CComponent**)&m_pModelCom))) { + return E_FAIL; + } + + return S_OK; } HRESULT CDummy_PhysXBox::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_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_fFar", m_pGameInstance->Get_CurrentCameraFar(), sizeof(_float)))) { + return E_FAIL; + } return S_OK; } @@ -158,8 +158,8 @@ void CDummy_PhysXBox::Free() __super::Free(); SAFE_RELEASE(m_pRigidBody); - //SAFE_RELEASE(m_pModelCom); - //SAFE_RELEASE(m_pShaderCom); + Safe_Release(m_pShaderCom); + Safe_Release(m_pModelCom); } void CDummy_PhysXBox::Describe_Entity() diff --git a/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp b/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp index 9bf8e5261..cdeb29156 100644 --- a/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp +++ b/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp @@ -16,29 +16,30 @@ CDummy_PhysXPlayable::CDummy_PhysXPlayable(const CDummy_PhysXPlayable& rhs): void CDummy_PhysXPlayable::Priority_Update(_float fTimeDelta) { m_pTransformCom->RewindMomentum(); + m_pTransformCom->Set_State(STATE::POSITION, m_pCharacter_Controller->Get_Position()); } void CDummy_PhysXPlayable::Update(_float fTimeDelta) { - if (m_pGameInstance->Key_Pressing(DIK_W)) { - m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, 1.f, 0.f)); + if (m_pGameInstance->Key_Pressing(DIK_UPARROW)) { + m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, 1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta); } - if (m_pGameInstance->Key_Pressing(DIK_A)) { - m_pTransformCom->AccumulateMomentum(XMVectorSet(-1.f, 0.f, 0.f, 0.f)); + if (m_pGameInstance->Key_Pressing(DIK_LEFT)) { + m_pTransformCom->AccumulateMomentum(XMVectorSet(-1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta); } - if (m_pGameInstance->Key_Pressing(DIK_S)) { - m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, -1.f, 0.f)); + if (m_pGameInstance->Key_Pressing(DIK_DOWN)) { + m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 0.f, -1.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta); } - if (m_pGameInstance->Key_Pressing(DIK_D)) { - m_pTransformCom->AccumulateMomentum(XMVectorSet(1.f, 0.f, 0.f, 0.f)); + if (m_pGameInstance->Key_Pressing(DIK_RIGHT)) { + m_pTransformCom->AccumulateMomentum(XMVectorSet(1.f, 0.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta); } if (m_pGameInstance->Key_Pressing(DIK_SPACE)) { - m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 10.f, 0.f, 0.f)); + m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, 10.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta); } if (m_pGameInstance->Key_Pressing(DIK_C)) { - m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -10.f, 0.f, 0.f)); + m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -10.f, 0.f, 0.f) * m_pTransformCom->Get_Speed() * fTimeDelta); } - //m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY, 0.f, 0.f)); + m_pTransformCom->AccumulateMomentum(XMVectorSet(0.f, -GRAVITY * fTimeDelta, 0.f, 0.f)); m_pCharacter_Controller->Move(fTimeDelta); } @@ -56,30 +57,21 @@ HRESULT CDummy_PhysXPlayable::Render() 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; - } + if (FAILED(m_pModelCom->Bind_Material(0, m_pShaderCom, "g_DiffuseTexture", aiTextureType_DIFFUSE, 0))) { + return E_FAIL; } + if (FAILED(m_pShaderCom->Begin(ENUM_CLASS(SHADER_PASS_MESH::DEFAULT)))) { + return E_FAIL; + } + + if (FAILED(m_pModelCom->Render(0))) { + return E_FAIL; + } +#ifdef _DEBUG + if (FAILED(m_pCharacter_Controller->Render())) { + return E_FAIL; + } +#endif // _DEBUG return S_OK; } @@ -104,9 +96,16 @@ HRESULT CDummy_PhysXPlayable::Initialize(void* pArg) HRESULT CDummy_PhysXPlayable::Ready_Components(void* pArg) { - if (FAILED(__super::Ready_Components(nullptr))) { + CTransform::TRANSFORM_DESC TransformDesc{}; + TransformDesc.fRadius = 100.f; + TransformDesc.fRotationPerSec = XMConvertToRadians(60.f); + TransformDesc.fSpeedPerSec = 30.f; + if (FAILED(__super::Ready_Components(&TransformDesc))) { return E_FAIL; } + PlayableSTARTPOS_DESC* pDesc = static_cast(pArg); + m_pTransformCom->Set_State(STATE::POSITION, XMVectorSetW(XMLoadFloat3(&pDesc->vPos), 1.f)); + m_pTransformCom->Rotation(pDesc->vRotRPY.x, pDesc->vRotRPY.y, pDesc->vRotRPY.z); { CCharacter_Controller::Character_Controller_DESC Desc{}; @@ -116,22 +115,24 @@ HRESULT CDummy_PhysXPlayable::Ready_Components(void* pArg) Desc.fMaterial = { 0.5f, 0.5f, 0.6f }; Desc.bAutoStepping = { false }; Desc.fStepOffset = { 0.05f }; - Desc.tCapsuleInfo.fRadius = 1.5f; - Desc.tCapsuleInfo.fHeight = 3.0f; + Desc.tCapsuleInfo.fRadius = 0.5f; + Desc.tCapsuleInfo.fHeight = 1.0f; Desc.tCapsuleInfo.eClimbingMode = PSX::PxCapsuleClimbingMode::eEASY; if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_CCT_CAPSULE"), (CComponent**)&m_pCharacter_Controller, &Desc))) { return E_FAIL; } } + m_pCharacter_Controller->Set_Position(m_pTransformCom->Get_State(STATE::POSITION)); /* Com_Shader */ - if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_ANIMMESH, + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, reinterpret_cast(&m_pShaderCom)))) return E_FAIL; - //m_pModelCom->Change_AnimationIndex(0, true, 0.4f, true); + if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, TEXT("Prototype_Component_Box"), (CComponent**)&m_pModelCom))) { + return E_FAIL; + } - return S_OK; return S_OK; } diff --git a/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp b/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp index 344c79e51..54db9e602 100644 --- a/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp +++ b/Jusin154_Team3D/Editor/Private/Level_PhysXLab.cpp @@ -97,24 +97,24 @@ HRESULT CLevel_PhysXLab::Ready_Layer_Terrain(const _wstring& strLayerTag) HRESULT CLevel_PhysXLab::Ready_Layer_PhysXObjects(const _wstring& strLayerTag) { - //for (int i = 0; i < 50; ++i) { - // CDummy_PhysXBox::BOXSTARTPOS_DESC Desc{}; - // Desc.vPos = { m_pGameInstance->Random_Float(0.f, 30.f), m_pGameInstance->Random_Float(3.f, 33.f), m_pGameInstance->Random_Float(0.f, 30.f) }; - // Desc.vRotRPY = { m_pGameInstance->Random_Float(0.f, XM_2PI), m_pGameInstance->Random_Float(0.f, XM_2PI), m_pGameInstance->Random_Float(0.f, XM_2PI) }; + for (int i = 0; i < 50; ++i) { + CDummy_PhysXBox::BOXSTARTPOS_DESC Desc{}; + Desc.vPos = { m_pGameInstance->Random_Float(0.f, 30.f), m_pGameInstance->Random_Float(3.f, 33.f), m_pGameInstance->Random_Float(0.f, 30.f) }; + Desc.vRotRPY = { m_pGameInstance->Random_Float(0.f, XM_2PI), m_pGameInstance->Random_Float(0.f, XM_2PI), m_pGameInstance->Random_Float(0.f, XM_2PI) }; - // if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_CUBE, &Desc))) { - // return E_FAIL; - // } - //} - // - //{ - // CDummy_PhysXPlayable::BOXSTARTPOS_DESC Desc{}; - // Desc.vPos = { 0.f, 10.f, 0.f }; - // Desc.vRotRPY = { 0.f, 0.f, 0.f }; - // if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_PLAYER, &Desc))) { - // return E_FAIL; - // } - //} + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_CUBE, &Desc))) { + return E_FAIL; + } + } + + { + CDummy_PhysXPlayable::PlayableSTARTPOS_DESC Desc{}; + Desc.vPos = { 0.f, 100.f, 0.f }; + Desc.vRotRPY = { 0.f, 0.f, 0.f }; + if (FAILED(m_pGameInstance->Add_GameObject_ToLayer(g_iStaticLevel, NEXT_LEVEL, LAYER_PLAYER, &Desc))) { + return E_FAIL; + } + } //{ // CDummy_PhysXMesh::BOXSTARTPOS_DESC Desc{}; diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 96b6d6fca..d9b61f573 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -533,17 +533,17 @@ HRESULT CLoader::Loading_For_PhysXLevel() m_strMessage = TEXT("Model Loading.."); - //if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Box"), - // CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/Box/Box.bin", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity())))){ - // return E_FAIL; - //} + if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Box"), + CModel::Create(m_pDevice, m_pContext, MODEL::NONANIM, "../Bin/Resources/Models/Box/Box.fbx", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixIdentity())))){ + return E_FAIL; + } #ifdef 기무리 vector<_wstring> ModelPrototypeTags = {}; vector ModelPrototypePath = {}; //for (const auto& file : filesystem::directory_iterator("..\\Bin\\Resources\\Models\\MapMesh")) - for (const auto& file : filesystem::directory_iterator("C:\\Users\\kimnuri\\Desktop\\Hogwart\\Game\\Environment\\Hogsmeade\\Common\\Meshes\\Terrain")) + for (const auto& file : filesystem::directory_iterator("C:\\Users\\kimnuri\\Desktop\\MeshTable\\Game\\Environment\\Hogsmeade\\Common\\Meshes\\Terrain")) { if (file.is_directory()){ continue; @@ -577,7 +577,8 @@ HRESULT CLoader::Loading_For_PhysXLevel() CRigidBody::RIGIDBODY_PROTOTYPEDESC Desc{}; for (_uint i = 0; i < iNumMesh; ++i) { Desc.eType = ACTOR::TRIANGLEMESH; - Desc.tRigidStaticDesc.szMeshName = pModel->Get_MeshName(i); + _string strDestName = pModel->Get_MeshName(i) + to_string(i); + Desc.tRigidStaticDesc.szMeshName = strDestName.c_str(); Desc.tRigidStaticDesc.vMatInfo = _float3(0.5f, 0.5f, 0.6f); if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, CMyTools::ToWstring(Desc.tRigidStaticDesc.szMeshName).c_str(), CRigidBody::Create(m_pDevice, m_pContext, Desc)))) { return E_FAIL; diff --git a/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp b/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp index cae66ff29..a07cfae66 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp @@ -32,6 +32,8 @@ HRESULT CMapObject_LOD::Initialize(void* pArg) for (_uint i = 0; i < m_iMaxLodLevel + 1; i++) { m_ModelPrototypeTags.push_back(pDesc->ModelPrototypeTags[i]); + } + for (_uint i = 0; i < pDesc->ModelPrototypeTags.size(); ++i) { m_ModelPathIndices.push_back((*pDesc->pModelPathIndices)[i]); } @@ -284,22 +286,22 @@ void CMapObject_LOD::Describe_Entity() GUI::SameLine(); if (GUI::Button("Bake!!!")) { CMapObject_Manager* pManager = m_pGameInstance->Get_Layer(CURRENT_LEVEL, LAYER_MAPOBJECTMANAGER)->Get_Object(); - for (_uint i = 0; i < (_uint)m_ModelPrototypeTags.size(); ++i) { + for (_uint i = 0; i < (_uint)m_ModelPathIndices.size(); ++i) { filesystem::path filePath = pManager->Get_PrototypePath(m_ModelPathIndices[i]); CModel* pModel = m_pModelComs[i]; _uint iNumMesh = pModel->Get_NumMeshes(); pModel->Save_PhysXTriMeshes(filePath.string().c_str()); - CRigidBody::RIGIDBODY_DESC Desc{}; Desc.eType = ACTOR::TRIANGLEMESH; for (_uint i = 0; i < iNumMesh; ++i) { // RIGID_BODY - Desc.tRigidStaticDesc.szMeshName = pModel->Get_MeshName(i); + _string strDestName = pModel->Get_MeshName(i) + to_string(i); + Desc.tRigidStaticDesc.szMeshName = strDestName.c_str(); - if (FAILED(Add_Asset_Component(g_iStaticLevel, CMyTools::ToWstring(pModel->Get_MeshName(i)).c_str(), nullptr, &Desc))) { + if (FAILED(Add_Asset_Component(g_iStaticLevel, CMyTools::ToWstring(pModel->Get_MeshName(i) + to_string(i)).c_str(), nullptr, &Desc))) { assert(false); } } diff --git a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp index eeac3dcd7..d75c6cc82 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_Manager.cpp @@ -683,8 +683,8 @@ void CMapObject_Manager::Update_PrototypeList() pMapObject = m_pGameInstance->Clone_Prototype(g_iStaticLevel, &Desc); - /* if(FAILED(m_pContainer->Add_Part(strKey, 0, &pMapObject, &Desc))) - break;*/ + /* if(FAILED(m_pContainer->Add_Part(strKey, 0, &pMapObject, &Desc))) + break;*/ m_MapObjects.push_back(pMapObject); } diff --git a/Jusin154_Team3D/Editor/Public/Dummy_PhysXBox.h b/Jusin154_Team3D/Editor/Public/Dummy_PhysXBox.h index 706670cd6..00f39daa0 100644 --- a/Jusin154_Team3D/Editor/Public/Dummy_PhysXBox.h +++ b/Jusin154_Team3D/Editor/Public/Dummy_PhysXBox.h @@ -33,8 +33,8 @@ class CDummy_PhysXBox final : public CGameObject private: CRigidBody* m_pRigidBody = { nullptr }; const PSX::PxRigidDynamic* m_pActor = { nullptr }; - //CModel* m_pModelCom = { nullptr }; - //CShader* m_pShaderCom = { nullptr }; + CModel* m_pModelCom = { nullptr }; + CShader* m_pShaderCom = { nullptr }; private: diff --git a/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h b/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h index 97fa5d0e3..44d4b7f3b 100644 --- a/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h +++ b/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h @@ -14,11 +14,11 @@ NS_BEGIN(Editor) class CDummy_PhysXPlayable final : public CGameObject { public: - typedef struct tagBoxStartPos + typedef struct tagPlayableStartPos { _float3 vPos = {}; _float3 vRotRPY = {}; - }BOXSTARTPOS_DESC; + }PlayableSTARTPOS_DESC; private: CDummy_PhysXPlayable(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CDummy_PhysXPlayable(const CDummy_PhysXPlayable& rhs); diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj b/Jusin154_Team3D/Engine/Default/Engine.vcxproj index 090a89d1b..b1dc0fd4d 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj @@ -127,9 +127,8 @@ d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;PhysXCharacterKinematic_static_64.lib;DirectXTKd.lib;Effects11d.lib;assimp-vc145-mtd.lib;%(AdditionalDependencies);%(AdditionalDependencies) - cd /d "$(SolutionDir)" -call CleanUp.bat - + + cd /d "$(SolutionDir)" @@ -160,9 +159,8 @@ call Update_Lib.bat d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;PhysXCharacterKinematic_static_64.lib;DirectXTK.lib;Effects11.lib;assimp-vc145-mt.lib;%(AdditionalDependencies);%(AdditionalDependencies) - cd /d "$(SolutionDir)" -call CleanUp.bat - + + cd /d "$(SolutionDir)" diff --git a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp index 6cc49ee53..435ff750d 100644 --- a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp +++ b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp @@ -13,6 +13,55 @@ CCharacter_Controller::CCharacter_Controller(const CCharacter_Controller& rhs) { } +#ifdef _DEBUG + +HRESULT CCharacter_Controller::Render() +{ + _vector vPos = Get_Position(); + _float3 vVolume = Get_Volume(); + _matrix WorldMatrix = XMMatrixTranslationFromVector(vPos); + + _matrix ViewMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW); + _matrix ProjMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ); + _vector vColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0x2fc48000, 1.f); + + switch (m_eBodyType) + { + case ACTOR::BOX: + { + // vVolume = half-extents(Hx,Hy,Hz) ¶ó°í °¡Á¤ + const _matrix ScaleMatrix = + XMMatrixScaling(vVolume.x / 0.5f, + vVolume.y / 0.5f, + vVolume.z / 0.5f); + m_pMainShape->Draw(ScaleMatrix * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + } break; + case ACTOR::CAPSULE: + { + _float fHalf = vVolume.y; + + _matrix ScaleMatrix = + XMMatrixScaling(vVolume.x / 0.5f, + fHalf / (2.f * 0.5f), + vVolume.x / 0.5f); + m_pMainShape->Draw(ScaleMatrix * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + + _matrix ScaleSphereMatrix = XMMatrixScaling(vVolume.x / 0.5f, vVolume.x / 0.5f, vVolume.x / 0.5f); + + _matrix WorldUp = XMMatrixTranslation(0.f, +fHalf * 0.5f, 0.f); + _matrix WorldDown = XMMatrixTranslation(0.f, -fHalf * 0.5f, 0.f); + + m_pSubShape->Draw(ScaleSphereMatrix * WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + m_pSubShape->Draw(ScaleSphereMatrix * WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + } + break; + default: + break; + } + return S_OK; +} + +#endif // _DEBUG void CCharacter_Controller::Modify_Volume(_float3 fVolume) { @@ -111,6 +160,12 @@ void CCharacter_Controller::Set_Position(_fvector vNewPos) m_pController->setPosition(pxLVec3NewPos); } +_vector CCharacter_Controller::Get_Position() +{ + PSX::PxExtendedVec3 pxVPos = m_pController->getPosition(); + return XMVectorSet((_float)pxVPos.x, (_float)pxVPos.y, (_float)pxVPos.z, 1.f); +} + _float3 CCharacter_Controller::Get_FootPosition() { PSX::PxExtendedVec3 pxLVecfootPos = m_pController->getFootPosition(); @@ -145,6 +200,10 @@ HRESULT CCharacter_Controller::Initialize(void* pArg) Desc.contactOffset = pDesc->fContactOffset; Desc.material = m_pGameInstance->Get_Material(pDesc->fMaterial); m_pController = m_pGameInstance->Add_BoxController(Desc); +#ifdef _DEBUG + _float3 vVolume = Get_Volume(); + m_pMainShape = (GeometricPrimitive::CreateBox(m_pContext, vVolume, false, false)); +#endif // _DEBUG } break; case Engine::ACTOR::CAPSULE: { @@ -155,6 +214,11 @@ HRESULT CCharacter_Controller::Initialize(void* pArg) Desc.contactOffset = pDesc->fContactOffset; Desc.material = m_pGameInstance->Get_Material(pDesc->fMaterial); m_pController = m_pGameInstance->Add_CapsuleController(Desc); +#ifdef _DEBUG + _float3 vVolume = Get_Volume(); + m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, vVolume.x, 10, false, false)); + m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, vVolume.y, vVolume.x, 10, false)); +#endif // _DEBUG } break; default: assert(false); // PhysX¿¡¼­ ºÒ°¡´É diff --git a/Jusin154_Team3D/Engine/Private/Material.cpp b/Jusin154_Team3D/Engine/Private/Material.cpp index 8ccb5fe54..8a2cc11ee 100644 --- a/Jusin154_Team3D/Engine/Private/Material.cpp +++ b/Jusin154_Team3D/Engine/Private/Material.cpp @@ -403,85 +403,6 @@ HRESULT CMaterial::Bind_SRV(CShader* pShader, const _char* pConstantName, _uint 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; -} - HRESULT CMaterial::Initialize(const _char* pModelFilePath, const SaveMaterial& _SaveMaterial) { for (size_t type = 0; type < 27; type++) @@ -522,19 +443,6 @@ HRESULT CMaterial::Initialize(const _char* pModelFilePath, const SaveMaterial& _ 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; -} - CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const SaveMaterial& _SaveMaterial) { CMaterial* pInstance = new CMaterial(pDevice, pContext); diff --git a/Jusin154_Team3D/Engine/Private/Mesh.cpp b/Jusin154_Team3D/Engine/Private/Mesh.cpp index 0e9f70129..4305bda17 100644 --- a/Jusin154_Team3D/Engine/Private/Mesh.cpp +++ b/Jusin154_Team3D/Engine/Private/Mesh.cpp @@ -607,7 +607,7 @@ HRESULT CMesh::SaveAsBinary(HANDLE hFile, DWORD& dwByte) return S_OK; } -PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _fmatrix WorldMatrix) +PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _matrix WorldMatrix) { PSX::PxTriangleMeshDesc tMeshDesc = {}; vector Vertices = {}; @@ -616,7 +616,7 @@ PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam, tMeshDesc.points.count = m_iNumVertices; tMeshDesc.points.stride = sizeof(PSX::PxVec3); Vertices.resize(m_iNumVertices); - XMVector3TransformCoordStream(reinterpret_cast<_float3*>(Vertices.data()), sizeof(PSX::PxVec3), (_float3*)m_pVertexPositions, sizeof(_float3), m_iNumVertices, WorldMatrix); + memcpy(Vertices.data(), m_pVertexPositions, sizeof(PSX::PxVec3) * m_iNumVertices); tMeshDesc.points.data = Vertices.data(); } { diff --git a/Jusin154_Team3D/Engine/Private/Model.cpp b/Jusin154_Team3D/Engine/Private/Model.cpp index eb690b3bc..cd5c2f967 100644 --- a/Jusin154_Team3D/Engine/Private/Model.cpp +++ b/Jusin154_Team3D/Engine/Private/Model.cpp @@ -351,7 +351,7 @@ HRESULT CModel::Ready_PhysXMeshes() m_TriMeshes.reserve(m_iNumMeshes); - m_pGameInstance->ConvertToTriMeshes(m_Meshes, m_TriMeshes, m_pTransform->Get_XMWorldMatrix()); + m_pGameInstance->ConvertToTriMeshes(m_Meshes, m_TriMeshes); return S_OK; } @@ -362,7 +362,7 @@ HRESULT CModel::Save_PhysXTriMeshes(const _char* pModelFilePath) return E_FAIL; } for (_uint i = 0; i < m_iNumMeshes; ++i) { - m_pGameInstance->RegistTriMesh(m_Meshes[i]->Get_Name(), m_TriMeshes[i]); + m_pGameInstance->RegistTriMesh((m_Meshes[i]->Get_Name() + to_string(i)).c_str(), m_TriMeshes[i]); } return m_pGameInstance->SaveTriMeshes(pModelFilePath, m_TriMeshes); } @@ -410,7 +410,7 @@ HRESULT CModel::Ready_Materials_FromFile(const aiScene* pAIScene, const _char* p if (!file.is_open()) { //MSG_BOX("Failed to Open Mesh File"); - /* LOD */ + ///* LOD */ return S_OK; } @@ -856,7 +856,9 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _ strcpy_s(Temp, szDir); strcat_s(Temp, szName); strcat_s(Temp, ".bin"); - Assimp_Model_Load(pModelFilePath, eType, PreTransformMatrix, 0); + if (FAILED(Assimp_Model_Load(pModelFilePath, eType, PreTransformMatrix, 0))) { + return E_FAIL; + } SaveAssimpModel(Temp); return S_OK; diff --git a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp index c9dcd5c73..4ce73dabb 100644 --- a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp @@ -5,7 +5,7 @@ #include "RigidBody.h" #include "Mesh.h" -static PSX::PxTransform XMWorldToPx(const _matrix& WorldMatrix) +static PSX::PxTransform XMWorldToPx_NoScale(const _matrix& WorldMatrix) { _vector vPos, vRotq, vScale; XMMatrixDecompose(&vScale, &vRotq, &vPos, WorldMatrix); @@ -15,7 +15,6 @@ static PSX::PxTransform XMWorldToPx(const _matrix& WorldMatrix) PSX::PxTransform out; XMStoreFloat3((_float3*)&out.p, vPos); XMStoreFloat4((_float4*)&out.q, vRotq); - return out; } @@ -33,12 +32,40 @@ const PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBod { _matrix WorldMatrix = RigidBody.Get_PxTransformPtr()->Get_XMWorldMatrix(); - PSX::PxTransform pxWorldMatrix = XMWorldToPx(WorldMatrix); + PSX::PxTransform pxWorldMatrix = XMWorldToPx_NoScale(WorldMatrix); // PxRigidDynamic ¾ÀÀÇ µ¿Àû ¹Ùµð ÀÎÅÍÆäÀ̽º PSX::PxRigidDynamic* pActorDynamic = m_pPhysics->createRigidDynamic(pxWorldMatrix); pActorDynamic->userData = &RigidBody; + + PSX::PxShape* pSrc = RigidBody.Get_ShapePtr(); + PSX::PxGeometryHolder geoHolder = pSrc->getGeometry(); + + PSX::PxShape* pClone = nullptr; + switch (RigidBody.Get_Type()) { + case ACTOR::BOX: + pClone = PSX::PxRigidActorExt::createExclusiveShape(*pActorDynamic, geoHolder.box(), *RigidBody.Get_PxMaterial()); + break; + case ACTOR::CAPSULE: + pClone = PSX::PxRigidActorExt::createExclusiveShape(*pActorDynamic, geoHolder.capsule(), *RigidBody.Get_PxMaterial()); + break; + case ACTOR::SPHERE: + pClone = PSX::PxRigidActorExt::createExclusiveShape(*pActorDynamic, geoHolder.sphere(), *RigidBody.Get_PxMaterial()); + break; + default: + assert(false); break; + } + pClone->setFlag(PSX::PxShapeFlag::eSIMULATION_SHAPE, true); + pClone->setFlag(PSX::PxShapeFlag::eSCENE_QUERY_SHAPE, true); + pClone->setContactOffset(RigidBody.Get_ContactOffset()); + pClone->setRestOffset(0.f); + + pActorDynamic->attachShape(*RigidBody.Get_ShapePtr()); + pActorDynamic->setRigidBodyFlag(PSX::PxRigidBodyFlag::eENABLE_CCD, true); + + + if (RigidBody.Is_Kinematic()) { pActorDynamic->setRigidBodyFlag(PSX::PxRigidBodyFlag::eKINEMATIC, true); } @@ -46,7 +73,6 @@ const PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBod PSX::PxRigidBodyExt::updateMassAndInertia(*pActorDynamic, (PSX::PxReal)RigidBody.Get_Density()); } - m_RigidBodys.emplace_back(&RigidBody, pActorDynamic); m_pScene->addActor(*pActorDynamic); @@ -57,10 +83,10 @@ const PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody) { _matrix WorldMatrix = RigidBody.Get_PxTransformPtr()->Get_XMWorldMatrix(); - PSX::PxTransform pxWorldMatrix = XMWorldToPx(WorldMatrix); + PSX::PxTransform pxWorldMatrix = XMWorldToPx_NoScale(WorldMatrix); // PxRigidStatic ¾ÀÀÇ Á¤Àû ¹Ùµð ÀÎÅÍÆäÀ̽º - const PSX::PxTriangleMesh* pPxMesh = { nullptr }; + PSX::PxTriangleMesh* pPxMesh = { nullptr }; { auto iter = m_TriangleMeshes.find(RigidBody.Get_PxMeshKey()); if (m_TriangleMeshes.end() == iter) { @@ -69,14 +95,23 @@ const PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody) } pPxMesh = iter->second; } - const PSX::PxTriangleMeshGeometry* pPxMeshGeometry = { nullptr }; + _vector vPos, vRotq, vScale; + XMMatrixDecompose(&vScale, &vRotq, &vPos, WorldMatrix); + + vRotq = XMQuaternionNormalize(vRotq); + + PSX::PxTransform out; + XMStoreFloat3((_float3*)&out.p, vPos); + XMStoreFloat4((_float4*)&out.q, vRotq); + PSX::PxMeshScale meshScale( + PSX::PxVec3(fabsf(vScale.m128_f32[0]), fabsf(vScale.m128_f32[1]), fabsf(vScale.m128_f32[2])), + PSX::PxQuat(PSX::PxIdentity) // ½ºÄÉÀÏ ÃàÀº ·ÎÄà ±âÁØ(º¸Åë Identity°¡ °¡Àå ¾ÈÀü) + ); + PSX::PxTriangleMeshGeometry* pPxMeshGeometry = new PSX::PxTriangleMeshGeometry(pPxMesh, meshScale); { - auto iter = m_TriangleMeshGeometry.find(RigidBody.Get_PxMeshKey()); - if (m_TriangleMeshGeometry.end() == iter) { - assert(false); - return nullptr; - } - pPxMeshGeometry = iter->second; + pPxMeshGeometry->meshFlags |= PSX::PxMeshGeometryFlag::eDOUBLE_SIDED; + PX_ASSERT(pPxMeshGeometry.isValid()); // À¯È¿¼º üũ + m_TriangleMeshGeometry.emplace(RigidBody.Get_PxMeshKey(), pPxMeshGeometry); } PSX::PxRigidStatic* pActor = m_pPhysics->createRigidStatic(pxWorldMatrix); @@ -124,9 +159,6 @@ PSX::PxShape* CPhysX_Manager::Create_Shape(ACTOR eType, _float3& vhalfGeometryIn void CPhysX_Manager::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh) { m_TriangleMeshes.emplace(CMyTools::ToWstring(pName), pPxTriMesh); - PSX::PxTriangleMeshGeometry* pGeometry = new PSX::PxTriangleMeshGeometry(pPxTriMesh); - pGeometry->meshFlags |= PSX::PxMeshGeometryFlag::eDOUBLE_SIDED; - m_TriangleMeshGeometry.emplace(CMyTools::ToWstring(pName), pGeometry); } HRESULT CPhysX_Manager::ConvertToTriMeshes(vector& Meshes, vector& pxTriMeshes, _fmatrix WorldMatrix) @@ -276,7 +308,7 @@ void CPhysX_Manager::Update_Kinematic() CRigidBody* pBody = pairBody.first; const CTransform* pTransform = pBody->Get_PxTransformPtr(); - pActor->setKinematicTarget(XMWorldToPx(pTransform->Get_XMWorldMatrix())); + pActor->setKinematicTarget(XMWorldToPx_NoScale(pTransform->Get_XMWorldMatrix())); } } } @@ -319,9 +351,13 @@ void CPhysX_Manager::Update_Dynamic() WorldMatrix = XMMatrixAffineTransformation(XMLoadFloat3(&vOriginalScale), XMVectorZero(), XMLoadFloat4((_float4*)&pPxTransform.q), XMLoadFloat3((_float3*)&pPxTransform.p)); pTransform->Set_WorldMatrix(WorldMatrix); - } } + //_uint iNumActor = (_uint)m_RigidBodys.size(); + //for (_uint i = 0; i < iNumActor; ++i) { + //for (auto& pairBody : m_RigidBodys) + // pairBody.second->userData + //} } void CPhysX_Manager::ClearScene() @@ -410,7 +446,7 @@ HRESULT CPhysX_Manager::Initialize() sceneDesc.filterShader = PSX::PxDefaultSimulationFilterShader; - sceneDesc.flags = PSX::PxSceneFlag::eENABLE_PCM | PSX::PxSceneFlag::eENABLE_ACTIVE_ACTORS | PSX::PxSceneFlag::eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS; + sceneDesc.flags = PSX::PxSceneFlag::eENABLE_PCM | PSX::PxSceneFlag::eENABLE_CCD| PSX::PxSceneFlag::eENABLE_ACTIVE_ACTORS | PSX::PxSceneFlag::eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS; if (false == sceneDesc.isValid()) { assert(false); return E_FAIL; @@ -432,8 +468,8 @@ HRESULT CPhysX_Manager::Initialize() #ifdef ±â¹«¸® physx::PxMaterial* pMaterial = m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f); - //physx::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 90), *pMaterial); - //m_pScene->addActor(*pGroundPlane); + physx::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *pMaterial); + m_pScene->addActor(*pGroundPlane); //{ // float halfExtent = .5f; @@ -451,7 +487,7 @@ HRESULT CPhysX_Manager::Initialize() // } // } //} - //pMaterial->release(); + pMaterial->release(); #endif // ±â¹«¸® diff --git a/Jusin154_Team3D/Engine/Private/PipeLine.cpp b/Jusin154_Team3D/Engine/Private/PipeLine.cpp index d66d8f09d..4dd54a78c 100644 --- a/Jusin154_Team3D/Engine/Private/PipeLine.cpp +++ b/Jusin154_Team3D/Engine/Private/PipeLine.cpp @@ -37,7 +37,7 @@ void CPipeLine::Update() XMStoreFloat4x4(&m_TransformStateMatrices[i], XMMatrixInverse(nullptr, Get_Transform_Matrix(static_cast(i-2)))); } - memcpy(&m_vCamPosition, &m_TransformStateMatrices[ENUM_CLASS(D3DTS::VIEW)].m[3], sizeof(_float4)); + memcpy(&m_vCamPosition, &m_TransformStateMatrices[ENUM_CLASS(D3DTS::VIEW_INV)].m[3], sizeof(_float4)); } CPipeLine* CPipeLine::Create() diff --git a/Jusin154_Team3D/Engine/Private/RigidBody.cpp b/Jusin154_Team3D/Engine/Private/RigidBody.cpp index 900beff26..155a5ea53 100644 --- a/Jusin154_Team3D/Engine/Private/RigidBody.cpp +++ b/Jusin154_Team3D/Engine/Private/RigidBody.cpp @@ -18,7 +18,7 @@ CRigidBody::CRigidBody(const CRigidBody& rhs): m_bExclusive(rhs.m_bExclusive), m_bKinematic(rhs.m_bKinematic) { - + //m_pMaterial->acquireReference(); } HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc) @@ -127,6 +127,10 @@ void CRigidBody::Free() __super::Free(); SAFE_RELEASE(m_pTransform); + //if (nullptr != m_pMaterial) { + // m_pMaterial->release(); + // m_pMaterial = nullptr; + //} } void CRigidBody::Describe_Entity() diff --git a/Jusin154_Team3D/Engine/Public/Character_Controller.h b/Jusin154_Team3D/Engine/Public/Character_Controller.h index 71382325c..5e92e8839 100644 --- a/Jusin154_Team3D/Engine/Public/Character_Controller.h +++ b/Jusin154_Team3D/Engine/Public/Character_Controller.h @@ -43,13 +43,19 @@ class ENGINE_DLL CCharacter_Controller final : CCharacter_Controller(const CCharacter_Controller& rhs); virtual ~CCharacter_Controller() = default; public: +#ifdef _DEBUG + virtual HRESULT Render() override; +#endif + _float Get_ContactOffset() const { return m_pController->getContactOffset(); } void Set_ContactOffset(_float fValue) const { return m_pController->setContactOffset((PSX::PxF32)fValue); } void Move(_float fTimeDelta); // À̵¿ void Set_Position(_fvector vNewPos); // ¼ø°£À̵¿ + _vector Get_Position(); _float3 Get_FootPosition(); // ContactOffsetÀÌ °í·ÁµÈ ¹ß¹Ù´Ú À§Ä¡( ½ÇÁ¦º¸´Ù ´õ ¾Æ·¡¿¡ À§Ä¡ÇÑ´Ù´Â ¶æ ) + void Resize_Volume(_float fHeight); // ³ôÀ̸¦ ¼öÁ¤ÇÏ°í ¹Ù´Ú¿¡ ºÙÀÓ void Modify_Volume(_float3 fVolume); _float3 Get_Volume(); @@ -65,6 +71,11 @@ class ENGINE_DLL CCharacter_Controller final : function m_funcHitCallback = { nullptr }; function m_funcBehaviorCallback = { nullptr }; PSX::PxControllerCollisionFlags m_eBeforeCollisionFlags = {};; +#ifdef _DEBUG + unique_ptr m_pMainShape = { nullptr }; + unique_ptr m_pSubShape = { nullptr }; +#endif // _DEBUG + private: virtual HRESULT Initialize_Prototype() override; virtual HRESULT Initialize(void* pArg) override; diff --git a/Jusin154_Team3D/Engine/Public/Engine_Struct.h b/Jusin154_Team3D/Engine/Public/Engine_Struct.h index 859a091fa..a053164a4 100644 --- a/Jusin154_Team3D/Engine/Public/Engine_Struct.h +++ b/Jusin154_Team3D/Engine/Public/Engine_Struct.h @@ -82,7 +82,7 @@ struct SaveBone string BoneName; unsigned int BoneNameSize = {}; - XMFLOAT4X4 OffsetMatrix; + _float4x4 OffsetMatrix = {}; int BoneIndex = {}; unsigned int WeightsCount = {}; vectorWeights = {}; @@ -95,7 +95,7 @@ struct SaveNode unsigned int NodeNameSize = {}; int ParentIndex = {}; unsigned int ChildrenCount = {}; - XMFLOAT4X4 Transformation; + _float4x4 Transformation = {}; vector ChildrenIndices; }; diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index d6b39de17..4ceb5feec 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -189,7 +189,7 @@ class ENGINE_DLL CGameInstance final : public CBase PSX::PxController* Get_Controller(_uint iControllerIndex); void ReleaseController(_uint iControllerIndex); - HRESULT ConvertToTriMeshes(vector& Meshes, vector& pxTriMeshes, _fmatrix WorldMatrix); + HRESULT ConvertToTriMeshes(vector& Meshes, vector& pxTriMeshes, _fmatrix WorldMatrix = XMMatrixIdentity()); HRESULT SaveTriMeshes(const _char* pPath, vector& TriMeshes); HRESULT LoadTriMeshes(const _char* pPath, vector& TriMeshes); // ¸ðµ¨ ºÒ·¯¿Ô´ø °æ·Î¿¡ ±×´ë·Î ÀÖÀ½ #pragma endregion diff --git a/Jusin154_Team3D/Engine/Public/Material.h b/Jusin154_Team3D/Engine/Public/Material.h index 60c305709..7f56edd79 100644 --- a/Jusin154_Team3D/Engine/Public/Material.h +++ b/Jusin154_Team3D/Engine/Public/Material.h @@ -34,13 +34,11 @@ class ENGINE_DLL CMaterial final : public CBase HRESULT Add_Texture(const _char* pTextureFolderPath, string& FileType); #endif // EDITOR_PROJECT - virtual HRESULT Initialize(const _char* pModelFilePath, HANDLE hFile, DWORD& dwByte); // ¹ÙÀ̳ʸ® HRESULT Initialize(const _char* pModelFilePath, const SaveMaterial& _SaveMaterial); // public: - static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, HANDLE hFile, DWORD& dwByte); // ¹ÙÀ̳ʸ® static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePathconst, const SaveMaterial& _SaveMaterial); // diff --git a/Jusin154_Team3D/Engine/Public/Mesh.h b/Jusin154_Team3D/Engine/Public/Mesh.h index d821533d6..63a669d03 100644 --- a/Jusin154_Team3D/Engine/Public/Mesh.h +++ b/Jusin154_Team3D/Engine/Public/Mesh.h @@ -28,7 +28,7 @@ class ENGINE_DLL CMesh final : public CVIBuffer public: static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, vector& Bones, const aiMesh* pAIMesh, _fmatrix& PreTransformMatrix); HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte); - PSX::PxTriangleMesh* ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _fmatrix WorldMatrix); + PSX::PxTriangleMesh* ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _matrix WorldMatrix); #endif // EDITOR_PROJECT public: diff --git a/Jusin154_Team3D/Engine/Public/Model.h b/Jusin154_Team3D/Engine/Public/Model.h index 8f724c0d8..2cdd0b66f 100644 --- a/Jusin154_Team3D/Engine/Public/Model.h +++ b/Jusin154_Team3D/Engine/Public/Model.h @@ -12,50 +12,59 @@ class ENGINE_DLL CModel final : public CComponent virtual ~CModel() = default; public: - static _int Get_BoneIndex(const _char* pBoneName, vector Bones); // º»ÀÇ º¤ÅÍ¿Í À̸§À» ³Ñ°ÜÁÖ¸é À妽º¸¦ ³Ñ°ÜÁÜ ( n ¼øÈ¸ ) - _int Get_BoneIndex(const _char* pBoneName) const; - void Set_RootBoneIndex(_int iIndex) { m_iRootBoneIndex = iIndex; } +#pragma region Model + MODEL Get_Type() const { return m_eType; } + _float4x4* Get_PreTransformMatrixPtr() { return &m_PreTransformMatrix; } + _float4x4 Get_PreTransformMatrix() const { return m_PreTransformMatrix; }; + virtual HRESULT Render(_uint iMeshIndex); + virtual HRESULT Render_Indexed(_uint iMeshIndex, _uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation); +#pragma endregion +#pragma region Animation void Change_AnimationIndex(_int iAnimationIndex, _bool bIsLoop, _float fLerpDuration, _bool bIgnoreCurrentIndex = false); // ¾Ö´Ï¸ÞÀ̼ÇÀ» ´Ù¸¥ À妽º·Î º¯°æÇÔ _bool Play_Animation(_float fTimeDelta); // ¾Ö´Ï¸ÞÀ̼ǿ¡ µ¨Å¸Å¸ÀÓÀ» ³Ö¾îÁÜ - void Set_AnimationIndex(_uint iIndex, _bool isLoop = true); + void RefreshAnim(); // ¾Ö´ÔÀ» ÇöÀç ¾Ö´ÔÀÇ Ãʱâ»óÅ·ΠµÇµ¹¸² + void Set_AnimationIndex(_uint iIndex, _bool isLoop = true); void Stop_Animation(); // ¾Ö´Ï¸ÞÀ̼ÇÀ» Á¤Áö (Ãʱâ»óÅ·Î) _bool IsFinishedAnim() const { return m_bIsFinishedAnim; } _bool IsFinishedLerp() const { return m_bIsFinishedLerp; } - void RefreshAnim(); // ¾Ö´ÔÀ» ÇöÀç ¾Ö´ÔÀÇ Ãʱâ»óÅ·ΠµÇµ¹¸² _float Get_AnimProgressRatio(); _int Get_AnimProgressPostion(const char* pAnimChannelName); _float Get_AnimEstimatedDuration(); void Set_AnimProgressPostion(const _char* pChannelName, _uint iPosition); void Set_AnimPauseState(_bool bValue);// ¾Ö´ÔÀ» ÇöÀç»óÅ·ΠÁ¤Áö void ReallocateResources(class CTransform* pTransform = nullptr); // ¾Ö´Ô À̵¿ÀÇ ´ë»ó Æ®·£½ºÆû(À̵¿½ÃÄѾßÇÒ Æ®·£½ºÆû)À» ÀçÁöÁ¤ÇÔ - _int Get_RootBoneIndex() const { return m_iRootBoneIndex; } - const _float4x4* Get_BoneMatrixPtr(const _char* pBoneName) const; - _uint Get_NumMeshes() const { return m_iNumMeshes; } - const _char* Get_MeshName(_uint iIndex); - MODEL Get_Type() const { return m_eType; } - _matrix Get_BoneMatrix(_uint iBoneIndex); - - _float4x4* Get_PreTransformMatrixPtr() { return &m_PreTransformMatrix; } - _float4x4 Get_PreTransformMatrix() const { return m_PreTransformMatrix; }; - void Get_BoneMatrices(_float4x4* pOut); - _uint Get_BonesNum() const { return (_uint)m_Bones.size(); } - void Set_CurrentTrackPosition(_float TrackPosition); const _char* Get_AnimList(_uint iIndex); size_t Get_AnimSize() { return m_Animations.size(); } _float Get_CurrentTrackPosition(); void Set_PlayAnim(_bool bPlayAnim) { m_bPlayAnim = bPlayAnim; } - _bool Get_PlayAnim() { return m_bPlayAnim; } - _int Get_AnimIndex() { return m_iCurrentAnimIndex; } + _bool Get_PlayAnim() const { return m_bPlayAnim; } + _int Get_AnimIndex() const { return m_iCurrentAnimIndex; } _float Get_AnimSpeed(); void Set_AnimSpeed(_float fSpeed); +#pragma endregion +#pragma region Mesh + const _char* Get_MeshName(_uint iIndex); + _uint Get_NumMeshes() const { return m_iNumMeshes; } +#pragma endregion +#pragma region Bone + HRESULT Bind_BoneMatrices(_uint iMeshIndex, class CShader* pShader, const _char* pConstantName); + void Get_BoneMatrices(_float4x4* pOut); + _uint Get_BonesNum() const { return (_uint)m_Bones.size(); } + const _float4x4* Get_BoneMatrixPtr(const _char* pBoneName) const; + _int Get_RootBoneIndex() const { return m_iRootBoneIndex; } + void Set_RootBoneIndex(_int iIndex) { m_iRootBoneIndex = iIndex; } +static _int Get_BoneIndex(const _char* pBoneName, vector Bones); // º»ÀÇ º¤ÅÍ¿Í À̸§À» ³Ñ°ÜÁÖ¸é À妽º¸¦ ³Ñ°ÜÁÜ ( n ¼øÈ¸ ) + _int Get_BoneIndex(const _char* pBoneName) const; + _matrix Get_BoneMatrix(_uint iBoneIndex); +#pragma endregion +#pragma region Material + HRESULT Bind_Material(_uint iMeshIndex, class CShader* pShader, const _char* pConstantName, _uint iType, _uint iTextureIndex); + +#pragma endregion + public: - HRESULT Bind_Material(_uint iMeshIndex, class CShader* pShader, const _char* pConstantName, _uint iType, _uint iTextureIndex); - HRESULT Bind_BoneMatrices(_uint iMeshIndex, class CShader* pShader, const _char* pConstantName); - virtual HRESULT Render(_uint iMeshIndex); - virtual HRESULT Render_Indexed(_uint iMeshIndex, _uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation); - #ifdef EDITOR_PROJECT HRESULT Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex); HRESULT Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& PreTransformMatrix); diff --git a/Jusin154_Team3D/Engine/Public/RigidBody.h b/Jusin154_Team3D/Engine/Public/RigidBody.h index ec4ba9b73..9bd599f90 100644 --- a/Jusin154_Team3D/Engine/Public/RigidBody.h +++ b/Jusin154_Team3D/Engine/Public/RigidBody.h @@ -65,11 +65,12 @@ class ENGINE_DLL CRigidBody final : public CComponent CRigidBody(const CRigidBody& rhs); virtual ~CRigidBody() = default; public: + ACTOR Get_Type() const { return m_eActorType; } PSX::PxShape* Get_ShapePtr() const { return m_pShape; } CTransform* Get_PxTransformPtr() const { return m_pTransform; } const _tchar* Get_PxMeshKey() const { return m_wstrMeshKey.c_str(); } const PSX::PxMaterial* Get_PxMaterial() const { return m_pMaterial; } - + _float Get_ContactOffset() { return m_fContactOffset; } _float Get_Density() const { return m_fDensity; } _bool Is_Kinematic() const { return m_bKinematic; } @@ -79,6 +80,7 @@ class ENGINE_DLL CRigidBody final : public CComponent PSX::PxMaterial* m_pMaterial = { nullptr }; // ÇÇÁ÷½º °´Ã¼ÀÇ ¼Ó¼º µî PSX::PxShape* m_pShape = { nullptr }; // ÇÇÁ÷½º °´Ã¼ÀÇ ¸ð¾ç ( ¸ÓÅ׸®¾ó·Î ¸¸µé¾îÁü ) _float3 m_vhalfGeometryInfo = {}; + _float m_fContactOffset = { 0.05f }; CTransform* m_pTransform = { nullptr }; _bool m_bKinematic = { false }; _bool m_bExclusive = { false }; diff --git a/Jusin154_Team3D/Engine/Public/pch.h b/Jusin154_Team3D/Engine/Public/pch.h index 83fef3926..ca3b1478e 100644 --- a/Jusin154_Team3D/Engine/Public/pch.h +++ b/Jusin154_Team3D/Engine/Public/pch.h @@ -19,6 +19,8 @@ #include "DirectXTK/SpriteBatch.h" #include "DirectXTK/SpriteFont.h" +#include "DirectXTK/GeometricPrimitive.h" + // FX11 #include "FX11/d3dx11effect.h"