[add] 플레이어 이동시 따라오는거까지 확인

This commit is contained in:
kimnuri
2025-12-27 19:04:17 +09:00
parent c6da7d680b
commit 7af4c0d495
36 changed files with 1043 additions and 477 deletions
@@ -166,6 +166,7 @@ call Update_Resources.bat
<ClInclude Include="..\Public\CallBack_NonPlayable_Behavior.h" />
<ClInclude Include="..\Public\CallBack_NonPlayable_HitReport.h" />
<ClInclude Include="..\Public\CallBack_Ranrok_HitReport.h" />
<ClInclude Include="..\Public\PlayerRobe.h" />
<ClInclude Include="..\Public\Player_ENUM.h" />
<ClInclude Include="..\Public\State_Fall.h" />
<ClInclude Include="..\Public\State_FireBall.h" />
@@ -401,6 +402,7 @@ call Update_Resources.bat
<ClCompile Include="..\Private\CallBack_NonPlayable_Behavior.cpp" />
<ClCompile Include="..\Private\CallBack_NonPlayable_HitReport.cpp" />
<ClCompile Include="..\Private\CallBack_Ranrok_HitReport.cpp" />
<ClCompile Include="..\Private\PlayerRobe.cpp" />
<ClCompile Include="..\Private\State_Fall.cpp" />
<ClCompile Include="..\Private\TransformationSide.cpp" />
<ClCompile Include="..\Private\Transformation.cpp" />
@@ -725,6 +725,9 @@
<ClInclude Include="..\Public\Player_ENUM.h">
<Filter>02.GameObjects\Player</Filter>
</ClInclude>
<ClInclude Include="..\Public\PlayerRobe.h">
<Filter>02.GameObjects\Player\Robe</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="Client.ico">
@@ -1506,6 +1509,9 @@
<Filter Include="02.GameObjects\PhysX\CallBack\HitReport\Monster\Ranrok">
<UniqueIdentifier>{93545681-c4c5-4a6a-9496-7b2e7b8a9302}</UniqueIdentifier>
</Filter>
<Filter Include="02.GameObjects\Player\Robe">
<UniqueIdentifier>{f3c7cf8d-2b83-49d3-85da-fe135e376a11}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Client.cpp">
@@ -2175,6 +2181,9 @@
<ClCompile Include="..\Private\CallBack_Ranrok_HitReport.cpp">
<Filter>02.GameObjects\PhysX\CallBack\HitReport\Monster\Ranrok</Filter>
</ClCompile>
<ClCompile Include="..\Private\PlayerRobe.cpp">
<Filter>02.GameObjects\Player\Robe</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\Private\Goblin_States.cpp">
@@ -16,7 +16,7 @@ void CCamPosition_Socket::Priority_Update(_float fTimeDelta)
{
/*_matrix socketMatrix = {};
socketMatrix = XMLoadFloat4x4(m_pSocketMatrices);
socketMatrix = XMLoadFloat4x4(m_pSocketMatrix);
for (int i = 0; i < 3; ++i) {
socketMatrix.r[i] = XMVector3Normalize(socketMatrix.r[i]);
@@ -40,7 +40,7 @@ HRESULT CCamPosition_Socket::Initialize_Prototype()
HRESULT CCamPosition_Socket::Initialize(void* pArg)
{
CAMERAPOSITION_PLAYER_DESC* pDesc = static_cast<CAMERAPOSITION_PLAYER_DESC*> (pArg);
//m_pSocketMatrices = pDesc->pSocketMatrices;
//m_pSocketMatrix = pDesc->pSocketMatrix;
if (FAILED(__super::Initialize(pArg)))
{
return E_FAIL;
@@ -581,6 +581,8 @@ HRESULT CLevel_GamePlay::Ready_Layer_Player(const _wstring& strLayerTag)
return E_FAIL;
}
#ifdef 기무리
#else
{
CNPC_Ollivander::NPCDESC NPCDesc{};
NPCDesc.vPos = _float4(40.f, 4.f, 68.9f, 1.f);
@@ -597,6 +599,7 @@ HRESULT CLevel_GamePlay::Ready_Layer_Player(const _wstring& strLayerTag)
return E_FAIL;
}
}
#endif // !기무리
return S_OK;
}
@@ -666,13 +669,13 @@ HRESULT CLevel_GamePlay::Ready_Layer_Monster()
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CTroll>(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) {
return E_FAIL;
}
#endif
#if 진우
#else
if (FAILED(m_pGameInstance->Add_GameObject_ToLayer<CRanrok>(g_iStaticLevel, NEXT_LEVEL, LAYER_MONSTER))) {
return E_FAIL;
}
#endif
#endif
+42 -18
View File
@@ -26,6 +26,7 @@
#pragma region ACTOR
#include "Player.h"
#include "PlayerRobe.h"
#include "Goblin.h"
#include "Goblin_Mage.h"
#include "Goblin_Spector.h"
@@ -1426,9 +1427,8 @@ HRESULT CLoader::Loading_For_GamePlay()
return E_FAIL;
}
#pragma endregion
#endif
#pragma endregion
#pragma region TERRAIN_TEXTURE
/* Terrain_Diffuse */
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Terrain_Diffuse"),
@@ -1762,19 +1762,38 @@ HRESULT CLoader::Loading_For_GamePlay()
CVIBuffer_UI_Instance::Create(m_pDevice, m_pContext, &Quest_Slot_Desc)))) {
return E_FAIL;
}
{
CRigidBody_Dynamic::RIGIDBODY_PROTOTYPE_DYNAMIC_DESC Desc{};
Desc.eType = ACTOR::SPHERE;
Desc.ePxRigidBodyFlags = { /*PSX::PxRigidBodyFlag::eKINEMATIC*/ };
Desc.ePxShapeFlags = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE };
Desc.ePxMaterialTypes = { PXMATERIAL::DEFAULT };
Desc.vMatInfo = { 0.5f, 0.5f, 0.001f };
Desc.fContactOffset = { 0.001f };
Desc.vhalfGeometryInfo = { 0.025f, 0.025f, 0.025f };
Desc.fDensity = 100000.f;
Desc.pxMassCenter = PSX::PxTransform(PSX::PxIDENTITY());
Desc.eLockFlag = {};
Desc.vAutoDamping = { 100.f, 100.f };
Desc.vLocalRotQ = { 0.f, 0.f, 0.f, 1.f };
Desc.vLocalTranslation = { 0.f, 0.f, 0.f };
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_JOINT_ANCHOR"), CRigidBody_Dynamic::Create(m_pDevice, m_pContext, Desc)))) {
return E_FAIL;
}
}
{
CRigidBody_Dynamic::RIGIDBODY_PROTOTYPE_DYNAMIC_DESC Desc{};
Desc.eType = ACTOR::CAPSULE;
Desc.ePxRigidBodyFlags = { /*PSX::PxRigidBodyFlag::eKINEMATIC*/ };
Desc.ePxShapeFlags = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE };
Desc.ePxMaterialTypes = { PXMATERIAL::DEFAULT };
Desc.vMatInfo = { 0.5f, 0.5f, 0.6f };
Desc.fContactOffset = { 0.01f };
Desc.vhalfGeometryInfo = { 0.0025f, 0.15f, 0.f };
Desc.fDensity = 1.f;
Desc.vMatInfo = { 0.5f, 0.5f, 0.001f };
Desc.fContactOffset = { 0.001f };
Desc.vhalfGeometryInfo = { 0.006f, 0.035f, 0.f };
Desc.fDensity = 100000.f;
Desc.pxMassCenter = PSX::PxTransform(PSX::PxIDENTITY());
Desc.eLockFlag = {};
Desc.vAutoDamping = { 1.f, 1.f };
Desc.vAutoDamping = { 100.f, 100.f };
Desc.vLocalRotQ = { 0.f, 0.f, 0.f, 1.f };
Desc.vLocalTranslation = { 0.f, 0.f, 0.f };
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), CRigidBody_Dynamic::Create(m_pDevice, m_pContext, Desc)))) {
@@ -1787,7 +1806,7 @@ HRESULT CLoader::Loading_For_GamePlay()
Desc.ePxRigidBodyFlags = { PSX::PxRigidBodyFlag::eKINEMATIC };
Desc.ePxShapeFlags = { PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE };
Desc.ePxMaterialTypes = { PXMATERIAL::DEFAULT };
Desc.vMatInfo = { 0.5f, 0.5f, 0.6f };
Desc.vMatInfo = { 0.5f, 0.5f, 0.01f };
Desc.fContactOffset = { 0.01f };
Desc.vhalfGeometryInfo = { 0.06f, 0.25f, 0.f };
Desc.fDensity = 1.f;
@@ -1801,7 +1820,7 @@ HRESULT CLoader::Loading_For_GamePlay()
}
}
{
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DynamicJoint"), CDynamic_Joint::Create(m_pDevice, m_pContext)))) {
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DynamicJoint"), CDynamic_D6Joint::Create(m_pDevice, m_pContext)))) {
return E_FAIL;
}
}
@@ -1850,15 +1869,15 @@ HRESULT CLoader::Loading_For_GamePlay()
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_SHIELD"), CRigidBody_Dynamic::Create(m_pDevice, m_pContext, Desc1)))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_CCT_CAPSULE"), CCharacter_Controller::Create(m_pDevice, m_pContext)))) {
return E_FAIL;
}
Desc.ePxRigidBodyFlags = { PSX::PxRigidBodyFlag::eKINEMATIC };
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX_KIN"), CRigidBody_Dynamic::Create(m_pDevice, m_pContext, Desc)))) {
return E_FAIL;
}
}
}
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_CCT_CAPSULE"), CCharacter_Controller::Create(m_pDevice, m_pContext)))) {
return E_FAIL;
}
{ // DOOR PHYSX
CRigidBody_Dynamic::RIGIDBODY_PROTOTYPE_DYNAMIC_DESC Desc{};
{
@@ -1901,9 +1920,10 @@ HRESULT CLoader::Loading_For_GamePlay()
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/PlayableCharacter/Playable.bin", XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))){
return E_FAIL;
}
#ifdef 기무리
#else
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Goblin_Model"),
CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin/Goblin.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))){
CModel::Create(m_pDevice, m_pContext, MODEL::ANIM, "../Bin/Resources/Models/Monster/Goblin/Goblin.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) {
return E_FAIL;
}
@@ -1916,17 +1936,17 @@ HRESULT CLoader::Loading_For_GamePlay()
return E_FAIL;
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_GerboldOlivander_Model"),
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/GerboldOllivander/GerboldOlivander.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))){
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/GerboldOllivander/GerboldOlivander.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Professor_EleazarFig_Model"),
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))){
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Human/Npc/EleazarFig/Professor_EleazarFig.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) {
return E_FAIL;
}
if (FAILED(m_pGameInstance->Add_Asset_Prototype(ENUM_CLASS(LEVEL::STATIC), TEXT("Prototype_Component_Troll_Model"),
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/SubTroll/troll.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))){
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/SubTroll/troll.bin", XMMatrixRotationY(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) {
return E_FAIL;
}
@@ -1934,6 +1954,7 @@ HRESULT CLoader::Loading_For_GamePlay()
CModel::Create(m_pDevice, m_pContext, MODEL::PBR_ANIM, "../Bin/Resources/Models/Monster/ConjuredDragon/ConjuredDragon.bin", XMMatrixScaling(0.01f, 0.01f, 0.01f) * XMMatrixRotationZ(XMConvertToRadians(180.f)) * XMMatrixIdentity())))) {
return E_FAIL;
}
#endif
#pragma endregion
@@ -1973,6 +1994,9 @@ HRESULT CLoader::Loading_For_GamePlay()
#pragma endregion
if (FAILED(m_pGameInstance->Add_Prototype(g_iStaticLevel, CPlayerRobe::Create(m_pDevice, m_pContext)))) {
return E_FAIL;
}
/* For.Prototype_Component_SkyboxModel */
@@ -56,7 +56,7 @@ HRESULT CMapElement_Chest::Initialize(void* pArg)
m_pActor = static_cast<PSX::PxRigidDynamic*>(m_pRigidBody->Get_Actor());
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Set_HalfGeometryInfo(pDesc->vBoxSize);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(_float4(0.f, 0.f, 0.f, 0.f), pDesc->vBoxLocalPosition);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(XMVectorSet(0.f, 0.f, 0.f, 1.f), XMLoadFloat3(&pDesc->vBoxLocalPosition));
return S_OK;
}
@@ -58,7 +58,7 @@ HRESULT CMapElement_Interactable::Initialize(void* pArg)
m_pActor = static_cast<PSX::PxRigidDynamic*>(m_pRigidBody->Get_Actor());
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Set_HalfGeometryInfo(pDesc->vBoxSize);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(_float4(0.f, 0.f, 0.f, 0.f), pDesc->vBoxLocalPosition);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(XMVectorSet(0.f, 0.f, 0.f, 1.f), XMLoadFloat3(&pDesc->vBoxLocalPosition));
//static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Set_Kinematic(false);
if (false == m_isPooled)
+13 -293
View File
@@ -15,6 +15,7 @@
#include "Monster.h"
#include "Broom.h"
#include "MapElement_Interactable.h"
#include "PlayerRobe.h"
#pragma region STATE
#include "State_Idle.h"
@@ -111,18 +112,6 @@ HRESULT CPlayer::Initialize(void* pArg)
m_BasicEffect->SetProjection(m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ));
m_Batch = make_unique<PrimitiveBatch<VertexPositionColor>>(m_pContext);
m_pBoneShape = (GeometricPrimitive::CreateSphere(m_pContext, 0.05f, 22, false, false));
m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, 0.05f, 22, false, false));
m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, 0.3f, 0.075f, 22, false));
D3D11_DEPTH_STENCIL_DESC depthStencilDesc = {};
depthStencilDesc.DepthEnable = FALSE;
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
depthStencilDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
depthStencilDesc.StencilEnable = FALSE;
HRESULT result = m_pDevice->CreateDepthStencilState(&depthStencilDesc, &m_pDepthStencilStateNone);
if (FAILED(result))
return E_FAIL;
#endif // _DEBUG
// UI 연동 추가
@@ -172,8 +161,6 @@ __super::Update(fTimeDelta);
m_pCallBack_HitReport->Set_CurrentSlop();
}
Update_LegsPosition();
if (m_pGameInstance->Mouse_Down(DIM_RBUTTON)){
m_pInfoInstance->Mouse_Input(ENUM_CLASS(KEYINPUT::DIM_RBUTTON_DOWN));
}
@@ -257,7 +244,17 @@ void CPlayer::Late_Update(_float fTimeDelta)
m_pTransformCom->Set_State(STATE::LOOK, look);
////////////////////////////////////////////////////////////////////////////
if (nullptr == m_pRobePart) {
{
CPlayerRobe::PlayerRobe_DESC Desc{};
Desc.pModel = m_pModelCom;
Desc.pParentTransform = m_pTransformCom;
Desc.pSocketMatrix = m_pModelCom->Get_BoneMatrixPtr("Hips_Cloth");
if (FAILED(Add_PartObject<CPlayerRobe>("RobePart", g_iStaticLevel, &m_pRobePart, &Desc))) {
assert(false);
}
}
}
}
HRESULT CPlayer::Render()
@@ -304,13 +301,9 @@ HRESULT CPlayer::Render()
}
#ifdef _DEBUG
if (RENDER::NONLIGHT == eType) {
//for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
// m_pRobeJointRoute[i]->Render();
//}
//m_pCharacter_Controller->Render();
//m_pRigidBody->Render();
Render_CameraCoordinateSystem();
Render_BonePhysX();
}
#endif
@@ -391,7 +384,6 @@ void CPlayer::Start_CameraShake(_float fTime, _float fIntense)
m_fCameraShakeIntense = fIntense;
m_bCameraShake = true;
}
#ifdef _DEBUG
void CPlayer::Render_CameraCoordinateSystem()
{
@@ -443,143 +435,6 @@ void CPlayer::Render_CameraCoordinateSystem()
);
m_Batch->End();
}
HRESULT CPlayer::Update_LegsPosition()
{
_matrix WorldMatrix = m_pTransformCom->Get_XMWorldMatrix();
_matrix FootMatrix = XMLoadFloat4x4(m_pModelCom->Get_BoneMatrixPtr("LeftFoot")) * WorldMatrix;
_matrix LegMatrix = XMLoadFloat4x4(m_pModelCom->Get_BoneMatrixPtr("LeftLeg")) * WorldMatrix;
m_pLeftLeg->Set_CenterTransform(WorldMatrix, FootMatrix.r[3], LegMatrix.r[3]);
#ifdef _DEBUG
{
_vector vCenterWorldPos = (FootMatrix.r[3] + LegMatrix.r[3]) * 0.5f;
_vector vRotQ = XMQuaternionIdentity();
_vector vDir = XMVectorSetW(LegMatrix.r[3] - FootMatrix.r[3], 0.f);
_float vLength = XMVectorGetX(XMVector3Length(vDir));
if (vLength > FLT_EPSILON5) {
vDir = XMVector3Normalize(vDir);
vRotQ = CMyTools::MakeQuaternionFromTo(XMVectorSet(0.f, 1.f, 0.f, 0.f), vDir);
}
XMStoreFloat4x4(&m_LeftLegMatrix, XMMatrixRotationQuaternion(vRotQ) * XMMatrixTranslationFromVector(vCenterWorldPos));
}
#endif // _DEBUG
FootMatrix = XMLoadFloat4x4(m_pModelCom->Get_BoneMatrixPtr("RightFoot")) * WorldMatrix;
LegMatrix = XMLoadFloat4x4(m_pModelCom->Get_BoneMatrixPtr("RightLeg")) * WorldMatrix;
m_pRightLeg->Set_CenterTransform(WorldMatrix, FootMatrix.r[3], LegMatrix.r[3]);
#ifdef _DEBUG
{
_vector vCenterWorldPos = (FootMatrix.r[3] + LegMatrix.r[3]) * 0.5f;
_vector vRotQ = XMQuaternionIdentity();
_vector vDir = XMVectorSetW(LegMatrix.r[3] - FootMatrix.r[3], 0.f);
_float vLength = XMVectorGetX(XMVector3Length(vDir));
if (vLength > FLT_EPSILON5) {
vDir = XMVector3Normalize(vDir);
vRotQ = CMyTools::MakeQuaternionFromTo(XMVectorSet(0.f, 1.f, 0.f, 0.f), vDir);
}
XMStoreFloat4x4(&m_RightLegMatrix, XMMatrixRotationQuaternion(vRotQ) * XMMatrixTranslationFromVector(vCenterWorldPos));
}
#endif // _DEBUG
return S_OK;
}
HRESULT CPlayer::Render_Legs()
{
_float fHeight = 0.25f;
_matrix WorldMatrix = XMLoadFloat4x4(&m_LeftLegMatrix);
_matrix ViewMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW);
_matrix ProjMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ);
_vector vColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0xff0000, 1.f);
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
_matrix WorldUp = XMMatrixTranslationFromVector(WorldMatrix.r[1] * fHeight);
_matrix WorldDown = XMMatrixTranslationFromVector(WorldMatrix.r[1] * -fHeight);
m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
WorldMatrix = XMLoadFloat4x4(&m_RightLegMatrix);
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
WorldUp = XMMatrixTranslationFromVector(WorldMatrix.r[1] * fHeight);
WorldDown = XMMatrixTranslationFromVector(WorldMatrix.r[1] * -fHeight);
m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
return S_OK;
}
//HRESULT CPlayer::Helper_JointGenerater(CDynamic_Joint::DYNAMICJOINT_DESC& Desc, _uint iRoute0, _bool bUseHead0, _uint iRoute1, _bool bUseHead1, _uint iJoint)
//{
// Desc.pActor0 = m_pRobeJointRoute[iRoute0]->Get_Actor();
// if (true == bUseHead0) {
// Desc.pLocalFrame0 = m_pRobeJointRoute[iRoute0]->Get_HeadPositionPxTransform();
// }
// else {
// Desc.pLocalFrame0 = m_pRobeJointRoute[iRoute0]->Get_FootPositionPxTransform();
// }
//
// Desc.pActor1 = m_pRobeJointRoute[iRoute1]->Get_Actor();
// if (true == bUseHead1) {
// Desc.pLocalFrame1 = m_pRobeJointRoute[iRoute1]->Get_HeadPositionPxTransform();
// }
// else {
// Desc.pLocalFrame1 = m_pRobeJointRoute[iRoute1]->Get_FootPositionPxTransform();
// }
// if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_DynamicJoint"), (CComponent**)&m_pDynamicJoints[iJoint], &Desc))) {
// return E_FAIL;
// }
// return S_OK;
//}
HRESULT CPlayer::Render_BonePhysX()
{
_vector vColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0x00ff00, 1.f);
_fmatrix OwnerMatrix = m_pTransformCom->Get_XMWorldMatrix();
_cmatrix ViewMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW);
_matrix ProjMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ);
ID3D11DepthStencilState* pPrevDSS = nullptr;
UINT iPrevStencilRef = 0;
m_pContext->OMGetDepthStencilState(&pPrevDSS, &iPrevStencilRef);
for (_uint iBoneIndex = 0; iBoneIndex < ENUM_CLASS(PLAYER_JOINT_ORDER::END); ++iBoneIndex)
{
_matrix WorldMatrix = XMLoadFloat4x4(m_pModelCom->Get_BoneMatrixPtr(PLAYER_JOINT_BONE_NAMES[iBoneIndex])) * OwnerMatrix;
m_pBoneShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
}
Render_Legs();
m_pContext->OMSetDepthStencilState(pPrevDSS, iPrevStencilRef);
if (pPrevDSS != nullptr){
pPrevDSS->Release();
}
return S_OK;
}
#endif // _DEBUG
HRESULT CPlayer::Ready_Components()
{
CTransform::TRANSFORM_DESC Desc = {};
@@ -652,128 +507,6 @@ HRESULT CPlayer::Ready_Components()
m_pGameInstance->Detach_Actor(*m_pRigidBody->Get_Actor(), NEXT_LEVEL);
}
{ //
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::LEG);
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_Player_Leg"), (CComponent**)&m_pLeftLeg, &Desc))) {
return E_FAIL;
}
}
{ //
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::LEG);
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_Player_Leg"), (CComponent**)&m_pRightLeg, &Desc))) {
return E_FAIL;
}
}
//{ // RobeSocket
// for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
// CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
// Desc.iSubKind = ENUM_CLASS(PXOBJECT::JOINT_ROUTE);
// if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), (CComponent**)&m_pRobeJointRoute[i], &Desc))) {
// return E_FAIL;
// }
// }
//}
//{
// CDynamic_Joint::DYNAMICJOINT_DESC Desc{}; // 조인트 실제 본이랑연결해야함
// Desc.eType = PHYSX_JOINT::D6;
// _uint iRoute0 = 0;
// _bool bHead0 = 0;
// _uint iRoute1 = 0;
// _bool bHead1 = 0;
// _uint iJoint = 0;
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::RIGHTUP);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::UP_R_T);
// bHead0 = false;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::UP_MIDDLE_R);
// bHead1 = false;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::LEFTUP);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::UP_T_L);
// bHead0 = false;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::UP_MIDDLE_L);
// bHead1 = false;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::RIGHT);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_R_T);
// bHead0 = false;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_TR);
// bHead1 = false;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::LEFT);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_T_L);
// bHead0 = false;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_TL);
// bHead1 = false;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::TAIL);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_TR);
// bHead0 = false;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_TL);
// bHead1 = false;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::RIGHTDOWNRIGHT);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_RR);
// bHead0 = true;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::DOWN_RR_TR);
// bHead1 = true;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::LEFTDOWNLEFT);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_LL);
// bHead0 = true;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::DOWN_TL_L);
// bHead1 = true;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::RIGHTDOWN);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_R);
// bHead0 = true;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::DOWN_R_RR);
// bHead1 = true;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
// {
// iJoint = ENUM_CLASS(PLAYER_JOINT_ORDER::LEFTDOWN);
// iRoute0 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::MIDDLE_DOWN_L);
// bHead0 = true;
// iRoute1 = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::DOWN_L_LL);
// bHead1 = true;
// if (FAILED(Helper_JointGenerater(Desc, iRoute0, bHead0, iRoute1, bHead1, iJoint))) {
// return E_FAIL;
// }
// }
//}
return S_OK;
}
@@ -813,8 +546,6 @@ HRESULT CPlayer::Ready_Parts()
return E_FAIL;
}
return S_OK;
}
@@ -982,18 +713,7 @@ void CPlayer::Free()
{
__super::Free();
#ifdef _DEBUG
SAFE_RELEASE(m_pDepthStencilStateNone);
#endif // _DEBUG
SAFE_RELEASE(m_pRightLeg);
SAFE_RELEASE(m_pLeftLeg);
//for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
// SAFE_RELEASE(m_pRobeJointRoute[i]);
//}
//for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ORDER::END); ++i) {
// SAFE_RELEASE(m_pDynamicJoints[i]);
//}
SAFE_RELEASE(m_pRobePart);
SAFE_RELEASE(m_pGrapInteractive);
if (nullptr != m_pInfoInstance) {
CInfoInstance* pInfo = m_pInfoInstance;
@@ -0,0 +1,505 @@
#include "pch.h"
#include "PlayerRobe.h"
#include "GameInstance.h"
CPlayerRobe::CPlayerRobe(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CPartObject(pDevice, pContext)
{
}
CPlayerRobe::CPlayerRobe(const CPlayerRobe& Prototype)
: CPartObject(Prototype)
{
}
void CPlayerRobe::Priority_Update(_float fTimeDelta)
{
}
void CPlayerRobe::Update(_float fTimeDelta)
{
_matrix OwnerMatrix = XMLoadFloat4x4(m_pParentTransformCom->Get_WorldMatrixPtr());
m_pTransformCom->Set_WorldMatrix(OwnerMatrix);
m_pRobeMainAnchor->Set_Transform(XMLoadFloat4x4(m_pSocketMatrix) * OwnerMatrix);
Update_LegsPosition();
}
void CPlayerRobe::Late_Update(_float fTimeDelta)
{
Update_RobeSocketPosition();
#ifdef _DEBUG
m_pGameInstance->Add_RenderGroup(RENDER::NONLIGHT, this);
#endif // _DEBUG
}
HRESULT CPlayerRobe::Render()
{
Render_BonePhysX();
return S_OK;
}
HRESULT CPlayerRobe::Update_RobeSocketPosition()
{
return S_OK;
}
HRESULT CPlayerRobe::Helper_RouteJointGenerater(CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC& Desc_Body, ROUTE_DESC& Desc_Route, _matrix* xmAnchorMatricesWorld)
{
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), (CComponent**)&m_pRobeJointRoute[Desc_Route.iTargetRouteIndex], &Desc_Body))) {
return E_FAIL;
}
m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Set_CenterTransform(xmAnchorMatricesWorld[Desc_Route.iStartBoneIndex].r[3], xmAnchorMatricesWorld[Desc_Route.iEndBoneIndex].r[3]);
{ // Joint
m_pDynamicJoints[Desc_Route.iStartJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeJointAnchor[Desc_Route.iStartJointIndex]->Get_Actor(), m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iStartJointIndex]->Get_GlobalPosition());
m_pDynamicJoints[Desc_Route.iEndJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_GlobalPosition());
}
return S_OK;
}
HRESULT CPlayerRobe::Update_LegsPosition()
{
_matrix WorldMatrix = m_pParentTransformCom->Get_XMWorldMatrix();
{
_vector vFootPos = XMVector4Transform(XMLoadFloat4((_float4*)&m_pLeftFootLocalMatrix->m[3][0]), WorldMatrix);
_vector vLegPos = XMVector4Transform(XMLoadFloat4((_float4*)&m_pLeftLegLocalMatrix->m[3][0]), WorldMatrix);
m_pLeftLeg->Set_CenterTransform(vFootPos, vLegPos);
#ifdef _DEBUG
{
_vector vCenterWorldPos = (vFootPos + vLegPos ) * 0.5f;
_vector vRotQ = XMQuaternionIdentity();
_vector vDir = XMVectorSetW(vLegPos - vFootPos, 0.f);
_float vLength = XMVectorGetX(XMVector3Length(vDir));
if (vLength > FLT_EPSILON5) {
vDir = XMVector3Normalize(vDir);
vRotQ = CMyTools::MakeQuaternionFromTo(XMVectorSet(0.f, 1.f, 0.f, 0.f), vDir);
}
XMStoreFloat4x4(&m_LeftLegMatrix, XMMatrixRotationQuaternion(vRotQ) * XMMatrixTranslationFromVector(vCenterWorldPos));
}
#endif // _DEBUG
vFootPos = XMVector4Transform(XMLoadFloat4((_float4*)&m_pRightFootLocalMatrix->m[3][0]), WorldMatrix);
vLegPos = XMVector4Transform(XMLoadFloat4((_float4*)&m_pRightLegLocalMatrix->m[3][0]), WorldMatrix);
m_pRightLeg->Set_CenterTransform(vFootPos, vLegPos);
#ifdef _DEBUG
{
_vector vCenterWorldPos = (vFootPos + vLegPos) * 0.5f;
_vector vRotQ = XMQuaternionIdentity();
_vector vDir = XMVectorSetW(vLegPos - vFootPos, 0.f);
_float vLength = XMVectorGetX(XMVector3Length(vDir));
if (vLength > FLT_EPSILON5) {
vDir = XMVector3Normalize(vDir);
vRotQ = CMyTools::MakeQuaternionFromTo(XMVectorSet(0.f, 1.f, 0.f, 0.f), vDir);
}
XMStoreFloat4x4(&m_RightLegMatrix, XMMatrixRotationQuaternion(vRotQ) * XMMatrixTranslationFromVector(vCenterWorldPos));
}
#endif // _DEBUG
}
//_matrix PreTransformMatrix = XMLoadFloat4x4(&m_PreTransformMatrix);
//_matrix SocketMatrix = {};
//for (_uint i = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RUP_TO_RMIDDLE_START); i < ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::END); ++i) {
// SocketMatrix = XMLoadFloat4x4(m_RobeJointAnchorMatrices[(i - ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RUP_TO_RMIDDLE_START)) /2]);
// m_pRobeJointAnchor[i]->Move_Kinematic((SocketMatrix * PreTransformMatrix * WorldMatrix));
//}
return S_OK;
}
#ifdef _DEBUG
HRESULT CPlayerRobe::Render_Legs()
{
_float fHeight = 0.25f;
_matrix WorldMatrix = XMLoadFloat4x4(&m_LeftLegMatrix);
_matrix ViewMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW);
_matrix ProjMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ);
_vector vColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0xff0000, 1.f);
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
_matrix WorldUp = XMMatrixTranslationFromVector(WorldMatrix.r[1] * fHeight);
_matrix WorldDown = XMMatrixTranslationFromVector(WorldMatrix.r[1] * -fHeight);
m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
WorldMatrix = XMLoadFloat4x4(&m_RightLegMatrix);
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
WorldUp = XMMatrixTranslationFromVector(WorldMatrix.r[1] * fHeight);
WorldDown = XMMatrixTranslationFromVector(WorldMatrix.r[1] * -fHeight);
m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
return S_OK;
}
HRESULT CPlayerRobe::Render_BonePhysX()
{
_vector vColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0x00ff00, 1.f);
_fmatrix OwnerMatrix = m_pParentTransformCom->Get_XMWorldMatrix();
_matrix PreTransformMatrix = XMLoadFloat4x4(&m_PreTransformMatrix);
_cmatrix ViewMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::VIEW);
_matrix ProjMatrix = m_pGameInstance->Get_Transform_Matrix(D3DTS::PROJ);
ID3D11DepthStencilState* pPrevDSS = nullptr;
UINT iPrevStencilRef = 0;
m_pContext->OMGetDepthStencilState(&pPrevDSS, &iPrevStencilRef);
//for (_uint iBoneIndex = 0; iBoneIndex < ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); ++iBoneIndex)
//{
// _matrix WorldMatrix = XMLoadFloat4x4(m_RobeJointAnchorMatrices[iBoneIndex]) * PreTransformMatrix * OwnerMatrix;
// m_pSubShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
// [this]() {
// m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
// });
//}
_matrix MainAnchorMatrix = XMLoadFloat4x4(m_pSocketMatrix) * OwnerMatrix;
m_pSubShape->Draw(MainAnchorMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true,
[this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
m_pRobeMainAnchor->Render([this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
Render_Legs();
_vector vRouteColor = CMyTools::ColorRGB_A_HEXtoVECTOR(0x0000ff, 1.f);
for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
if (nullptr != m_pRobeJointRoute[i]) {
m_pRobeJointRoute[i]->Render([this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
}
}
for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::END); ++i) {
m_pRobeJointAnchor[i]->Render([this]() {
m_pContext->OMSetDepthStencilState(m_pDepthStencilStateNone, 0);
});
}
m_pContext->OMSetDepthStencilState(pPrevDSS, iPrevStencilRef);
if (pPrevDSS != nullptr) {
pPrevDSS->Release();
}
return S_OK;
}
#endif // _DEBUG
HRESULT CPlayerRobe::Ready_Components()
{
__super::Ready_Components(nullptr);
_matrix PreTransformMatrix = XMLoadFloat4x4(&m_PreTransformMatrix);
_matrix parentWorld = m_pParentTransformCom->Get_XMWorldMatrix();
_matrix socketMatrix = XMLoadFloat4x4(m_pSocketMatrix);
_matrix socketWorld = socketMatrix * parentWorld;
_matrix xmAnchorMatricesWorld[ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END)] = { };
for (_uint iBoneIndex = 0; iBoneIndex < ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); ++iBoneIndex) {
xmAnchorMatricesWorld[iBoneIndex] = XMLoadFloat4x4(m_RobeJointAnchorMatrices[iBoneIndex]) * PreTransformMatrix * parentWorld;
}
{ //
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::LEG);
Desc.bAutoOwnerTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_Player_Leg"), (CComponent**)&m_pLeftLeg, &Desc))) {
return E_FAIL;
}
}
{ //
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::LEG);
Desc.bAutoOwnerTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_Player_Leg"), (CComponent**)&m_pRightLeg, &Desc))) {
return E_FAIL;
}
}
{ // RobeSocket
{ // Fixed_MainAnchor
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::JOINT_ANCHOR);
Desc.bAutoOwnerTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ANCHOR"), (CComponent**)&m_pRobeMainAnchor, &Desc))) {
return E_FAIL;
}
m_pRobeMainAnchor->Set_Kinematic(true);
m_pRobeMainAnchor->Set_Transform(socketWorld);
#ifdef _DEBUG
m_pRobeMainAnchor->Set_Name("MainAnchor");
#endif // _DEBUG
}
// SubAnchors
for (_int i = 0; i < ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::END); ++i) {
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc{};
Desc.iSubKind = ENUM_CLASS(PXOBJECT::JOINT_ANCHOR);
Desc.bAutoOwnerTranslation = false;
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ANCHOR"), (CComponent**)&m_pRobeJointAnchor[i], &Desc))) {
return E_FAIL;
}
if (i < ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RUP_TO_RMIDDLE_START)) {
m_pRobeJointAnchor[i]->Set_Transform(socketWorld);
#ifdef _DEBUG
m_pRobeJointAnchor[i]->Set_Name("SubAnchor");
#endif // _DEBUG
}
else {
m_pRobeJointAnchor[i]->Set_Transform(xmAnchorMatricesWorld[(i - ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RUP_TO_RMIDDLE_START))/2]);
#ifdef _DEBUG
m_pRobeJointAnchor[i]->Set_Name(PLAYER_JOINT_BONE_NAMES[(i - ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RUP_TO_RMIDDLE_START)) /2]);
#endif // _DEBUG
}
}
}
{ // RobeRoute
CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC Desc_Body = {};
ROUTE_DESC Desc_Route = {};
Desc_Body.bAutoOwnerTranslation = false;
Desc_Body.iSubKind = ENUM_CLASS(PXOBJECT::JOINT_ROUTE);
/*Origin_Linked_Routes*/
{
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::ORIGIN_TO_RUP);
Desc_Route.iStartBoneIndex = -1;
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHTUP);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::ORIGIN_TO_RUP_START);
Desc_Route.iEndJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RUP_TO_RMIDDLE_END);
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), (CComponent**)&m_pRobeJointRoute[Desc_Route.iTargetRouteIndex], &Desc_Body))) {
return E_FAIL;
}
m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Set_CenterTransform(socketWorld.r[3], xmAnchorMatricesWorld[Desc_Route.iEndBoneIndex].r[3]);
#ifdef _DEBUG
m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Set_Name("Origin_Linked_Routes");
#endif // _DEBUG
{ // Joint
m_pDynamicJoints[Desc_Route.iStartJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeMainAnchor->Get_Actor(), m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeMainAnchor->Get_GlobalPosition());
m_pDynamicJoints[Desc_Route.iEndJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_GlobalPosition());
}
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::ORIGIN_TO_TUP);
Desc_Route.iStartBoneIndex = -1;
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::TAILUP);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::ORIGIN_TO_TUP_START);
Desc_Route.iEndJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::TUP_TO_TMIDDLE_END);
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), (CComponent**)&m_pRobeJointRoute[Desc_Route.iTargetRouteIndex], &Desc_Body))) {
return E_FAIL;
}
m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Set_CenterTransform(socketWorld.r[3], xmAnchorMatricesWorld[Desc_Route.iEndBoneIndex].r[3]);
#ifdef _DEBUG
m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Set_Name("Origin_Linked_Routes");
#endif // _DEBUG
{ // Joint
m_pDynamicJoints[Desc_Route.iStartJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeMainAnchor->Get_Actor(), m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeMainAnchor->Get_GlobalPosition());
m_pDynamicJoints[Desc_Route.iEndJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_GlobalPosition());
}
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::ORIGIN_TO_LUP);
Desc_Route.iStartBoneIndex = -1;
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::LEFTUP);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::ORIGIN_TO_LUP_START);
Desc_Route.iEndJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::LUP_TO_LMIDDLE_END);
if (FAILED(Add_Asset_Component(g_iStaticLevel, TEXT("PHYSX_JOINT_ROUTE"), (CComponent**)&m_pRobeJointRoute[Desc_Route.iTargetRouteIndex], &Desc_Body))) {
return E_FAIL;
}
m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Set_CenterTransform(socketWorld.r[3], xmAnchorMatricesWorld[Desc_Route.iEndBoneIndex].r[3]);
#ifdef _DEBUG
m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Set_Name("Origin_Linked_Routes");
#endif // _DEBUG
{ // Joint
m_pDynamicJoints[Desc_Route.iStartJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeMainAnchor->Get_Actor(), m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeMainAnchor->Get_GlobalPosition());
m_pDynamicJoints[Desc_Route.iEndJointIndex] = m_pGameInstance->Create_PxD6Joint(m_pRobeJointRoute[Desc_Route.iTargetRouteIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_Actor(), m_pRobeJointAnchor[Desc_Route.iEndJointIndex]->Get_GlobalPosition());
}
}
}
/*UP_TO_MIDDLE*/
{
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::RUP_TO_RMIDDLE);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHTUP);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHT);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RUP_TO_RMIDDLE_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::TUP_TO_TMIDDLE);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::TAILUP);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::TAIL);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::TUP_TO_TMIDDLE_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::LUP_TO_LMIDDLE);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::LEFTUP);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::LEFT);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::LUP_TO_LMIDDLE_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
}
/*MIDDLE_TO_DOWN*/
{
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::RMIDDLE_TO_RR);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHT);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHTDOWNRIGHT);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RMIDDLE_TO_RR_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::RMIDDLE_TO_R);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHT);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::RIGHTDOWN);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::RMIDDLE_TO_R_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::TMIDDLE_TO_TR);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::TAIL);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::TAILRIGHTDOWN);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::TMIDDLE_TO_TR_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::TMIDDLE_TO_TL);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::TAIL);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::TAILLEFTDOWN);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::TMIDDLE_TO_TL_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::LMIDDLE_TO_L);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::LEFT);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::LEFTDOWN);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::LMIDDLE_TO_L_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
{
Desc_Route.iTargetRouteIndex = ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::LMIDDLE_TO_LL);
Desc_Route.iStartBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::LEFT);
Desc_Route.iEndBoneIndex = ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::LEFTDOWNLEFT);
Desc_Route.iStartJointIndex = ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::LMIDDLE_TO_LL_START);
Desc_Route.iEndJointIndex = Desc_Route.iStartJointIndex + 1;
Helper_RouteJointGenerater(Desc_Body, Desc_Route, xmAnchorMatricesWorld);
}
}
}
return S_OK;
}
HRESULT CPlayerRobe::Initialize_Prototype()
{
return S_OK;
}
HRESULT CPlayerRobe::Initialize(void* pArg)
{
PlayerRobe_DESC* pDesc = static_cast<PlayerRobe_DESC*> (pArg);
m_pSocketMatrix = pDesc->pSocketMatrix;
m_pModelCom = pDesc->pModel;
m_pLeftFootLocalMatrix = m_pModelCom->Get_BoneMatrixPtr("LeftFoot");
m_pLeftLegLocalMatrix = m_pModelCom->Get_BoneMatrixPtr("LeftLeg");
m_pRightFootLocalMatrix = m_pModelCom->Get_BoneMatrixPtr("RightFoot");
m_pRightLegLocalMatrix = m_pModelCom->Get_BoneMatrixPtr("RightLeg");
m_PreTransformMatrix = *m_pModelCom->Get_PreTransformMatrixPtr();
for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END); ++i) {
m_RobeJointAnchorMatrices[i] = m_pModelCom->Get_BoneLocalMatrixPtr(PLAYER_JOINT_BONE_NAMES[i]);
}
if (FAILED(__super::Initialize(pArg))) {
return E_FAIL;
}
if (FAILED(Ready_Components())) {
return E_FAIL;
}
#ifdef _DEBUG
m_pSubShape = (GeometricPrimitive::CreateSphere(m_pContext, 0.05f, 22, false, false));
m_pMainShape = (GeometricPrimitive::CreateCylinder(m_pContext, 0.3f, 0.075f, 22, false));
D3D11_DEPTH_STENCIL_DESC depthStencilDesc = {};
depthStencilDesc.DepthEnable = FALSE;
depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
depthStencilDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
depthStencilDesc.StencilEnable = FALSE;
HRESULT result = m_pDevice->CreateDepthStencilState(&depthStencilDesc, &m_pDepthStencilStateNone);
if (FAILED(result)){
return E_FAIL;
}
#endif // _DEBUG
return S_OK;
}
CPlayerRobe* CPlayerRobe::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CPlayerRobe* pInstance = new CPlayerRobe(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype()))
{
MSG_BOX("Failed to Created : CPlayerRobe");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
CGameObject* CPlayerRobe::Clone(void* pArg, CGameObject* pOwner)
{
CPlayerRobe* pInstance = new CPlayerRobe(*this);
pInstance->m_pOwner = pOwner;
if (FAILED(pInstance->Initialize(pArg)))
{
MSG_BOX("Failed to Cloned : CPlayerRobe");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CPlayerRobe::Free()
{
__super::Free();
#ifdef _DEBUG
SAFE_RELEASE(m_pDepthStencilStateNone);
#endif // _DEBUG
SAFE_RELEASE(m_pRightLeg);
SAFE_RELEASE(m_pLeftLeg);
for (_uint i = 0; i < ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END); ++i) {
SAFE_RELEASE(m_pRobeJointRoute[i]);
}
}
#ifdef _DEBUG
void CPlayerRobe::Describe_Entity()
{
}
#endif // _DEBUG
+2 -17
View File
@@ -13,7 +13,6 @@ class CPlayer final : public CUnit
_float4 vPos;
_float4 vRotQ;
}PLAYERDESC;
private:
CPlayer(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CPlayer(const CPlayer& Prototype);
@@ -34,7 +33,6 @@ class CPlayer final : public CUnit
_int Get_UIState() { return m_eUIState; }
#ifdef _DEBUG
void Render_CameraCoordinateSystem();
HRESULT Render_BonePhysX();
#endif // _DEBUG
_bool Set_Sprint(_bool bSprint) { m_bSprintToggle = bSprint; }
_matrix Get_WandPos();
@@ -74,10 +72,8 @@ class CPlayer final : public CUnit
class CTransform* m_pBroomTransform = { nullptr };
class CBroom* m_pBroom = { nullptr };
CStat* m_pStat = { nullptr };
CRigidBody_Dynamic* m_pRightLeg = { nullptr };
CRigidBody_Dynamic* m_pLeftLeg = { nullptr };
//CRigidBody_Dynamic* m_pRobeJointRoute[ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END)] = { nullptr };
//CDynamic_Joint* m_pDynamicJoints[ENUM_CLASS(PLAYER_JOINT_ORDER::END)] = { nullptr };
class CPlayerRobe* m_pRobePart = { nullptr };
private:
virtual HRESULT Initialize_Prototype() override;
virtual HRESULT Initialize(void* pArg) override;
@@ -90,21 +86,10 @@ class CPlayer final : public CUnit
void Add_SpellEvent(_uint AnimIndex, _float fRatio);
void Play_SpellHitAnim();
HRESULT Update_LegsPosition();
HRESULT Render_Legs();
//HRESULT Helper_JointGenerater(CDynamic_Joint::DYNAMICJOINT_DESC& Desc, _uint iRoute0, _bool bUseHead0, _uint iRoute1, _bool bUseHead1, _uint iJoint);
void Update_CameraCoordinateSystem(_float fTimeDelta);
#ifdef _DEBUG
unique_ptr<BasicEffect> m_BasicEffect;
unique_ptr<PrimitiveBatch<VertexPositionColor>> m_Batch;
unique_ptr<GeometricPrimitive> m_pBoneShape = { nullptr };
unique_ptr<GeometricPrimitive> m_pMainShape = { nullptr };
unique_ptr<GeometricPrimitive> m_pSubShape = { nullptr };
ID3D11DepthStencilState* m_pDepthStencilStateNone = { nullptr };
_float4x4 m_LeftLegMatrix = {};
_float4x4 m_RightLegMatrix = {};
#endif // _DEBUG
@@ -0,0 +1,81 @@
#pragma once
#include "Client_Define.h"
#include "PartObject.h"
#include "Player_ENUM.h"
NS_BEGIN(Client)
class CPlayerRobe final : public CPartObject
{
typedef struct tagRouteCreater {
_uint iTargetRouteIndex = UINT_MAX; // 만들려는 루트
_uint iStartBoneIndex = UINT_MAX; // 시작 앵커
_uint iEndBoneIndex = UINT_MAX; // 끝 앵커
_uint iStartJointIndex = UINT_MAX; // 시작 앵커가 할당받을 인덱스
_uint iEndJointIndex = UINT_MAX; // 끝 앵커가 할당받을 인덱스
}ROUTE_DESC;
public:
typedef struct tagPlayerRobe : public CPartObject::PARTOBJECT_DESC
{
const _float4x4* pSocketMatrix = { };
CModel* pModel = { nullptr };
}PlayerRobe_DESC;
private:
CPlayerRobe(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CPlayerRobe(const CPlayerRobe& Prototype);
virtual ~CPlayerRobe() = default;
public:
virtual void Priority_Update(_float fTimeDelta) override;
virtual void Update(_float fTimeDelta) override;
virtual void Late_Update(_float fTimeDelta) override;
virtual HRESULT Render() override;
private:
_float4x4 m_PreTransformMatrix = { };
const _float4x4* m_pSocketMatrix = { nullptr };
const _float4x4* m_pLeftFootLocalMatrix = { nullptr };
const _float4x4* m_pLeftLegLocalMatrix = { nullptr };
const _float4x4* m_pRightFootLocalMatrix = { nullptr };
const _float4x4* m_pRightLegLocalMatrix = { nullptr };
const _float4x4* m_RobeJointAnchorMatrices[ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END)] = { nullptr };
CModel* m_pModelCom = { nullptr };
CRigidBody_Dynamic* m_pRightLeg = { nullptr };
CRigidBody_Dynamic* m_pLeftLeg = { nullptr };
CRigidBody_Dynamic* m_pRobeMainAnchor = { nullptr };
CRigidBody_Dynamic* m_pRobeJointRoute[ENUM_CLASS(PLAYER_JOINT_ROUTE_ORDER::END)] = { nullptr };
CRigidBody_Dynamic* m_pRobeJointAnchor[ENUM_CLASS(PLAYER_JOINT_ANCHOR_ORDER::END)] = { nullptr };
PSX::PxD6Joint* m_pDynamicJoints[ENUM_CLASS(PLAYER_JOINT_BONE_ORDER::END)] = { nullptr };
#ifdef _DEBUG
unique_ptr<GeometricPrimitive> m_pMainShape = { nullptr };
unique_ptr<GeometricPrimitive> m_pSubShape = { nullptr };
ID3D11DepthStencilState* m_pDepthStencilStateNone = { nullptr };
_float4x4 m_LeftLegMatrix = {};
_float4x4 m_RightLegMatrix = {};
#endif // _DEBUG
private:
virtual HRESULT Initialize_Prototype() override;
virtual HRESULT Initialize(void* pArg) override;
HRESULT Ready_Components();
HRESULT Bind_ShaderResources() { return S_OK; }
HRESULT Update_LegsPosition();
HRESULT Update_RobeSocketPosition();
HRESULT Helper_RouteJointGenerater(CRigidBody_Dynamic::RIGIDBODY_DYNAMIC_DESC& Desc_Body, ROUTE_DESC& Desc_Route, _matrix* xmAnchorMatricesWorld);
#ifdef _DEBUG
HRESULT Render_BonePhysX();
HRESULT Render_Legs();
#endif // _DEBUG
public:
static CPlayerRobe* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual CGameObject* Clone(void* pArg, CGameObject* pOwner = nullptr)override;
virtual void Free() override;
#ifdef _DEBUG
void Describe_Entity() override;
#endif // _DEBUG
};
NS_END
+75 -41
View File
@@ -23,25 +23,6 @@ enum class PLAYER_MESH_ORDER {
END
};
enum class PLAYER_JOINT_ORDER {
RIGHTUP
, TAILUP //
, LEFTUP
, RIGHT
, TAIL
, LEFT
, RIGHTDOWN
, RIGHTDOWNRIGHT
, TAILRIGHTDOWN //
, TAILLEFTDOWN //
, LEFTDOWNLEFT
, LEFTDOWN
, END
};
static const _char* PLAYER_JOINT_BONE_NAMES[12] = {
"RightUpLeg_Cloth"
, "TailUp_Cloth"
@@ -60,32 +41,85 @@ static const _char* PLAYER_JOINT_BONE_NAMES[12] = {
, "LeftDownLeg_Cloth"
};
enum class PLAYER_JOINT_ROUTE_ORDER {
UP_R_T
, UP_T_L
enum class PLAYER_JOINT_BONE_ORDER {
RIGHTUP
, TAILUP
, LEFTUP
, UP_MIDDLE_R
// , UP_MIDDLE_T //
, UP_MIDDLE_L
, RIGHT
, TAIL
, LEFT
, MIDDLE_R_T
, MIDDLE_T_L
, RIGHTDOWNRIGHT
, RIGHTDOWN
, TAILRIGHTDOWN
, MIDDLE_DOWN_R
, MIDDLE_DOWN_RR
, MIDDLE_DOWN_TR
, MIDDLE_DOWN_TL
, MIDDLE_DOWN_LL
, MIDDLE_DOWN_L
, DOWN_R_RR
, DOWN_RR_TR
// , DOWN_TR_TL //
, DOWN_TL_L
, DOWN_L_LL
, TAILLEFTDOWN
, LEFTDOWN
, LEFTDOWNLEFT
, END
};
enum class PLAYER_JOINT_ANCHOR_ORDER {
ORIGIN_TO_RUP_START
, ORIGIN_TO_RUP_END
, ORIGIN_TO_TUP_START
, ORIGIN_TO_TUP_END
, ORIGIN_TO_LUP_START
, ORIGIN_TO_LUP_END
, RUP_TO_RMIDDLE_START
, RUP_TO_RMIDDLE_END
, TUP_TO_TMIDDLE_START
, TUP_TO_TMIDDLE_END
, LUP_TO_LMIDDLE_START
, LUP_TO_LMIDDLE_END
, RMIDDLE_TO_RR_START
, RMIDDLE_TO_RR_END
, RMIDDLE_TO_R_START
, RMIDDLE_TO_R_END
, TMIDDLE_TO_TR_START
, TMIDDLE_TO_TR_END
, TMIDDLE_TO_TL_START
, TMIDDLE_TO_TL_END
, LMIDDLE_TO_L_START
, LMIDDLE_TO_L_END
, LMIDDLE_TO_LL_START
, LMIDDLE_TO_LL_END
, END
};
enum class PLAYER_JOINT_ROUTE_ORDER {
ORIGIN_TO_RUP
, ORIGIN_TO_TUP
, ORIGIN_TO_LUP
, RUP_TO_RMIDDLE
, TUP_TO_TMIDDLE
, LUP_TO_LMIDDLE
, RMIDDLE_TO_RR
, RMIDDLE_TO_R
, TMIDDLE_TO_TR
, TMIDDLE_TO_TL
, LMIDDLE_TO_L
, LMIDDLE_TO_LL
, END
};
NS_END
@@ -16,7 +16,7 @@ void CCamPosition_Socket::Priority_Update(_float fTimeDelta)
{
/*_matrix socketMatrix = {};
socketMatrix = XMLoadFloat4x4(m_pSocketMatrices);
socketMatrix = XMLoadFloat4x4(m_pSocketMatrix);
for (int i = 0; i < 3; ++i) {
socketMatrix.r[i] = XMVector3Normalize(socketMatrix.r[i]);
@@ -40,7 +40,7 @@ HRESULT CCamPosition_Socket::Initialize_Prototype()
HRESULT CCamPosition_Socket::Initialize(void* pArg)
{
CAMERAPOSITION_PLAYER_DESC* pDesc = static_cast<CAMERAPOSITION_PLAYER_DESC*> (pArg);
//m_pSocketMatrices = pDesc->pSocketMatrices;
//m_pSocketMatrix = pDesc->pSocketMatrix;
if (FAILED(__super::Initialize(pArg)))
{
return E_FAIL;
@@ -60,7 +60,7 @@ HRESULT CMapElement_Chest::Initialize(void* pArg)
m_pActor = static_cast<PSX::PxRigidDynamic*>(m_pRigidBody->Get_Actor());
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Set_HalfGeometryInfo(pDesc->vBoxSize);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(_float4(0.f, 0.f, 0.f, 0.f), pDesc->vBoxLocalPosition);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(XMVectorSet(0.f, 0.f, 0.f, 1.f), XMLoadFloat3(&pDesc->vBoxLocalPosition));
return S_OK;
}
@@ -54,7 +54,7 @@ HRESULT CMapElement_Interactable::Initialize(void* pArg)
m_pActor = static_cast<PSX::PxRigidDynamic*>(m_pRigidBody->Get_Actor());
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Set_HalfGeometryInfo(pDesc->vBoxSize);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(_float4(0.f, 0.f, 0.f, 0.f), pDesc->vBoxLocalPosition);
static_cast<CRigidBody_Dynamic*>(m_pRigidBody)->Move_LocalPos(XMVectorSet(0.f, 0.f, 0.f, 1.f), XMLoadFloat3(&pDesc->vBoxLocalPosition));
return S_OK;
}
@@ -208,7 +208,7 @@ call Update_Lib.bat
<ClCompile Include="..\Private\ComputeShader.cpp" />
<ClCompile Include="..\Private\ContainerObject.cpp" />
<ClCompile Include="..\Private\DebugDraw.cpp" />
<ClCompile Include="..\Private\Dynamic_Joint.cpp" />
<ClCompile Include="..\Private\Dynamic_D6Joint.cpp" />
<ClCompile Include="..\private\Fog.cpp" />
<ClCompile Include="..\private\Font.cpp" />
<ClCompile Include="..\private\Font_Manager.cpp" />
@@ -421,7 +421,7 @@ call Update_Lib.bat
<ClInclude Include="..\Public\Bounding_OBB.h" />
<ClInclude Include="..\Public\Bounding_Sphere.h" />
<ClInclude Include="..\Public\CallBack_QueryFilterCallback.h" />
<ClInclude Include="..\Public\Dynamic_Joint.h" />
<ClInclude Include="..\Public\Dynamic_D6Joint.h" />
<ClInclude Include="..\public\Fog.h" />
<ClInclude Include="..\public\Font.h" />
<ClInclude Include="..\public\Font_Manager.h" />
@@ -588,7 +588,7 @@
<ClCompile Include="..\Private\CallBack_QueryFilterCallback.cpp">
<Filter>02.Element\02.Component\08.Character_Controller\CallBack</Filter>
</ClCompile>
<ClCompile Include="..\Private\Dynamic_Joint.cpp">
<ClCompile Include="..\Private\Dynamic_D6Joint.cpp">
<Filter>02.Element\02.Component\07.RigidBody\20.Joint</Filter>
</ClCompile>
</ItemGroup>
@@ -1235,7 +1235,7 @@
<ClInclude Include="..\Public\CallBack_QueryFilterCallback.h">
<Filter>02.Element\02.Component\08.Character_Controller\CallBack</Filter>
</ClInclude>
<ClInclude Include="..\Public\Dynamic_Joint.h">
<ClInclude Include="..\Public\Dynamic_D6Joint.h">
<Filter>02.Element\02.Component\07.RigidBody\20.Joint</Filter>
</ClInclude>
</ItemGroup>
@@ -347,7 +347,6 @@ HRESULT CCharacter_Controller::Initialize(void* pArg)
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 ACTOR::CAPSULE:
{
@@ -363,14 +362,16 @@ HRESULT CCharacter_Controller::Initialize(void* pArg)
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에서 불가능
return E_FAIL;
break;
}
PSX::PxRigidDynamic* pActor = m_pController->getActor();
pActor->userData = &m_tagData;
m_pGameInstance->ApplyFilterData(pActor);
m_pController->setStepOffset(pDesc->fStepOffset);
if (nullptr == m_pController) {
@@ -1,31 +1,31 @@
#include "pch.h"
#include "Dynamic_Joint.h"
#include "Dynamic_D6Joint.h"
#include "GameInstance.h"
CDynamic_Joint::CDynamic_Joint(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
CDynamic_D6Joint::CDynamic_D6Joint(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CComponent(pDevice, pContext)
{
}
CDynamic_Joint::CDynamic_Joint(const CDynamic_Joint& rhs)
CDynamic_D6Joint::CDynamic_D6Joint(const CDynamic_D6Joint& rhs)
: CComponent(rhs)
{
}
HRESULT CDynamic_Joint::Initialize_Prototype()
HRESULT CDynamic_D6Joint::Initialize_Prototype()
{
return S_OK;
}
HRESULT CDynamic_Joint::Initialize(void* pArg)
HRESULT CDynamic_D6Joint::Initialize(void* pArg)
{
DYNAMICJOINT_DESC* pDesc = static_cast<DYNAMICJOINT_DESC*>(pArg);
m_pJoint = m_pGameInstance->Create_PxJoint(pDesc->eType, pDesc->pActor0, pDesc->pLocalFrame0, pDesc->pActor1, pDesc->pLocalFrame1);
m_pJoint = m_pGameInstance->Create_PxD6Joint(pDesc->pActor0, pDesc->pActor1, *pDesc->pxJointWorldPos);
return S_OK;
}
#ifdef _DEBUG
HRESULT CDynamic_Joint::Add_DebugShape()
HRESULT CDynamic_D6Joint::Add_DebugShape()
{
if (nullptr != m_pMainShape){
m_pMainShape.reset();
@@ -34,7 +34,7 @@ HRESULT CDynamic_Joint::Add_DebugShape()
return S_OK;
}
HRESULT CDynamic_Joint::Render()
HRESULT CDynamic_D6Joint::Render()
{
//PSX::PxTransform pxTranform = m_pRigidBody->getGlobalPose();
//_matrix WorldMatrix = XMMatrixTranslation(m_vLocalTranslation.x, m_vLocalTranslation.y, m_vLocalTranslation.z) * XMMatrixAffineTransformation(XMVectorSet(1.f, 1.f, 1.f, 0.f), XMVectorZero(), XMLoadFloat4((_float4*)&pxTranform.q), XMVectorSetW(XMLoadFloat3((_float3*)&pxTranform.p), 1.f));
@@ -49,37 +49,37 @@ HRESULT CDynamic_Joint::Render()
#endif // _DEBUG
CDynamic_Joint* CDynamic_Joint::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
CDynamic_D6Joint* CDynamic_D6Joint::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CDynamic_Joint* pInstance = new CDynamic_Joint(pDevice, pContext);
CDynamic_D6Joint* pInstance = new CDynamic_D6Joint(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype())) {
MSG_BOX("CDynamic_Joint Prototype Created Failed");
MSG_BOX("CDynamic_D6Joint Prototype Created Failed");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
CComponent* CDynamic_Joint::Clone(void* pArg, CGameObject* pOwner)
CComponent* CDynamic_D6Joint::Clone(void* pArg, CGameObject* pOwner)
{
CDynamic_Joint* pInstance = new CDynamic_Joint(*this);
CDynamic_D6Joint* pInstance = new CDynamic_D6Joint(*this);
pInstance->m_pOwner = pOwner;
if (FAILED(pInstance->Initialize(pArg))) {
MSG_BOX("CDynamic_Joint Prototype Created Failed");
MSG_BOX("CDynamic_D6Joint Prototype Created Failed");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CDynamic_Joint::Free()
void CDynamic_D6Joint::Free()
{
__super::Free();
}
#ifdef _DEBUG
void CDynamic_Joint::Describe_Entity()
void CDynamic_D6Joint::Describe_Entity()
{
}
@@ -1004,6 +1004,10 @@ PSX::PxJoint* CGameInstance::Create_PxJoint(PHYSX_JOINT eType, PSX::PxRigidActor
{
return m_pPhysX_Manager->Create_PxJoint(eType, pActor0, pxLocalFrame0, pActor1, pxLocalFrame1);
}
PSX::PxD6Joint* CGameInstance::Create_PxD6Joint(PSX::PxRigidActor* pActor0, PSX::PxRigidActor* pActor1, const PSX::PxTransform& pxJointWorldPos)
{
return m_pPhysX_Manager->Create_PxD6Joint(pActor0, pActor1, pxJointWorldPos);
}
_bool CGameInstance::SphereCast(_float fRadius, _float3 vStartPos, _float3 vDir, _float fDistance, PSX::PxHitFlags flagHitsData, PSX::PxQueryFlags flagQuery, PSX::PxSweepBuffer& hitBuffer)
{
return m_pPhysX_Manager->SphereCast(fRadius, vStartPos, vDir, fDistance, flagHitsData, flagQuery, hitBuffer);
@@ -1048,6 +1052,10 @@ void CGameInstance::Release_Actor(PSX::PxActor& Actor)
{
m_pPhysX_Manager->Release_Actor(Actor);
}
void CGameInstance::ApplyFilterData(PSX::PxRigidActor* pRigidActor)
{
m_pPhysX_Manager->ApplyFilterData(pRigidActor);
}
HRESULT CGameInstance::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix)
{
return m_pPhysX_Manager->ConvertToTriMeshes(Meshes, pxTriMeshes, WorldMatrix);
+27
View File
@@ -551,6 +551,21 @@ const _float4x4* CModel::Get_BoneMatrixPtr(const _char* pBoneName)
return m_Bones[boneIdx]->Get_CombinedTransformationMatrixPtr();
}
const _float4x4* CModel::Get_BoneLocalMatrixPtr(const _char* pBoneName)
{
_int boneIdx = Get_BoneIndex(pBoneName);
if (boneIdx < 0) {
return nullptr;
}
//Mark_CPUChain(boneIdx);
//Apply_CPUMask_ToBones();
return m_Bones[boneIdx]->Get_TransformationMatrixPtr();
}
_matrix CModel::Get_BoneMatrix(const _char* pBoneName) const
{
vector<CBone*>::const_iterator iter = find_if(m_Bones.begin(), m_Bones.end(), [&](CBone* pBone)->_bool
@@ -597,6 +612,18 @@ void CModel::Combined_BoneMatrix()
}
}
void CModel::Combined_BoneMatrix(_int iStartBoneIndex, _uint iBoneCount)
{
if (iStartBoneIndex < 0) {
return;
}
_matrix IdenMatrix = XMMatrixIdentity();
_uint iEndIndex = (_uint)iStartBoneIndex + iBoneCount;
for (_uint i = iStartBoneIndex; i < iEndIndex; ++i) {
m_Bones[i]->Update_CombinedTransformationMatrix(m_Bones, IdenMatrix);
}
}
_int CModel::Find_BoneIndex(const _char* pBoneName)
{
if (pBoneName == nullptr)
@@ -59,6 +59,7 @@ PSX::PxRigidDynamic* CPhysX_Manager::Add_DynamicActor(CRigidBody_Dynamic& RigidB
PSX::PxRigidBodyExt::updateMassAndInertia(*pActorDynamic, (PSX::PxReal)RigidBody.Get_Density());
m_pRestBodies[iLevel].insert(pActorDynamic);
ApplyFilterData(pActorDynamic);
Attach_Actor(*pActorDynamic, iLevel);
return pActorDynamic;
@@ -71,7 +72,7 @@ PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody_Static& RigidBody
// PxRigidStatic 씬의 정적 바디 인터페이스
PSX::PxRigidStatic* pActor = m_pPhysics->createRigidStatic(pxWorldMatrix);
PSX::PxRigidStatic* pActorStatic = m_pPhysics->createRigidStatic(pxWorldMatrix);
PSX::PxShape* pShape = { nullptr };
PSX::PxGeometry* pGeometry = { nullptr };
@@ -130,16 +131,17 @@ PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody_Static& RigidBody
break;
}
pShape = PSX::PxRigidActorExt::createExclusiveShape(*pActor, *pGeometry, *m_pMaterials[ENUM_CLASS(RigidBody.Get_MaterialType())]);
pShape = PSX::PxRigidActorExt::createExclusiveShape(*pActorStatic, *pGeometry, *m_pMaterials[ENUM_CLASS(RigidBody.Get_MaterialType())]);
pShape->setFlags(RigidBody.Get_ShapeFlags());
pShape->setContactOffset(RigidBody.Get_ContactOffset());
pShape->setRestOffset(0.f);
m_pRestBodies[iLevel].insert(pActor);
Attach_Actor(*pActor, iLevel);
m_pRestBodies[iLevel].insert(pActorStatic);
ApplyFilterData(pActorStatic);
Attach_Actor(*pActorStatic, iLevel);
return pActor;
return pActorStatic;
}
PSX::PxJoint* CPhysX_Manager::Create_PxJoint(PHYSX_JOINT eType, PSX::PxRigidActor* pActor0, PSX::PxTransform& pxLocalFrame0, PSX::PxRigidActor* pActor1, PSX::PxTransform& pxLocalFrame1)
@@ -173,6 +175,22 @@ PSX::PxJoint* CPhysX_Manager::Create_PxJoint(PHYSX_JOINT eType, PSX::PxRigidActo
return pOut;
}
PSX::PxD6Joint* CPhysX_Manager::Create_PxD6Joint(PSX::PxRigidActor* pActor0, PSX::PxRigidActor* pActor1, const PSX::PxTransform& pxJointWorldPos)
{
const PSX::PxTransform pxWorldParentPos = pActor0->getGlobalPose();
const PSX::PxTransform pxWorldChildPos = pActor1->getGlobalPose();
const PSX::PxTransform pxLocalParentPOs = pxWorldParentPos.transformInv(pxJointWorldPos);
const PSX::PxTransform pxLocalChildPos = pxWorldChildPos.transformInv(pxJointWorldPos);
PSX::PxD6Joint* pJoint = PSX::PxD6JointCreate(*m_pPhysics, pActor0, pxLocalParentPOs, pActor1, pxLocalChildPos);
for (_uint i = PSX::PxD6Axis::Enum::eTWIST; i < PSX::PxD6Axis::eCOUNT; ++i) {
pJoint->setMotion((PSX::PxD6Axis::Enum)i, PSX::PxD6Motion::eFREE);
}
pJoint->setBreakForce(1e30f, 1e30f);
return pJoint;
}
PSX::PxMaterial* CPhysX_Manager::Create_Material(const _float3* vMatInfo)
{
PSX::PxMaterial* pPxMaterial = m_pPhysics->createMaterial(vMatInfo->x, vMatInfo->y, vMatInfo->z);
@@ -399,7 +417,11 @@ void CPhysX_Manager::Update_Kinematic()
if (pActor->getRigidBodyFlags() & PSX::PxRigidBodyFlag::eKINEMATIC)
{
const CTransform* pTransform = static_cast<PhsXUserData*>(pBody->userData)->pOwner->Get_Component<CTransform>();
PhsXUserData* pUserData = (PhsXUserData*)pBody->userData;
if (false == pUserData->bAutoOwnerTranslation) {
continue;
}
const CTransform* pTransform = pUserData->pOwner->Get_Component<CTransform>();
pActor->setKinematicTarget(XMWorldToPx_NoScale(pTransform->Get_XMWorldMatrix()));
}
@@ -442,6 +464,9 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
if (nullptr == ppActiveActors[i]->userData) {
continue;
}
if (false == pUserData->bAutoOwnerTranslation) {
continue;
}
CTransform* pTransform = pUserData->pOwner->Get_Component<CTransform>();
PSX::PxTransform pPxTransform = pActorDynamic->getGlobalPose();
@@ -454,6 +479,85 @@ void CPhysX_Manager::Update_Dynamic_ActiveActors()
}
}
uint32_t CPhysX_Manager::ConvertPhysxKindToBit(PHYSX_KIND physxKind)
{
switch (physxKind)
{
case PHYSX_KIND::BODY_STATIC: return COLLISIONCATERGORY_BIT32::WorldStatic;
case PHYSX_KIND::BODY_DYNAMIC: return COLLISIONCATERGORY_BIT32::WorldDynamic;
case PHYSX_KIND::CCTActor: return COLLISIONCATERGORY_BIT32::CharacterController;
default: return 0u;
}
}
uint32_t CPhysX_Manager::BuildCollisionMaskFromCategoryBit(uint32_t iMyBit)
{
if (iMyBit == COLLISIONCATERGORY_BIT32::CharacterController)
{
// CCT는 조인트 파츠 충돌x
return COLLISIONCATERGORY_BIT32::WorldStatic | COLLISIONCATERGORY_BIT32::WorldDynamic;
}
if (iMyBit == COLLISIONCATERGORY_BIT32::JointedParts)
{
// 조인트 파츠도 CCT 충돌x
return COLLISIONCATERGORY_BIT32::WorldStatic | COLLISIONCATERGORY_BIT32::WorldDynamic | COLLISIONCATERGORY_BIT32::JointedParts;
}
// 기본값
return COLLISIONCATERGORY_BIT32::WorldStatic | COLLISIONCATERGORY_BIT32::WorldDynamic | COLLISIONCATERGORY_BIT32::CharacterController | COLLISIONCATERGORY_BIT32::JointedParts;
}
void CPhysX_Manager::ApplyFilterData(PSX::PxRigidActor* pRigidActor)
{
if (pRigidActor == nullptr){
return;
}
PhsXUserData* physxUserData = reinterpret_cast<PhsXUserData*>(pRigidActor->userData);
if (physxUserData == nullptr){
return;
}
const uint32_t CategoryBit = ConvertPhysxKindToBit(physxUserData->eKind); // who am i
const uint32_t MaskBits = BuildCollisionMaskFromCategoryBit(CategoryBit); // for what
PSX::PxFilterData simulationFilterData = {};
simulationFilterData.word0 = CategoryBit; // “나는 누구인가”
simulationFilterData.word1 = MaskBits; // “누구와 부딪힐 것인가”
const PSX::PxU32 shapeCount = pRigidActor->getNbShapes();
vector<PSX::PxShape*> shapes(shapeCount);
pRigidActor->getShapes(shapes.data(), shapeCount);
for (PSX::PxShape* shape : shapes)
{
shape->setSimulationFilterData(simulationFilterData);
}
}
PSX::PxFilterFlags CPhysX_Manager::SimulationFilterShader(PSX::PxFilterObjectAttributes pxAttributes0, PSX::PxFilterData pxFilterData0, PSX::PxFilterObjectAttributes pxAttributes1, PSX::PxFilterData pxFilterData1, PSX::PxPairFlags& pxPairFlags, const void* pConstantBlock, PSX::PxU32 iConstantBlockSize)
{
_bool bFilter0_1 = (pxFilterData0.word0 & pxFilterData1.word1) != 0u;
_bool bFilter1_0 = (pxFilterData1.word0 & pxFilterData0.word1) != 0u;
if (!bFilter0_1 || !bFilter1_0)
{
// Event. 접촉제거
return PSX::PxFilterFlag::eSUPPRESS;
}
if (PSX::PxFilterObjectIsTrigger(pxAttributes0) || PSX::PxFilterObjectIsTrigger(pxAttributes1))
{
// 트리거 처리
pxPairFlags = PSX::PxPairFlag::eTRIGGER_DEFAULT;
return PSX::PxFilterFlag::eDEFAULT;
}
pxPairFlags = PSX::PxPairFlag::eCONTACT_DEFAULT;
return PSX::PxFilterFlag::eDEFAULT;
}
void CPhysX_Manager::ClearScene(_uint iLevel)
{
for (auto& pBody : m_pActiveBodys[iLevel]) {
@@ -622,7 +726,7 @@ HRESULT CPhysX_Manager::Initialize(_uint iLevel)
}
sceneDesc.cpuDispatcher = m_pDispatcher;
//sceneDesc.simulationEventCallback = ; // fetchResults 때 불림. 아래 필터랑, pair랑 같이 짝꿍임. 좀 더 공부해야 쓸 수 있을듯;;
sceneDesc.filterShader = PSX::PxDefaultSimulationFilterShader; // 레이어 충돌, 오브젝트에 속성을 주고 복잡한 필터링 충돌 식
sceneDesc.filterShader = &SimulationFilterShader;// PSX::PxDefaultSimulationFilterShader; // 레이어 충돌, 오브젝트에 속성을 주고 복잡한 필터링 충돌 식
sceneDesc.flags =
PSX::PxSceneFlag::eENABLE_PCM // 기본 true, 현대적인 충돌시스템 적용
| PSX::PxSceneFlag::eENABLE_ACTIVE_ACTORS // 현재 움직임이 있는 액터만 가져옴
@@ -651,7 +755,6 @@ HRESULT CPhysX_Manager::Initialize(_uint iLevel)
}
m_pScene = m_pPhysics->createScene(sceneDesc);
// CCT
m_pCCTManager = PxCreateControllerManager(*m_pScene);
m_pCCTManager->setOverlapRecoveryModule(true); // 복구모듈은 하이트필드에는 적용되지 않음, 오직 스태틱만 대상
@@ -20,6 +20,10 @@ CRigidBody_Dynamic::CRigidBody_Dynamic(const CRigidBody_Dynamic& rhs) :
#ifdef _DEBUG
HRESULT CRigidBody_Dynamic::Render()
{
return Render(nullptr);
}
HRESULT CRigidBody_Dynamic::Render(function<void()> custumState)
{
PSX::PxTransform pxTranform = m_pRigidBody->getGlobalPose();
_matrix WorldMatrix = XMMatrixTranslation(m_vLocalTranslation.x, m_vLocalTranslation.y, m_vLocalTranslation.z)
@@ -27,25 +31,24 @@ HRESULT CRigidBody_Dynamic::Render()
_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);
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true, custumState);
} break;
case ACTOR::CAPSULE:
{
WorldMatrix = XMMatrixAffineTransformation(XMVectorSet(1.f, 1.f, 1.f, 0.f), XMVectorZero(), XMLoadFloat4((_float4*)&pxTranform.q), XMVectorSetW(XMLoadFloat3((_float3*)&pxTranform.p), 1.f));
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
WorldMatrix = XMMatrixAffineTransformation(XMVectorSet(1.f, 1.f, 1.f, 0.f), XMVectorZero(), XMQuaternionMultiply(XMQuaternionRotationAxis(XMVectorSet(1.f, 0.f, 0.f, 0.f), XMConvertToRadians(90.f)), XMLoadFloat4((_float4*)&pxTranform.q)), XMVectorSetW(XMLoadFloat3((_float3*)&pxTranform.p), 1.f));
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true, custumState);
_matrix WorldUp = XMMatrixTranslationFromVector(WorldMatrix.r[1] * m_vhalfGeometryInfo.y);
_matrix WorldDown = XMMatrixTranslationFromVector(WorldMatrix.r[1] * -m_vhalfGeometryInfo.y);
m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
m_pSubShape->Draw(WorldUp * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true, custumState);
m_pSubShape->Draw(WorldDown * WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true, custumState);
} break;
case ACTOR::SPHERE:
{
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true);
m_pMainShape->Draw(WorldMatrix, ViewMatrix, ProjMatrix, vColor, nullptr, true, custumState);
} break;
default:
break;
@@ -53,6 +56,10 @@ HRESULT CRigidBody_Dynamic::Render()
return S_OK;
}
#endif
void CRigidBody_Dynamic::Set_Name(const _char* szName)
{
m_pRigidBody->setName(szName);
}
void CRigidBody_Dynamic::Set_HalfGeometryInfo(_float3 vhalfGeometryInfo)
{
m_vhalfGeometryInfo = vhalfGeometryInfo;
@@ -104,17 +111,26 @@ void CRigidBody_Dynamic::Set_HalfGeometryInfo(_float3 vhalfGeometryInfo)
Add_DebugShape();
#endif // _DEBUG
}
void CRigidBody_Dynamic::Move_LocalPos(_float4 vNewRotQ, _float3 vNewTranslation)
void CRigidBody_Dynamic::Move_LocalPos(_matrix newLocalPos)
{
m_vLocalRotQ = vNewRotQ;
m_vLocalTranslation = vNewTranslation;
_vector vScale, vPos, vRotQ;
XMMatrixDecompose(&vScale, &vRotQ, &vPos, newLocalPos);
Move_LocalPos(vPos, vRotQ);
}
void CRigidBody_Dynamic::Move_LocalPos(_float4& vNewRotQ, _float3& vNewTranslation)
{
Move_LocalPos(XMLoadFloat4(&vNewRotQ), XMLoadFloat3(&vNewTranslation));
}
void CRigidBody_Dynamic::Move_LocalPos(_fvector vNewRotQ, _gvector vNewTranslation)
{
XMStoreFloat4(&m_vLocalRotQ, vNewRotQ);
XMStoreFloat3(&m_vLocalTranslation, vNewTranslation);
PSX::PxShape* pShape = { nullptr };
m_pRigidBody->getShapes(&pShape, m_pRigidBody->getNbShapes());
pShape->setLocalPose(PSX::PxTransform(vNewTranslation.x, vNewTranslation.y, vNewTranslation.z, PSX::PxQuat(vNewRotQ.x, vNewRotQ.y, vNewRotQ.z, vNewRotQ.w)));
pShape->setLocalPose(PSX::PxTransform(m_vLocalTranslation.x, m_vLocalTranslation.y, m_vLocalTranslation.z, PSX::PxQuat(m_vLocalRotQ.x, m_vLocalRotQ.y, m_vLocalRotQ.z, m_vLocalRotQ.w)));
#ifdef _DEBUG
Add_DebugShape();
#endif // _DEBUG
}
_float CRigidBody_Dynamic::Get_Mass()
{
@@ -140,6 +156,26 @@ void CRigidBody_Dynamic::Set_Kinematic(_bool bKinematic)
m_pRigidBody->setRigidBodyFlag(PSX::PxRigidBodyFlag::eKINEMATIC, bKinematic);
}
void CRigidBody_Dynamic::Move_Kinematic(_fmatrix xmTransform)
{
_vector vScale, vPos, vRotQ;
XMMatrixDecompose(&vScale, &vRotQ, &vPos, xmTransform);
Move_Kinematic(vPos, vRotQ);
}
void CRigidBody_Dynamic::Move_Kinematic(_fvector vPos, _gvector vRotq)
{
PSX::PxTransform pxTransform = {};
XMStoreFloat3((_float3*)&pxTransform.p, vPos);
XMStoreFloat4((_float4*)&pxTransform.q, vRotq);
Move_Kinematic(pxTransform);
}
void CRigidBody_Dynamic::Move_Kinematic(PSX::PxTransform& pxDestination)
{
m_pRigidBody->setKinematicTarget(pxDestination);
}
HRESULT CRigidBody_Dynamic::ConvertToCCT(CCharacter_Controller& CCTOriginal)
{
m_pTransform->Set_WorldMatrix(m_pRigidBody->getGlobalPose());
@@ -186,6 +222,13 @@ void CRigidBody_Dynamic::Set_Rotation(_vector vRotQ)
Set_Transform(pxTransform);
}
void CRigidBody_Dynamic::Set_Transform(_matrix WorldMatrix)
{
_vector vScale, vPos, vRotQ;
XMMatrixDecompose(&vScale, &vRotQ, &vPos, WorldMatrix);
Set_Transform(vPos, vRotQ);
}
void CRigidBody_Dynamic::Set_Transform(_vector vPos, _vector vRotQ)
{
PSX::PxTransform pxTransform = m_pRigidBody->getGlobalPose();
@@ -200,17 +243,22 @@ void CRigidBody_Dynamic::Set_Transform(_vector vPos, _vector vRotQ)
Set_Transform(pxTransform);
}
void CRigidBody_Dynamic::Set_CenterTransform(_matrix CenterMatrix, _vector StartMatrix, _vector EndMatrix)
void CRigidBody_Dynamic::Set_CenterTransform(_vector vStart, _vector vEnd)
{
_vector vCenterWorldPos = (StartMatrix + EndMatrix) * 0.5f;
_vector vCenterWorldPos = (vStart + vEnd) * 0.5f;
_vector vRotQ = XMQuaternionIdentity();
_vector vDir = XMVectorSetW(EndMatrix - StartMatrix, 0.f);
_vector vDir = XMVectorSetW(vEnd - vStart, 0.f);
_float vLength = XMVectorGetX(XMVector3Length(vDir));
if (vLength > FLT_EPSILON5) {
vDir = XMVector3Normalize(vDir);
vRotQ = CMyTools::MakeQuaternionFromTo(XMVectorSet(1.f, 0.f, 0.f, 0.f), vDir);
}
Set_Transform(vCenterWorldPos, vRotQ);
if (m_pRigidBody->getRigidBodyFlags() & PSX::PxRigidBodyFlag::eKINEMATIC) {
Move_Kinematic(vCenterWorldPos, vRotQ);
}
else {
Set_Transform(vCenterWorldPos, vRotQ);
}
}
void CRigidBody_Dynamic::Set_Transform(PSX::PxTransform pxTransform)
@@ -312,9 +360,11 @@ HRESULT CRigidBody_Dynamic::Initialize(void* pArg)
return E_FAIL;
}
#endif // _DEBUG
RIGIDBODY_DYNAMIC_DESC* pDesc = static_cast<RIGIDBODY_DYNAMIC_DESC*>(pArg);
m_tagData.pOwner = m_pOwner;
XMStoreFloat4x4(&m_tagData.BeforeMatrix, m_pTransform->Get_XMWorldMatrix());
m_tagData.pBody = this;
m_tagData.bAutoOwnerTranslation = pDesc->bAutoOwnerTranslation;
m_pRigidBody = m_pGameInstance->Add_DynamicActor(*this, m_pGameInstance->Get_NextLevelID());
m_pRigidBody->userData = &m_tagData;
m_pRigidBody->setCMassLocalPose(m_PxMassCenter);
@@ -322,8 +372,8 @@ HRESULT CRigidBody_Dynamic::Initialize(void* pArg)
m_pRigidBody->setLinearDamping(m_vDamping.x);
m_pRigidBody->setAngularDamping(m_vDamping.y);
Move_LocalPos(m_vLocalRotQ, m_vLocalTranslation);
//m_pRigidBody->joint;
//PSX::PxRevol
return S_OK;
}
+4 -6
View File
@@ -11,12 +11,10 @@ class ENGINE_DLL CBone final : public CBase
CBone(const CBone& other);
virtual ~CBone() = default;
public:
_matrix Get_CombinedTransformationMatrix() const {
return XMLoadFloat4x4(&m_CombinedTransformationMatrix);
}
_float4x4* Get_CombinedTransformationMatrixPtr() {
return &m_CombinedTransformationMatrix;
}
_matrix Get_CombinedTransformationMatrix() const { return XMLoadFloat4x4(&m_CombinedTransformationMatrix); }
_float4x4* Get_CombinedTransformationMatrixPtr() { return &m_CombinedTransformationMatrix; }
_float4x4* Get_TransformationMatrixPtr() { return &m_TransformationMatrix; };
void Set_CombinedTransformationMatrixPtr(_matrix& newMatrix) {
return XMStoreFloat4x4(&m_CombinedTransformationMatrix, newMatrix);
}
@@ -15,10 +15,16 @@ class CPhysX_CctQueryFilterCallback final : public PSX::PxQueryFilterCallback
{
switch (PXOBJECT(physxUserData->iSubKind))
{
case Engine::PXOBJECT::LEG:
case PXOBJECT::LEG:
return PSX::PxQueryHitType::eNONE;
break;
case Engine::PXOBJECT::SKILL_PROTEGO:
case PXOBJECT::SKILL_PROTEGO:
return PSX::PxQueryHitType::eNONE;
break;
case PXOBJECT::JOINT_ROUTE:
return PSX::PxQueryHitType::eNONE;
break;
case PXOBJECT::JOINT_ANCHOR:
return PSX::PxQueryHitType::eNONE;
break;
default:
@@ -5,27 +5,27 @@ NS_BEGIN(Engine)
class CTransform;
class CMesh;
class ENGINE_DLL CDynamic_Joint final : public CComponent
class ENGINE_DLL CDynamic_D6Joint final : public CComponent
{
public:
typedef struct tagDynamicJointDesc {
PHYSX_JOINT eType;
PSX::PxRigidActor* pActor0;
PSX::PxTransform pLocalFrame0;
PSX::PxRigidActor* pActor1;
PSX::PxTransform pLocalFrame1;
PHYSX_JOINT eType;
PSX::PxRigidActor* pActor0;
PSX::PxRigidActor* pActor1;
const PSX::PxTransform* pxJointWorldPos;
}DYNAMICJOINT_DESC;
private:
CDynamic_Joint(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CDynamic_Joint(const CDynamic_Joint& rhs);
~CDynamic_Joint() = default;
CDynamic_D6Joint(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CDynamic_D6Joint(const CDynamic_D6Joint& rhs);
~CDynamic_D6Joint() = default;
public:
#ifdef _DEBUG
virtual HRESULT Render()override;
#endif // _DEBUG
PSX::PxD6Joint* Get_JointPtr() { return m_pJoint; };
private:
PSX::PxJoint* m_pJoint = { nullptr };
PSX::PxD6Joint* m_pJoint = { nullptr };
#ifdef _DEBUG
unique_ptr<GeometricPrimitive> m_pMainShape = { nullptr };
@@ -40,7 +40,7 @@ class ENGINE_DLL CDynamic_Joint final : public CComponent
#endif
public:
static CDynamic_Joint* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
static CDynamic_D6Joint* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override;
virtual void Free() override;
#ifdef _DEBUG
@@ -223,6 +223,7 @@ enum class PXOBJECT : _uint {
NOCOLLIDE = 900,
GAIL,
JOINT_ROUTE,
JOINT_ANCHOR,
#pragma endregion
END = 999
@@ -59,32 +59,7 @@ static PSX::PxTransform XMWorldToPx_NoScale(const _fmatrix& WorldMatrix)
XMStoreFloat4((_float4*)&out.q, vRotq);
return out;
}
// 주의, XMWorldToPx_NoScale 만들었을 때는 lh rh 변환을 생각안하고 했었음
// 지금 쓰는 이 함수는 lh -> rh 자동 변환임
static _matrix PxToXMWorld_NoScale(const PSX::PxTransform& pxTransform)
{
_vector vPos = XMVectorSet(
pxTransform.p.x,
pxTransform.p.y,
pxTransform.p.z,
1.f
);
_vector vRotQ = XMVectorSet(
-pxTransform.q.x,
-pxTransform.q.y,
pxTransform.q.z,
pxTransform.q.w
);
vRotQ = XMQuaternionNormalize(vRotQ);
_matrix rotationMatrix = XMMatrixRotationQuaternion(vRotQ);
_matrix translationMatrix = XMMatrixTranslationFromVector(vPos);
_matrix worldMatrix = rotationMatrix * translationMatrix;
return worldMatrix;
}
static void GUIHelpMarker(const char* desc)
@@ -376,6 +376,7 @@ typedef struct tagVertexInstance_UIDesc
typedef struct tagPhsXUserData {
PHYSX_KIND eKind = PHYSX_KIND::NOT_DEFINED;
_bool bAutoOwnerTranslation = true;
class CGameObject* pOwner = { nullptr };
_float4x4 BeforeMatrix = { };
@@ -211,6 +211,7 @@ class ENGINE_DLL CGameInstance final : public CBase
PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody_Dynamic& RigidBody, _uint iLevel);
PSX::PxRigidStatic* Add_StaticActor(CRigidBody_Static& RigidBody, _uint iLevel);
PSX::PxJoint* Create_PxJoint(PHYSX_JOINT eType, PSX::PxRigidActor* pActor0, PSX::PxTransform& pxLocalFrame0, PSX::PxRigidActor* pActor1, PSX::PxTransform& pxLocalFrame1);
PSX::PxD6Joint* Create_PxD6Joint(PSX::PxRigidActor* pActor0, PSX::PxRigidActor* pActor1, const PSX::PxTransform& pxJointWorldPos);
_bool SphereCast(_float fRadius, _float3 vStartPos, _float3 vDir, _float fDistance, PSX::PxHitFlags flagHitsData, PSX::PxQueryFlags flagQuery, PSX::PxSweepBuffer& hitBuffer);
_bool SphereCast(_float fRadius, _fvector vStartPos, _gvector vDir, _float fDistance, PSX::PxHitFlags flagHitsData, PSX::PxQueryFlags flagQuery, PSX::PxSweepBuffer& hitBuffer);
@@ -224,6 +225,7 @@ class ENGINE_DLL CGameInstance final : public CBase
void Attach_Actor(PSX::PxActor& Actor, _uint iLevel);
void Detach_Actor(PSX::PxActor& pActor, _uint iLevel);
void Release_Actor(PSX::PxActor& Actor);
void ApplyFilterData(PSX::PxRigidActor* pRigidActor);
HRESULT ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix = XMMatrixIdentity());
#ifdef EDITOR_PROJECT
HRESULT SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
+2
View File
@@ -86,12 +86,14 @@ class ENGINE_DLL CModel final : public CComponent
#pragma region Bone
HRESULT Bind_BoneMatrices(_uint iMeshIndex, class CShader* pShader, const _char* pConstantName);
const _float4x4* Get_BoneMatrixPtr(const _char* pBoneName);
const _float4x4* Get_BoneLocalMatrixPtr(const _char* pBoneName);
_matrix Get_BoneMatrix(const _char* pBoneName) const;
_matrix Get_BoneLocalMatrix(const _char* pBoneName) const;
static _int Get_BoneIndex(const _char* pBoneName, vector<class CBone*> Bones); // 본의 벡터와 이름을 넘겨주면 인덱스를 넘겨줌 ( n 순회 )
_int Get_BoneIndex(const _char* pBoneName) const;
_matrix Get_BoneMatrix(_uint iBoneIndex);
void Combined_BoneMatrix();
void Combined_BoneMatrix(_int iStartBoneIndex, _uint iBoneCount);
_int Find_BoneIndex(const _char* pBoneName);
#pragma endregion
@@ -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
+18 -1
View File
@@ -11,6 +11,16 @@ class CMesh;
class CPhysX_Manager final : public CBase
{
private:
// 주의: 피직스 내부 플래그 전용. 건드리려면 먼저 말하고 건드리기
// 가장 기본이 되는 필터 플래그
enum COLLISIONCATERGORY_BIT32 : uint32_t
{
CharacterController = 1u << 0
, JointedParts = 1u << 1
, WorldStatic = 1u << 2
, WorldDynamic = 1u << 3
};
private:
CPhysX_Manager(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual ~CPhysX_Manager() = default;
@@ -26,6 +36,7 @@ class CPhysX_Manager final : public CBase
// https://documentation.help/nvidia-physx-sdk-guide/Joints.html
PSX::PxJoint* Create_PxJoint(PHYSX_JOINT eType, PSX::PxRigidActor* pActor0, PSX::PxTransform& pxLocalFrame0, PSX::PxRigidActor* pActor1, PSX::PxTransform& pxLocalFrame1);
PSX::PxD6Joint* Create_PxD6Joint(PSX::PxRigidActor* pActor0, PSX::PxRigidActor* pActor1, const PSX::PxTransform& pxJointWorldPos);
void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh, _uint iLevel);
void RegistHeight(const _tchar* pName, PSX::PxHeightFieldDesc& Desc, _uint iLevel);
@@ -61,6 +72,7 @@ class CPhysX_Manager final : public CBase
public:
PSX::PxController* Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc);
PSX::PxController* Add_BoxController(PSX::PxBoxControllerDesc& Desc);
void ApplyFilterData(PSX::PxRigidActor* pRigidActor);
PSX::PxController* Get_Controller(_uint iControllerIndex);
void ReleaseController(_uint iControllerIndex);
@@ -115,7 +127,12 @@ class CPhysX_Manager final : public CBase
void Update_Kinematic();
void Update_Dynamic_ActiveActors();
//void Update_Dynamic_AllActors();
uint32_t ConvertPhysxKindToBit(PHYSX_KIND physxKind);
uint32_t BuildCollisionMaskFromCategoryBit(uint32_t iMyBit);
static PSX::PxFilterFlags SimulationFilterShader(PSX::PxFilterObjectAttributes pxAttributes0, PSX::PxFilterData pxFilterData0,
PSX::PxFilterObjectAttributes pxAttributes1, PSX::PxFilterData pxFilterData1,
PSX::PxPairFlags& pxPairFlags, const void* pConstantBlock, PSX::PxU32 iConstantBlockSize);
public:
static CPhysX_Manager* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, _uint iLevel);
@@ -7,7 +7,7 @@
#include "Navigation.h"
#include "RigidBody_Dynamic.h"
#include "RigidBody_Static.h"
#include "Dynamic_Joint.h"
#include "Dynamic_D6Joint.h"
#include "Texture.h"
#include "Cell.h"
#include "Model.h"
@@ -39,6 +39,8 @@ class ENGINE_DLL CRigidBody abstract : public CComponent
PSX::PxShapeFlags Get_ShapeFlags() const { return m_ePxShapeFlags; }
PSX::PxRigidBodyFlags Get_RigidBodyFlags() const { return m_ePxRigidBodyFlags; }
const PhsXUserData* Get_UserDataPtr() const { return &m_tagData; };
protected:
ACTOR m_eActorType = ACTOR::END;
PSX::PxRigidBodyFlags m_ePxRigidBodyFlags = { };
@@ -19,7 +19,7 @@ class ENGINE_DLL CRigidBody_Dynamic : public CRigidBody
typedef struct tagRigidBody_DYNAMIC_Desc : public CRigidBody::RIGIDBODY_DESC
{
_bool bAutoOwnerTranslation = true;
}RIGIDBODY_DYNAMIC_DESC;
private:
@@ -31,18 +31,25 @@ class ENGINE_DLL CRigidBody_Dynamic : public CRigidBody
#ifdef _DEBUG
_float3 Get_LocalTranslation() {return m_vLocalTranslation; }
virtual HRESULT Render()override;
HRESULT Render(function<void()> custumState);
#endif // _DEBUG
virtual PSX::PxRigidDynamic* Get_Actor() override { return m_pRigidBody; };
void Set_Name(const _char* szName);
_float3 Get_HalfGeometryInfo() const { return m_vhalfGeometryInfo; }
void Set_HalfGeometryInfo(_float3 vhalfGeometryInfo);
void Move_LocalPos(_float4 vNewRotQ, _float3 vNewTranslation);
void Move_LocalPos(_matrix newLocalPos);
void Move_LocalPos(_fvector vNewRotQ, _gvector vNewTranslation);
void Move_LocalPos(_float4& vNewRotQ, _float3& vNewTranslation);
_float Get_Density() const { return m_fDensity; }
_float Get_Mass();
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);
void Move_Kinematic(_fmatrix xmTransform);
void Move_Kinematic(_fvector vPos, _gvector vRotq);
void Move_Kinematic(PSX::PxTransform& pxDestination);
HRESULT ConvertToCCT(class CCharacter_Controller& CCTOriginal);
void Detach_Actor(_uint iLevel);
@@ -52,9 +59,12 @@ class ENGINE_DLL CRigidBody_Dynamic : public CRigidBody
_vector Get_Position();
void Set_Position(_vector vPos);
void Set_Rotation(_vector vRotQ);
void Set_AutoOwnerTranlation(_bool bAutoOwnerTranslation) { m_tagData.bAutoOwnerTranslation = bAutoOwnerTranslation; };
_bool Get_AutoOwnerTranlation() { return m_tagData.bAutoOwnerTranslation; };
void Set_Transform(_matrix WorldMatrix);
void Set_Transform(_vector vPos, _vector vRotQ);
void Set_CenterTransform(_matrix CenterMatrix, _vector StartMatrix, _vector EndMatrix);
void Set_Transform(PSX::PxTransform pxTransform);
void Set_CenterTransform(_vector vStart, _vector vEnd);
_float3 Get_FootPosition();
_float3 Get_HeadPosition();
PSX::PxTransform Get_GlobalPosition();