diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj b/Jusin154_Team3D/Editor/Default/Editor.vcxproj index ba99dc222..0f2a4a5e1 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj @@ -165,6 +165,8 @@ + + @@ -232,6 +234,8 @@ + + diff --git a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters index d382b78cd..1dc0b7394 100644 --- a/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters +++ b/Jusin154_Team3D/Editor/Default/Editor.vcxproj.filters @@ -202,6 +202,21 @@ {6872c5bc-5eac-46a1-b6d8-3ec0f4fb2cd5} + + {b6d1496a-c8ef-4b7a-9ed4-f00b0a244313} + + + {a225d78f-7eec-4407-bdfd-9e14452f3338} + + + {a32d5869-5562-4099-925a-f8c022e9aac7} + + + {83781d7f-b84d-45a3-8361-b6bed2722b74} + + + {b6d1496a-c8ef-4b7a-9ed4-f00b0a244313} + @@ -405,6 +420,12 @@ 02.GameObjects\Layer_Effect\Dummy_Plane + + 02.GameObjects\Dummys\DummyPhysX\Callback\Playable\Playable + + + 02.GameObjects\Dummys\DummyPhysX\Callback\Playable\Behavior + @@ -604,6 +625,12 @@ 02.GameObjects\Layer_Effect\Dummy_Plane + + 02.GameObjects\Dummys\DummyPhysX\Callback\Playable\Playable + + + 02.GameObjects\Dummys\DummyPhysX\Callback\Playable\Behavior + diff --git a/Jusin154_Team3D/Editor/Private/CallBack_Playable_Behavior.cpp b/Jusin154_Team3D/Editor/Private/CallBack_Playable_Behavior.cpp new file mode 100644 index 000000000..b900b6837 --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/CallBack_Playable_Behavior.cpp @@ -0,0 +1,53 @@ +#include "pch.h" +#include "CallBack_Playable_Behavior.h" +#include "GameInstance.h" + + +CCallBack_Playable_Behavior::CCallBack_Playable_Behavior() +{ +} + +PSX::PxControllerBehaviorFlags CCallBack_Playable_Behavior::getBehaviorFlags(const PSX::PxShape& shape, const PSX::PxActor& actor) +{ + if (nullptr == actor.userData) { + return PSX::PxControllerBehaviorFlags(0); + } + PhsXUserData* pActorData = static_cast(actor.userData); + + switch (pActorData->eKind) + { + case PHYSX_KIND::BODY_STATIC: + return PSX::PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT + | PSX::PxControllerBehaviorFlag::eCCT_SLIDE; + break; + case PHYSX_KIND::BODY_DYNAMIC: + return PSX::PxControllerBehaviorFlag::eCCT_SLIDE; + break; + case PHYSX_KIND::CCTActor: + // Action + break; + case PHYSX_KIND::OBSTACLEActor: + break; + default: + break; + } + + + // 나머지는 아무 특별 동작 없음 + return PSX::PxControllerBehaviorFlags(0); +} + +PSX::PxControllerBehaviorFlags CCallBack_Playable_Behavior::getBehaviorFlags(const PSX::PxController& controller) +{ + // CCT끼리 부딪힐 때를 굳이 안 쓰면 0 리턴 + return PSX::PxControllerBehaviorFlags(0); +} + +PSX::PxControllerBehaviorFlags CCallBack_Playable_Behavior::getBehaviorFlags(const PSX::PxObstacle& obstacle) +{ + // Obstacle이 움직이는 발판이다? + // 여기서 ride/slide 세팅 + //return PSX::PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT; + + return PSX::PxControllerBehaviorFlags(0); +} diff --git a/Jusin154_Team3D/Editor/Private/CallBack_Playable_HitRepot.cpp b/Jusin154_Team3D/Editor/Private/CallBack_Playable_HitRepot.cpp new file mode 100644 index 000000000..eec7eb11f --- /dev/null +++ b/Jusin154_Team3D/Editor/Private/CallBack_Playable_HitRepot.cpp @@ -0,0 +1,94 @@ +#include "pch.h" +#include "CallBack_Playable_HitRepot.h" +#include "GameInstance.h" + +CCallBack_Playable_HitRepot::CCallBack_Playable_HitRepot() +{ +} + +void CCallBack_Playable_HitRepot::onShapeHit(const PSX::PxControllerShapeHit& hit) +{ + PSX::PxController* pController = hit.controller; + PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 + PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 + PSX::PxVec3 vDir = hit.dir; // 시도한 move 방향 + _float fLength = hit.length; // 시도한 move 길이 + + PSX::PxShape* pShape = hit.shape; + PSX::PxRigidActor* pActor = hit.actor; + + if (nullptr != pController && nullptr != pActor) { + PhsXUserData* pActorData = static_cast(pActor->userData); + if (nullptr == pActorData) { // missing user data + return; + } + switch (pActorData->eKind) + { + case PHYSX_KIND::BODY_STATIC: + // action + break; + case PHYSX_KIND::BODY_DYNAMIC: + { + PSX::PxRigidDynamic* pDynamic = static_cast(pActor); + pDynamic->addForce(vDir * fLength * 100000.f, PSX::PxForceMode::eIMPULSE); + } break; + case PHYSX_KIND::CCTActor: + assert(false); + break; + case PHYSX_KIND::OBSTACLEActor: + break; + default: + break; + } + } +} + +void CCallBack_Playable_HitRepot::onControllerHit(const PSX::PxControllersHit& hit) +{ + PSX::PxController* pController = hit.controller; + PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 + PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 + PSX::PxVec3 vDir = hit.dir; // 시도한 move 방향 + _float fLength = hit.length; // 시도한 move 길이 + + PSX::PxController* pOtherController = hit.other; // 다른 컨트롤러 + + if (nullptr != pController && nullptr != pOtherController) { + PhsXUserData* pActorData = static_cast(pOtherController->getActor()->userData); + assert(nullptr != pActorData); // missing user data + + switch (pActorData->eKind) + { + case PHYSX_KIND::BODY_STATIC: + assert(false); + break; + case PHYSX_KIND::BODY_DYNAMIC: + assert(false); + break; + case PHYSX_KIND::CCTActor: + // Action + break; + case PHYSX_KIND::OBSTACLEActor: + break; + default: + break; + } + } +} + +void CCallBack_Playable_HitRepot::onObstacleHit(const PSX::PxControllerObstacleHit& hit) +{ + PSX::PxController* pController = hit.controller; + PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 + PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 + PSX::PxVec3 vDir = hit.dir; // 시도한 move 방향 + _float fLength = hit.length; // 시도한 move 길이 + + const void* pOtherController = hit.userData; // 장애물 + + //switch (pOtherController.member) + //{ + //default: + // break; + //} +} diff --git a/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp b/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp index 92f3e2ea9..1c559c2c8 100644 --- a/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp +++ b/Jusin154_Team3D/Editor/Private/Dummy_PhysXBox.cpp @@ -86,7 +86,7 @@ HRESULT CDummy_PhysXBox::Ready_Components(void* pArg) { // RIGID_BODY - CRigidBody::RIGIDBODY_DESC Desc{}; + CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{}; if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), (CComponent**)&m_pRigidBody, &Desc))) { return E_FAIL; @@ -95,8 +95,9 @@ HRESULT CDummy_PhysXBox::Ready_Components(void* pArg) /* Com_Shader */ if (FAILED(__super::Add_Asset_Component(g_iStaticLevel, FX_MESH, - reinterpret_cast(&m_pShaderCom)))) + 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; diff --git a/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp b/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp index 91a44dfff..5287d0b35 100644 --- a/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp +++ b/Jusin154_Team3D/Editor/Private/Dummy_PhysXPlayable.cpp @@ -1,6 +1,5 @@ #include "pch.h" #include "Dummy_PhysXPlayable.h" - #include "GameInstance.h" CDummy_PhysXPlayable::CDummy_PhysXPlayable(ID3D11Device* pDevice, ID3D11DeviceContext* pContext): @@ -119,6 +118,8 @@ HRESULT CDummy_PhysXPlayable::Ready_Components(void* pArg) Desc.fStepOffset = { 0.05f }; Desc.fRadius = 0.5f; Desc.fHeight = 1.0f; + Desc.pCallback_HitReport = &m_pCallBack_HitReport; + Desc.pCallback_Behavior = &m_pCallBack_Behavior; Desc.eClimbingMode = PSX::PxCapsuleClimbingMode::eEASY; if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_CCT_CAPSULE"), (CComponent**)&m_pCharacter_Controller, &Desc))) { return E_FAIL; diff --git a/Jusin154_Team3D/Editor/Private/Loader.cpp b/Jusin154_Team3D/Editor/Private/Loader.cpp index 7288f2f42..aba29a9f5 100644 --- a/Jusin154_Team3D/Editor/Private/Loader.cpp +++ b/Jusin154_Team3D/Editor/Private/Loader.cpp @@ -530,7 +530,7 @@ HRESULT CLoader::Loading_For_PhysXLevel() m_strMessage = TEXT("PhysX Bodies Loading.."); { - CRigidBody::RIGIDBODY_PROTOTYPEDESC Desc{}; + CRigidBody_Dynamic::RIGIDBODY_PROTOTYPE_DYNAMIC_DESC Desc{}; { Desc.eType = ACTOR::BOX; Desc.ePxRigidBodyFlags = {}; @@ -541,7 +541,7 @@ HRESULT CLoader::Loading_For_PhysXLevel() Desc.vhalfGeometryInfo = { 1.f, 1.f, 1.f }; Desc.fDensity = 10.f; } - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), CRigidBody::Create(m_pDevice, m_pContext, Desc)))) { + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), CRigidBody_Dynamic::Create(m_pDevice, m_pContext, Desc)))) { return E_FAIL; } } @@ -605,7 +605,7 @@ HRESULT CLoader::Loading_For_PhysXLevel() _uint iNumMesh = pModel->Get_NumMeshes(); - CRigidBody::RIGIDBODY_PROTOTYPEDESC Desc{}; + CRigidBody_Static::RIGIDBODY_STATIC_PROTOTYPEDESC Desc{}; for (_uint i = 0; i < iNumMesh; ++i) { _string strDestName = pModel->Get_MeshName(i) + to_string(i); { // basic static RIGIDBODY @@ -616,7 +616,7 @@ HRESULT CLoader::Loading_For_PhysXLevel() Desc.vMatInfo = _float3(0.5f, 0.5f, 0.6f); Desc.fContactOffset = 0.f; } - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, CMyTools::ToWstring(strDestName).c_str(), CRigidBody::Create(m_pDevice, m_pContext, Desc)))) { + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, CMyTools::ToWstring(strDestName).c_str(), CRigidBody_Static::Create(m_pDevice, m_pContext, Desc)))) { return E_FAIL; } } @@ -723,7 +723,7 @@ HRESULT CLoader::MapFolderLoad(const _char* pDirectoryPath, const _char* pFileEx _uint iNumMesh = pModel->Get_NumMeshes(); - CRigidBody::RIGIDBODY_PROTOTYPEDESC Desc{}; + CRigidBody_Static::RIGIDBODY_STATIC_PROTOTYPEDESC Desc{}; for (_uint i = 0; i < iNumMesh; ++i) { _string strDestName = pModel->Get_MeshName(i) + to_string(i); { @@ -734,7 +734,7 @@ HRESULT CLoader::MapFolderLoad(const _char* pDirectoryPath, const _char* pFileEx Desc.vMatInfo = _float3(0.5f, 0.5f, 0.6f); Desc.fContactOffset = 0.f; } - if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, CMyTools::ToWstring(strDestName).c_str(), CRigidBody::Create(m_pDevice, m_pContext, Desc)))) { + if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, CMyTools::ToWstring(strDestName).c_str(), CRigidBody_Static::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 a3ebfaaab..3221add85 100644 --- a/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp +++ b/Jusin154_Team3D/Editor/Private/MapObject_LOD.cpp @@ -285,21 +285,21 @@ 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_ModelPathIndices.size(); ++i) { - filesystem::path filePath = pManager->Get_PrototypePath(m_ModelPathIndices[i]); + for (_uint iModelIndex = 0; iModelIndex < (_uint)m_ModelPathIndices.size(); ++iModelIndex) { + filesystem::path filePath = pManager->Get_PrototypePath(m_ModelPathIndices[iModelIndex]); - CModel* pModel = m_pModelComs[i]; + CModel* pModel = m_pModelComs[iModelIndex]; _uint iNumMesh = pModel->Get_NumMeshes(); pModel->Save_PhysXTriMeshes(filePath.string().c_str()); - CRigidBody::RIGIDBODY_DESC Desc{}; + CRigidBody_Static::RIGIDBODY_STATIC_DESC Desc{}; - for (_uint i = 0; i < iNumMesh; ++i) + for (_uint iMeshIndex = 0; iMeshIndex < iNumMesh; ++iMeshIndex) { // RIGID_BODY - _string strDestName = pModel->Get_MeshName(i) + to_string(i); - Desc.szMeshName = strDestName.c_str(); + _wstring dest = CMyTools::ToWstring(m_pModelComs[iModelIndex]->Get_MeshName(iMeshIndex) + to_string(iMeshIndex)).c_str(); + Desc.pMeshName = dest.c_str(); - if (FAILED(Add_Asset_Component(g_iStaticLevel, CMyTools::ToWstring(strDestName).c_str(), nullptr, &Desc))) { + if (FAILED(Add_Asset_Component(g_iStaticLevel, Desc.pMeshName, nullptr, &Desc))) { assert(false); } } diff --git a/Jusin154_Team3D/Editor/Public/CallBack_Playable_Behavior.h b/Jusin154_Team3D/Editor/Public/CallBack_Playable_Behavior.h new file mode 100644 index 000000000..67bec0771 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/CallBack_Playable_Behavior.h @@ -0,0 +1,31 @@ +#pragma once + +#include "Editor_Define.h" + +NS_BEGIN(Editor) + +class CCallBack_Playable_Behavior final : public PSX::PxControllerBehaviorCallback +{ + // 구현 예시 + // CCT는 RigidBody의 PxSimulationEventCallback에 안걸리고, 이 전용 콜백에서 처리되는 구조임 + // + // PxUserControllerHitReport = "무엇과 부딪혔는지 알려줌(이벤트 알림)" + // PxControllerBehaviorCallback = "부딪힌 것에 대해 어떤 행동 정책을 쓸지 물어봄(질의)" + // PxSimulationEventCallback = "씬 전체에 대한 글로벌 콜백(일반 물리 이벤트)" + +public: + CCallBack_Playable_Behavior(); + ~CCallBack_Playable_Behavior() = default; + +public: + // PxControllerBehaviorCallback을(를) 통해 상속됨 + // 충돌알림이 아닌, 행동정책 정해주기. CCT vs CCT는 지원안함 + // slopeLimit로 미끄러져 갈 수 있는지 없는지 이분법적인 계산 대신, 원하는 물체에 대해서만 미끄러운 표면으로 정의해줌 + // 주인이 되는 CCT가 이 물체에 대해 이 물체를 어떻게 해야 할까? -> (타고 올라갈까? Ride?) (미끄러져갈까? Slide?) ( 직접 내가 구현할까? user defined ride? ) + virtual PSX::PxControllerBehaviorFlags getBehaviorFlags(const PSX::PxShape& shape, const PSX::PxActor& actor) override; + + virtual PSX::PxControllerBehaviorFlags getBehaviorFlags(const PSX::PxController& controller) override; + + virtual PSX::PxControllerBehaviorFlags getBehaviorFlags(const PSX::PxObstacle& obstacle) override; +}; +NS_END diff --git a/Jusin154_Team3D/Editor/Public/CallBack_Playable_HitRepot.h b/Jusin154_Team3D/Editor/Public/CallBack_Playable_HitRepot.h new file mode 100644 index 000000000..de402f1f0 --- /dev/null +++ b/Jusin154_Team3D/Editor/Public/CallBack_Playable_HitRepot.h @@ -0,0 +1,30 @@ +#pragma once + +#include "Editor_Define.h" + +NS_BEGIN(Editor) + +class CCallBack_Playable_HitRepot final : public PSX::PxUserControllerHitReport +{ + // 구현 예시 + // CCT는 RigidBody의 PxSimulationEventCallback에 안걸리고, 이 전용 콜백에서 처리되는 구조임 + // + // PxUserControllerHitReport = "무엇과 부딪혔는지 알려줌(이벤트 알림)" + // PxControllerBehaviorCallback = "부딪힌 것에 대해 어떤 행동 정책을 쓸지 물어봄(질의)" + // PxSimulationEventCallback = "씬 전체에 대한 글로벌 콜백(일반 물리 이벤트)" + +public: + CCallBack_Playable_HitRepot(); + ~CCallBack_Playable_HitRepot() = default; + +public: + // PxUserControllerHitReport을(를) 통해 상속됨 + // 충돌알림!! + // 주인이 되는 CCT가 이 물체에 대해 어떻게 반응해야 할까? + virtual void onShapeHit(const PSX::PxControllerShapeHit& hit) override; // statc, rigid 등과 부딪힌 경우 + + virtual void onControllerHit(const PSX::PxControllersHit& hit) override; // 다른 CCT와 부딪힌 경우 + + virtual void onObstacleHit(const PSX::PxControllerObstacleHit& hit) override; // 사용자 정의 장애물과 부딪힌 경우 +}; +NS_END diff --git a/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h b/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h index 0a9e42f12..611c5582c 100644 --- a/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h +++ b/Jusin154_Team3D/Editor/Public/Dummy_PhysXPlayable.h @@ -2,6 +2,8 @@ #include "Editor_Define.h" #include "GameObject.h" +#include "CallBack_Playable_Behavior.h" +#include "CallBack_Playable_HitRepot.h" NS_BEGIN(Engine) class CModel; @@ -34,7 +36,9 @@ class CDummy_PhysXPlayable final : public CGameObject CCharacter_Controller* m_pCharacter_Controller = { nullptr }; CModel* m_pModelCom = { nullptr }; CShader* m_pShaderCom = { nullptr }; - + + CCallBack_Playable_Behavior m_pCallBack_Behavior = {}; + CCallBack_Playable_HitRepot m_pCallBack_HitReport = {}; private: virtual HRESULT Initialize_Prototype() override; @@ -49,4 +53,4 @@ class CDummy_PhysXPlayable final : public CGameObject void Describe_Entity() override; }; -NS_END \ No newline at end of file +NS_END diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj b/Jusin154_Team3D/Engine/Default/Engine.vcxproj index 4ece1fa21..f326c1bdb 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj @@ -203,7 +203,6 @@ call Update_Lib.bat - @@ -287,6 +286,8 @@ call Update_Lib.bat + + @@ -305,6 +306,14 @@ call Update_Lib.bat + + true + true + + + true + true + @@ -398,6 +407,14 @@ call Update_Lib.bat + + true + true + + + true + true + @@ -419,7 +436,6 @@ call Update_Lib.bat - @@ -503,6 +519,8 @@ call Update_Lib.bat + + diff --git a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters index 86210937d..0f75cf308 100644 --- a/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters +++ b/Jusin154_Team3D/Engine/Default/Engine.vcxproj.filters @@ -244,15 +244,9 @@ {a60a7ba5-a937-41d7-baac-db67f86f3ba1} - - {05865481-fa20-4432-a5a7-945d4f8c7f3c} - {bed0de44-4e62-4b5f-9767-65cfc8a933a3} - - {33ac85a2-be8e-4ad9-a179-1239d818dc9c} - {fda41884-634b-4dd4-8bd2-f6f7ad68ab1f} @@ -262,6 +256,9 @@ {8727e975-e9e2-4b59-9a52-27ad3ad79f2f} + + {05865481-fa20-4432-a5a7-945d4f8c7f3c} + @@ -438,9 +435,6 @@ 03.Management\21.PhysX_Manager - - 02.Element\02.Component\07.RigidBody - 02.Element\02.Component\50.UI @@ -477,8 +471,20 @@ 03.Management\03.Light_Manager - - 02.Element\02.Component\08.Character_Controller\Collision_Callback + + 02.Element\02.Component\07.RigidBody\00.Static + + + 02.Element\02.Component\07.RigidBody\10.Dynamic + + + 02.Element\02.Component\07.RigidBody + + + 02.Element\02.Component\08.Character_Controller\CallBack + + + 02.Element\02.Component\08.Character_Controller\CallBack @@ -1061,8 +1067,17 @@ 03.Management\03.Light_Manager - - 02.Element\02.Component\08.Character_Controller\Collision_Callback + + 02.Element\02.Component\07.RigidBody\00.Static + + + 02.Element\02.Component\07.RigidBody\10.Dynamic + + + 02.Element\02.Component\08.Character_Controller\CallBack + + + 02.Element\02.Component\08.Character_Controller\CallBack diff --git a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp index ab1f4eacc..d3c624cca 100644 --- a/Jusin154_Team3D/Engine/Private/Character_Controller.cpp +++ b/Jusin154_Team3D/Engine/Private/Character_Controller.cpp @@ -1,7 +1,6 @@ #include "pch.h" #include "Character_Controller.h" #include "GameInstance.h" -#include "Collision_Callback.h" CCharacter_Controller::CCharacter_Controller(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : CComponent{ pDevice, pContext } @@ -202,11 +201,12 @@ HRESULT CCharacter_Controller::Initialize(void* pArg) Desc.halfSideExtent = pDesc->vBoxSize.x; Desc.halfForwardExtent = pDesc->vBoxSize.z; Desc.contactOffset = pDesc->fContactOffset; - Desc.reportCallback = static_cast(pDesc->pCallback); - Desc.behaviorCallback = static_cast(pDesc->pCallback); + Desc.reportCallback = pDesc->pCallback_HitReport; + Desc.behaviorCallback = pDesc->pCallback_Behavior; Desc.material = m_pGameInstance->Create_Material(&pDesc->fMaterial); m_pController = m_pGameInstance->Add_BoxController(Desc); m_pController->setUserData(&m_tagData); + m_pController->getActor()->userData = &m_tagData; } break; case Engine::ACTOR::CAPSULE: { @@ -215,11 +215,12 @@ HRESULT CCharacter_Controller::Initialize(void* pArg) Desc.height = pDesc->fHeight; Desc.climbingMode = pDesc->eClimbingMode; // 기본 eEASY Desc.contactOffset = pDesc->fContactOffset; - Desc.reportCallback = static_cast(pDesc->pCallback); - Desc.behaviorCallback = static_cast(pDesc->pCallback); + Desc.reportCallback = pDesc->pCallback_HitReport; + Desc.behaviorCallback = pDesc->pCallback_Behavior; Desc.material = m_pGameInstance->Create_Material(&pDesc->fMaterial); m_pController = m_pGameInstance->Add_CapsuleController(Desc); m_pController->setUserData(&m_tagData); + m_pController->getActor()->userData = &m_tagData; } break; default: assert(false); // PhysX에서 불가능 diff --git a/Jusin154_Team3D/Engine/Private/Collision_Callback.cpp b/Jusin154_Team3D/Engine/Private/Collision_Callback.cpp deleted file mode 100644 index 92b8c75bd..000000000 --- a/Jusin154_Team3D/Engine/Private/Collision_Callback.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "pch.h" -#include "Collision_Callback.h" -#include "GameInstance.h" - -CCollision_Callback::CCollision_Callback() -{ -} - -void CCollision_Callback::onShapeHit(const PSX::PxControllerShapeHit& hit) -{ - PSX::PxController* pController = hit.controller; - PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 - PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 - PSX::PxVec3 vDir = hit.dir; // move 방향 - _float fLength = hit.length; // move 길이 - - PSX::PxShape* pShape = hit.shape; - PSX::PxRigidActor* pActor = hit.actor; - - - if (nullptr != pController && nullptr != pActor) { - PhsXUserData* pActorData = static_cast(pActor->userData); - assert(nullptr != pActor); // missing user data - switch (pActorData->eKind) - { - case PHYSX_KIND::BODY_STATIC: - // action - break; - case PHYSX_KIND::BODY_DYNAMIC: - // action - break; - case PHYSX_KIND::CCTActor: - assert(false); - break; - case PHYSX_KIND::OBSTACLEActor: - break; - default: - break; - } - } -} - -void CCollision_Callback::onControllerHit(const PSX::PxControllersHit& hit) -{ - PSX::PxController* pController = hit.controller; - PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 - PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 - PSX::PxVec3 vDir = hit.dir; // move 방향 - _float fLength = hit.length; // move 길이 - - PSX::PxController* pOtherController= hit.other; // 다른 컨트롤러 - - if (nullptr != pController && nullptr != pOtherController) { - PhsXUserData* pActorData = static_cast(pOtherController->getActor()->userData); - assert(nullptr != pOtherController); // missing user data - - switch (pActorData->eKind) - { - case PHYSX_KIND::BODY_STATIC: - assert(false); - break; - case PHYSX_KIND::BODY_DYNAMIC: - assert(false); - break; - case PHYSX_KIND::CCTActor: - // Action - break; - case PHYSX_KIND::OBSTACLEActor: - break; - default: - break; - } - } -} - -void CCollision_Callback::onObstacleHit(const PSX::PxControllerObstacleHit& hit) -{ - PSX::PxController* pController = hit.controller; - PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 - PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 - PSX::PxVec3 vDir = hit.dir; // move 방향 - _float fLength = hit.length; // move 길이 - - const void* pOtherController= hit.userData; // 장애물 - - //switch (pOtherController.member) - //{ - //default: - // break; - //} -} - -PSX::PxControllerBehaviorFlags CCollision_Callback::getBehaviorFlags(const PSX::PxShape& shape, const PSX::PxActor& actor) -{ - //if (actor.userData.subKind == kMovingPlatformTag) - // return PSX::PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT - // | PSX::PxControllerBehaviorFlag::eCCT_SLIDE; - - // 나머지는 아무 특별 동작 없음 - return PSX::PxControllerBehaviorFlags(0); -} - -PSX::PxControllerBehaviorFlags CCollision_Callback::getBehaviorFlags(const PSX::PxController& controller) -{ - // CCT끼리 부딪힐 때를 굳이 안 쓰면 0 리턴 - return PSX::PxControllerBehaviorFlags(0); -} - -PSX::PxControllerBehaviorFlags CCollision_Callback::getBehaviorFlags(const PSX::PxObstacle& obstacle) -{ - // Obstacle이 움직이는 발판이다? - // 여기서 ride/slide 세팅 - //return PSX::PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT; - - return PSX::PxControllerBehaviorFlags(); -} diff --git a/Jusin154_Team3D/Engine/Private/GameInstance.cpp b/Jusin154_Team3D/Engine/Private/GameInstance.cpp index 97d4e7c0f..b27c9aa7c 100644 --- a/Jusin154_Team3D/Engine/Private/GameInstance.cpp +++ b/Jusin154_Team3D/Engine/Private/GameInstance.cpp @@ -581,11 +581,11 @@ void CGameInstance::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTr return m_pPhysX_Manager->RegistTriMesh(pName, pPxTriMesh); } -PSX::PxRigidDynamic* CGameInstance::Add_DynamicActor(CRigidBody& RigidBody) +PSX::PxRigidDynamic* CGameInstance::Add_DynamicActor(CRigidBody_Dynamic& RigidBody) { return m_pPhysX_Manager->Add_DynamicActor(RigidBody); } -PSX::PxRigidStatic* CGameInstance::Add_StaticActor(CRigidBody& RigidBody) +PSX::PxRigidStatic* CGameInstance::Add_StaticActor(CRigidBody_Static& RigidBody) { return m_pPhysX_Manager->Add_StaticActor(RigidBody); } diff --git a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp index c62c73e1f..4be6fb4d1 100644 --- a/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp +++ b/Jusin154_Team3D/Engine/Private/PhysX_Manager.cpp @@ -15,7 +15,7 @@ CPhysX_Manager::CPhysX_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pCont SAFE_ADDREF(m_pGameInstance); } -PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBody) +PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody_Dynamic& RigidBody) { _matrix WorldMatrix = RigidBody.Get_TransformPtr()->Get_XMWorldMatrix(); PSX::PxTransform pxWorldMatrix = XMWorldToPx_NoScale(WorldMatrix); @@ -68,7 +68,7 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBody) return pActorDynamic; } -PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody) +PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody_Static& RigidBody) { _matrix WorldMatrix = RigidBody.Get_TransformPtr()->Get_XMWorldMatrix(); PSX::PxTransform pxWorldMatrix = XMWorldToPx_NoScale(WorldMatrix); @@ -260,9 +260,9 @@ HRESULT CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector::iterator iter = m_TriangleMeshes.find(wstrMeshKey); + map<_wstring, PSX::PxTriangleMesh*>::iterator iter = m_TriangleMeshes.find(pMeshName); if (iter != m_TriangleMeshes.end()) { return iter->second; } diff --git a/Jusin154_Team3D/Engine/Private/RigidBody.cpp b/Jusin154_Team3D/Engine/Private/RigidBody.cpp index be78ff429..8589650a7 100644 --- a/Jusin154_Team3D/Engine/Private/RigidBody.cpp +++ b/Jusin154_Team3D/Engine/Private/RigidBody.cpp @@ -11,80 +11,12 @@ CRigidBody::CRigidBody(ID3D11Device* pDevice, ID3D11DeviceContext* pContext): CRigidBody::CRigidBody(const CRigidBody& rhs) : CComponent(rhs), m_eActorType(rhs.m_eActorType), - m_vhalfGeometryInfo(rhs.m_vhalfGeometryInfo), - m_wstrMeshKey(rhs.m_wstrMeshKey), - m_vMatInfo(rhs.m_vMatInfo), m_ePxRigidBodyFlags(rhs.m_ePxRigidBodyFlags), m_ePxShapeFlags(rhs.m_ePxShapeFlags), m_eMatType(rhs.m_eMatType), m_fContactOffset(rhs.m_fContactOffset) { } -#ifdef _DEBUG -HRESULT CRigidBody::Render() -{ - _matrix WorldMatrix = m_pTransform->Get_XMWorldMatrix(); - _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_eActorType) - { - case ACTOR::BOX: - { - m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); - } break; - case ACTOR::CAPSULE: - { - m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); - _matrix WorldUp = XMMatrixTranslationFromVector(m_pTransform->Get_State(STATE::UP) * m_vhalfGeometryInfo.y); - _matrix WorldDown = XMMatrixTranslationFromVector(m_pTransform->Get_State(STATE::UP) * -m_vhalfGeometryInfo.y); - m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); - m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); - } break; - case ACTOR::SPHERE: - { - m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); - } break; - default: - break; - } - return S_OK; -} -#endif // _DEBUG - -void CRigidBody::Set_Kinematic(_bool bKinematic) -{ - static_cast(m_pRigidBody)->setRigidBodyFlag(PSX::PxRigidBodyFlag::eKINEMATIC, bKinematic); -} - -void CRigidBody::Add_Force(_fvector vForce, PSX::PxForceMode::Enum eType) -{ - PSX::PxVec3 vPxForce = {}; - XMStoreFloat3((_float3*)&vPxForce, vForce); - static_cast(m_pRigidBody)->addForce(vPxForce, eType); -} - -void CRigidBody::Add_Torque(_fvector vDirection, PSX::PxForceMode::Enum eType) -{ - PSX::PxVec3 vPxTorque = {}; - XMStoreFloat3((_float3*)&vPxTorque, vDirection); - static_cast(m_pRigidBody)->addForce(vPxTorque, eType); -} - -HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc) -{ - m_eActorType = Desc.eType; - m_ePxRigidBodyFlags = Desc.ePxRigidBodyFlags; - m_ePxShapeFlags = Desc.ePxShapeFlags; - m_eMatType = Desc.ePxMaterialTypes; - m_vMatInfo = Desc.vMatInfo; - m_fContactOffset = Desc.fContactOffset; - m_vhalfGeometryInfo = Desc.vhalfGeometryInfo; - m_fDensity = Desc.fDensity; - - return S_OK; -} HRESULT CRigidBody::Initialize(void* pArg) { @@ -97,136 +29,11 @@ HRESULT CRigidBody::Initialize(void* pArg) m_pTransform = m_pOwner->Get_Component(); SAFE_ADDREF(m_pTransform); - switch (m_eActorType) - { - case Engine::ACTOR::BOX: - case Engine::ACTOR::CAPSULE: - case Engine::ACTOR::SPHERE: - m_pRigidBody = m_pGameInstance->Add_DynamicActor(*this); - break; - case Engine::ACTOR::PLANE: - break; - case Engine::ACTOR::TRIANGLEMESH: - m_pRigidBody = m_pGameInstance->Add_StaticActor(*this); - break; - case Engine::ACTOR::HEIGHTFIELD: - break; - case Engine::ACTOR::END: - break; - default: - break; - } - - Initialize_UserData(); - m_pRigidBody->userData = &m_tagData; - - - -#ifdef _DEBUG - if (FAILED(Add_DebugShape())) { - return E_FAIL; - } -#endif // _DEBUG - return S_OK; } -HRESULT CRigidBody::Initialize_UserData() -{ - switch (m_eActorType) - { - case Engine::ACTOR::BOX: - m_tagData.eKind = PHYSX_KIND::BODY_DYNAMIC; - m_tagData.pOwner = m_pOwner; - XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix()); - m_tagData.pBody = this; - break; - case Engine::ACTOR::CAPSULE: - m_tagData.eKind = PHYSX_KIND::BODY_DYNAMIC; - m_tagData.pOwner = m_pOwner; - XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix()); - m_tagData.pBody = this; - break; - case Engine::ACTOR::SPHERE: - m_tagData.eKind = PHYSX_KIND::BODY_DYNAMIC; - m_tagData.pOwner = m_pOwner; - XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix()); - m_tagData.pBody = this; - break; - case Engine::ACTOR::PLANE: - break; - case Engine::ACTOR::TRIANGLEMESH: - m_tagData.eKind = PHYSX_KIND::BODY_STATIC; - m_tagData.pOwner = m_pOwner; - XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix()); - m_tagData.pBody = this; - break; - case Engine::ACTOR::HEIGHTFIELD: - break; - case Engine::ACTOR::END: - break; - default: - break; - } - - return S_OK; -} - -#ifdef _DEBUG -HRESULT CRigidBody::Add_DebugShape() -{ - switch (m_eActorType) - { - case ACTOR::BOX: - m_pMainShape = (GeometricPrimitive::CreateBox(m_pContext, m_vhalfGeometryInfo, false, false)); - break; - case ACTOR::CAPSULE: - m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x, 10, false, false)); - m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, m_vhalfGeometryInfo.y, m_vhalfGeometryInfo.x, 10, false)); - break; - case ACTOR::SPHERE: - m_pMainShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x, 10, false, false)); - break; - case ACTOR::PLANE: - case ACTOR::TRIANGLEMESH: - case ACTOR::HEIGHTFIELD: - break; - default: - break; - } - return S_OK; -} -#endif // _DEBUG - -CRigidBody* CRigidBody::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_PROTOTYPEDESC& Desc) -{ - CRigidBody* pInstance = new CRigidBody(pDevice, pContext); - - if (FAILED(pInstance->Initialize_Prototype(Desc))) { - MSG_BOX("CRigidBody Prototype Created Failed"); - SAFE_RELEASE(pInstance); - } - - return pInstance; -} - -CComponent* CRigidBody::Clone(void* pArg, CGameObject* pOwner) -{ - CRigidBody* pInstance = new CRigidBody(*this); - pInstance->m_pOwner = pOwner; - if (FAILED(pInstance->Initialize(pArg))) { - MSG_BOX("CRigidBody Prototype Created Failed"); - SAFE_RELEASE(pInstance); - } - - return pInstance; -} - void CRigidBody::Free() { - if (nullptr != m_pRigidBody) { - m_pRigidBody = nullptr; - } __super::Free(); SAFE_RELEASE(m_pTransform); diff --git a/Jusin154_Team3D/Engine/Private/RigidBody_Dynamic.cpp b/Jusin154_Team3D/Engine/Private/RigidBody_Dynamic.cpp new file mode 100644 index 000000000..02bd3d71c --- /dev/null +++ b/Jusin154_Team3D/Engine/Private/RigidBody_Dynamic.cpp @@ -0,0 +1,159 @@ +#include "pch.h" +#include "RigidBody_Dynamic.h" +#include "GameInstance.h" + +CRigidBody_Dynamic::CRigidBody_Dynamic(ID3D11Device* pDevice, ID3D11DeviceContext* pContext): + CRigidBody(pDevice, pContext) +{ +} + +CRigidBody_Dynamic::CRigidBody_Dynamic(const CRigidBody_Dynamic& rhs) : + CRigidBody(rhs), + m_vMatInfo(rhs.m_vMatInfo), + m_vhalfGeometryInfo(rhs.m_vhalfGeometryInfo) +{ +} + +#ifdef _DEBUG +HRESULT CRigidBody_Dynamic::Render() +{ + _matrix WorldMatrix = m_pTransform->Get_XMWorldMatrix(); + _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_eActorType) + { + case ACTOR::BOX: + { + m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + } break; + case ACTOR::CAPSULE: + { + m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + _matrix WorldUp = XMMatrixTranslationFromVector(m_pTransform->Get_State(STATE::UP) * m_vhalfGeometryInfo.y); + _matrix WorldDown = XMMatrixTranslationFromVector(m_pTransform->Get_State(STATE::UP) * -m_vhalfGeometryInfo.y); + m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + } break; + case ACTOR::SPHERE: + { + m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true); + } break; + default: + break; + } + return S_OK; +} +#endif // _DEBUG +void CRigidBody_Dynamic::Add_Force(_fvector vForce, PSX::PxForceMode::Enum eType) +{ + PSX::PxVec3 vPxForce = {}; + XMStoreFloat3((_float3*)&vPxForce, vForce); + m_pRigidBody->addForce(vPxForce, eType); +} + +void CRigidBody_Dynamic::Add_Torque(_fvector vDirection, PSX::PxForceMode::Enum eType) +{ + PSX::PxVec3 vPxTorque = {}; + XMStoreFloat3((_float3*)&vPxTorque, vDirection); + m_pRigidBody->addForce(vPxTorque, eType); +} + +void CRigidBody_Dynamic::Set_Kinematic(_bool bKinematic) +{ + m_pRigidBody->setRigidBodyFlag(PSX::PxRigidBodyFlag::eKINEMATIC, bKinematic); +} + +HRESULT CRigidBody_Dynamic::Initialize_Prototype(RIGIDBODY_PROTOTYPE_DYNAMIC_DESC& Desc) +{ + m_eActorType = Desc.eType; + m_ePxRigidBodyFlags = Desc.ePxRigidBodyFlags; + m_ePxShapeFlags = Desc.ePxShapeFlags; + m_eMatType = Desc.ePxMaterialTypes; + m_vMatInfo = Desc.vMatInfo; + m_fContactOffset = Desc.fContactOffset; + m_vhalfGeometryInfo = Desc.vhalfGeometryInfo; + m_fDensity = Desc.fDensity; + m_vMassCenter = Desc.vMassCenter; + + return S_OK; +} + +HRESULT CRigidBody_Dynamic::Initialize(void* pArg) +{ + m_tagData.eKind = PHYSX_KIND::BODY_DYNAMIC; + if (FAILED(__super::Initialize(pArg))) { + return E_FAIL; + } + +#ifdef _DEBUG + if (FAILED(Add_DebugShape())) { + return E_FAIL; + } +#endif // _DEBUG + m_tagData.pOwner = m_pOwner; + XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix()); + m_tagData.pBody = this; + m_pRigidBody = m_pGameInstance->Add_DynamicActor(*this); + m_pRigidBody->userData = &m_tagData; + + return S_OK; +} + +#ifdef _DEBUG +HRESULT CRigidBody_Dynamic::Add_DebugShape() +{ + switch (m_eActorType) + { + case ACTOR::BOX: + m_pMainShape = (GeometricPrimitive::CreateBox(m_pContext, m_vhalfGeometryInfo, false, false)); + break; + case ACTOR::CAPSULE: + m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x, 10, false, false)); + m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, m_vhalfGeometryInfo.y, m_vhalfGeometryInfo.x, 10, false)); + break; + case ACTOR::SPHERE: + m_pMainShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x, 10, false, false)); + break; + default: + break; + } + return S_OK; +} +#endif // _DEBUG +CRigidBody_Dynamic* CRigidBody_Dynamic::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_PROTOTYPE_DYNAMIC_DESC& Desc) +{ + CRigidBody_Dynamic* pInstance = new CRigidBody_Dynamic(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype(Desc))) { + MSG_BOX("CRigidBody_Dynamic Prototype Created Failed"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CComponent* CRigidBody_Dynamic::Clone(void* pArg, CGameObject* pOwner) +{ + CRigidBody_Dynamic* pInstance = new CRigidBody_Dynamic(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) { + MSG_BOX("CRigidBody_Dynamic Prototype Created Failed"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CRigidBody_Dynamic::Free() +{ + __super::Free(); + if (nullptr != m_pRigidBody) { + m_pRigidBody = nullptr; + } +} + +void CRigidBody_Dynamic::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Engine/Private/RigidBody_Static.cpp b/Jusin154_Team3D/Engine/Private/RigidBody_Static.cpp new file mode 100644 index 000000000..4261d682c --- /dev/null +++ b/Jusin154_Team3D/Engine/Private/RigidBody_Static.cpp @@ -0,0 +1,76 @@ +#include "pch.h" +#include "RigidBody_Static.h" +#include "GameInstance.h" + +CRigidBody_Static::CRigidBody_Static(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) : + CRigidBody(pDevice, pContext) +{ +} + +CRigidBody_Static::CRigidBody_Static(const CRigidBody_Static& rhs) : + CRigidBody(rhs), + m_pMeshName(rhs.m_pMeshName) +{ +} + +HRESULT CRigidBody_Static::Initialize_Prototype(RIGIDBODY_STATIC_PROTOTYPEDESC& Desc) +{ + m_eActorType = Desc.eType; + m_ePxRigidBodyFlags = Desc.ePxRigidBodyFlags; + m_ePxShapeFlags = Desc.ePxShapeFlags; + m_eMatType = Desc.ePxMaterialTypes; + m_fContactOffset = Desc.fContactOffset; + + return S_OK; +} + +HRESULT CRigidBody_Static::Initialize(void* pArg) +{ + m_tagData.eKind = PHYSX_KIND::BODY_STATIC; + if (FAILED(__super::Initialize(pArg))) { + return E_FAIL; + } + m_tagData.pOwner = m_pOwner; + XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix()); + m_tagData.pBody = this; + m_pRigidBody = m_pGameInstance->Add_StaticActor(*this); + m_pRigidBody->userData = &m_tagData; + + return S_OK; +} + +CRigidBody_Static* CRigidBody_Static::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_STATIC_PROTOTYPEDESC& Desc) +{ + CRigidBody_Static* pInstance = new CRigidBody_Static(pDevice, pContext); + + if (FAILED(pInstance->Initialize_Prototype(Desc))) { + MSG_BOX("CRigidBody_Static Prototype Created Failed"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +CComponent* CRigidBody_Static::Clone(void* pArg, CGameObject* pOwner) +{ + CRigidBody_Static* pInstance = new CRigidBody_Static(*this); + pInstance->m_pOwner = pOwner; + if (FAILED(pInstance->Initialize(pArg))) { + MSG_BOX("CRigidBody_Static Prototype Created Failed"); + SAFE_RELEASE(pInstance); + } + + return pInstance; +} + +void CRigidBody_Static::Free() +{ + __super::Free(); + if (nullptr != m_pRigidBody) { + m_pRigidBody = nullptr; + } +} + +void CRigidBody_Static::Describe_Entity() +{ +} diff --git a/Jusin154_Team3D/Engine/Public/Character_Controller.h b/Jusin154_Team3D/Engine/Public/Character_Controller.h index baf5c7826..d9b4c1f65 100644 --- a/Jusin154_Team3D/Engine/Public/Character_Controller.h +++ b/Jusin154_Team3D/Engine/Public/Character_Controller.h @@ -24,7 +24,8 @@ class ENGINE_DLL CCharacter_Controller final : _bool bAutoStepping = { false }; // 계단 높이 타게 할건지 // 박스 콜라이더는 생각한대로 되는데 캡슐은 바닥의 구체 때문에 예상보다 더 높은 곳까지 오를 수 있음 _float fStepOffset = { 0.05f }; // 허용가능한 계단 높이, 작게 유지하는게 좋음 - void* pCallback = { }; // move가 호출될 때 호출 됨 // dll을 받는 각 프로젝트에서 CCollision_Callback 을 구현해야함 + PSX::PxUserControllerHitReport* pCallback_HitReport = { }; // move가 호출될 때 호출 됨 // dll을 받는 각 프로젝트에서 구현해야함 + PSX::PxControllerBehaviorCallback* pCallback_Behavior = { }; // move가 호출될 때 호출 됨 // dll을 받는 각 프로젝트에서 구현해야함 // 타고 올라갈 수 없는 경사면의 각도를 정의함. 0.f 면 비활성화 됨 // _float fSlopeLimit = { 코사인각도 }; diff --git a/Jusin154_Team3D/Engine/Public/GameInstance.h b/Jusin154_Team3D/Engine/Public/GameInstance.h index 7b2e7446e..b543b2739 100644 --- a/Jusin154_Team3D/Engine/Public/GameInstance.h +++ b/Jusin154_Team3D/Engine/Public/GameInstance.h @@ -182,8 +182,8 @@ class ENGINE_DLL CGameInstance final : public CBase #pragma region PhysX_Manager PSX::PxMaterial* Create_Material(_float3* vMatInfo); void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh); - PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody); - PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody); + PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody_Dynamic& RigidBody); + PSX::PxRigidStatic* Add_StaticActor(CRigidBody_Static& RigidBody); PSX::PxController* Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc); diff --git a/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.cpp b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.cpp new file mode 100644 index 000000000..327329d62 --- /dev/null +++ b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.cpp @@ -0,0 +1,52 @@ +#include "pch.h" +#include "CallBack_Playable_Behavior.h" + + +CCallBack_Playable_Behavior::CCallBack_Playable_Behavior() +{ +} + +PSX::PxControllerBehaviorFlags CCallBack_Playable_Behavior::getBehaviorFlags(const PSX::PxShape& shape, const PSX::PxActor& actor) +{ + if (nullptr == actor.userData) { + return PSX::PxControllerBehaviorFlags(0); + } + PhsXUserData* pActorData = static_cast(actor.userData); + + switch (pActorData->eKind) + { + case PHYSX_KIND::BODY_STATIC: + return PSX::PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT + | PSX::PxControllerBehaviorFlag::eCCT_SLIDE; + break; + case PHYSX_KIND::BODY_DYNAMIC: + return PSX::PxControllerBehaviorFlag::eCCT_SLIDE; + break; + case PHYSX_KIND::CCTActor: + // Action + break; + case PHYSX_KIND::OBSTACLEActor: + break; + default: + break; + } + + + // 나머지는 아무 특별 동작 없음 + return PSX::PxControllerBehaviorFlags(0); +} + +PSX::PxControllerBehaviorFlags CCallBack_Playable_Behavior::getBehaviorFlags(const PSX::PxController& controller) +{ + // CCT끼리 부딪힐 때를 굳이 안 쓰면 0 리턴 + return PSX::PxControllerBehaviorFlags(0); +} + +PSX::PxControllerBehaviorFlags CCallBack_Playable_Behavior::getBehaviorFlags(const PSX::PxObstacle& obstacle) +{ + // Obstacle이 움직이는 발판이다? + // 여기서 ride/slide 세팅 + //return PSX::PxControllerBehaviorFlag::eCCT_CAN_RIDE_ON_OBJECT; + + return PSX::PxControllerBehaviorFlags(0); +} diff --git a/Jusin154_Team3D/Engine/Public/Collision_Callback.h b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.h similarity index 65% rename from Jusin154_Team3D/Engine/Public/Collision_Callback.h rename to Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.h index d413812ce..f08a7ef67 100644 --- a/Jusin154_Team3D/Engine/Public/Collision_Callback.h +++ b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_Behavior.h @@ -1,8 +1,12 @@ #pragma once #include "Base.h" +NS_BEGIN(PSX) +class PxControllerBehaviorCallback; +class PxUserControllerHitReport; +NS_END -class CCollision_Callback final : public PSX::PxUserControllerHitReport, PSX::PxControllerBehaviorCallback +class CCallBack_Playable_Behavior final : public PSX::PxControllerBehaviorCallback { // 구현 예시 // CCT는 RigidBody의 PxSimulationEventCallback에 안걸리고, 이 전용 콜백에서 처리되는 구조임 @@ -12,21 +16,10 @@ class CCollision_Callback final : public PSX::PxUserControllerHitReport, PSX::Px // PxSimulationEventCallback = "씬 전체에 대한 글로벌 콜백(일반 물리 이벤트)" public: - NO_COPY(CCollision_Callback) - CCollision_Callback(); - ~CCollision_Callback()=default; + CCallBack_Playable_Behavior(); + ~CCallBack_Playable_Behavior() = default; public: - // PxUserControllerHitReport을(를) 통해 상속됨 - // 충돌알림!! - // 주인이 되는 CCT가 이 물체에 대해 어떻게 반응해야 할까? - virtual void onShapeHit(const PSX::PxControllerShapeHit& hit) override; // statc, rigid 등과 부딪힌 경우 - - virtual void onControllerHit(const PSX::PxControllersHit& hit) override; // 다른 CCT와 부딪힌 경우 - - virtual void onObstacleHit(const PSX::PxControllerObstacleHit& hit) override; // 사용자 정의 장애물과 부딪힌 경우 - - // PxControllerBehaviorCallback을(를) 통해 상속됨 // 충돌알림이 아닌, 행동정책 정해주기. CCT vs CCT는 지원안함 // slopeLimit로 미끄러져 갈 수 있는지 없는지 이분법적인 계산 대신, 원하는 물체에 대해서만 미끄러운 표면으로 정의해줌 @@ -37,4 +30,3 @@ class CCollision_Callback final : public PSX::PxUserControllerHitReport, PSX::Px virtual PSX::PxControllerBehaviorFlags getBehaviorFlags(const PSX::PxObstacle& obstacle) override; }; - diff --git a/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.cpp b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.cpp new file mode 100644 index 000000000..71ecacfcf --- /dev/null +++ b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.cpp @@ -0,0 +1,94 @@ +#include "pch.h" +#include "CallBack_Playable_HitRepot.h" +#include "GameInstance.h" + +CCallBack_Playable_HitRepot::CCallBack_Playable_HitRepot() +{ +} + +void CCallBack_Playable_HitRepot::onShapeHit(const PSX::PxControllerShapeHit& hit) +{ + PSX::PxController* pController = hit.controller; + PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 + PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 + PSX::PxVec3 vDir = hit.dir; // 시도한 move 방향 + _float fLength = hit.length; // 시도한 move 길이 + + PSX::PxShape* pShape = hit.shape; + PSX::PxRigidActor* pActor = hit.actor; + + if (nullptr != pController && nullptr != pActor) { + PhsXUserData* pActorData = static_cast(pActor->userData); + if (nullptr == pActorData) { // missing user data + return; + } + switch (pActorData->eKind) + { + case PHYSX_KIND::BODY_STATIC: + // action + break; + case PHYSX_KIND::BODY_DYNAMIC: + { + PSX::PxRigidDynamic* pDynamic = static_cast(pActor); + pDynamic->addForce(vDir * fLength, PSX::PxForceMode::eIMPULSE); + } break; + case PHYSX_KIND::CCTActor: + assert(false); + break; + case PHYSX_KIND::OBSTACLEActor: + break; + default: + break; + } + } +} + +void CCallBack_Playable_HitRepot::onControllerHit(const PSX::PxControllersHit& hit) +{ + PSX::PxController* pController = hit.controller; + PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 + PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 + PSX::PxVec3 vDir = hit.dir; // 시도한 move 방향 + _float fLength = hit.length; // 시도한 move 길이 + + PSX::PxController* pOtherController = hit.other; // 다른 컨트롤러 + + if (nullptr != pController && nullptr != pOtherController) { + PhsXUserData* pActorData = static_cast(pOtherController->getActor()->userData); + assert(nullptr != pActorData); // missing user data + + switch (pActorData->eKind) + { + case PHYSX_KIND::BODY_STATIC: + assert(false); + break; + case PHYSX_KIND::BODY_DYNAMIC: + assert(false); + break; + case PHYSX_KIND::CCTActor: + // Action + break; + case PHYSX_KIND::OBSTACLEActor: + break; + default: + break; + } + } +} + +void CCallBack_Playable_HitRepot::onObstacleHit(const PSX::PxControllerObstacleHit& hit) +{ + PSX::PxController* pController = hit.controller; + PSX::PxExtendedVec3 vWorldPos = hit.worldPos; // 접촉지점 + PSX::PxVec3 vWorldNormal = hit.worldNormal; // 접촉노말 + PSX::PxVec3 vDir = hit.dir; // 시도한 move 방향 + _float fLength = hit.length; // 시도한 move 길이 + + const void* pOtherController = hit.userData; // 장애물 + + //switch (pOtherController.member) + //{ + //default: + // break; + //} +} diff --git a/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.h b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.h new file mode 100644 index 000000000..198023d22 --- /dev/null +++ b/Jusin154_Team3D/Engine/Public/NCallBack_Playable_HitRepot.h @@ -0,0 +1,31 @@ +#pragma once + +#include "Base.h" +NS_BEGIN(PSX) +class PxControllerBehaviorCallback; +class PxUserControllerHitReport; +NS_END + +class CCallBack_Playable_HitRepot final : public PSX::PxUserControllerHitReport +{ + // 구현 예시 + // CCT는 RigidBody의 PxSimulationEventCallback에 안걸리고, 이 전용 콜백에서 처리되는 구조임 + // + // PxUserControllerHitReport = "무엇과 부딪혔는지 알려줌(이벤트 알림)" + // PxControllerBehaviorCallback = "부딪힌 것에 대해 어떤 행동 정책을 쓸지 물어봄(질의)" + // PxSimulationEventCallback = "씬 전체에 대한 글로벌 콜백(일반 물리 이벤트)" + +public: + CCallBack_Playable_HitRepot(); + ~CCallBack_Playable_HitRepot() = default; + +public: + // PxUserControllerHitReport을(를) 통해 상속됨 + // 충돌알림!! + // 주인이 되는 CCT가 이 물체에 대해 어떻게 반응해야 할까? + virtual void onShapeHit(const PSX::PxControllerShapeHit& hit) override; // statc, rigid 등과 부딪힌 경우 + + virtual void onControllerHit(const PSX::PxControllersHit& hit) override; // 다른 CCT와 부딪힌 경우 + + virtual void onObstacleHit(const PSX::PxControllerObstacleHit& hit) override; // 사용자 정의 장애물과 부딪힌 경우 +}; diff --git a/Jusin154_Team3D/Engine/Public/PhysX/characterkinematic/PxCapsuleController.h b/Jusin154_Team3D/Engine/Public/PhysX/characterkinematic/PxCapsuleController.h index d8e624ecb..fa9dd981c 100644 --- a/Jusin154_Team3D/Engine/Public/PhysX/characterkinematic/PxCapsuleController.h +++ b/Jusin154_Team3D/Engine/Public/PhysX/characterkinematic/PxCapsuleController.h @@ -1,4 +1,4 @@ -// Redistribution and use in source and binary forms, with or without +// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright diff --git a/Jusin154_Team3D/Engine/Public/PhysX_Manager.h b/Jusin154_Team3D/Engine/Public/PhysX_Manager.h index ae18d5506..2d939e44a 100644 --- a/Jusin154_Team3D/Engine/Public/PhysX_Manager.h +++ b/Jusin154_Team3D/Engine/Public/PhysX_Manager.h @@ -4,6 +4,8 @@ NS_BEGIN(Engine) class CRigidBody; +class CRigidBody_Dynamic; +class CRigidBody_Static; class CTransform; class CMesh; @@ -20,8 +22,8 @@ class CPhysX_Manager final : public CBase // HRESULT Update_RegionOfInterest(); ( 충돌 컬링, 필터링도 검색해야함 ) // Aggregate ( 충돌 그룹, 이 그룹끼리는 서로 충돌검사를 하지 않음, 지형, 레그돌 등 ) - PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody); - PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody); + PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody_Dynamic& RigidBody); + PSX::PxRigidStatic* Add_StaticActor(CRigidBody_Static& RigidBody); void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh); PSX::PxMaterial* Create_Material(const _float3* vMatInfo); @@ -30,7 +32,7 @@ class CPhysX_Manager final : public CBase HRESULT SaveTriMeshes(const _char* pPath, vector& TriMeshes); HRESULT LoadTriMeshes(const _char* pPath, vector& TriMeshes); //HRESULT LoadTriMeshes_Binary(const _char* pPath, vector& TriMeshes); - PSX::PxTriangleMesh* Find_TriangleMesh(const _wstring& wstrMeshKey); + PSX::PxTriangleMesh* Find_TriangleMesh(const _tchar* pMeshName); void Update(_float fTimeDelta); void ClearScene(); @@ -76,6 +78,11 @@ class CPhysX_Manager final : public CBase list> m_RigidBodys = { }; map<_wstring, PSX::PxTriangleMesh*> m_TriangleMeshes = {}; map<_wstring, PSX::PxTriangleMeshGeometry*> m_TriangleMeshGeometry = {}; +#ifdef 기무리 + PhsXUserData PlaneData = {}; + +#endif // 기무리 + vector m_pMaterials = { }; _uint m_iNumLevel = {}; diff --git a/Jusin154_Team3D/Engine/Public/Prototype_Manager.h b/Jusin154_Team3D/Engine/Public/Prototype_Manager.h index 2d0692764..aad27801c 100644 --- a/Jusin154_Team3D/Engine/Public/Prototype_Manager.h +++ b/Jusin154_Team3D/Engine/Public/Prototype_Manager.h @@ -5,7 +5,8 @@ #include "VIBuffer_Cell.h" #include "Shader.h" #include "Navigation.h" -#include "RigidBody.h" +#include "RigidBody_Dynamic.h" +#include "RigidBody_Static.h" #include "Texture.h" #include "Cell.h" #include "Model.h" diff --git a/Jusin154_Team3D/Engine/Public/RigidBody.h b/Jusin154_Team3D/Engine/Public/RigidBody.h index 6b6620497..803574e02 100644 --- a/Jusin154_Team3D/Engine/Public/RigidBody.h +++ b/Jusin154_Team3D/Engine/Public/RigidBody.h @@ -10,9 +10,9 @@ NS_BEGIN(Engine) class CTransform; class CMesh; -class ENGINE_DLL CRigidBody final : public CComponent +class ENGINE_DLL CRigidBody abstract : public CComponent { -public: // MORE INFO ON ENGINE_ENUM +protected: // MORE INFO ON ENGINE_ENUM typedef struct tagRigidBody_PrototypeDesc // 다 채우세요 NONE 빼고, 목적에 안맞는거 빼고 { ACTOR eType; @@ -22,91 +22,41 @@ class ENGINE_DLL CRigidBody final : public CComponent _float3 vMatInfo = { 0.5f, 0.5f, 0.6f }; // 피직스 객체의 속성 등 _float fContactOffset = { 0.05f }; // 접촉 유격 오프셋 -#pragma region DYNAMIC - _float3 vhalfGeometryInfo; // 박스는 vSize, 캡슐은 radius, height로 씀 - _float fDensity = { 1000.f }; // 밀도, 실제 무게는 부피에 따라 달라짐 - -#pragma endregion -#pragma region STATIC -#pragma endregion }RIGIDBODY_PROTOTYPEDESC; typedef struct tagRigidBody_Desc { -#pragma region DYNAMIC -#pragma endregion -#pragma region STATIC - const _char* szMeshName = { }; -#pragma endregion + }RIGIDBODY_DESC; -private: +protected: CRigidBody(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); CRigidBody(const CRigidBody& rhs); virtual ~CRigidBody() = default; public: -#ifdef _DEBUG - virtual HRESULT Render()override; -#endif // _DEBUG - - ACTOR Get_Type() const { return m_eActorType; } - PSX::PxActor* Get_Actor() const { return m_pRigidBody; } + virtual PSX::PxActor* Get_Actor()PURE; CTransform* Get_TransformPtr() const { return m_pTransform; } - const _tchar* Get_PxMeshKey() const { return m_wstrMeshKey.c_str(); } PXMATERIAL Get_MaterialType() const { return m_eMatType; } _float Get_ContactOffset() const { return m_fContactOffset; } - _float Get_Density() const { return m_fDensity; } PSX::PxShapeFlags Get_ShapeFlags() const { return m_ePxShapeFlags; } PSX::PxRigidBodyFlags Get_RigidBodyFlags() const { return m_ePxRigidBodyFlags; } - _float3 Get_HalfGeometryInfo() const { return m_vhalfGeometryInfo; } - - // 키네마틱은 transform으로 이동 ( simulate 전에 이동함 ) - // 키네마틱이 아닌 dynamic은 토크와 포스로 이동 ( simulate 후에 이동함 ) - void Set_Kinematic(_bool bKinematic); - - - void Add_Force(_fvector vForce, PSX::PxForceMode::Enum eType = PSX::PxForceMode::Enum::eFORCE); // 속도 + 방향 - void Add_Torque(_fvector vDirection, PSX::PxForceMode::Enum eType = PSX::PxForceMode::Enum::eFORCE); // 방향 - -private: +protected: ACTOR m_eActorType = ACTOR::END; - PSX::PxRigidBodyFlags m_ePxRigidBodyFlags = {}; + PSX::PxRigidBodyFlags m_ePxRigidBodyFlags = { }; + PSX::PxShapeFlags m_ePxShapeFlags = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE }; PXMATERIAL m_eMatType = { PXMATERIAL::END }; _float m_fContactOffset = { 0.05f }; - PSX::PxActor* m_pRigidBody = { nullptr }; // 실제 시뮬레이션을 도는 본체 CTransform* m_pTransform = { nullptr }; PhsXUserData m_tagData = {}; -#pragma region DYNAMIC - PSX::PxShapeFlags m_ePxShapeFlags = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE }; - _float3 m_vMatInfo = {}; - _float3 m_vhalfGeometryInfo = {}; - _float3 m_vCenterOfMess = {}; // 회전축 - _float m_fDensity = { 1000.f }; -#pragma endregion -#pragma region STATIC - _wstring m_wstrMeshKey = { }; // 짝꿍 스태틱 메시의 triangleMesh 키 -#pragma endregion -#ifdef _DEBUG - unique_ptr m_pMainShape = { nullptr }; - unique_ptr m_pSubShape = { nullptr }; -#endif // _DEBUG - -private: - HRESULT Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc); - HRESULT Initialize(void* pArg); - HRESULT Initialize_UserData(); -#ifdef _DEBUG - HRESULT Add_DebugShape(); -#endif +protected: + virtual HRESULT Initialize(void* pArg); public: - static CRigidBody* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_PROTOTYPEDESC& Desc); - virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override; virtual void Free() override; virtual void Describe_Entity() override; }; diff --git a/Jusin154_Team3D/Engine/Public/RigidBody_Dynamic.h b/Jusin154_Team3D/Engine/Public/RigidBody_Dynamic.h new file mode 100644 index 000000000..4b6e83943 --- /dev/null +++ b/Jusin154_Team3D/Engine/Public/RigidBody_Dynamic.h @@ -0,0 +1,68 @@ +#pragma once +#include "RigidBody.h" + +NS_BEGIN(Engine) +class CTransform; +class CMesh; + +class ENGINE_DLL CRigidBody_Dynamic : public CRigidBody +{ +public: + typedef struct tagRigidBody_Prototype_DYNAMIC_Desc : public CRigidBody::RIGIDBODY_PROTOTYPEDESC + { + _float3 vhalfGeometryInfo; // 박스는 vSize, 캡슐은 radius, height로 씀 + _float fDensity = { 1000.f }; // 밀도, 실제 무게는 부피에 따라 달라짐 + _float3 vMassCenter = {}; + }RIGIDBODY_PROTOTYPE_DYNAMIC_DESC; + + typedef struct tagRigidBody_DYNAMIC_Desc : public CRigidBody::RIGIDBODY_DESC + { + + }RIGIDBODY_DYNAMIC_DESC; + +private: + CRigidBody_Dynamic(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CRigidBody_Dynamic(const CRigidBody_Dynamic& rhs); + virtual ~CRigidBody_Dynamic() = default; + +public: +#ifdef _DEBUG + virtual HRESULT Render()override; +#endif // _DEBUG + + virtual PSX::PxRigidDynamic* Get_Actor() override { return m_pRigidBody; }; + _float3 Get_HalfGeometryInfo() const { return m_vhalfGeometryInfo; } + _float Get_Density() const { return m_fDensity; } + + virtual void Add_Force(_fvector vForce, PSX::PxForceMode::Enum eType = PSX::PxForceMode::Enum::eFORCE); // 속도 + 방향 + virtual void Add_Torque(_fvector vDirection, PSX::PxForceMode::Enum eType = PSX::PxForceMode::Enum::eFORCE); // 방향 ( 회전축은 MassCenter ) + void Set_Kinematic(_bool bKinematic); + +private: + PSX::PxRigidDynamic* m_pRigidBody = { nullptr }; // 실제 시뮬레이션을 도는 본체 + _float3 m_vMatInfo = {}; + _float3 m_vhalfGeometryInfo = {}; + _float3 m_vMassCenter = {}; // 회전축 + _float m_fDensity = { 1000.f }; + +#ifdef _DEBUG + unique_ptr m_pMainShape = { nullptr }; + unique_ptr m_pSubShape = { nullptr }; +#endif // _DEBUG + +private: + HRESULT Initialize_Prototype(RIGIDBODY_PROTOTYPE_DYNAMIC_DESC& Desc); + virtual HRESULT Initialize(void* pArg) override; + +#ifdef _DEBUG + HRESULT Add_DebugShape(); +#endif + +public: + static CRigidBody_Dynamic* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_PROTOTYPE_DYNAMIC_DESC& Desc); + virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override; + virtual void Free() override; + virtual void Describe_Entity() override; +}; + +NS_END diff --git a/Jusin154_Team3D/Engine/Public/RigidBody_Static.h b/Jusin154_Team3D/Engine/Public/RigidBody_Static.h new file mode 100644 index 000000000..0e965b0a9 --- /dev/null +++ b/Jusin154_Team3D/Engine/Public/RigidBody_Static.h @@ -0,0 +1,47 @@ +#pragma once +#include "RigidBody.h" + +NS_BEGIN(Engine) +class CTransform; +class CMesh; + + +class ENGINE_DLL CRigidBody_Static : public CRigidBody +{ +public: + typedef struct tagRigidBody_Prototype_STATIC_Desc : public CRigidBody::RIGIDBODY_PROTOTYPEDESC + { + + }RIGIDBODY_STATIC_PROTOTYPEDESC; + + typedef struct tagRigidBody_STATIC_Desc : public CRigidBody::RIGIDBODY_PROTOTYPEDESC + { + const _tchar* pMeshName = { nullptr }; + }RIGIDBODY_STATIC_DESC; + +private: + CRigidBody_Static(ID3D11Device* pDevice, ID3D11DeviceContext* pContext); + CRigidBody_Static(const CRigidBody_Static& rhs); + virtual ~CRigidBody_Static() = default; + +public: + PSX::PxRigidStatic* Get_Actor() override { return m_pRigidBody; } + const _tchar* Get_PxMeshKey() const { return m_pMeshName; } + +private: + PSX::PxRigidStatic* m_pRigidBody = { nullptr }; // 실제 시뮬레이션을 도는 본체 + const _tchar* m_pMeshName = { nullptr }; // 짝꿍 스태틱 메시의 triangleMesh 키 + +private: + HRESULT Initialize_Prototype(RIGIDBODY_STATIC_PROTOTYPEDESC& Desc); + virtual HRESULT Initialize(void* pArg) override; + +public: + static CRigidBody_Static* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, RIGIDBODY_STATIC_PROTOTYPEDESC& Desc); + virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override; + virtual void Free() override; + virtual void Describe_Entity() override; + +}; + +NS_END