@@ -203,7 +203,6 @@ call Update_Lib.bat
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Collider.cpp" />
|
||||
<ClCompile Include="..\Private\Collider_Manager.cpp" />
|
||||
<ClCompile Include="..\Private\Collision_Callback.cpp" />
|
||||
<ClCompile Include="..\Private\Component.cpp" />
|
||||
<ClCompile Include="..\Private\ComputeShader.cpp" />
|
||||
<ClCompile Include="..\Private\ContainerObject.cpp" />
|
||||
@@ -287,6 +286,8 @@ call Update_Lib.bat
|
||||
<ClCompile Include="..\Private\RenderTarget.cpp" />
|
||||
<ClCompile Include="..\Private\RenderTarget_Manager.cpp" />
|
||||
<ClCompile Include="..\Private\RigidBody.cpp" />
|
||||
<ClCompile Include="..\Private\RigidBody_Dynamic.cpp" />
|
||||
<ClCompile Include="..\Private\RigidBody_Static.cpp" />
|
||||
<ClCompile Include="..\Private\Shader.cpp" />
|
||||
<ClCompile Include="..\Private\Shadow.cpp" />
|
||||
<ClCompile Include="..\Private\SoundSrc.cpp" />
|
||||
@@ -305,6 +306,14 @@ call Update_Lib.bat
|
||||
<ClCompile Include="..\Private\Instance_Model.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer_Rect.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer_Terrain.cpp" />
|
||||
<ClCompile Include="..\Public\NCallBack_Playable_Behavior.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Public\NCallBack_Playable_HitRepot.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Public\Animation.h" />
|
||||
@@ -398,6 +407,14 @@ call Update_Lib.bat
|
||||
<ClInclude Include="..\Public\Bounding_AABB.h" />
|
||||
<ClInclude Include="..\Public\Bounding_OBB.h" />
|
||||
<ClInclude Include="..\Public\Bounding_Sphere.h" />
|
||||
<ClInclude Include="..\Public\NCallBack_Playable_Behavior.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\NCallBack_Playable_HitRepot.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Camera.h">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
</ExcludedFromBuild>
|
||||
@@ -419,7 +436,6 @@ call Update_Lib.bat
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Collider.h" />
|
||||
<ClInclude Include="..\Public\Collider_Manager.h" />
|
||||
<ClInclude Include="..\Public\Collision_Callback.h" />
|
||||
<ClInclude Include="..\Public\Component.h" />
|
||||
<ClInclude Include="..\Public\ComputeShader.h" />
|
||||
<ClInclude Include="..\Public\ContainerObject.h" />
|
||||
@@ -503,6 +519,8 @@ call Update_Lib.bat
|
||||
<ClInclude Include="..\Public\RenderTarget.h" />
|
||||
<ClInclude Include="..\Public\RenderTarget_Manager.h" />
|
||||
<ClInclude Include="..\Public\RigidBody.h" />
|
||||
<ClInclude Include="..\Public\RigidBody_Dynamic.h" />
|
||||
<ClInclude Include="..\Public\RigidBody_Static.h" />
|
||||
<ClInclude Include="..\Public\Shader.h" />
|
||||
<ClInclude Include="..\Public\Shadow.h" />
|
||||
<ClInclude Include="..\Public\SoundSrc.h" />
|
||||
|
||||
@@ -244,15 +244,9 @@
|
||||
<Filter Include="01.Utility\06.Picking">
|
||||
<UniqueIdentifier>{a60a7ba5-a937-41d7-baac-db67f86f3ba1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\08.Character_Controller\Collision_Callback">
|
||||
<UniqueIdentifier>{05865481-fa20-4432-a5a7-945d4f8c7f3c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\07.RigidBody\10.Dynamic">
|
||||
<UniqueIdentifier>{bed0de44-4e62-4b5f-9767-65cfc8a933a3}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\07.RigidBody\11.Kinematic">
|
||||
<UniqueIdentifier>{33ac85a2-be8e-4ad9-a179-1239d818dc9c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\07.RigidBody\00.Static">
|
||||
<UniqueIdentifier>{fda41884-634b-4dd4-8bd2-f6f7ad68ab1f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -262,6 +256,9 @@
|
||||
<Filter Include="03.Management\03.Light_Manager">
|
||||
<UniqueIdentifier>{8727e975-e9e2-4b59-9a52-27ad3ad79f2f}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="02.Element\02.Component\08.Character_Controller\CallBack">
|
||||
<UniqueIdentifier>{05865481-fa20-4432-a5a7-945d4f8c7f3c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\Private\Base.cpp">
|
||||
@@ -438,9 +435,6 @@
|
||||
<ClCompile Include="..\Private\PhysX_Manager.cpp">
|
||||
<Filter>03.Management\21.PhysX_Manager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\RigidBody.cpp">
|
||||
<Filter>02.Element\02.Component\07.RigidBody</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\private\UIComponent.cpp">
|
||||
<Filter>02.Element\02.Component\50.UI</Filter>
|
||||
</ClCompile>
|
||||
@@ -477,8 +471,20 @@
|
||||
<ClCompile Include="..\Private\Light_Manager.cpp">
|
||||
<Filter>03.Management\03.Light_Manager</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\Collision_Callback.cpp">
|
||||
<Filter>02.Element\02.Component\08.Character_Controller\Collision_Callback</Filter>
|
||||
<ClCompile Include="..\Private\RigidBody_Static.cpp">
|
||||
<Filter>02.Element\02.Component\07.RigidBody\00.Static</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\RigidBody_Dynamic.cpp">
|
||||
<Filter>02.Element\02.Component\07.RigidBody\10.Dynamic</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\RigidBody.cpp">
|
||||
<Filter>02.Element\02.Component\07.RigidBody</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Public\NCallBack_Playable_HitRepot.cpp">
|
||||
<Filter>02.Element\02.Component\08.Character_Controller\CallBack</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Public\NCallBack_Playable_Behavior.cpp">
|
||||
<Filter>02.Element\02.Component\08.Character_Controller\CallBack</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -1061,8 +1067,17 @@
|
||||
<ClInclude Include="..\Public\Light_Manager.h">
|
||||
<Filter>03.Management\03.Light_Manager</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\Collision_Callback.h">
|
||||
<Filter>02.Element\02.Component\08.Character_Controller\Collision_Callback</Filter>
|
||||
<ClInclude Include="..\Public\RigidBody_Static.h">
|
||||
<Filter>02.Element\02.Component\07.RigidBody\00.Static</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\RigidBody_Dynamic.h">
|
||||
<Filter>02.Element\02.Component\07.RigidBody\10.Dynamic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\NCallBack_Playable_HitRepot.h">
|
||||
<Filter>02.Element\02.Component\08.Character_Controller\CallBack</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\NCallBack_Playable_Behavior.h">
|
||||
<Filter>02.Element\02.Component\08.Character_Controller\CallBack</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -154,7 +154,7 @@ void CChannel::Update_TransformationMatirx(const vector<CBone*>& Bones, _float f
|
||||
_vector vDeltaAdjusted = {};
|
||||
|
||||
XMMATRIX pre = XMLoadFloat4x4(&m_PreTransformMatrix);
|
||||
vDeltaAdjusted = XMVector3TransformNormal(vDeltaLocal, pre);
|
||||
vDeltaAdjusted = XMVector3TransformNormal(vDeltaLocal, pre*20.f);
|
||||
|
||||
_vector vRight = pTransform->Get_State(STATE::RIGHT);
|
||||
_vector vUp = pTransform->Get_State(STATE::UP);
|
||||
|
||||
@@ -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 }
|
||||
@@ -61,6 +60,11 @@ HRESULT CCharacter_Controller::Render()
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
PSX::PxRigidDynamic* CCharacter_Controller::Get_Actor()
|
||||
{
|
||||
return m_pController->getActor();
|
||||
}
|
||||
|
||||
#endif // _DEBUG
|
||||
|
||||
void CCharacter_Controller::Resize_Volume(_float fHeight)
|
||||
@@ -189,8 +193,9 @@ HRESULT CCharacter_Controller::Initialize(void* pArg)
|
||||
{ // PhsXUserData
|
||||
m_tagData.eKind = PHYSX_KIND::CCTActor;
|
||||
m_tagData.pOwner = m_pOwner;
|
||||
XMStoreFloat4x4(&m_tagData.m_BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
XMStoreFloat4x4(&m_tagData.BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pCharacter = this;
|
||||
m_tagData.iSubKind = pDesc->iSubKind;
|
||||
}
|
||||
|
||||
switch (m_eBodyType)
|
||||
@@ -202,11 +207,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<PSX::PxUserControllerHitReport*>(pDesc->pCallback);
|
||||
Desc.behaviorCallback = static_cast<PSX::PxControllerBehaviorCallback*>(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 +221,12 @@ HRESULT CCharacter_Controller::Initialize(void* pArg)
|
||||
Desc.height = pDesc->fHeight;
|
||||
Desc.climbingMode = pDesc->eClimbingMode; // 기본 eEASY
|
||||
Desc.contactOffset = pDesc->fContactOffset;
|
||||
Desc.reportCallback = static_cast<PSX::PxUserControllerHitReport*>(pDesc->pCallback);
|
||||
Desc.behaviorCallback = static_cast<PSX::PxControllerBehaviorCallback*>(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에서 불가능
|
||||
|
||||
@@ -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<PhsXUserData*>(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<PhsXUserData*>(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();
|
||||
}
|
||||
@@ -112,7 +112,6 @@ void CGameInstance::Update_Engine(_float fTimeDelta)
|
||||
|
||||
m_pObject_Manager->Update(fTimeDelta);
|
||||
|
||||
m_pRenderer->Refresh_Renderer();
|
||||
m_pObject_Manager->Late_Update(fTimeDelta);
|
||||
|
||||
m_pLevel_Manager->Update(fTimeDelta);
|
||||
@@ -400,14 +399,9 @@ void CGameInstance::Clear_Objects_With_Layers(_uint iLevelIndex)
|
||||
m_pObject_Manager->Clear(iLevelIndex);
|
||||
}
|
||||
|
||||
void CGameInstance::Refresh_Renderer()
|
||||
HRESULT CGameInstance::Add_RenderGroup(RENDER eRenderGroup, CGameObject* pRenderObject)
|
||||
{
|
||||
m_pRenderer->Refresh_Renderer();
|
||||
}
|
||||
|
||||
HRESULT CGameInstance::Add_RenderGroup(RENDER eRenderGroup, CGameObject* pRenderObject, _float4& vPos, _float fCullRadius)
|
||||
{
|
||||
return m_pRenderer->Add_RenderGroup(eRenderGroup, pRenderObject, vPos, fCullRadius);
|
||||
return m_pRenderer->Add_RenderGroup(eRenderGroup, pRenderObject);
|
||||
}
|
||||
|
||||
void CGameInstance::Set_Transform(D3DTS eState, _fmatrix TransformStateMatrix)
|
||||
@@ -435,6 +429,21 @@ const _vector CGameInstance::Get_CamXMPosition()
|
||||
return m_pPipeLine->Get_CamXMPosition();
|
||||
}
|
||||
|
||||
void CGameInstance::Transform_Frustum_ToLocalSpace(_fmatrix WorldMatrixInverse)
|
||||
{
|
||||
m_pPipeLine->Transform_Frustum_ToLocalSpace(WorldMatrixInverse);
|
||||
}
|
||||
|
||||
_bool CGameInstance::isIn_WorldFrustum(_fvector vWorldPos, _float fRadius)
|
||||
{
|
||||
return m_pPipeLine->isIn_WorldFrustum(vWorldPos, fRadius);
|
||||
}
|
||||
|
||||
_bool CGameInstance::isIn_LocalFrustum(_fvector vLocalPos, _float fRadius)
|
||||
{
|
||||
return m_pPipeLine->isIn_LocalFrustum(vLocalPos, fRadius);
|
||||
}
|
||||
|
||||
void CGameInstance::Add_Light(_uint _iCurrentLevel, CLight* _pLight)
|
||||
{
|
||||
m_pLight_Manager->Add_Light(_iCurrentLevel, _pLight);
|
||||
@@ -591,11 +600,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);
|
||||
}
|
||||
@@ -615,13 +624,17 @@ void CGameInstance::ReleaseController(_uint iControllerIndex)
|
||||
{
|
||||
m_pPhysX_Manager->ReleaseController(iControllerIndex);
|
||||
}
|
||||
void CGameInstance::Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor)
|
||||
void CGameInstance::Attach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
m_pPhysX_Manager->Attach_Actor(RigidBody, Actor);
|
||||
m_pPhysX_Manager->Attach_Actor(Actor);
|
||||
}
|
||||
void CGameInstance::Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor)
|
||||
void CGameInstance::Detach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
m_pPhysX_Manager->Detach_Actor(RigidBody, pActor);
|
||||
m_pPhysX_Manager->Detach_Actor(Actor);
|
||||
}
|
||||
void CGameInstance::Release_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
m_pPhysX_Manager->Detach_Actor(Actor);
|
||||
}
|
||||
HRESULT CGameInstance::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix)
|
||||
{
|
||||
|
||||
@@ -315,12 +315,12 @@ void CModel::Set_AnimSpeed(_float fSpeed)
|
||||
|
||||
void CModel::Set_Anim(CModel* Source)
|
||||
{
|
||||
m_Animations = Source->m_Animations;
|
||||
for (auto& Animations : Source->m_Animations)
|
||||
{
|
||||
m_Animations.push_back(Animations);
|
||||
}
|
||||
|
||||
for (auto& anim : m_Animations)
|
||||
anim->Remap_Channels_By_Name(this);
|
||||
|
||||
m_iNumAnimations = (_uint)m_Animations.size();
|
||||
m_iNumAnimations += (_uint)Source->m_Animations.size();
|
||||
}
|
||||
|
||||
|
||||
@@ -881,6 +881,7 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
||||
}
|
||||
m_pSaveModel = m_pGameInstance->Load_SaveModel(pModelFilePath);
|
||||
|
||||
LoadAdditionalAnimations(pModelFilePath);
|
||||
|
||||
XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix);
|
||||
|
||||
@@ -909,6 +910,35 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CModel::LoadAdditionalAnimations(const char* ModelFilePath)
|
||||
{
|
||||
filesystem::path fullPath(ModelFilePath);
|
||||
filesystem::path folder = fullPath.parent_path();
|
||||
_string baseName = fullPath.stem().string();
|
||||
|
||||
_string defaultModel = fullPath.filename().string();
|
||||
|
||||
for (auto& entry : filesystem::directory_iterator(folder))
|
||||
{
|
||||
if (!entry.is_regular_file())
|
||||
continue;
|
||||
|
||||
auto file = entry.path().filename().string();
|
||||
auto stem = entry.path().stem().string();
|
||||
auto ext = entry.path().extension().string();
|
||||
|
||||
if (ext != ".bin")
|
||||
continue;
|
||||
|
||||
if (file == defaultModel)
|
||||
continue;
|
||||
|
||||
if (stem.rfind(baseName, 0) == 0)
|
||||
{
|
||||
LoadAnim(entry.path().string().c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_bool CModel::LoadData(const _char* filename)
|
||||
@@ -1043,6 +1073,108 @@ _bool CModel::LoadData(const _char* filename)
|
||||
return true;
|
||||
}
|
||||
|
||||
void CModel::LoadAnim(const _char* fileName)
|
||||
{
|
||||
FILE* fp = nullptr;
|
||||
fopen_s(&fp, fileName, "rb");
|
||||
if (!fp) return;
|
||||
|
||||
_uint MeshCount, MaterialCount, AnimationCount, NodeCount;
|
||||
|
||||
fread(&MeshCount, sizeof(_uint), 1, fp);
|
||||
fread(&MaterialCount, sizeof(_uint), 1, fp);
|
||||
fread(&AnimationCount, sizeof(_uint), 1, fp);
|
||||
fread(&NodeCount, sizeof(_uint), 1, fp);
|
||||
|
||||
for (_uint i = 0; i < MeshCount; i++)
|
||||
{
|
||||
_uint nameSize, vtxCount, idxCount, matIndex, boneCount;
|
||||
|
||||
fread(&nameSize, sizeof(_uint), 1, fp);
|
||||
fseek(fp, nameSize, SEEK_CUR);
|
||||
|
||||
fread(&vtxCount, sizeof(_uint), 1, fp);
|
||||
fread(&idxCount, sizeof(_uint), 1, fp);
|
||||
fread(&matIndex, sizeof(_uint), 1, fp);
|
||||
fread(&boneCount, sizeof(_uint), 1, fp);
|
||||
|
||||
fseek(fp, sizeof(SaveVertex) * vtxCount, SEEK_CUR);
|
||||
|
||||
fseek(fp, sizeof(_uint) * idxCount, SEEK_CUR);
|
||||
|
||||
for (_uint b = 0; b < boneCount; b++)
|
||||
{
|
||||
_uint boneNameSize = 0;
|
||||
fread(&boneNameSize, sizeof(_uint), 1, fp);
|
||||
fseek(fp, boneNameSize, SEEK_CUR);
|
||||
|
||||
fseek(fp, sizeof(_float4x4), SEEK_CUR);
|
||||
|
||||
_uint weightCount = 0;
|
||||
fread(&weightCount, sizeof(_uint), 1, fp);
|
||||
fseek(fp, (sizeof(_uint) + sizeof(_float)) * weightCount, SEEK_CUR);
|
||||
}
|
||||
}
|
||||
|
||||
for (_uint i = 0; i < NodeCount; i++)
|
||||
{
|
||||
_uint nodeNameSize;
|
||||
fread(&nodeNameSize, sizeof(_uint), 1, fp);
|
||||
fseek(fp, nodeNameSize, SEEK_CUR);
|
||||
|
||||
fseek(fp, sizeof(int), SEEK_CUR);
|
||||
fseek(fp, sizeof(XMFLOAT4X4), SEEK_CUR);
|
||||
|
||||
_uint childrenCount;
|
||||
fread(&childrenCount, sizeof(_uint), 1, fp);
|
||||
fseek(fp, sizeof(_int) * childrenCount, SEEK_CUR);
|
||||
}
|
||||
|
||||
for (_uint i = 0; i < AnimationCount; i++)
|
||||
{
|
||||
SaveAnimation saveAnim = {};
|
||||
|
||||
fread(&saveAnim.AnimNameSize, sizeof(_uint), 1, fp);
|
||||
saveAnim.AnimName.resize(saveAnim.AnimNameSize);
|
||||
fread(saveAnim.AnimName.data(), 1, saveAnim.AnimNameSize, fp);
|
||||
|
||||
fread(&saveAnim.mDuration, sizeof(_float), 1, fp);
|
||||
fread(&saveAnim.mTicksPerSecond, sizeof(_float), 1, fp);
|
||||
|
||||
fread(&saveAnim.ChannelCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels.resize(saveAnim.ChannelCount);
|
||||
|
||||
for (size_t j = 0; j < saveAnim.ChannelCount; j++)
|
||||
{
|
||||
fread(&saveAnim.Channels[j].ChannelNameSize, sizeof(_uint), 1, fp);
|
||||
|
||||
saveAnim.Channels[j].ChannelName.resize(saveAnim.Channels[j].ChannelNameSize);
|
||||
fread(saveAnim.Channels[j].ChannelName.data(), 1, saveAnim.Channels[j].ChannelNameSize, fp);
|
||||
|
||||
fread(&saveAnim.Channels[j].ScalingKeyCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels[j].ScalingKeys.resize(saveAnim.Channels[j].ScalingKeyCount);
|
||||
fread(saveAnim.Channels[j].ScalingKeys.data(),
|
||||
sizeof(SaveKeyFrameVec), saveAnim.Channels[j].ScalingKeyCount, fp);
|
||||
|
||||
fread(&saveAnim.Channels[j].RotationKeyCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels[j].RotationKeys.resize(saveAnim.Channels[j].RotationKeyCount);
|
||||
fread(saveAnim.Channels[j].RotationKeys.data(),
|
||||
sizeof(SaveKeyFrameRotation), saveAnim.Channels[j].RotationKeyCount, fp);
|
||||
|
||||
fread(&saveAnim.Channels[j].PositionKeyCount, sizeof(_uint), 1, fp);
|
||||
saveAnim.Channels[j].PositionKeys.resize(saveAnim.Channels[j].PositionKeyCount);
|
||||
fread(saveAnim.Channels[j].PositionKeys.data(),
|
||||
sizeof(SaveKeyFrameVec), saveAnim.Channels[j].PositionKeyCount, fp);
|
||||
}
|
||||
|
||||
m_pSaveModel->Animations.push_back(saveAnim);
|
||||
m_pSaveModel->AnimationCount++;
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
|
||||
HRESULT CModel::Initialize(void* pArg)
|
||||
{
|
||||
m_pLerpAnim = CLerpAnim::Create((_uint)m_Bones.size(), 1.f, m_Bones);
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
#include "PhysX_Manager.h"
|
||||
#include "GameObject.h"
|
||||
#include "GameInstance.h"
|
||||
#include "RigidBody.h"
|
||||
#include "RigidBody_Dynamic.h"
|
||||
#include "RigidBody_Static.h"
|
||||
#include "Mesh.h"
|
||||
|
||||
CPhysX_Manager::CPhysX_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) :
|
||||
@@ -15,7 +16,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);
|
||||
@@ -54,8 +55,6 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBody)
|
||||
PSX::PxRigidBodyFlags pxRigidFlags = RigidBody.Get_RigidBodyFlags();
|
||||
pActorDynamic->setRigidBodyFlags(pxRigidFlags);
|
||||
|
||||
|
||||
|
||||
if (pxRigidFlags.isSet(PSX::PxRigidBodyFlag::eKINEMATIC)) {
|
||||
|
||||
}
|
||||
@@ -63,12 +62,13 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody& RigidBody)
|
||||
PSX::PxRigidBodyExt::updateMassAndInertia(*pActorDynamic, (PSX::PxReal)RigidBody.Get_Density());
|
||||
}
|
||||
|
||||
Attach_Actor(RigidBody, *pActorDynamic);
|
||||
m_pRestBodies.insert(pActorDynamic);
|
||||
Attach_Actor(*pActorDynamic);
|
||||
|
||||
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);
|
||||
@@ -118,8 +118,8 @@ PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody)
|
||||
pShape->setContactOffset(RigidBody.Get_ContactOffset());
|
||||
pShape->setRestOffset(0.f);
|
||||
|
||||
|
||||
Attach_Actor(RigidBody, *pActor);
|
||||
m_pRestBodies.insert(pActor);
|
||||
Attach_Actor(*pActor);
|
||||
|
||||
return pActor;
|
||||
}
|
||||
@@ -222,47 +222,9 @@ HRESULT CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangle
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
// 바이너리 로드에는 128B 정렬된 메모리 포인터를 넘겨야 함. InputData 그대로 넘기면 안됨
|
||||
// 심지어 바이너리로 불러온 블럭은 피직스의 모든 메시들을 릴리즈 한 뒤에 해제 해야 함
|
||||
//_bool CPhysX_Manager::LoadTriMeshes_Binary(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
//{
|
||||
// filesystem::path pathPhysX = pPath;
|
||||
// pathPhysX.replace_extension(".bmap");
|
||||
//
|
||||
// PSX::PxSerializationRegistry* pSerializationRegistry = PSX::PxSerialization::createSerializationRegistry(*m_pPhysics);
|
||||
//
|
||||
// PSX::PxDefaultFileInputData InputData(pathPhysX.string().c_str());
|
||||
// PSX::PxCollection* extRefs = PxCreateCollection();
|
||||
//
|
||||
// PSX::PxCollection* pCollections = PSX::PxSerialization::createCollectionFromBinary(&InputData, *pSerializationRegistry, extRefs);
|
||||
// if (nullptr == pCollections) {
|
||||
// extRefs->release();
|
||||
// pSerializationRegistry->release();
|
||||
// assert(pCollections);
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// const PSX::PxU32 iNumTriMeshes = pCollections->getNbObjects();
|
||||
// TriMeshes.reserve(iNumTriMeshes);
|
||||
// for (PSX::PxU32 i = 0; i < iNumTriMeshes; ++i) {
|
||||
// PSX::PxBase& pObject = pCollections->getObject(i);
|
||||
//
|
||||
// if (pObject.getConcreteType() == PSX::PxConcreteType::eTRIANGLE_MESH_BVH34) {
|
||||
// PSX::PxTriangleMesh* pTriMesh = static_cast<PSX::PxTriangleMesh*>(&pObject);
|
||||
// pTriMesh->acquireReference();
|
||||
// TriMeshes.push_back(pTriMesh);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// extRefs->release();
|
||||
// pCollections->release();
|
||||
// pSerializationRegistry->release();
|
||||
// return true;
|
||||
//}
|
||||
|
||||
PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _wstring& wstrMeshKey)
|
||||
PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _tchar* pMeshName)
|
||||
{
|
||||
map<_wstring, PSX::PxTriangleMesh*>::iterator iter = m_TriangleMeshes.find(wstrMeshKey);
|
||||
map<_wstring, PSX::PxTriangleMesh*>::iterator iter = m_TriangleMeshes.find(pMeshName);
|
||||
if (iter != m_TriangleMeshes.end()) {
|
||||
return iter->second;
|
||||
}
|
||||
@@ -271,18 +233,16 @@ PSX::PxTriangleMesh* CPhysX_Manager::Find_TriangleMesh(const _wstring& wstrMeshK
|
||||
|
||||
void CPhysX_Manager::Update_Kinematic()
|
||||
{
|
||||
for (auto& pairBody : m_RigidBodys) {
|
||||
PSX::PxRigidDynamic* pActor = pairBody.second->is<PSX::PxRigidDynamic>();
|
||||
for (auto& pBody : m_pActiveBodys) {
|
||||
PSX::PxRigidDynamic* pActor = pBody->is<PSX::PxRigidDynamic>();
|
||||
if (nullptr == pActor) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pActor->getRigidBodyFlags() & PSX::PxRigidBodyFlag::eKINEMATIC)
|
||||
{
|
||||
CRigidBody* pBody = pairBody.first;
|
||||
const CTransform* pTransform = pBody->Get_TransformPtr();
|
||||
const CTransform* pTransform = static_cast<PhsXUserData*>(pBody->userData)->pOwner->Get_Component<CTransform>();
|
||||
|
||||
|
||||
pActor->setKinematicTarget(XMWorldToPx_NoScale(pTransform->Get_XMWorldMatrix()));
|
||||
}
|
||||
}
|
||||
@@ -320,10 +280,6 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
|
||||
}
|
||||
CTransform* pTransform = pUserData->pOwner->Get_Component<CTransform>();
|
||||
|
||||
|
||||
// PSX::PxTransform pPrevPxTransform = pUserData->m_BeforeMatrix;
|
||||
// XMMatrixDecompose(nullptr, (_vector*)&pPrevPxTransform.q, (_vector*)&pPrevPxTransform.p, XMLoadFloat4x4(&pUserData->m_BeforeMatrix));
|
||||
|
||||
PSX::PxTransform pPxTransform = pActorDynamic->getGlobalPose();
|
||||
_float3 vOriginalScale = pTransform->Get_Scale();
|
||||
_matrix WorldMatrix = {};
|
||||
@@ -332,60 +288,58 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
|
||||
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::Update_Dynamic_AllActors()
|
||||
//{
|
||||
// for (pair<CRigidBody*, PSX::PxActor*>& pairActors : m_RigidBodys) {
|
||||
// PSX::PxRigidDynamic* pActorDynamic = pairActors.second->is<PSX::PxRigidDynamic>();
|
||||
// if (nullptr != pActorDynamic) {
|
||||
// CTransform* pTransform = ((CRigidBody*)(pActorDynamic->userData))->Get_TransformPtr();
|
||||
//
|
||||
// PSX::PxTransform pxTransform = pActorDynamic->getGlobalPose();
|
||||
// _float3 vOriginalScale = pTransform->Get_Scale();
|
||||
// _matrix WorldMatrix = {};
|
||||
// WorldMatrix = XMMatrixAffineTransformation(XMLoadFloat3(&vOriginalScale), XMVectorZero(), XMLoadFloat4((_float4*)&pxTransform.q), XMLoadFloat3((_float3*)&pxTransform.p));
|
||||
// pTransform->Set_WorldMatrix(WorldMatrix);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
void CPhysX_Manager::ClearScene()
|
||||
{
|
||||
for (auto& pObject : m_RigidBodys) {
|
||||
pObject.second->release();
|
||||
} m_RigidBodys.clear();
|
||||
for (auto& pBody : m_pActiveBodys) {
|
||||
pBody->release();
|
||||
} m_pActiveBodys.clear();
|
||||
for (auto& pBody : m_pRestBodies) {
|
||||
pBody->release();
|
||||
} m_pRestBodies.clear();
|
||||
}
|
||||
void CPhysX_Manager::Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor)
|
||||
void CPhysX_Manager::Attach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
if (m_pScene == nullptr){
|
||||
unordered_set<PSX::PxActor*>::iterator iter = m_pRestBodies.find(&Actor);
|
||||
if (m_pRestBodies.end() == iter) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_RigidBodys.emplace_back(&RigidBody, &Actor);
|
||||
m_pScene->addActor(Actor);
|
||||
else {
|
||||
m_pRestBodies.erase(&Actor);
|
||||
}
|
||||
m_pActiveBodys.insert(&Actor);
|
||||
if (m_pScene != nullptr) {
|
||||
m_pScene->addActor(Actor);
|
||||
}
|
||||
}
|
||||
|
||||
void CPhysX_Manager::Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor)
|
||||
unordered_set<PSX::PxActor*>::iterator CPhysX_Manager::Detach_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
if (m_pScene == nullptr){
|
||||
return;
|
||||
}
|
||||
|
||||
list<pair<CRigidBody*, PSX::PxActor*>>::iterator iter = m_RigidBodys.begin();
|
||||
for (; iter != m_RigidBodys.end(); ++iter){
|
||||
if ((*iter).second == pActor) {
|
||||
m_RigidBodys.erase(iter);
|
||||
break;
|
||||
unordered_set<PSX::PxActor*>::iterator iterOut = m_pRestBodies.end();
|
||||
unordered_set<PSX::PxActor*>::iterator iter = m_pActiveBodys.find(&Actor);
|
||||
if (m_pActiveBodys.end() != iter) {
|
||||
m_pActiveBodys.erase(iter); // 액터를 활성화 맵에서 분리 해주고
|
||||
iterOut = m_pRestBodies.insert(&Actor).first; // 액터를 다시 쓸 수 있기 때문에 따로 보관해줌
|
||||
if (m_pScene != nullptr) {
|
||||
m_pScene->removeActor(Actor);
|
||||
}
|
||||
}
|
||||
|
||||
m_pScene->removeActor(*pActor);
|
||||
return iterOut;
|
||||
}
|
||||
|
||||
void CPhysX_Manager::Release_Actor(PSX::PxActor& Actor)
|
||||
{
|
||||
// 혹시 활성화 맵에 들어있을 수도 있으니 검사
|
||||
unordered_set<PSX::PxActor*>::iterator iterResult = Detach_Actor(Actor);
|
||||
if (m_pRestBodies.end() != iterResult) { // 방금 전까지만 해도 활성화 중이었던 액터 라면
|
||||
m_pRestBodies.erase(iterResult); // 바로 지워줌
|
||||
}
|
||||
else {
|
||||
m_pActiveBodys.erase(&Actor);
|
||||
m_pRestBodies.erase(&Actor);
|
||||
}
|
||||
Actor.release();
|
||||
}
|
||||
|
||||
PSX::PxController* CPhysX_Manager::Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc)
|
||||
@@ -441,7 +395,7 @@ HRESULT CPhysX_Manager::Initialize()
|
||||
}
|
||||
|
||||
if (FAILED(Connect_DebugServer())) {
|
||||
assert(false);
|
||||
ASSERT_NURI(false);
|
||||
}
|
||||
|
||||
{ // 씬 세팅
|
||||
@@ -512,10 +466,17 @@ HRESULT CPhysX_Manager::Initialize()
|
||||
// m_pScene->overlap();??????
|
||||
|
||||
#ifdef 기무리
|
||||
PlaneData.eKind = PHYSX_KIND::BODY_STATIC;
|
||||
PlaneData.iSubKind = UINT_MAX;
|
||||
PlaneData.pOwner = nullptr;
|
||||
PlaneData.pBody = nullptr;
|
||||
|
||||
m_pMaterials.reserve(ENUM_CLASS(PXMATERIAL::END));
|
||||
m_pMaterials.push_back(m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f));
|
||||
PSX::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *m_pMaterials[ENUM_CLASS(PXMATERIAL::DEFAULT)]);
|
||||
m_pScene->addActor(*pGroundPlane);
|
||||
pGroundPlane->userData = &PlaneData;
|
||||
pGroundPlane->setName("PHYSX_MANAGER_PLANE");
|
||||
m_pScene->addActor(*pGroundPlane);;
|
||||
|
||||
//{
|
||||
// float halfExtent = .5f;
|
||||
@@ -555,7 +516,9 @@ HRESULT CPhysX_Manager::Connect_DebugServer()
|
||||
assert(false);
|
||||
return E_FAIL;
|
||||
}
|
||||
m_pPvd->connect(*m_pTransport, PSX::PxPvdInstrumentationFlag::eALL);
|
||||
if (false == (m_pPvd->connect(*m_pTransport, PSX::PxPvdInstrumentationFlag::eALL))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -571,9 +534,7 @@ CPhysX_Manager* CPhysX_Manager::Create(ID3D11Device* pDevice, ID3D11DeviceContex
|
||||
|
||||
void CPhysX_Manager::Free()
|
||||
{
|
||||
for (auto& pObjects : m_RigidBodys) {
|
||||
pObjects.second->release();
|
||||
} m_RigidBodys.clear();
|
||||
ClearScene();
|
||||
|
||||
for (auto& pMeshes : m_TriangleMeshes) {
|
||||
pMeshes.second->release();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "pch.h"
|
||||
#include "pch.h"
|
||||
#include "PipeLine.h"
|
||||
|
||||
CPipeLine::CPipeLine()
|
||||
@@ -30,6 +30,40 @@ const _vector CPipeLine::Get_CamXMPosition()
|
||||
return XMLoadFloat4(&m_vCamPosition);
|
||||
}
|
||||
|
||||
void CPipeLine::Transform_Frustum_ToLocalSpace(_fmatrix WorldMatrixInverse)
|
||||
{
|
||||
_float4 vLocalPoints[8] = {};
|
||||
for (size_t i = 0; i < 8; i++)
|
||||
{
|
||||
XMStoreFloat4(&vLocalPoints[i],
|
||||
XMVector3TransformCoord(XMLoadFloat4(&m_vWorldPoints[i]), WorldMatrixInverse));
|
||||
}
|
||||
|
||||
Make_Planes(vLocalPoints, m_vLocalPlanes);
|
||||
}
|
||||
|
||||
_bool CPipeLine::isIn_WorldFrustum(_fvector vWorldPos, _float fRadius)
|
||||
{
|
||||
for (size_t i = 0; i < 6; i++)
|
||||
{
|
||||
if (fRadius < XMVectorGetX(XMPlaneDotCoord(XMLoadFloat4(&m_vWorldPlanes[i]), vWorldPos)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
_bool CPipeLine::isIn_LocalFrustum(_fvector vLocalPos, _float fRadius)
|
||||
{
|
||||
for (size_t i = 0; i < 6; i++)
|
||||
{
|
||||
if (fRadius < XMVectorGetX(XMPlaneDotCoord(XMLoadFloat4(&m_vLocalPlanes[i]), vLocalPos)))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPipeLine::Update()
|
||||
{
|
||||
for (_uint i = ENUM_CLASS(D3DTS::VIEW_INV); i < ENUM_CLASS(D3DTS::END); ++i)
|
||||
@@ -38,11 +72,53 @@ void CPipeLine::Update()
|
||||
}
|
||||
|
||||
memcpy(&m_vCamPosition, &m_TransformStateMatrices[ENUM_CLASS(D3DTS::VIEW_INV)].m[3], sizeof(_float4));
|
||||
_matrix ProjInvMatrix = XMLoadFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(D3DTS::PROJ_INV)]);
|
||||
_matrix ViewInvMatrix = XMLoadFloat4x4(&m_TransformStateMatrices[ENUM_CLASS(D3DTS::VIEW_INV)]);
|
||||
for (size_t i = 0; i < 8; i++)
|
||||
{
|
||||
XMStoreFloat4(&m_vWorldPoints[i], XMVector3TransformCoord(XMLoadFloat4(&m_vOriginalPoints[i]), ProjInvMatrix));
|
||||
XMStoreFloat4(&m_vWorldPoints[i], XMVector3TransformCoord(XMLoadFloat4(&m_vWorldPoints[i]), ViewInvMatrix));
|
||||
}
|
||||
|
||||
Make_Planes(m_vWorldPoints, m_vWorldPlanes);
|
||||
}
|
||||
|
||||
HRESULT CPipeLine::Initialize()
|
||||
{
|
||||
m_vOriginalPoints[0] = _float4(-1.f, 1.f, 0.f, 1.f); // LT
|
||||
m_vOriginalPoints[1] = _float4(1.f, 1.f, 0.f, 1.f); // RT
|
||||
m_vOriginalPoints[2] = _float4(1.f, -1.f, 0.f, 1.f); // RB
|
||||
m_vOriginalPoints[3] = _float4(-1.f, -1.f, 0.f, 1.f); // LB
|
||||
|
||||
m_vOriginalPoints[4] = _float4(-1.f, 1.f, 1.f, 1.f); // LT
|
||||
m_vOriginalPoints[5] = _float4(1.f, 1.f, 1.f, 1.f); // RT
|
||||
m_vOriginalPoints[6] = _float4(1.f, -1.f, 1.f, 1.f); // RB
|
||||
m_vOriginalPoints[7] = _float4(-1.f, -1.f, 1.f, 1.f); // LB
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
void CPipeLine::Make_Planes(const _float4* pPoints, _float4* pPlanes)
|
||||
{
|
||||
XMStoreFloat4(&pPlanes[0], XMPlaneFromPoints(XMLoadFloat4(&pPoints[1]), XMLoadFloat4(&pPoints[5]), XMLoadFloat4(&pPoints[6])));
|
||||
XMStoreFloat4(&pPlanes[1], XMPlaneFromPoints(XMLoadFloat4(&pPoints[4]), XMLoadFloat4(&pPoints[0]), XMLoadFloat4(&pPoints[3])));
|
||||
XMStoreFloat4(&pPlanes[2], XMPlaneFromPoints(XMLoadFloat4(&pPoints[4]), XMLoadFloat4(&pPoints[5]), XMLoadFloat4(&pPoints[1])));
|
||||
XMStoreFloat4(&pPlanes[3], XMPlaneFromPoints(XMLoadFloat4(&pPoints[3]), XMLoadFloat4(&pPoints[2]), XMLoadFloat4(&pPoints[6])));
|
||||
XMStoreFloat4(&pPlanes[4], XMPlaneFromPoints(XMLoadFloat4(&pPoints[5]), XMLoadFloat4(&pPoints[4]), XMLoadFloat4(&pPoints[7])));
|
||||
XMStoreFloat4(&pPlanes[5], XMPlaneFromPoints(XMLoadFloat4(&pPoints[0]), XMLoadFloat4(&pPoints[1]), XMLoadFloat4(&pPoints[2])));
|
||||
}
|
||||
|
||||
CPipeLine* CPipeLine::Create()
|
||||
{
|
||||
return new CPipeLine();
|
||||
CPipeLine* pInstance = new CPipeLine();
|
||||
|
||||
if (FAILED(pInstance->Initialize()))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CPipeLine");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
void CPipeLine::Free()
|
||||
{
|
||||
|
||||
@@ -15,71 +15,24 @@ CRenderer::CRenderer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
|
||||
SAFE_ADDREF(m_pGameInstance);
|
||||
}
|
||||
|
||||
|
||||
void CRenderer::Refresh_Renderer()
|
||||
HRESULT CRenderer::Add_RenderGroup(RENDER eRenderGroup, CGameObject* pRenderObject)
|
||||
{
|
||||
if (nullptr == m_pGameInstance->Get_CamPosition()) {
|
||||
return;
|
||||
}
|
||||
_matrix matViewInv = m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW);
|
||||
_matrix matProjInv = m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ);
|
||||
|
||||
matProjInv = XMMatrixInverse(nullptr, matProjInv);
|
||||
matViewInv = XMMatrixInverse(nullptr, matViewInv);
|
||||
|
||||
memcpy_s(&m_CubeViewFrustum, sizeof(_float3) * 8, m_CubeNDC, sizeof(_float3) * 8);
|
||||
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
XMStoreFloat3(&m_CubeViewFrustum[i], XMVector3TransformCoord(XMVectorSet(m_CubeViewFrustum[i].x, m_CubeViewFrustum[i].y, m_CubeViewFrustum[i].z, 1.f), matProjInv));
|
||||
XMStoreFloat3(&m_CubeViewFrustum[i], XMVector3TransformCoord(XMVectorSet(m_CubeViewFrustum[i].x, m_CubeViewFrustum[i].y, m_CubeViewFrustum[i].z, 1.f), matViewInv));
|
||||
}
|
||||
// 0(1, 3, 4), 6(2, 5, 7) ( 법선벡터 후보 )
|
||||
// 0, 6( 한 점 후보)
|
||||
//_float3 m_CubeNDC[8] = {
|
||||
// 근 좌하 우하 우상 좌상
|
||||
// 원 좌하 우하 우상 좌상
|
||||
// 0, 1, 2, 3
|
||||
// 4, 5, 6, 7
|
||||
//{ -1.f, -1.f, 0.f }, { 1.f, -1.f, 0.f }, { 1.f, 1.f, 0.f }, { -1.f, 1.f, 0.f },
|
||||
//{ -1.f, -1.f, 1.f }, { 1.f, -1.f, 1.f }, { 1.f, 1.f, 1.f }, { -1.f, 1.f, 1.f }
|
||||
//};
|
||||
_vector vPlanes[8] = {};
|
||||
XMStoreFloat4(&m_vPlanes[0], XMPlaneNormalize(XMPlaneFromPoints(XMLoadFloat3(&m_CubeViewFrustum[0]), XMLoadFloat3(&m_CubeViewFrustum[3]), XMLoadFloat3(&m_CubeViewFrustum[4]))));
|
||||
XMStoreFloat4(&m_vPlanes[1], XMPlaneNormalize(XMPlaneFromPoints(XMLoadFloat3(&m_CubeViewFrustum[5]), XMLoadFloat3(&m_CubeViewFrustum[6]), XMLoadFloat3(&m_CubeViewFrustum[2]))));
|
||||
XMStoreFloat4(&m_vPlanes[2], XMPlaneNormalize(XMPlaneFromPoints(XMLoadFloat3(&m_CubeViewFrustum[1]), XMLoadFloat3(&m_CubeViewFrustum[2]), XMLoadFloat3(&m_CubeViewFrustum[3]))));
|
||||
XMStoreFloat4(&m_vPlanes[3], XMPlaneNormalize(XMPlaneFromPoints(XMLoadFloat3(&m_CubeViewFrustum[4]), XMLoadFloat3(&m_CubeViewFrustum[7]), XMLoadFloat3(&m_CubeViewFrustum[6]))));
|
||||
XMStoreFloat4(&m_vPlanes[4], XMPlaneNormalize(XMPlaneFromPoints(XMLoadFloat3(&m_CubeViewFrustum[0]), XMLoadFloat3(&m_CubeViewFrustum[4]), XMLoadFloat3(&m_CubeViewFrustum[5]))));
|
||||
XMStoreFloat4(&m_vPlanes[5], XMPlaneNormalize(XMPlaneFromPoints(XMLoadFloat3(&m_CubeViewFrustum[3]), XMLoadFloat3(&m_CubeViewFrustum[2]), XMLoadFloat3(&m_CubeViewFrustum[7]))));
|
||||
}
|
||||
|
||||
HRESULT CRenderer::Add_RenderGroup(RENDER eRenderGroup, CGameObject* pRenderObject, _float4& vPos, _float fCullRadius)
|
||||
{
|
||||
if (nullptr == pRenderObject)
|
||||
if (nullptr == pRenderObject || pRenderObject->isDead()){
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_bool bPossible = { true };
|
||||
//if (pRenderObject->isDead()) {
|
||||
// return E_FAIL;
|
||||
//}
|
||||
//// 프러스텀컬링 예외 추가
|
||||
//if (RENDER::UI == eRenderGroup || RENDER::PRIORITY == eRenderGroup /* || RENDER::SHADOW == eRenderGroup*/ || RENDER::BLUR == eRenderGroup) {
|
||||
// m_RenderObjects[ENUM_CLASS(eRenderGroup)].push_back(pRenderObject);
|
||||
// SAFE_ADDREF(pRenderObject);
|
||||
// return S_OK;
|
||||
//}
|
||||
//for (int i = 0; i < 6; ++i) {
|
||||
// if (XMVectorGetX(XMVector4Dot(XMLoadFloat4(&m_vPlanes[i]),
|
||||
// XMLoadFloat4(&vPos))) + fCullRadius < 0) {
|
||||
// bPossible = false;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
if (bPossible) {
|
||||
_bool bPossible = { false };
|
||||
// 프러스텀컬링 예외 추가
|
||||
if (RENDER::UI == eRenderGroup || RENDER::PRIORITY == eRenderGroup /* || RENDER::SHADOW == eRenderGroup*/ || RENDER::BLUR == eRenderGroup) {
|
||||
bPossible = true;
|
||||
}
|
||||
bPossible = true;
|
||||
if (true == bPossible) {
|
||||
m_RenderObjects[ENUM_CLASS(eRenderGroup)].push_back(pRenderObject);
|
||||
SAFE_ADDREF(pRenderObject);
|
||||
return S_OK;
|
||||
}
|
||||
return S_OK;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
@@ -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<PSX::PxRigidDynamic*>(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<PSX::PxRigidDynamic*>(m_pRigidBody)->addForce(vPxForce, eType);
|
||||
}
|
||||
|
||||
void CRigidBody::Add_Torque(_fvector vDirection, PSX::PxForceMode::Enum eType)
|
||||
{
|
||||
PSX::PxVec3 vPxTorque = {};
|
||||
XMStoreFloat3((_float3*)&vPxTorque, vDirection);
|
||||
static_cast<PSX::PxRigidDynamic*>(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,13 @@ HRESULT CRigidBody::Initialize(void* pArg)
|
||||
m_pTransform = m_pOwner->Get_Component<CTransform>();
|
||||
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
|
||||
m_tagData.iSubKind = pDesc->iSubKind;
|
||||
|
||||
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);
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
#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),
|
||||
m_PxMassCenter(rhs.m_PxMassCenter),
|
||||
m_eLockFlag(rhs.m_eLockFlag),
|
||||
m_vDamping(rhs.m_vDamping)
|
||||
{
|
||||
}
|
||||
|
||||
#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->addTorque(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_eLockFlag = Desc.eLockFlag;
|
||||
m_PxMassCenter = Desc.pxMassCenter;
|
||||
m_vDamping = Desc.vAutoDamping;
|
||||
|
||||
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.BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
|
||||
m_tagData.pBody = this;
|
||||
m_pRigidBody = m_pGameInstance->Add_DynamicActor(*this);
|
||||
m_pRigidBody->userData = &m_tagData;
|
||||
m_pRigidBody->setCMassLocalPose(m_PxMassCenter);
|
||||
m_pRigidBody->setRigidDynamicLockFlags(m_eLockFlag);
|
||||
m_pRigidBody->setLinearDamping(m_vDamping.x);
|
||||
m_pRigidBody->setAngularDamping(m_vDamping.y);
|
||||
//m_pRigidBody->joint;
|
||||
//PSX::PxRevol
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
HRESULT CRigidBody_Dynamic::Add_DebugShape()
|
||||
{
|
||||
switch (m_eActorType)
|
||||
{
|
||||
case ACTOR::BOX:
|
||||
_float3 vDXGeometricSize = { m_vhalfGeometryInfo.x * 2.f, m_vhalfGeometryInfo.y * 2.f, m_vhalfGeometryInfo.z * 2.f };
|
||||
m_pMainShape = (GeometricPrimitive::CreateBox(m_pContext, vDXGeometricSize, false, false));
|
||||
break;
|
||||
case ACTOR::CAPSULE:
|
||||
m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x * 2.f, 10, false, false));
|
||||
m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, m_vhalfGeometryInfo.y * 2.f, m_vhalfGeometryInfo.x * 2.f, 10, false));
|
||||
break;
|
||||
case ACTOR::SPHERE:
|
||||
m_pMainShape = (GeometricPrimitive::CreateSphere(m_pContext, m_vhalfGeometryInfo.x * 2.f, 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()
|
||||
{
|
||||
}
|
||||
@@ -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.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()
|
||||
{
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "pch.h"
|
||||
#include "pch.h"
|
||||
#include "Transform.h"
|
||||
#include "Shader.h"
|
||||
|
||||
@@ -40,7 +40,7 @@ _vector CTransform::Get_RollPitchYawVector() const
|
||||
_vector vQuaternion = XMQuaternionNormalize(Get_QuarternionVector());
|
||||
|
||||
_float roll, pitch, yaw;
|
||||
{ // XMMatrixRotationRollPitchYawFromVector로 완벽히 복구됨
|
||||
{ // XMMatrixRotationRollPitchYawFromVector로 완벽히 복구됨
|
||||
XMFLOAT4 q;
|
||||
XMStoreFloat4(&q, vQuaternion);
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ class ENGINE_DLL CAnimation : public CBase
|
||||
_float Get_CurrentTrackPosition() { return m_fCurrentTrackPosition; }
|
||||
void Set_AnimSpeed(_float fSpeed) { m_fAnimSpeed = fSpeed; }
|
||||
_float Get_AnimSpeed() { return m_fAnimSpeed; }
|
||||
void Set_Channel(CAnimation* Animation);
|
||||
void Remap_Channels_By_Name(class CModel* TargetModel);
|
||||
#ifdef EDITOR_PROJECT
|
||||
private:
|
||||
|
||||
@@ -12,9 +12,6 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
// kinematic 기반임
|
||||
public:
|
||||
#pragma region STRUCT
|
||||
struct CapsuleInfo
|
||||
{
|
||||
};
|
||||
typedef struct tagCharacter_ControllerDesc
|
||||
{
|
||||
CTransform* pTransform = { nullptr };
|
||||
@@ -23,8 +20,9 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
_float3 fMaterial = { 0.5f, 0.5f, 0.6f };
|
||||
_bool bAutoStepping = { false }; // 계단 높이 타게 할건지 // 박스 콜라이더는 생각한대로 되는데 캡슐은 바닥의 구체 때문에 예상보다 더 높은 곳까지 오를 수 있음
|
||||
_float fStepOffset = { 0.05f }; // 허용가능한 계단 높이, 작게 유지하는게 좋음
|
||||
|
||||
void* pCallback = { }; // move가 호출될 때 호출 됨 // dll을 받는 각 프로젝트에서 CCollision_Callback 을 구현해야함
|
||||
_uint iSubKind = { };
|
||||
PSX::PxUserControllerHitReport* pCallback_HitReport = { }; // move가 호출될 때 호출 됨 // dll을 받는 각 프로젝트에서 구현해야함
|
||||
PSX::PxControllerBehaviorCallback* pCallback_Behavior = { }; // move가 호출될 때 호출 됨 // dll을 받는 각 프로젝트에서 구현해야함
|
||||
|
||||
// 타고 올라갈 수 없는 경사면의 각도를 정의함. 0.f 면 비활성화 됨
|
||||
// _float fSlopeLimit = { 코사인각도 };
|
||||
@@ -49,6 +47,7 @@ class ENGINE_DLL CCharacter_Controller final :
|
||||
#ifdef _DEBUG
|
||||
virtual HRESULT Render() override;
|
||||
#endif
|
||||
PSX::PxRigidDynamic* Get_Actor();
|
||||
|
||||
_float Get_ContactOffset() const { return m_pController->getContactOffset(); }
|
||||
void Set_ContactOffset(_float fValue) { return m_pController->setContactOffset((PSX::PxF32)fValue); }
|
||||
|
||||
@@ -20,7 +20,10 @@ enum class PXMATERIAL {
|
||||
DEFAULT,
|
||||
END,
|
||||
};
|
||||
|
||||
enum class PXBODYSTATE {
|
||||
DYNAMIC,
|
||||
KINEMATIC,
|
||||
};
|
||||
|
||||
enum class MOUSEKEYSTATE { LBUTTON, RBUTTON, WBUTTON, XBUTTON };
|
||||
enum class MOUSEMOVESTATE { X, Y, W };
|
||||
|
||||
@@ -318,10 +318,10 @@ typedef struct tagVertexModelInstanceParticleDesc
|
||||
|
||||
typedef struct tagPhsXUserData {
|
||||
|
||||
PHYSX_KIND eKind = PHYSX_KIND::NOT_DEFINED;
|
||||
_uint iSubKind = UINT_MAX;
|
||||
class CGameObject* pOwner = { nullptr };
|
||||
_float4x4 m_BeforeMatrix = { };
|
||||
PHYSX_KIND eKind = PHYSX_KIND::NOT_DEFINED;
|
||||
class CGameObject* pOwner = { nullptr };
|
||||
_float4x4 BeforeMatrix = { };
|
||||
_uint iSubKind = UINT_MAX;
|
||||
|
||||
union {
|
||||
class CRigidBody* pBody;
|
||||
|
||||
@@ -95,8 +95,7 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
|
||||
|
||||
#pragma region RENDERER
|
||||
void Refresh_Renderer();
|
||||
HRESULT Add_RenderGroup(RENDER eRenderGroup, class CGameObject* pRenderObject, _float4& vPos, _float fCullRadius);
|
||||
HRESULT Add_RenderGroup(RENDER eRenderGroup, class CGameObject* pRenderObject);
|
||||
#pragma endregion
|
||||
|
||||
#pragma region ASSET_MANAGER
|
||||
@@ -117,7 +116,7 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
#pragma region MOUSE_MANAGER
|
||||
POINT Get_MouseViewPortPos();
|
||||
_bool Toggle_MouseCenter();
|
||||
_float3 Get_MouseMove();
|
||||
_float3 Get_MouseMove();
|
||||
void Picking();
|
||||
HRESULT Ray_WorldToLocal(_fmatrix* InvWorldMatrix);
|
||||
_bool MousePicking_InLocalSpace(const _float3& vPointA, const _float3& vPointB, const _float3& vPointC, _float3& pOut);
|
||||
@@ -131,6 +130,10 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
_matrix Get_Transform_Matrix(D3DTS eState);
|
||||
const _float4* Get_CamPosition();
|
||||
const _vector Get_CamXMPosition();
|
||||
void Transform_Frustum_ToLocalSpace(_fmatrix WorldMatrixInverse);
|
||||
_bool isIn_WorldFrustum(_fvector vWorldPos, _float fRadius);
|
||||
_bool isIn_LocalFrustum(_fvector vLocalPos, _float fRadius);
|
||||
|
||||
#pragma endregion
|
||||
#pragma region LIGHT_MANAGER
|
||||
void Add_Light(_uint _iCurrentLevel, class CLight* _pLight);
|
||||
@@ -184,16 +187,17 @@ 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);
|
||||
PSX::PxController* Add_BoxController(PSX::PxBoxControllerDesc& Desc);
|
||||
PSX::PxController* Get_Controller(_uint iControllerIndex);
|
||||
void ReleaseController(_uint iControllerIndex);
|
||||
void Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor);
|
||||
void Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor);
|
||||
void Attach_Actor(PSX::PxActor& Actor);
|
||||
void Detach_Actor(PSX::PxActor& pActor);
|
||||
void Release_Actor(PSX::PxActor& Actor);
|
||||
|
||||
HRESULT ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix = XMMatrixIdentity());
|
||||
HRESULT SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
|
||||
@@ -21,7 +21,7 @@ class ENGINE_DLL CModel final : public CComponent
|
||||
#pragma endregion
|
||||
#pragma region Animation
|
||||
void Change_AnimationIndex(_int iAnimationIndex, _bool bIsLoop, _float fLerpDuration, _bool bIgnoreCurrentIndex = false); // 애니메이션을 다른 인덱스로 변경함
|
||||
_bool Play_Animation(_float fTimeDelta, class CTransform* pTransform); // 애니메이션에 델타타임을 넣어줌
|
||||
_bool Play_Animation(_float fTimeDelta, class CTransform* pTransform = nullptr); // 애니메이션에 델타타임을 넣어줌
|
||||
void RefreshAnim(); // 애님을 현재 애님의 초기상태로 되돌림
|
||||
void Set_AnimationIndex(_uint iIndex, _bool isLoop = true);
|
||||
void Stop_Animation(); // 애니메이션을 정지 (초기상태로)
|
||||
@@ -126,7 +126,9 @@ static _int Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones); /
|
||||
private:
|
||||
// 바이너리
|
||||
virtual HRESULT Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix);
|
||||
void LoadAdditionalAnimations(const char* ModelFilePath);
|
||||
bool LoadData(const _char* filename);
|
||||
void LoadAnim(const _char* fileName);
|
||||
//
|
||||
virtual HRESULT Initialize(void* pArg) override;
|
||||
|
||||
|
||||
@@ -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<PhsXUserData*>(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);
|
||||
}
|
||||
+7
-15
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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<PhsXUserData*>(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<PSX::PxRigidDynamic*>(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<PhsXUserData*>(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;
|
||||
//}
|
||||
}
|
||||
@@ -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; // 사용자 정의 장애물과 부딪힌 경우
|
||||
};
|
||||
@@ -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
|
||||
|
||||
@@ -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,14 +32,14 @@ class CPhysX_Manager final : public CBase
|
||||
HRESULT SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
HRESULT LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
//HRESULT LoadTriMeshes_Binary(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
PSX::PxTriangleMesh* Find_TriangleMesh(const _wstring& wstrMeshKey);
|
||||
PSX::PxTriangleMesh* Find_TriangleMesh(const _tchar* pMeshName);
|
||||
|
||||
void Update(_float fTimeDelta);
|
||||
void ClearScene();
|
||||
void Attach_Actor(CRigidBody& RigidBody, PSX::PxActor& Actor);
|
||||
void Detach_Actor(CRigidBody& RigidBody, PSX::PxActor*& pActor);
|
||||
void Attach_Actor(PSX::PxActor& Actor);
|
||||
unordered_set<PSX::PxActor*>::iterator Detach_Actor(PSX::PxActor& Actor);
|
||||
void Release_Actor(PSX::PxActor& Actor);
|
||||
#pragma endregion
|
||||
|
||||
#pragma region CHARACTER_CONTROLLER
|
||||
/* dev-treadmill.tistory.com/158 */
|
||||
|
||||
@@ -73,9 +75,15 @@ class CPhysX_Manager final : public CBase
|
||||
|
||||
|
||||
|
||||
list<pair<CRigidBody*, PSX::PxActor*>> m_RigidBodys = { };
|
||||
unordered_set<PSX::PxActor*> m_pActiveBodys = { };
|
||||
unordered_set<PSX::PxActor*> m_pRestBodies = { }; // 피직스의 액터로 구별되기 때문에 피직스액터 포인터를 키로 사용함
|
||||
map<_wstring, PSX::PxTriangleMesh*> m_TriangleMeshes = {};
|
||||
map<_wstring, PSX::PxTriangleMeshGeometry*> m_TriangleMeshGeometry = {};
|
||||
#ifdef 기무리
|
||||
PhsXUserData PlaneData = {};
|
||||
|
||||
#endif // 기무리
|
||||
|
||||
|
||||
vector<PSX::PxMaterial*> m_pMaterials = { };
|
||||
_uint m_iNumLevel = {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
@@ -17,6 +17,11 @@ class CPipeLine final : public CBase
|
||||
const _float4* Get_CamPosition();
|
||||
const _vector Get_CamXMPosition();
|
||||
|
||||
void Transform_Frustum_ToLocalSpace(_fmatrix WorldMatrixInverse);
|
||||
_bool isIn_WorldFrustum(_fvector vWorldPos, _float fRadius);
|
||||
_bool isIn_LocalFrustum(_fvector vLocalPos, _float fRadius);
|
||||
|
||||
|
||||
public:
|
||||
void Update();
|
||||
|
||||
@@ -24,10 +29,18 @@ class CPipeLine final : public CBase
|
||||
_float4x4 m_TransformStateMatrices[ENUM_CLASS(D3DTS::END)] = {};
|
||||
_float4 m_vCamPosition = {};
|
||||
|
||||
_float4 m_vOriginalPoints[8] = {};
|
||||
_float4 m_vWorldPoints[8] = {};
|
||||
_float4 m_vWorldPlanes[6] = {};
|
||||
_float4 m_vLocalPlanes[6] = {};
|
||||
|
||||
private:
|
||||
HRESULT Initialize();
|
||||
void Make_Planes(const _float4* pPoints, _float4* pPlanes);
|
||||
public:
|
||||
static CPipeLine* Create();
|
||||
virtual void Free() override;
|
||||
|
||||
};
|
||||
|
||||
NS_END
|
||||
NS_END
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -11,9 +11,8 @@ class CRenderer final : public CBase
|
||||
virtual ~CRenderer() = default;
|
||||
|
||||
public:
|
||||
void Refresh_Renderer();
|
||||
void Render();
|
||||
HRESULT Add_RenderGroup(RENDER eRenderGroup, class CGameObject* pRenderObject, _float4& vPos, _float fCullRadius);
|
||||
HRESULT Add_RenderGroup(RENDER eRenderGroup, class CGameObject* pRenderObject);
|
||||
|
||||
#ifdef _DEBUG
|
||||
private:
|
||||
@@ -39,12 +38,6 @@ class CRenderer final : public CBase
|
||||
_float4x4 m_WorldMatrix = {};
|
||||
_float4x4 m_ViewMatrix = {};
|
||||
_float4x4 m_ProjMatrix = {};
|
||||
_float4 m_vPlanes[6] = {};
|
||||
_float3 m_CubeViewFrustum[8] = {};
|
||||
_float3 m_CubeNDC[8] = {
|
||||
{ -1.f, -1.f, 0.f }, { 1.f, -1.f, 0.f }, { 1.f, 1.f, 0.f }, { -1.f, 1.f, 0.f },
|
||||
{ -1.f, -1.f, 1.f }, { 1.f, -1.f, 1.f }, { 1.f, 1.f, 1.f }, { -1.f, 1.f, 1.f }
|
||||
};
|
||||
|
||||
ID3D11DepthStencilView* m_pShadowDSV = { nullptr };
|
||||
|
||||
|
||||
@@ -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
|
||||
_uint iSubKind = { };
|
||||
}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<GeometricPrimitive> m_pMainShape = { nullptr };
|
||||
unique_ptr<GeometricPrimitive> 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;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#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 }; // 밀도, 실제 무게는 부피에 따라 달라짐
|
||||
PSX::PxRigidDynamicLockFlags eLockFlag = {};
|
||||
PSX::PxTransform pxMassCenter = {};
|
||||
_float2 vAutoDamping = {}; // 0, 0 이면 off, 선형감쇠값, 각 감쇠값
|
||||
}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 }; // 실제 시뮬레이션을 도는 본체
|
||||
PSX::PxRigidDynamicLockFlags m_eLockFlag = { };
|
||||
PSX::PxTransform m_PxMassCenter = {}; // 회전축
|
||||
_float3 m_vMatInfo = {};
|
||||
_float3 m_vhalfGeometryInfo = {};
|
||||
_float2 m_vDamping = { 0.f, 0.f };
|
||||
_float m_fDensity = { 1000.f };
|
||||
|
||||
#ifdef _DEBUG
|
||||
unique_ptr<GeometricPrimitive> m_pMainShape = { nullptr };
|
||||
unique_ptr<GeometricPrimitive> 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
|
||||
@@ -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
|
||||
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
#include "Component.h"
|
||||
|
||||
NS_BEGIN(Engine)
|
||||
@@ -19,7 +19,7 @@ class ENGINE_DLL CTransform final :
|
||||
CTransform(const CTransform& rhs);
|
||||
virtual ~CTransform() = default;
|
||||
public:
|
||||
HRESULT Bind_ShaderResource(class CShader* pShader, const _char* pConstantName) const;
|
||||
HRESULT Bind_ShaderResource(class CShader* pShader, const _char* pConstantName) const;
|
||||
|
||||
void Set_Scale(_float3& vScale);
|
||||
void Mult_Scale(_float3& vScale);
|
||||
@@ -30,7 +30,7 @@ class ENGINE_DLL CTransform final :
|
||||
_float Get_RotationSpeed() const { return m_fRotationPerSec; }
|
||||
_float Get_Radius() const { return m_fRadius; }
|
||||
_float3 Get_Scale() const;
|
||||
_vector Get_QuarternionVector() const; // 현재 회전정보를 담고 있는 쿼터니언 벡터를 out
|
||||
_vector Get_QuarternionVector() const; // 현재 회전정보를 담고 있는 쿼터니언 벡터를 out
|
||||
_vector Get_RollPitchYawVector() const;
|
||||
_vector Get_State(STATE eState) const { return XMLoadFloat4(reinterpret_cast<const _float4*>(&m_WorldMatrix.m[ENUM_CLASS(eState)])); }
|
||||
const _float4* Get_StatePtr(STATE eState) { return reinterpret_cast<_float4*>(&m_WorldMatrix.m[ENUM_CLASS(eState)]); }
|
||||
@@ -60,17 +60,17 @@ class ENGINE_DLL CTransform final :
|
||||
void Rotation(_float fRadianX, _float fRadianY, _float fRadianZ);
|
||||
void Rotation(_float3& vRadian);
|
||||
|
||||
// Up, Down 벡터를 바라보게 하면 터짐
|
||||
// Up, Down 벡터를 바라보게 하면 터짐
|
||||
void LookAt(_fvector vAt);
|
||||
|
||||
private:
|
||||
_float m_fSpeedPerSec = {};
|
||||
_float m_fRotationPerSec = {};
|
||||
_float4x4 m_WorldMatrix = {};
|
||||
_float m_fRadius = {};
|
||||
_float m_fRadius = { 20.f };
|
||||
|
||||
_float3 m_vMomentum = {}; // 현재 프레임에 계산된 이동량
|
||||
_float3 m_vBackMomentum = {}; // 다음 프레임에 계산될 이동량
|
||||
_float3 m_vMomentum = {}; // 현재 프레임에 계산된 이동량
|
||||
_float3 m_vBackMomentum = {}; // 다음 프레임에 계산될 이동량
|
||||
|
||||
private:
|
||||
virtual HRESULT Initialize_Prototype() override;
|
||||
@@ -84,4 +84,4 @@ class ENGINE_DLL CTransform final :
|
||||
virtual void Describe_Entity() override;
|
||||
};
|
||||
|
||||
NS_END
|
||||
NS_END
|
||||
|
||||
Reference in New Issue
Block a user