This commit is contained in:
GiJungSUk
2025-11-12 21:19:49 +09:00
parent 73da3d98f1
commit 3d992e221d
12839 changed files with 25732 additions and 283825 deletions
@@ -32,13 +32,6 @@ sampler BorderZeroSampler = sampler_state
BorderColor = float4(0, 0, 0, 0);
};
sampler PointSampler = sampler_state
{
Filter = MIN_MAG_MIP_POINT;
AddressU = wrap;
AddressV = wrap;
};
RasterizerState RS_Default
{
FillMode = Solid;
@@ -190,21 +183,3 @@ float2 Get_MovedUV(float2 vOriginalUV, float fDeltaU, float fDeltaV, uint iIndex
float2 vOffset = float2(iIndexU * fDeltaU, iIndexV * fDeltaV);
return vOriginalUV * vDelta + vOffset;
}
float2 UV_Cutting(float2 vUV, float2 vUVCutting, int iCurrentFrame)
{
float2 UV = vUV; // 이미지의 UV값
int iTotalFrame = vUVCutting.x * vUVCutting.y; // 이미지의 최대 프레임 (몇 곱하기 몇인지)
int iFrameX = iCurrentFrame % (int) vUVCutting.x; // 현재 x축의 위치(현재 이미지의 몇번째 칸을 보여줄 지)
int iFrameY = iCurrentFrame / (int) vUVCutting.x; // 현재 y축의 위치(현재 이미지의 몇번째 줄을 보여줄 지)
float fFreamWidth = 1.0 / vUVCutting.x; // 1.0 나누기 이미지 갯수를 해서 한칸에 얼마나 갈지 정해준다.
float fFreamHeight = 1.0 / vUVCutting.y; // 1.0 나누기 이미지 갯수를 해서 한줄에 얼마나 갈지 정해준다.
UV.x = UV.x * fFreamWidth + iFrameX * fFreamWidth; // 먼저 uv를 0~1이 아닌 0~fFrameWidth로 만든 다음에 한칸씩 옆으로 밀어준다.
UV.y = UV.y * fFreamHeight + iFrameY * fFreamHeight; // 먼저 uv를 0~1이 아닌 0~fFrameHeight로 만든 다음에 한줄씩 밑으로 내려준다.
return UV;
}
@@ -69,16 +69,16 @@ PS_OUT_BACKBUFFER PS_OUT_LASTCOLOR(PS_IN In)
Out.vBackBuffer.rgb = vColorTexture.rgb;
break;
case 2:
Out.vBackBuffer.rgb += vColorTexture.rgb;
Out.vBackBuffer.rgb *= vColorTexture.rgb;
break;
case 3:
Out.vBackBuffer.rgb -= vColorTexture.rgb;
break;
case 4:
Out.vBackBuffer.rgb *= vColorTexture.rgb;
Out.vBackBuffer.rgb /= vColorTexture.rgb;
break;
case 5:
Out.vBackBuffer.rgb /= vColorTexture.rgb;
Out.vBackBuffer.rgb += vColorTexture.rgb;
break;
default:
break;
@@ -11,8 +11,8 @@ struct Particle
struct ParticleValue
{
float fSpeed;
float fRotaionSpeed;
float fSpeed;
float fRotaionSpeed;
float4 vOriginRight;
float4 vOriginUp;
@@ -21,56 +21,40 @@ struct ParticleValue
float2 vMaskingUVMoveTime;
float2 vDiffuseUVMoveTime;
float2 vNoiseUVMoveTime;
float2 vAniTime;
float2 vAniIndex;
};
struct ParticleOut
{
float4 vRight;
float4 vUp;
float4 vLook;
float4 vTranslation;
float2 vLifeTime;
float2 vMaskingUVMoveTime;
float2 vDiffuseUVMoveTime;
float2 vAniTime;
float2 vAniIndex;
};
StructuredBuffer<Particle> g_ParticleBufferInput : register(t0);
StructuredBuffer<ParticleValue> g_ParticleValueBufferInput : register(t1);
RWStructuredBuffer<Particle> g_VBInstanceOutput : register(u0);
RWStructuredBuffer<ParticleValue> g_ParticleValueOutput : register(u1);
RWStructuredBuffer<ParticleOut> g_ParticleBufferOutput : register(u0);
cbuffer g_ConstantBuffer : register(b0) // b0 << 이 숫자와 컨스턴트 쉐이더 바인딩할때 인덱스가 동일해야함
{
row_major matrix CamViewInvMatrix;
float fTimeDelta;
bool isLoop; // 상수 버퍼에서 불값은 4바이트로 처리되기 때문에 반드시 클라에서는 int형으로 선언해라
bool isBillboard;
bool isPadding2;
bool isPadding3;
float fTimeDelta;
float fPadding; // 반드시 상수버퍼는 16바이트 배수로 만들어져야 한다.
float fPadding2;
float fPadding3;
}
void Billboard(Particle particle)
{
if (isBillboard == true)
{
float3 vScale;
vScale.x = length(particle.vRight);
vScale.y = length(particle.vUp);
vScale.z = length(particle.vLook);
particle.vRight = CamViewInvMatrix[0] * vScale.x;
particle.vUp = CamViewInvMatrix[1] * vScale.y;
particle.vLook = CamViewInvMatrix[2] * vScale.z;
//180도 회전 시키기
particle.vRight.x *= -1.f;
particle.vLook.z *= -1.f;
}
float fPadding; // 반드시 상수버퍼는 16바이트 배수로 만들어져야 한다.
float fPadding2;
float fPadding3;
}
//내가 몇개의 스레드를 사용할 것인지 지정하는데
@@ -85,6 +69,8 @@ void CS_MAIN(
ParticleValue particleValue = g_ParticleValueBufferInput[iIndex];
ParticleOut ParticleOut;
// 라이프타임 움직임
particle.vTranslation.y -= particleValue.fSpeed * fTimeDelta;
@@ -92,18 +78,10 @@ void CS_MAIN(
if (particle.vLifeTime.x >= particle.vLifeTime.y)
{
if (isLoop == false)
{
return;
}
particle.vLifeTime.x = 0.f;
particle.vTranslation.y = 0.f;
}
Billboard(particle);
//애니메이션 속도 , 인덱스
@@ -113,7 +91,7 @@ void CS_MAIN(
{
particleValue.vAniTime.x = 0.f;
particleValue.vAniIndex.x += 1.f;
particleValue.vAniIndex.x++;
if (particleValue.vAniIndex.x > particleValue.vAniIndex.y) // 애니메이션에 끝에 다다랐다면
{
@@ -127,7 +105,7 @@ void CS_MAIN(
particleValue.vMaskingUVMoveTime.x += fTimeDelta;
if (particleValue.vMaskingUVMoveTime.x >= particleValue.vMaskingUVMoveTime.y)
if (particleValue.vMaskingUVMoveTime.x >= particleValue.vMaskingUVMoveTime.x)
{
particleValue.vMaskingUVMoveTime.x = 0.f;
}
@@ -137,23 +115,25 @@ void CS_MAIN(
particleValue.vDiffuseUVMoveTime.x += fTimeDelta;
if (particleValue.vDiffuseUVMoveTime.x >= particleValue.vDiffuseUVMoveTime.y)
if (particleValue.vDiffuseUVMoveTime.x >= particleValue.vDiffuseUVMoveTime.x)
{
particleValue.vDiffuseUVMoveTime.x = 0.f;
}
//노이즈 움직임
particleValue.vNoiseUVMoveTime.x += fTimeDelta;
if (particleValue.vNoiseUVMoveTime.x >= particleValue.vNoiseUVMoveTime.y)
{
particleValue.vNoiseUVMoveTime.x = 0.f;
}
//아웃풋 대입
g_VBInstanceOutput[iIndex] = particle;
g_ParticleValueOutput[iIndex] = particleValue;
ParticleOut.vRight = particle.vRight;
ParticleOut.vUp = particle.vUp;
ParticleOut.vLook = particle.vLook;
ParticleOut.vTranslation = particle.vTranslation;
ParticleOut.vLifeTime = particle.vLifeTime;
ParticleOut.vMaskingUVMoveTime = particleValue.vMaskingUVMoveTime;
ParticleOut.vDiffuseUVMoveTime = particleValue.vDiffuseUVMoveTime;
ParticleOut.vAniTime = particleValue.vAniTime;
ParticleOut.vAniIndex = particleValue.vAniIndex;
g_ParticleBufferOutput[iIndex] = ParticleOut;
}
+25 -5
View File
@@ -126,6 +126,16 @@
<AdditionalLibraryDirectories>../ThirdPartyLib/fMod/;../ThirdPartyLib/DirectXTK/;../ThirdPartyLib/FX11/;../ThirdPartyLib/Assimp/;../ThirdPartyLib/PhysX/PhysX_$(Configuration)/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;PhysXCharacterKinematic_static_64.lib;DirectXTKd.lib;Effects11d.lib;assimp-vc145-mtd.lib;%(AdditionalDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>cd /d "$(SolutionDir)"
call CleanUp.bat
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>cd /d "$(SolutionDir)"
call Update_Lib.bat
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
@@ -133,7 +143,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>EDITOR_PROJECT;ENGINE_EXPORTS;IMGUI_EXPORTS;TINYXML2_EXPORT;$(USERDOMAIN);NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>EDITOR_PROJECT;ENGINE_EXPORTS;IMGUI_EXPORTS;TINYXML2_EXPORT;$(USERNAME);NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalIncludeDirectories>../Public/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
@@ -149,6 +159,16 @@
<AdditionalLibraryDirectories>../ThirdPartyLib/fMod/;../ThirdPartyLib/DirectXTK/;../ThirdPartyLib/FX11/;../ThirdPartyLib/Assimp/;../ThirdPartyLib/PhysX/PhysX_$(Configuration)/;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>d3d11.lib;fmod_vc.lib;dinput8.lib;LowLevel_static_64.lib;LowLevelAABB_static_64.lib;LowLevelDynamics_static_64.lib;PhysX_64.lib;PhysXCommon_64.lib;PhysXCooking_64.lib;PhysXExtensions_static_64.lib;PhysXFoundation_64.lib;PhysXPvdSDK_static_64.lib;PhysXTask_static_64.lib;SceneQuery_static_64.lib;SimulationController_static_64.lib;PhysXCharacterKinematic_static_64.lib;DirectXTK.lib;Effects11.lib;assimp-vc145-mt.lib;%(AdditionalDependencies);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PreBuildEvent>
<Command>cd /d "$(SolutionDir)"
call CleanUp.bat
</Command>
</PreBuildEvent>
<PostBuildEvent>
<Command>cd /d "$(SolutionDir)"
call Update_Lib.bat
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\Private\Animation.cpp" />
@@ -174,8 +194,8 @@
<ClCompile Include="..\Private\Cell.cpp" />
<ClCompile Include="..\Private\Channel.cpp" />
<ClCompile Include="..\Private\Character_Controller.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\Private\Collider.cpp" />
<ClCompile Include="..\Private\Collider_Manager.cpp" />
@@ -389,8 +409,8 @@
<ClInclude Include="..\Public\Cell.h" />
<ClInclude Include="..\Public\Channel.h" />
<ClInclude Include="..\Public\Character_Controller.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\Public\Collider.h" />
<ClInclude Include="..\Public\Collider_Manager.h" />
+1 -1
View File
@@ -189,7 +189,7 @@ HRESULT CAnimation::Initialize(const CModel* pModel, SaveAnimation* pSaveAnimati
{
m_pSaveAnim = pSaveAnimation;
strcpy_s(m_szName, pSaveAnimation->Name);
strcpy_s(m_szName, pSaveAnimation->AnimName.c_str());
m_fDuration = pSaveAnimation->mDuration;
m_fTickPerSecond = pSaveAnimation->mTicksPerSecond;
+1 -1
View File
@@ -124,7 +124,7 @@ HRESULT CBone::Initialize(HANDLE hFile, DWORD& dwByte)
HRESULT CBone::Initialize(const SaveNode& _SaveNode, _int iParentIndex)
{
strcpy_s(m_szName, _SaveNode.Name);
strcpy_s(m_szName, _SaveNode.NodeName.c_str());
m_iParentBoneIndex = iParentIndex;
+1 -1
View File
@@ -185,7 +185,7 @@ HRESULT CChannel::Initialize(HANDLE hFile, DWORD& dwByte)
HRESULT CChannel::Initialize(const CModel* pModel, SaveChannel* pSaveChannel)
{
strcpy_s(m_szName, pSaveChannel->Name);
strcpy_s(m_szName, pSaveChannel->ChannelName.c_str());
m_iBoneIndex = pModel->Get_BoneIndex(m_szName);
m_PreTransformMatrix = pModel->Get_PreTransformMatrix();
@@ -2,37 +2,261 @@
#include "Character_Controller.h"
#include "GameInstance.h"
CCharacter_Controller::CCharacter_Controller(ID3D11Device* pDevice, ID3D11DeviceContext* pContext) :
m_pDevice(pDevice),
m_pContext(pContext),
m_pGameInstance(CGameInstance::GetInstance())
CCharacter_Controller::CCharacter_Controller(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
: CComponent{ pDevice, pContext }
{
SAFE_ADDREF(m_pDevice);
SAFE_ADDREF(m_pContext);
SAFE_ADDREF(m_pGameInstance);
}
CCharacter_Controller* CCharacter_Controller::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, PSX::PxScene* pScene)
CCharacter_Controller::CCharacter_Controller(const CCharacter_Controller& rhs)
: CComponent(rhs)
{
}
void CCharacter_Controller::Modify_Volume(_float3 fVolume)
{
switch (m_eBodyType)
{
case Engine::ACTOR::BOX:
{
PSX::PxBoxController* pBox = static_cast<PSX::PxBoxController*>(m_pController);
if (0 != fVolume.x) {
pBox->setHalfSideExtent(fVolume.x);
}
if (0 != fVolume.y) {
pBox->setHalfHeight(fVolume.y);
}
if (0 != fVolume.z) {
pBox->setHalfForwardExtent(fVolume.z);
}
}
break;
case Engine::ACTOR::CAPSULE:
{
PSX::PxCapsuleController* pCapsule = static_cast<PSX::PxCapsuleController*>(m_pController);
if (0 != fVolume.x) {
pCapsule->setRadius(fVolume.x);
}
if (0 != fVolume.y) {
pCapsule->setHeight(fVolume.y);
}
}
break;
default:
break;
}
// Overlap();
}
_float3 CCharacter_Controller::Get_Volume()
{
switch (m_eBodyType)
{
case Engine::ACTOR::BOX:
{
PSX::PxBoxController* pBox = static_cast<PSX::PxBoxController*>(m_pController);
return {
pBox->getHalfSideExtent(),
pBox->getHalfHeight(),
pBox->getHalfForwardExtent()
};
}
break;
case Engine::ACTOR::CAPSULE:
{
PSX::PxCapsuleController* pCapsule = static_cast<PSX::PxCapsuleController*>(m_pController);
return {
pCapsule->getRadius(),
pCapsule->getHeight(),
0.f
};
}
break;
default:
return { -1.f, -1.f, -1.f };
break;
}
}
void CCharacter_Controller::Move(_float fTimeDelta)
{
PSX::PxVec3 pxVecMomentum = {}; // 순간 이동량
_float fMinimumDistant = FLT_EPSILON3; // 이동량 오차 허용치, ( 크면 클수록 이동이 더 일찍 끝난다, 순간 이동량보다 같거나 더 크면 안움직일듯? )
_vector vMomentum = m_pTransform->Get_CurrentMomentum();
XMStoreFloat3((_float3*)&pxVecMomentum, vMomentum);
PSX::PxControllerFilters pxFilter = {}; // 충돌 대상 필터
const PSX::PxObstacleContext* pPxObstacles = { nullptr }; // 캐릭터가 충돌해야할 추가적인 장애물 객체?, 닿은 장애물은 캐시된다?
// eCOLLISION_SIDES = (1 << 0), //!< Character is colliding to the sides.
// eCOLLISION_UP = (1 << 1), //!< Character has collision above.
// eCOLLISION_DOWN = (1 << 2) //!< Character has collision below.
m_eBeforeCollisionFlags = m_pController->move(pxVecMomentum, fMinimumDistant, fTimeDelta, pxFilter, pPxObstacles);
//PSX::PxUserControllerHitReport* pHitCallBack = { nullptr };
//PSX::PxControllerShapeHit ShapeHit = {};
//ShapeHit.
//pHitCallBack->onShapeHit();
}
void CCharacter_Controller::Set_Position(_fvector vNewPos)
{
PSX::PxExtendedVec3 pxLVec3NewPos = {};
pxLVec3NewPos.x = vNewPos.m128_f32[0];
pxLVec3NewPos.y = vNewPos.m128_f32[1];
pxLVec3NewPos.z = vNewPos.m128_f32[2];
m_pController->setPosition(pxLVec3NewPos);
}
_float3 CCharacter_Controller::Get_FootPosition()
{
PSX::PxExtendedVec3 pxLVecfootPos = m_pController->getFootPosition();
return { (_float)pxLVecfootPos.x, (_float)pxLVecfootPos.y, (_float)pxLVecfootPos.z };
}
void CCharacter_Controller::Resize_Volume(_float fHeight)
{
m_pController->resize(fHeight);
}
HRESULT CCharacter_Controller::Initialize_Prototype()
{
return S_OK;
}
HRESULT CCharacter_Controller::Initialize(void* pArg)
{
Character_Controller_DESC* pDesc = static_cast<Character_Controller_DESC*>(pArg);
m_eBodyType = pDesc->eBodyType;
m_bAutoStepping = pDesc->bAutoStepping;
m_pTransform = pDesc->pTransform;
switch (m_eBodyType)
{
case Engine::ACTOR::BOX:
{
PSX::PxBoxControllerDesc Desc{};
Desc.halfHeight = {};
Desc.halfSideExtent = {};
Desc.halfForwardExtent = {};
Desc.contactOffset = pDesc->fContactOffset;
Desc.material = m_pGameInstance->Get_Material(pDesc->fMaterial);
m_pController = m_pGameInstance->Add_BoxController(Desc);
} break;
case Engine::ACTOR::CAPSULE:
{
PSX::PxCapsuleControllerDesc Desc{};
Desc.radius = pDesc->tCapsuleInfo.fRadius;
Desc.height = pDesc->tCapsuleInfo.fHeight;
Desc.climbingMode = pDesc->tCapsuleInfo.eClimbingMode; // 기본 eEASY
Desc.contactOffset = pDesc->fContactOffset;
Desc.material = m_pGameInstance->Get_Material(pDesc->fMaterial);
m_pController = m_pGameInstance->Add_CapsuleController(Desc);
} break;
default:
assert(false); // PhysX에서 불가능
return E_FAIL;
break;
}
if (nullptr == m_pController) {
assert(false);
return E_FAIL;
}
m_pController->setSlopeLimit(m_fSlopeLimit);
return S_OK;
}
_bool CCharacter_Controller::Check_Overlap()
{
return _bool();
}
CCharacter_Controller* CCharacter_Controller::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CCharacter_Controller* pInstance = new CCharacter_Controller(pDevice, pContext);
if (FAILED(pInstance->Initialize(pScene))) {
if (FAILED(pInstance->Initialize_Prototype()))
{
MSG_BOX("Failed to Created : CCharacter_Controller");
SAFE_RELEASE(pInstance);
assert(false);
}
return pInstance;
}
HRESULT CCharacter_Controller::Initialize(PSX::PxScene* pScene)
CComponent* CCharacter_Controller::Clone(void* pArg, class CGameObject* pOwner)
{
m_pScene = pScene;
return S_OK;
CCharacter_Controller* pInstance = new CCharacter_Controller(*this);
pInstance->m_pOwner = pOwner;
if (FAILED(pInstance->Initialize(pArg)))
{
MSG_BOX("Failed to Cloned : CCharacter_Controller");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
void CCharacter_Controller::Free()
{
__super::Free();
}
SAFE_RELEASE(m_pDevice);
SAFE_RELEASE(m_pContext);
SAFE_RELEASE(m_pGameInstance);
}
void CCharacter_Controller::Describe_Entity()
{
GUI::Begin("Character_Controller");
m_pTransform->Describe_Entity();
GUI::TextLinkOpenURL("More details here", "https://dev-treadmill.tistory.com/158");
_float fContact = m_pController->getContactOffset();
PSX::PxVec3 vUpDirection = m_pController->getUpDirection();
PSX::PxExtendedVec3 vCenterPosition = m_pController->getPosition();
PSX::PxExtendedVec3 vFootPosition = m_pController->getFootPosition();
_float3 vVolume = Get_Volume();
_float fStepOffset = m_pController->getStepOffset();
GUI::Text("eBodyType $d", (_uint)m_eBodyType); GUIHelpMarker("Body: only box and capsule available");
if (GUI::SliderFloat3("UpDirection", (_float*)&vUpDirection, -1.f, 1.f)) {
m_pController->setUpDirection(vUpDirection.getNormalized());
} GUIHelpMarker("Up vector in PhysX");
GUI::Text("vCenterPosition %lf, %lf, %lf", vCenterPosition.x, vCenterPosition.y, vCenterPosition.z); GUIHelpMarker("Exact center of the rigid body owned by the controller");
GUI::Text("vFootPosition %lf, %lf, %lf", vFootPosition.x, vFootPosition.y, vFootPosition.z); GUIHelpMarker("Foot position including step offset from the body center to the ground");
if (GUI::SliderFloat("ContactOffset", &fContact, 0.01f, 10.f, "%.2f")) {
m_pController->setContactOffset(fContact);
} GUIHelpMarker("Actual contact offset in PhysX; increasing it may make the controller appear to hover");
if (GUI::SliderFloat("StepOffset", &fStepOffset, 0.f, 3.f, "%.2f")) {
m_pController->setStepOffset(fStepOffset);
} GUIHelpMarker("In stepped regions, the tolerance height the controller can climb.\n Capsule behaves slightly differently.");
if (ACTOR::CAPSULE == m_eBodyType) {
PSX::PxCapsuleController* pController = (PSX::PxCapsuleController*)m_pController;
if (0.f != fStepOffset) {
switch (pController->getClimbingMode())
{
case PSX::PxCapsuleClimbingMode::eEASY:
if (GUI::Button("ClimbingMode : eEasy")) {
pController->setClimbingMode(PSX::PxCapsuleClimbingMode::eCONSTRAINED);
}
break;
case PSX::PxCapsuleClimbingMode::eCONSTRAINED:
if (GUI::Button("ClimbingMode : eConstrained")) {
pController->setClimbingMode(PSX::PxCapsuleClimbingMode::eEASY);
}
break;
default:
break;
}
GUIHelpMarker("A capsule is affected by its lower sphere and tends to generate an up vector on steps.\nIn eEASY, the up vector is combined with the step offset, allowing easier climbing; in eCONSTRAINED, the up vector is removed during step detection and only the step offset is used.");
}
}
if (GUI::SliderFloat3("Volume", (_float*)&vVolume, 0.1f, 10.f, "%.2f")) {
Modify_Volume(vVolume);
}GUIHelpMarker("Box uses vSize; Capsule uses x->fRadius, y->fHeight.\nThe capsule's fHeight is likely the distance from the lower sphere center to the upper sphere center.");
GUI::End();
}
+62 -112
View File
@@ -13,16 +13,16 @@ CComputeShader::CComputeShader(ID3D11Device* pDevice, ID3D11DeviceContext* pCont
Safe_AddRef(m_pGameInstance);
}
HRESULT CComputeShader::Initialize(const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[])
HRESULT CComputeShader::Initialize(const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iOutputStructStride, _uint iInputStructStride[])
{
m_iNumElement = iNumElement;
m_iNumInputBuffer = iNumInputBuffer;
m_iNumOutputBuffer = iNumOutputBuffer;
m_iOutputStructStride = iOutputStructStride;
if (FAILED(CreateComputeShader(pShaderFilePath, pStartFunctionName)))
return E_FAIL;
if (FAILED(CreateBuffer(iNumElement, iInputStructStride, iOutputStructStride)))
if (FAILED(CreateBuffer(iNumElement, iNumInputBuffer, iInputStructStride)))
return E_FAIL;
if (FAILED(CreateResurceViews(iNumElement, iNumInputBuffer)))
@@ -33,7 +33,7 @@ HRESULT CComputeShader::Initialize(const _tchar* pShaderFilePath, const _char* p
return S_OK;
}
vector<D3D11_MAPPED_SUBRESOURCE> CComputeShader::Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer)
D3D11_MAPPED_SUBRESOURCE CComputeShader::Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer)
{
//VBBuffer-> dynamic , pConstantBuffer-> dynamic , m_pInputBuffer, m_pOutputBuffer-> default , m_pStagingBuffer-> Staging
@@ -47,9 +47,9 @@ vector<D3D11_MAPPED_SUBRESOURCE> CComputeShader::Dispatch(_uint iSRVIndex, _uint
{
D3D11_MAPPED_SUBRESOURCE PreSubResource = {};
m_pContext->CopyResource(m_pInputStagingBuffer[i], ppBuffers[i]);
m_pContext->CopyResource(m_pStagingBuffer[i], ppBuffers[i]);
m_pContext->CopyResource(m_pInputBuffer[i], m_pInputStagingBuffer[i]);
m_pContext->CopyResource(m_pInputBuffer[i], m_pStagingBuffer[i]);
}
@@ -71,30 +71,22 @@ vector<D3D11_MAPPED_SUBRESOURCE> CComputeShader::Dispatch(_uint iSRVIndex, _uint
//디폴트-> 스테이징 버퍼는 복사가 가능함 (다이나믹은 cpu 기반이라 복사 안됨)
//0번 스테이징 버퍼가 아우풋 스테이징 버퍼와 같음
m_pContext->CopyResource(m_pOutputStagingBuffer, m_pOutputBuffer);
vector<D3D11_MAPPED_SUBRESOURCE> StagingSubResources = {};
//스테이징 버퍼를 열어서 카피함
D3D11_MAPPED_SUBRESOURCE StagingSubResource = {};
//D3D11_MAPPED_SUBRESOURCE OutSubResource = {};
for (_uint i = 0; i < m_iNumOutputBuffer; i++)
if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer, 0, D3D11_MAP_READ, 0, &StagingSubResource)))
{
m_pContext->CopyResource(m_pOutputStagingBuffer[i], m_pOutputBuffer[i]);
//스테이징 버퍼를 열어서 카피함
D3D11_MAPPED_SUBRESOURCE StagingSubResource = {};
if (SUCCEEDED(m_pContext->Map(m_pOutputStagingBuffer[i], 0, D3D11_MAP_READ, 0, &StagingSubResource)))
{
StagingSubResources.push_back(StagingSubResource);
m_pContext->Unmap(m_pOutputStagingBuffer[i], 0);
}
}
m_pContext->Unmap(m_pOutputStagingBuffer, 0);
}
Reset();
return StagingSubResources;
return StagingSubResource;
}
void CComputeShader::Bind_SRV(_uint iIndex)
@@ -106,45 +98,34 @@ void CComputeShader::Bind_SRV(_uint iIndex)
void CComputeShader::Bind_UAV(_uint iIndex)
{
m_pContext->CSSetUnorderedAccessViews(iIndex, m_iNumOutputBuffer, &m_pOutputUAV[0], nullptr);
m_pContext->CSSetUnorderedAccessViews(iIndex, 1, &m_pOutputUAV, nullptr);
}
void CComputeShader::Bind_OutPut_SRV(_uint iIndex , _uint iBufferIndex)
void CComputeShader::Bind_OutPut_SRV(_uint iIndex)
{
m_pContext->PSSetShaderResources(iIndex, // 시작슬롯 번호
m_pContext->CSSetShaderResources(iIndex, // 시작슬롯 번호
1, // 버퍼 개수
&m_pOutputSRV[iBufferIndex]); // 버퍼 시작 주소
&m_pOutputSRV); // 버퍼 시작 주소
}
void CComputeShader::Reset()
{
//다음 랜더링 패스에 연관되지 않도록 초기화
ID3D11UnorderedAccessView* pResetUAV[1] = { nullptr };
ID3D11ShaderResourceView* pResetSRV[2] = { nullptr, nullptr };
vector<ID3D11ShaderResourceView*> pResetSRVs = {};
vector<ID3D11UnorderedAccessView*> pResetUAVs = {};
for (_uint i = 0; i < m_iNumInputBuffer; i++)
{
pResetSRVs.push_back(nullptr);
}
for (_uint i = 0; i < m_iNumOutputBuffer; i++)
{
pResetUAVs.push_back(nullptr);
}
m_pContext->CSSetShaderResources(0, m_iNumInputBuffer, &pResetSRVs[0]);
m_pContext->CSSetUnorderedAccessViews(0, m_iNumOutputBuffer, &pResetUAVs[0], nullptr);
m_pContext->CSSetUnorderedAccessViews(0, 1, pResetUAV, nullptr);
m_pContext->CSSetShaderResources(0, 2, pResetSRV);
m_pContext->CSSetShader(nullptr, nullptr, 0);
}
HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride[], _uint iOuputStructStride[])
HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iNumInputBuffer, _uint iInputStructStride[])
{
//인 아웃풋 버퍼
for (_uint i = 0; i < m_iNumInputBuffer; i++) // 인풋 버퍼를 여러개 사용할 수 있도록 만든다
for (_uint i = 0; i < iNumInputBuffer; i++) // 인풋 버퍼를 여러개 사용할 수 있도록 만든다
{
D3D11_BUFFER_DESC InputBufferdesc = {};
@@ -174,18 +155,14 @@ HRESULT CComputeShader::CreateBuffer(_uint iNumElement, _uint iInputStructStride
if (FAILED(m_pDevice->CreateBuffer(&StagingBufferDesc, nullptr, &pStagingBuffer)))
return E_FAIL;
m_pInputStagingBuffer.push_back(pStagingBuffer);
m_pStagingBuffer.push_back(pStagingBuffer);
}
for (_uint i = 0; i < m_iNumOutputBuffer; i++)
{
// 아웃풋 버퍼
//아웃풋 버퍼
D3D11_BUFFER_DESC Bufferdesc = {};
Bufferdesc.ByteWidth = iOuputStructStride[i] * iNumElement;
Bufferdesc.StructureByteStride = iOuputStructStride[i];
Bufferdesc.ByteWidth = m_iOutputStructStride * iNumElement;
Bufferdesc.StructureByteStride = m_iOutputStructStride;
Bufferdesc.Usage = D3D11_USAGE_DEFAULT; // 인 아웃풋 버퍼는 디폴트로 설정해야함
Bufferdesc.CPUAccessFlags = 0; // 디폴트 버퍼는 CPU에서 Read Write가 불가능하며
//오직 Update_SubResource를 통해서만 갱신이 가능하다.
@@ -193,28 +170,23 @@ for (_uint i = 0; i < m_iNumOutputBuffer; i++)
Bufferdesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_UNORDERED_ACCESS;
Bufferdesc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
ID3D11Buffer* pOutputBuffer = nullptr;
if (FAILED(m_pDevice->CreateBuffer(&Bufferdesc, nullptr, &pOutputBuffer)))
if(FAILED(m_pDevice->CreateBuffer(&Bufferdesc, nullptr, &m_pOutputBuffer)))
return E_FAIL;
m_pOutputBuffer.push_back(pOutputBuffer);
//아웃풋 스테이징 버퍼
D3D11_BUFFER_DESC OutPutStagingBufferDesc = {};
OutPutStagingBufferDesc.Usage = D3D11_USAGE_STAGING; // 스테이징 버퍼
OutPutStagingBufferDesc.ByteWidth = iOuputStructStride[i] * iNumElement;
OutPutStagingBufferDesc.StructureByteStride = iOuputStructStride[i];
OutPutStagingBufferDesc.ByteWidth = m_iOutputStructStride * iNumElement;
OutPutStagingBufferDesc.StructureByteStride = m_iOutputStructStride;
OutPutStagingBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE;
ID3D11Buffer* pOutputStagingBuffer = nullptr;
if (FAILED(m_pDevice->CreateBuffer(&OutPutStagingBufferDesc, nullptr, &pOutputStagingBuffer)))
if (FAILED(m_pDevice->CreateBuffer(&OutPutStagingBufferDesc, nullptr, &m_pOutputStagingBuffer)))
return E_FAIL;
m_pOutputStagingBuffer.push_back(pOutputStagingBuffer);
}
return S_OK;
}
@@ -229,8 +201,8 @@ HRESULT CComputeShader::CreateResurceViews(_uint iNumElement, _uint iNumInputBuf
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
srvDesc.Format = DXGI_FORMAT_UNKNOWN;
srvDesc.Buffer.FirstElement = 0;
srvDesc.Buffer.NumElements = iNumElement;
srvDesc.BufferEx.FirstElement = 0;
srvDesc.BufferEx.NumElements = iNumElement;
if (FAILED(m_pDevice->CreateShaderResourceView(m_pInputBuffer[i], &srvDesc, &pSrv)))
return E_FAIL;
@@ -239,42 +211,26 @@ HRESULT CComputeShader::CreateResurceViews(_uint iNumElement, _uint iNumInputBuf
}
// UAV
D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
uavDesc.Buffer.FirstElement = 0;
uavDesc.Buffer.NumElements = iNumElement;
if(FAILED(m_pDevice->CreateUnorderedAccessView(m_pOutputBuffer, &uavDesc, &m_pOutputUAV)))
return E_FAIL;
//OUTPUT
for (_uint i = 0; i < m_iNumOutputBuffer; i++)
{
//UAV
D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
uavDesc.Format = DXGI_FORMAT_UNKNOWN;
uavDesc.Buffer.FirstElement = 0;
uavDesc.Buffer.NumElements = iNumElement;
ID3D11UnorderedAccessView* pOutputUAV = { nullptr };
if (FAILED(m_pDevice->CreateUnorderedAccessView(m_pOutputBuffer[i], &uavDesc, &pOutputUAV)))
return E_FAIL;
m_pOutputUAV.push_back(pOutputUAV);
//SRV
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.Format = DXGI_FORMAT_UNKNOWN; // StructuredBuffer는 UNKNOWN
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
srvDesc.Buffer.NumElements = iNumElement;
srvDesc.Buffer.FirstElement = 0;
ID3D11ShaderResourceView* pOutputSrv = {};
if (FAILED(m_pDevice->CreateShaderResourceView(m_pOutputBuffer[i], &srvDesc, &pOutputSrv)))
return E_FAIL;
m_pOutputSRV.push_back(pOutputSrv);
}
D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
srvDesc.Format = DXGI_FORMAT_UNKNOWN; // StructuredBuffer는 UNKNOWN
srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
srvDesc.Buffer.NumElements = iNumElement;
srvDesc.BufferEx.FirstElement = 0;
if (FAILED(m_pDevice->CreateShaderResourceView(m_pOutputBuffer, &srvDesc, &m_pOutputSRV)))
return E_FAIL;
return S_OK;
}
@@ -316,11 +272,11 @@ HRESULT CComputeShader::CreateComputeShader(const _tchar* pShaderFilePath, const
}
CComputeShader* CComputeShader::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[])
CComputeShader* CComputeShader::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iOutputStructStride, _uint iInputStructStride[])
{
CComputeShader* pInstance = new CComputeShader(pDevice, pContext);
if (FAILED(pInstance->Initialize(pShaderFilePath, pStartFunctionName , iNumElement, iNumInputBuffer, iNumOutputBuffer,iOutputStructStride, iInputStructStride)))
if (FAILED(pInstance->Initialize(pShaderFilePath, pStartFunctionName , iNumElement, iNumInputBuffer, iOutputStructStride, iInputStructStride)))
{
MSG_BOX("Failed to Created : CComputeShader Prototype");
Safe_Release(pInstance);
@@ -337,17 +293,11 @@ void CComputeShader::Free()
{
Safe_Release(m_pInputSRV[i]);
Safe_Release(m_pInputBuffer[i]);
Safe_Release(m_pInputStagingBuffer[i]);
Safe_Release(m_pStagingBuffer[i]);
}
for (_uint i = 0; i < m_iNumOutputBuffer; i++)
{
Safe_Release(m_pOutputUAV[i]);
Safe_Release(m_pOutputBuffer[i]);
Safe_Release(m_pOutputSRV[i]);
}
Safe_Release(m_pOutputUAV);
Safe_Release(m_pOutputBuffer);
Safe_Release(m_pComputeShader);
Safe_Release(m_pDevice);
Safe_Release(m_pContext);
@@ -23,10 +23,6 @@ HRESULT CContainerObject::Initialize(void* pArg)
return E_FAIL;
}
if (FAILED(Ready_Components(pArg))) {
return E_FAIL;
}
return S_OK;
}
+33 -24
View File
@@ -158,27 +158,6 @@ _int CGameInstance::Random_Int(_int iMin, _int iMax)
return iMin + (_int)(Random_Normal() * (iMax - iMin));
}
void CGameInstance::BillBoard(CTransform* pTransform)
{
_matrix ScaleMatrix = {};
_matrix BillBoardMatrix = Get_Transform_Matrix(D3DTS::VIEW_INV);
_float3 vScale = pTransform->Get_Scale();
_vector vPosition = pTransform->Get_State(STATE::POSITION);
_matrix RotationMatrix = XMMatrixRotationAxis(XMVectorSet(0.f, 1.f, 0.f, 0.f), XMConvertToRadians(180.f));
ScaleMatrix = XMMatrixIdentity() * XMMatrixScaling(vScale.x, vScale.y, vScale.z);
BillBoardMatrix.r[3] = vPosition;
pTransform->Set_WorldMatrix(ScaleMatrix * RotationMatrix * BillBoardMatrix );
}
void CGameInstance::Save_ModelFilePath(const _char* FilePath)
{
m_FilePaths.push_back(FilePath);
@@ -291,7 +270,7 @@ void CGameInstance::Present_TimeCost() const
GUI::SameLine(0.f, GUI::GetStyle().ItemInnerSpacing.x);
GUI::Text("Timer_Occupancy %d", int(m_fTimer_Present / fTotal * 100.f));
}
GUI::Text("GameInstance RefCNT : %d", m_iRefCnt);
static float values[60] = {};
static int values_offset = 0;
static double refresh_time = 0.0;
@@ -562,10 +541,12 @@ PSX::PxMaterial* CGameInstance::Get_Material(_float3& vMatInfo)
{
return m_pPhysX_Manager->Get_Material(vMatInfo);
}
HRESULT CGameInstance::Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh)
void CGameInstance::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh)
{
return m_pPhysX_Manager->Create_TriangleMesh(wstrMeshKey, pMesh);
return m_pPhysX_Manager->RegistTriMesh(pName, pPxTriMesh);
}
PSX::PxShape* CGameInstance::Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive, PSX::PxShapeFlags ePxShapeFlag)
{
return m_pPhysX_Manager->Create_Shape(eType, vhalfGeometryInfo, pxMaterial, bExclusive, ePxShapeFlag);
@@ -578,6 +559,34 @@ const PSX::PxRigidStatic* CGameInstance::Add_StaticActor(CRigidBody& RigidBody)
{
return m_pPhysX_Manager->Add_StaticActor(RigidBody);
}
PSX::PxController* CGameInstance::Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc)
{
return m_pPhysX_Manager->Add_CapsuleController(Desc);
}
PSX::PxController* CGameInstance::Add_BoxController(PSX::PxBoxControllerDesc& Desc)
{
return m_pPhysX_Manager->Add_BoxController(Desc);
}
PSX::PxController* CGameInstance::Get_Controller(_uint iControllerIndex)
{
return m_pPhysX_Manager->Get_Controller(iControllerIndex);
}
void CGameInstance::ReleaseController(_uint iControllerIndex)
{
m_pPhysX_Manager->ReleaseController(iControllerIndex);
}
HRESULT CGameInstance::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix)
{
return m_pPhysX_Manager->ConvertToTriMeshes(Meshes, pxTriMeshes, WorldMatrix);
}
HRESULT CGameInstance::SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
{
return m_pPhysX_Manager->SaveTriMeshes(pPath, TriMeshes);
}
HRESULT CGameInstance::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
{
return m_pPhysX_Manager->LoadTriMeshes(pPath, TriMeshes);
}
#pragma endregion
bool CGameInstance::Key_Pressing(int _iKey)
@@ -89,48 +89,10 @@ HRESULT CInstance_Model::Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fma
}
#endif
HRESULT CInstance_Model::Change_NumInstance()
{
Safe_Release(m_pVBInstance);
Safe_Release(m_pComputeShader);
Safe_Release(m_pConstantBuffer);
Safe_Release(m_pParticleValueBuffer);
//모든 버퍼를 지우고 재 생성 해야함
if (FAILED(Create_Instance_Buffer(&m_InstanceDesc)))
return E_FAIL;
if (FAILED(Create_SubResource_Buffer()))
return E_FAIL;
//시작 시에 인스턴트 버퍼를 구성 해줌
Instane_Buffer_ReStruct();
_uint CS_InputStrides[] = {
sizeof(VTX_INSTANCE_PARTICLE),
sizeof(CS_PARTICLE_VALUE_DESC),
};
_uint CS_OutputStrides[] = {
sizeof(VTX_INSTANCE_PARTICLE),
sizeof(CS_PARTICLE_VALUE_DESC),
};
m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext,
L"../Bin/Resources/ShaderFiles/Shader_Particle_Compute.hlsl", "CS_MAIN", m_iNumInstance, 2, 2, CS_OutputStrides, CS_InputStrides);
if (m_pComputeShader == nullptr)
return E_FAIL;
return S_OK;
}
HRESULT CInstance_Model::Create_Instance_Buffer(const INSTANCE_DESC* pDesc)
{
if (pDesc != nullptr)
m_InstanceDesc = *pDesc;
m_InstanceDesc = *pDesc;
m_iNumInstance = m_InstanceDesc.iNumInstance;
@@ -196,7 +158,8 @@ HRESULT CInstance_Model::Initialize(void* pArg)
INSTANCE_DESC* pInstanceDesc = static_cast<INSTANCE_DESC*>(pArg);
if (pInstanceDesc == nullptr)
return E_FAIL;
if (FAILED(Create_Instance_Buffer(pInstanceDesc)))
return E_FAIL;
@@ -207,18 +170,13 @@ HRESULT CInstance_Model::Initialize(void* pArg)
//시작 시에 인스턴트 버퍼를 구성 해줌
Instane_Buffer_ReStruct();
_uint CS_InputStrides[] = {
_uint CS_Strides[] = {
sizeof(VTX_INSTANCE_PARTICLE),
sizeof(CS_PARTICLE_VALUE_DESC),
};
_uint CS_OutputStrides[] = {
sizeof(VTX_INSTANCE_PARTICLE),
sizeof(CS_PARTICLE_VALUE_DESC),
};
m_pComputeShader = CComputeShader::Create(m_pDevice, m_pContext,
L"../Bin/Resources/ShaderFiles/Shader_Particle_Compute.hlsl", "CS_MAIN", m_iNumInstance, 2, 2, CS_OutputStrides, CS_InputStrides);
L"../Bin/Resources/ShaderFiles/Shader_Particle_Compute.hlsl", "CS_MAIN", m_iNumInstance, 2, sizeof(CS_PARTICLE_OUT), CS_Strides);
if (m_pComputeShader == nullptr)
return E_FAIL;
@@ -235,9 +193,9 @@ void CInstance_Model::Drop(_float fTimeDelta)
CS_PARTICLE_DESC* pDesc = static_cast<CS_PARTICLE_DESC*>(ConstantSubResource.pData);
pDesc->fTimeDelta = fTimeDelta;
pDesc->isLoop = m_InstanceDesc.isLoop;
pDesc->isBillboard = m_InstanceDesc.isBillboard;
pDesc->CamViewInvMatrix = *m_pGameInstance->Get_Transform_Float4x4(D3DTS::VIEW_INV);
pDesc->fPadding = 0;
pDesc->fPadding2 = 0;
pDesc->fPadding3 = 0;
m_pContext->Unmap(m_pConstantBuffer, 0);
}
@@ -253,31 +211,19 @@ void CInstance_Model::Drop(_float fTimeDelta)
};
vector<D3D11_MAPPED_SUBRESOURCE> OutSubResources = {};
D3D11_MAPPED_SUBRESOURCE OutSubResource = {};
D3D11_MAPPED_SUBRESOURCE VBInstanceResource = {};
OutSubResources = m_pComputeShader->Dispatch(0, 0, _float3((_float)iGroupCountX, 1.f, 1.f), CSBuffers, m_pConstantBuffer);
OutSubResource = m_pComputeShader->Dispatch(0, 0, _float3((_float)iGroupCountX, 1.f, 1.f), CSBuffers, m_pConstantBuffer);
if (SUCCEEDED(m_pContext->Map(m_pVBInstance, 0, D3D11_MAP_WRITE_DISCARD, 0, &VBInstanceResource)))
{
memcpy(VBInstanceResource.pData, OutSubResources[0].pData, m_iInstanceStride * m_InstanceDesc.iNumInstance); // 아웃풋 버퍼에 들어온 값들을 전부 복사한다.
memcpy(VBInstanceResource.pData, OutSubResource.pData, m_iInstanceStride * m_InstanceDesc.iNumInstance); // 아웃풋 버퍼에 들어온 값들을 전부 복사한다.
m_pContext->Unmap(m_pVBInstance, 0);
}
D3D11_MAPPED_SUBRESOURCE ParticleValueResource = {};
if (SUCCEEDED(m_pContext->Map(m_pParticleValueBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &ParticleValueResource)))
{
CS_PARTICLE_VALUE_DESC* pValueDesc = static_cast<CS_PARTICLE_VALUE_DESC*>(OutSubResources[1].pData);
memcpy(ParticleValueResource.pData, OutSubResources[1].pData, sizeof(CS_PARTICLE_VALUE_DESC) * m_InstanceDesc.iNumInstance); // 아웃풋 버퍼에 들어온 값들을 전부 복사한다.
m_pContext->Unmap(m_pParticleValueBuffer, 0);
}
//TODO:: 벨류버퍼 갱신 해야함 , OutPut버퍼 두개만들어야할듯..
}
@@ -356,7 +302,6 @@ void CInstance_Model::Instane_Buffer_ReStruct()
pParticleValues[i].vAniTime = _float2(0.0f, m_pGameInstance->Random_Float(m_InstanceDesc.vAniTime.x, m_InstanceDesc.vAniTime.y));
pParticleValues[i].vMaskingUVMoveTime = _float2(0.0f, m_pGameInstance->Random_Float(m_InstanceDesc.vMaskingUVMoveTime.x, m_InstanceDesc.vMaskingUVMoveTime.y));
pParticleValues[i].vDiffuseUVMoveTime = _float2(0.0f, m_pGameInstance->Random_Float(m_InstanceDesc.vDiffuseUVMoveTime.x, m_InstanceDesc.vDiffuseUVMoveTime.y));
pParticleValues[i].vNoiseUVMoveTime = _float2(0.0f, m_pGameInstance->Random_Float(m_InstanceDesc.vNoiseUVMoveTime.x, m_InstanceDesc.vNoiseUVMoveTime.y));
pParticleValues[i].fSpeed = m_pGameInstance->Random_Float(m_InstanceDesc.vSpeed.x, m_InstanceDesc.vSpeed.y);
pParticleValues[i].fRotaionSpeed = m_pGameInstance->Random_Float(m_InstanceDesc.vRotationSpeed.x, m_InstanceDesc.vRotationSpeed.y);
pParticleValues[i].vAniIndex = _float2(0.f, m_InstanceDesc.vAniIndex.y);
@@ -376,12 +321,12 @@ void CInstance_Model::Instane_Buffer_ReStruct()
}
HRESULT CInstance_Model::Bind_CS_Output(_uint Index, _uint iBufferIndex)
HRESULT CInstance_Model::Bind_CS_Output(_uint Index)
{
if (m_pComputeShader == nullptr)
return E_FAIL;
m_pComputeShader->Bind_OutPut_SRV(Index , iBufferIndex);
m_pComputeShader->Bind_OutPut_SRV(Index);
return S_OK;
}
@@ -437,23 +382,12 @@ void CInstance_Model::Describe_Entity()
if (ImGui::TreeNode("Model Option"))
{
ImGui::Separator(); ImGui::Spacing();
ImGui::PushItemWidth(120);
if (ImGui::InputInt("NumInstance", &m_InstanceDesc.iNumInstance))
{
Change_NumInstance();
}
if (GUI::Checkbox("Loop", &m_InstanceDesc.isLoop))
{
Instane_Buffer_ReStruct();
}
if(GUI::Checkbox("BillBoard", &m_InstanceDesc.isBillboard))
{
Instane_Buffer_ReStruct();
}
if (ImGui::DragFloat3("SizeMin", reinterpret_cast<_float*>(&m_InstanceDesc.vSizeMin)))
{
Instane_Buffer_ReStruct();
@@ -510,11 +444,6 @@ void CInstance_Model::Describe_Entity()
Instane_Buffer_ReStruct();
}
if (ImGui::DragFloat2("NoiseUVMoveTime", reinterpret_cast<_float*>(&m_InstanceDesc.vNoiseUVMoveTime)))
{
Instane_Buffer_ReStruct();
}
if (ImGui::DragFloat2("AniTime", reinterpret_cast<_float*>(&m_InstanceDesc.vAniTime)))
{
Instane_Buffer_ReStruct();
@@ -524,7 +453,6 @@ void CInstance_Model::Describe_Entity()
Instane_Buffer_ReStruct();
}
ImGui::PopItemWidth();
ImGui::TreePop();
}
@@ -106,5 +106,5 @@ void CLight_Manager::Free()
}
Safe_Delete(pairLight.second);
} m_pLights[i].clear();
}
} Safe_Delete_Array(m_pLights);
}
+33 -4
View File
@@ -196,11 +196,14 @@ HRESULT CMaterial::Read_MaterialFile(const _char* pMaterialFilePath, const _char
/* Texture */
case 1:
// value
iBeginIndex = (_uint)strText.find("Environment");
iBeginIndex = (_uint)strText.find("/");
iEndIndex = (_uint)strText.find('.');
if (256 < iBeginIndex || 256 < iEndIndex)
{
Value = "none";
return S_OK;
}
else
Value = strText.substr(iBeginIndex, iEndIndex - iBeginIndex);
@@ -258,7 +261,7 @@ HRESULT CMaterial::Add_Texture(const _char* pTextureFolderPath, string& FileType
else if (!strcmp(FileType.c_str(), "MROH"))
eTexture = aiTextureType::aiTextureType_METALNESS;
else if (!strcmp(FileType.c_str(), "MROA"))
eTexture = aiTextureType::aiTextureType_DIFFUSE_ROUGHNESS;
eTexture = aiTextureType::aiTextureType_SPECULAR;
else if (!strcmp(FileType.c_str(), "SRO"))
eTexture = aiTextureType::aiTextureType_SPECULAR;
else if (!strcmp(FileType.c_str(), "SROH"))
@@ -268,7 +271,7 @@ HRESULT CMaterial::Add_Texture(const _char* pTextureFolderPath, string& FileType
else if (!strcmp(FileType.c_str(), "HDR"))
return S_OK;
else if (!strcmp(FileType.c_str(), "MSK"))
eTexture = aiTextureType::aiTextureType_MAYA_BASE;
eTexture = aiTextureType::aiTextureType_AMBIENT_OCCLUSION;
else if (!strcmp(FileType.c_str(), "basecolor"))
eTexture = aiTextureType::aiTextureType_DIFFUSE;
else if (!strcmp(FileType.c_str(), "E"))
@@ -312,7 +315,33 @@ HRESULT CMaterial::Add_Texture(const _char* pTextureFolderPath, string& FileType
strTexturePath = CMyTools::ToString(szTextureFilePath);
}
m_SaveMaterial.Path[ENUM_CLASS(eTexture)].push_back(strTexturePath);
_string strPrefix = "../Bin/Resources/Models/MapMesh/";
_string strSearchString = "MeshTable";
_string strResultPath = {};
size_t mapRePos = strTexturePath.find(strSearchString);
if (mapRePos != std::string::npos)
{
size_t startPos = mapRePos + strSearchString.length();
// 'MapRe' 뒤에 오는 경로 건너뛰기
if (startPos < strTexturePath.length() &&
(strTexturePath[startPos] == '\\' || strTexturePath[startPos] == '/')) {
startPos++;
}
// 'MapRe' 이후의 나머지 경로를 추출
strResultPath = strPrefix + strTexturePath.substr(startPos);
}
else
{
MSG_BOX("FAILED to Find Path");
}
replace(strResultPath.begin(), strResultPath.end(), '\\', '/');
m_SaveMaterial.Path[ENUM_CLASS(eTexture)].push_back(strResultPath);
m_SRVs[ENUM_CLASS(eTexture)].push_back(pSRV);
return S_OK;
+46 -25
View File
@@ -90,14 +90,16 @@ HRESULT CMesh::Initialize_Prototype(MODEL eType, vector<class CBone*>& Bones, co
_uint* pIndices = new _uint[m_iNumIndices];
ZeroMemory(pIndices, sizeof(_uint) * m_iNumIndices);
m_pIndices = new _uint[m_iNumIndices];
ZeroMemory(m_pIndices, sizeof(_uint) * m_iNumIndices);
_uint iNumIndices = {};
for (size_t i = 0; i < pAIMesh->mNumFaces; i++)
{
pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[0];
pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[1];
pIndices[iNumIndices++] = pAIMesh->mFaces[i].mIndices[2];
pIndices[iNumIndices++] = m_pIndices[iNumIndices] = pAIMesh->mFaces[i].mIndices[0];
pIndices[iNumIndices++] = m_pIndices[iNumIndices] = pAIMesh->mFaces[i].mIndices[1];
pIndices[iNumIndices++] = m_pIndices[iNumIndices] = pAIMesh->mFaces[i].mIndices[2];
}
@@ -232,7 +234,7 @@ HRESULT CMesh::Initialize_Prototype(HANDLE hFile, DWORD& dwByte)
HRESULT CMesh::Initialize_Prototype(MODEL eType, const CModel* pModel, SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix)
{
strcpy_s(m_szName, _SaveMesh->Name);
strcpy_s(m_szName, _SaveMesh->MeshName.c_str());
m_iMaterialIndex = _SaveMesh->MaterialIndex;
m_iNumVertexBuffers = 1;
@@ -352,7 +354,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(HANDLE hFile, DWORD& dwByte)
return S_OK;
}
HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreTransformMatrix)
HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(SaveMesh* SaveMesh, _fmatrix PreTransformMatrix)
{
m_iVertexStride = sizeof(VTXMESH);
D3D11_BUFFER_DESC VBDesc{};
@@ -371,23 +373,23 @@ HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(SaveMesh* _SaveMesh, _fmatrix PreT
for (_uint i = 0; i < m_iNumVertices; ++i)
{
memcpy(&pVertices[i].vPosition, &_SaveMesh->Vertices[i].Pos, sizeof(_float3));
memcpy(&pVertices[i].vPosition, &SaveMesh->Vertices[i].Pos, sizeof(_float3));
XMStoreFloat3(&pVertices[i].vPosition,
XMVector3TransformCoord(XMLoadFloat3(&pVertices[i].vPosition), PreTransformMatrix));
memcpy(&pVertices[i].vNormal, &_SaveMesh->Vertices[i].Normal, sizeof(_float3));
memcpy(&pVertices[i].vNormal, &SaveMesh->Vertices[i].Normal, sizeof(_float3));
XMStoreFloat3(&pVertices[i].vNormal,
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vNormal), PreTransformMatrix)));
memcpy(&pVertices[i].vTangent, &_SaveMesh->Vertices[i].Tan, sizeof(_float3));
memcpy(&pVertices[i].vTangent, &SaveMesh->Vertices[i].Tan, sizeof(_float3));
XMStoreFloat3(&pVertices[i].vTangent,
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vTangent), PreTransformMatrix)));
memcpy(&pVertices[i].vBinormal, &_SaveMesh->Vertices[i].BiNoraml, sizeof(_float3));
memcpy(&pVertices[i].vBinormal, &SaveMesh->Vertices[i].BiNoraml, sizeof(_float3));
XMStoreFloat3(&pVertices[i].vBinormal,
XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vBinormal), PreTransformMatrix)));
pVertices[i].vTexcoord = _SaveMesh->Vertices[i].UV;
pVertices[i].vTexcoord = SaveMesh->Vertices[i].UV;
}
D3D11_SUBRESOURCE_DATA InitialVBData{};
@@ -420,6 +422,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save
for (_uint i = 0; i < m_iNumVertices; ++i)
{
memcpy(&m_pVertexPositions[i], &_SaveMesh->Vertices[i].Pos, sizeof(_float3));
memcpy(&pVertices[i].vPosition, &_SaveMesh->Vertices[i].Pos, sizeof(_float3));
if (_SaveMesh->Vertices[i].bHasNormal)
memcpy(&pVertices[i].vNormal, &_SaveMesh->Vertices[i].Normal, sizeof(_float3));
@@ -451,11 +454,11 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(const CModel* pModel, SaveMesh* _Save
for (_uint i = 0; i < m_iNumBones; i++)
{
SaveBone _SaveBone = _SaveMesh->Bones[i];
strcpy_s(m_szName, _SaveBone.Name);
strcpy_s(m_szName, _SaveBone.BoneName.c_str());
memcpy(&OffsetMatrix, &_SaveBone.OffsetMatrix, sizeof(_float4x4));
_int iBoneIndex = pModel->Get_BoneIndex(_SaveBone.Name);
_int iBoneIndex = pModel->Get_BoneIndex(_SaveBone.BoneName.c_str());
if (-1 == iBoneIndex)
return E_FAIL;
@@ -604,26 +607,42 @@ HRESULT CMesh::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
return S_OK;
}
PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam)
PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _fmatrix WorldMatrix)
{
PSX::PxTriangleMeshDesc Desc;
vector<PSX::PxVec3> Vertices;
vector<PSX::PxU32> Triangles;
PSX::PxTriangleMeshDesc tMeshDesc = {};
vector<PSX::PxVec3> Vertices = {};
vector<PSX::PxU32> Triangles = {};
{
Desc.points.count = m_iNumVertices;
Desc.points.stride = sizeof(PSX::PxVec3);
tMeshDesc.points.count = m_iNumVertices;
tMeshDesc.points.stride = sizeof(PSX::PxVec3);
Vertices.resize(m_iNumVertices);
memcpy_s(Vertices.data(), sizeof(PSX::PxVec3) * m_iNumVertices, m_pVertexPositions, sizeof(_float3) * m_iNumVertices);
Desc.points.data = Vertices.data();
XMVector3TransformCoordStream(reinterpret_cast<_float3*>(Vertices.data()), sizeof(PSX::PxVec3), (_float3*)m_pVertexPositions, sizeof(_float3), m_iNumVertices, WorldMatrix);
tMeshDesc.points.data = Vertices.data();
}
{
Desc.triangles.count = m_iNumIndices / 3;
Desc.triangles.stride = sizeof(PSX::PxU32) * 3;
tMeshDesc.triangles.count = m_iNumIndices / 3;
tMeshDesc.triangles.stride = sizeof(PSX::PxU32) * 3;
Triangles.resize(m_iNumIndices);
memcpy_s(Triangles.data(), sizeof(PSX::PxU32) * m_iNumIndices, m_pIndices, sizeof(PSX::PxU32) * m_iNumIndices);
Desc.triangles.data = Triangles.data();
tMeshDesc.triangles.data = Triangles.data();
}
PSX::PxTriangleMesh* pTriangleMesh = PxCreateTriangleMesh(*pParam, Desc);
PSX::PxDefaultMemoryOutputStream streamWriteBuffer = {};
PSX::PxTriangleMeshCookingResult::Enum eCookResult = {};
const _bool bCooked = PxCookTriangleMesh(*pParam, tMeshDesc, streamWriteBuffer, &eCookResult);
if (false == bCooked) {
assert(false);
return nullptr;
}
PSX::PxDefaultMemoryInputData readBuff(streamWriteBuffer.getData(), streamWriteBuffer.getSize());
PSX::PxTriangleMesh* pTriangleMesh = pPhysX->createTriangleMesh(readBuff);
PX_ASSERT(pTriangleMesh);
PX_ASSERT(pTriangleMesh->getReferenceCount() == 1);
if (nullptr == pTriangleMesh) {
assert(false);
return nullptr;
}
return pTriangleMesh;
}
@@ -647,6 +666,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_NonAnim(const aiMesh* pAIMesh, _fmatrix Pr
for (_uint i = 0; i < m_iNumVertices; ++i)
{
memcpy(&pVertices[i].vPosition, &pAIMesh->mVertices[i], sizeof(_float3));
memcpy(&m_pVertexPositions[i], &pAIMesh->mVertices[i], sizeof(_float3));
XMStoreFloat3(&pVertices[i].vPosition, XMVector3TransformCoord(XMLoadFloat3(&pVertices[i].vPosition), PreTransformMatrix));
memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3));
XMStoreFloat3(&pVertices[i].vNormal, XMVector3Normalize(XMVector3TransformNormal(XMLoadFloat3(&pVertices[i].vNormal), PreTransformMatrix)));
@@ -688,6 +708,7 @@ HRESULT CMesh::Ready_VertexBuffer_For_Anim(vector<class CBone*>& Bones, const ai
for (_uint i = 0; i < m_iNumVertices; ++i)
{
memcpy(&pVertices[i].vPosition, &pAIMesh->mVertices[i], sizeof(_float3));
memcpy(&m_pVertexPositions[i], &pAIMesh->mVertices[i], sizeof(_float3));
memcpy(&pVertices[i].vNormal, &pAIMesh->mNormals[i], sizeof(_float3));
memcpy(&pVertices[i].vTangent, &pAIMesh->mTangents[i], sizeof(_float3));
memcpy(&pVertices[i].vBinormal, &pAIMesh->mBitangents[i], sizeof(_float3));
+136 -115
View File
@@ -1,4 +1,4 @@
#include "pch.h"
#include "pch.h"
#include "Model.h"
#include "Bone.h"
#include "Mesh.h"
@@ -37,7 +37,7 @@ CModel::CModel(const CModel& rhs)
}
m_Animations.reserve(m_iNumAnimations);
for (_uint i = 0; i < m_iNumAnimations; ++i) {
m_Animations.push_back(rhs.m_Animations[i]->Clone()); // 멤버 전부 얕은복사.
m_Animations.push_back(rhs.m_Animations[i]->Clone()); // 멤버 전부 얕은복사.
}
}
@@ -89,9 +89,9 @@ void CModel::Change_AnimationIndex(_int iAnimationIndex, _bool bIsLoop, _float f
m_PrevAnimationMatrix = Get_BoneMatrix(m_iRootBoneIndex);
m_Animations[m_iCurrentAnimIndex]->Depart_Animation(); // 애니메이션 종료 이벤트 ( 럴프애님은 자체적으로 불림 )
vector<_int>* BeforeAnimIndex = m_Animations[m_iCurrentAnimIndex]->Capture_Bones(); // 영향을 받는 본 인덱스 추출 1
vector<_int>* AfterAnimIndex = m_Animations[iAnimationIndex]->Capture_Bones(); // 영향을 받는 본 인덱스 추출 2
m_Animations[m_iCurrentAnimIndex]->Depart_Animation(); // 애니메이션 종료 이벤트 ( 럴프애님은 자체적으로 불림 )
vector<_int>* BeforeAnimIndex = m_Animations[m_iCurrentAnimIndex]->Capture_Bones(); // 영향을 받는 본 인덱스 추출 1
vector<_int>* AfterAnimIndex = m_Animations[iAnimationIndex]->Capture_Bones(); // 영향을 받는 본 인덱스 추출 2
unordered_set<_int> UnionAnimIndex = {};
vector<LERPDESC> LerpStartFrames;
@@ -101,20 +101,20 @@ void CModel::Change_AnimationIndex(_int iAnimationIndex, _bool bIsLoop, _float f
for (_int i : *AfterAnimIndex) {
UnionAnimIndex.insert(i);
}
LerpStartFrames.reserve(UnionAnimIndex.size()); // 영향을 받는 모든 현재 본을 가져옴
LerpStartFrames.reserve(UnionAnimIndex.size()); // 영향을 받는 모든 현재 본을 가져옴
// 스타팅 키프레임 채우기 pair < 본 인덱스, 키프레임 >
// 스타팅 키프레임 채우기 pair < 본 인덱스, 키프레임 >
for (auto iter = UnionAnimIndex.begin(); iter != UnionAnimIndex.end(); ++iter) {
LERPDESC desc = {};
desc.iSlot = *iter;
m_Bones[desc.iSlot]->Get_KeyFrame(desc.tagKeyFrame, true); // 스타팅 키프레임 채우기
m_Bones[desc.iSlot]->Get_KeyFrame(desc.tagKeyFrame, true); // 스타팅 키프레임 채우기
LerpStartFrames.emplace_back(desc);
}
// 엔딩 키프레임 채우기 pair < 본인덱스, 키프레임 >
// 엔딩 키프레임 채우기 pair < 본인덱스, 키프레임 >
vector<LERPDESC> LerpEndFrames = m_Animations[iAnimationIndex]->Get_StartFrameInformations();
// 럴프 애니메이션 시작
// 럴프 애니메이션 시작
m_pLerpAnim->Begin(m_Bones, LerpStartFrames, LerpEndFrames, fLerpDuration, m_iRootBoneIndex);
}
@@ -144,41 +144,41 @@ _bool CModel::Play_Animation(_float fTimeDelta)
{
if (!m_bPlayAnim)
return false;
if (-1 == m_iCurrentAnimIndex // 정지 혹은 시작을 안시켜준 애님
|| m_iCurrentAnimIndex >= (_int)m_iNumAnimations) // 애님 인덱스 초과됨
if (-1 == m_iCurrentAnimIndex // 정지 혹은 시작을 안시켜준 애님
|| m_iCurrentAnimIndex >= (_int)m_iNumAnimations) // 애님 인덱스 초과됨
{
return false; // 잘못된 초기화
return false; // 잘못된 초기화
}
if (true == m_pLerpAnim->IsLerping()) { // 럴프중이면 자동으로 럴프 Update를 부름
if (true == m_pLerpAnim->IsLerping()) { // 럴프중이면 자동으로 럴프 Update를 부름
m_bIsFinishedLerp = m_pLerpAnim->Update_TransformationMatrices(m_Bones, fTimeDelta);
}
else { // 럴프중이지 않다면 실제 애니메이션 재생을 시작함
else { // 럴프중이지 않다면 실제 애니메이션 재생을 시작함
m_bIsFinishedAnim = m_Animations[m_iCurrentAnimIndex]->Update_TransformationMatrices(m_Bones, m_bIsLoop, fTimeDelta);
}
for (int i = 0; i < m_Bones.size(); ++i)
for (_int i = 0; i < m_Bones.size(); ++i)
{
m_Bones[i]->Update_CombinedTransformationMatrix(m_Bones, XMLoadFloat4x4(&m_PreTransformMatrix));
if (i == m_iRootBoneIndex) { // 루트본의 매트릭스를 갱신했다면 애니메이션에 맞게 이동량을 루트본에서 트랜스폼으로 보정시킴
if (true == m_pLerpAnim->IsLerping()) { // 럴프중이었으면 이동량 반영 x
if (i == m_iRootBoneIndex) { // 루트본의 매트릭스를 갱신했다면 애니메이션에 맞게 이동량을 루트본에서 트랜스폼으로 보정시킴
if (true == m_pLerpAnim->IsLerping()) { // 럴프중이었으면 이동량 반영 x
_matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex);
currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f);
m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix);
}
else {
_matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex); // 현재 루트본의 컴바인드 트랜스폼을 꺼내오고
_matrix deltaAnimMatrix = XMMatrixMultiply(XMMatrixInverse(nullptr, m_PrevAnimationMatrix), currAnimMatrix); // 이전 트랜스폼이랑 비교해서 델타매트릭스를 꺼냄
_matrix currAnimMatrix = Get_BoneMatrix(m_iRootBoneIndex); // 현재 루트본의 컴바인드 트랜스폼을 꺼내오고
_matrix deltaAnimMatrix = XMMatrixMultiply(XMMatrixInverse(nullptr, m_PrevAnimationMatrix), currAnimMatrix); // 이전 트랜스폼이랑 비교해서 델타매트릭스를 꺼냄
_vector momentum = XMMatrixMultiply(deltaAnimMatrix, XMMatrixRotationQuaternion(m_pTransform->Get_QuarternionVector())).r[3];
deltaAnimMatrix.r[3] = XMVectorSetW(momentum, 0.f);
m_pTransform->AccumulateMomentum(deltaAnimMatrix.r[3]); // 모체 트랜스폼에 이동량 반영
m_pTransform->AccumulateMomentum(deltaAnimMatrix.r[3]); // 모체 트랜스폼에 이동량 반영
//m_pTransform->Set_State(STATE::POSITION, m_pTransform->Get_State(STATE::POSITION) + deltaAnimMatrix.r[3]);
m_PrevAnimationMatrix = currAnimMatrix;
currAnimMatrix.r[3] = XMVectorSet(0.f, 0.f, 0.f, 1.f);
m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix); // 루트본의 이동량 소거
m_Bones[i]->Set_CombinedTransformationMatrixPtr(currAnimMatrix); // 루트본의 이동량 소거
}
}
}
@@ -201,13 +201,13 @@ void CModel::Set_AnimationIndex(_uint iIndex, _bool isLoop)
void CModel::Stop_Animation()
{
if (-1 == m_iCurrentAnimIndex // 정지 혹은 시작을 안시켜준 애님
|| m_iCurrentAnimIndex >= (_int)m_iNumAnimations) // 애님 인덱스 초과됨
if (-1 == m_iCurrentAnimIndex // 정지 혹은 시작을 안시켜준 애님
|| m_iCurrentAnimIndex >= (_int)m_iNumAnimations) // 애님 인덱스 초과됨
{
return; // 잘못된 초기화
return; // 잘못된 초기화
}
m_Animations[m_iCurrentAnimIndex]->Depart_Animation(); // 애님이 퇴근할 때 불리는 함수를 부르면서 초기상태로 되돌림
m_Animations[m_iCurrentAnimIndex]->Depart_Animation(); // 애님이 퇴근할 때 불리는 함수를 부르면서 초기상태로 되돌림
}
void CModel::RefreshAnim()
@@ -219,7 +219,7 @@ _float CModel::Get_AnimProgressRatio()
{
return m_Animations[m_iCurrentAnimIndex]->Get_AnimProgressRatio();
}
_int CModel::Get_AnimProgressPostion(const char* pAnimChannelName)
_int CModel::Get_AnimProgressPostion(const _char* pAnimChannelName)
{
return m_Animations[m_iCurrentAnimIndex]->Get_AnimProgressPostion(pAnimChannelName);
}
@@ -262,6 +262,11 @@ const _float4x4* CModel::Get_BoneMatrixPtr(const _char* pBoneName) const
return (*iter)->Get_CombinedTransformationMatrixPtr();
}
const _char* CModel::Get_MeshName(_uint iIndex)
{
return m_Meshes[iIndex]->Get_Name();
}
_matrix CModel::Get_BoneMatrix(_uint iBoneIndex)
{
@@ -340,6 +345,28 @@ HRESULT CModel::Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& Pre
return S_OK;
}
HRESULT CModel::Ready_PhysXMeshes()
{
m_iNumPhysXMeshes = m_iNumMeshes;
m_TriMeshes.reserve(m_iNumMeshes);
m_pGameInstance->ConvertToTriMeshes(m_Meshes, m_TriMeshes, m_pTransform->Get_XMWorldMatrix());
return S_OK;
}
HRESULT CModel::Save_PhysXTriMeshes(const _char* pModelFilePath)
{
if (FAILED(Ready_PhysXMeshes())) {
return E_FAIL;
}
for (_uint i = 0; i < m_iNumMeshes; ++i) {
m_pGameInstance->RegistTriMesh(m_Meshes[i]->Get_Name(), m_TriMeshes[i]);
}
return m_pGameInstance->SaveTriMeshes(pModelFilePath, m_TriMeshes);
}
HRESULT CModel::Ready_Materials(const aiScene* pAIScene, const _char* pModelFilePath)
{
m_iNumMaterials = pAIScene->mNumMaterials;
@@ -367,21 +394,15 @@ HRESULT CModel::Ready_Materials_FromFile(const aiScene* pAIScene, const _char* p
vector<_string> MaterialFilePathes;
string strFolderPath = pModelFilePath;
size_t iFolderPos = strFolderPath.find("Environment");
size_t iFolderPos = strFolderPath.find("MeshTable");
strFolderPath = strFolderPath.substr(0, iFolderPos);
strFolderPath = strFolderPath.substr(0, iFolderPos) + "MeshTable/";
_splitpath_s(pModelFilePath, szDrive, MAX_PATH, szDir, MAX_PATH, szFileName, MAX_PATH, nullptr, 0);
string FileName = szFileName;
auto iPos = FileName.find_last_of('.');
FileName = FileName.substr(0, iPos);
strcpy_s(szMeshFilePath, szDrive);
strcat_s(szMeshFilePath, szDir);
strcat_s(szMeshFilePath, FileName.c_str());
strcat_s(szMeshFilePath, szFileName);
strcat_s(szMeshFilePath, ".props.txt");
ifstream file(szMeshFilePath);
@@ -403,17 +424,19 @@ HRESULT CModel::Ready_Materials_FromFile(const aiScene* pAIScene, const _char* p
{
getline(file, strText);
// value
_uint iBeginIndex = (_uint)strText.find("Environment");
_uint iEndIndex = (_uint)strText.find('.');
if ((_uint)strText.size() < iEndIndex - iBeginIndex)
_int iBeginIndex = (_int)strText.find_first_of("/");
_int iEndIndex = (_int)strText.find('.');
if (-1 == iBeginIndex || -1 == iEndIndex) {
MSG_BOX("Fail Path _ NotExist"); // Not Exsist
return E_FAIL;
}
if ((_int)strText.size() < iEndIndex - iBeginIndex)
{
MSG_BOX("Fail Path");
return E_FAIL;
}
string strPath = strFolderPath + strText.substr(iBeginIndex, iEndIndex - iBeginIndex);
string strPath = strFolderPath + strText.substr(iBeginIndex + 1, iEndIndex - iBeginIndex - 1);
MaterialFilePathes.push_back(strPath);
}
@@ -462,7 +485,7 @@ HRESULT CModel::Ready_Bones(const aiNode* pAINode, _int iParentIndex)
return S_OK;
}
bool CModel::SaveAssimpModel(const _char* filename)
_bool CModel::SaveAssimpModel(const _char* filename)
{
if (!m_pAIScene) return false;
@@ -471,23 +494,25 @@ bool CModel::SaveAssimpModel(const _char* filename)
_splitpath_s(filename, nullptr, 0, nullptr, 0, nullptr, 0, szExt, MAX_PATH);
strcat_s(szModel, sizeof(_char) * MAX_PATH, szExt);
_string savePath = filename;
_string savePath = filename;
SaveModel modelData;
modelData.MeshCount = m_pAIScene->mNumMeshes;
modelData.MaterialCount = m_pAIScene->mNumMaterials;
for (unsigned int i = 0; i < m_pAIScene->mNumMeshes; i++)
for (_uint i = 0; i < m_pAIScene->mNumMeshes; i++)
{
aiMesh* mesh = m_pAIScene->mMeshes[i];
SaveMesh saveMesh{};
strcpy_s(saveMesh.Name, mesh->mName.C_Str());
saveMesh.MeshName = mesh->mName.C_Str();
saveMesh.MeshNameSize = (_int)saveMesh.MeshName.size() + 1;
saveMesh.VertexCount = mesh->mNumVertices;
saveMesh.IndexCount = mesh->mNumFaces * 3;
saveMesh.MaterialIndex = mesh->mMaterialIndex;
saveMesh.Vertices.resize(saveMesh.VertexCount);
for (unsigned int i = 0; i < mesh->mNumVertices; i++)
for (_uint i = 0; i < mesh->mNumVertices; i++)
{
saveMesh.Vertices[i].Pos = XMFLOAT3{ mesh->mVertices[i].x , mesh->mVertices[i].y,mesh->mVertices[i].z };
@@ -547,7 +572,8 @@ bool CModel::SaveAssimpModel(const _char* filename)
saveMesh.Bones.resize(mesh->mNumBones);
for (size_t j = 0; j < mesh->mNumBones; j++)
{
strcpy_s(saveMesh.Bones[j].Name, sizeof(saveMesh.Bones[j].Name), mesh->mBones[j]->mName.C_Str());
saveMesh.Bones[j].BoneName = mesh->mBones[j]->mName.C_Str();
saveMesh.Bones[j].BoneNameSize = (_int)saveMesh.Bones[j].BoneName.size();
memcpy(&saveMesh.Bones[j].OffsetMatrix, &mesh->mBones[j]->mOffsetMatrix, sizeof(_float4x4));
XMStoreFloat4x4(&saveMesh.Bones[j].OffsetMatrix, XMMatrixTranspose(XMLoadFloat4x4(&saveMesh.Bones[j].OffsetMatrix)));
@@ -561,10 +587,10 @@ bool CModel::SaveAssimpModel(const _char* filename)
}
saveMesh.Indices.reserve(saveMesh.IndexCount);
for (unsigned int i = 0; i < mesh->mNumFaces; i++)
for (_uint i = 0; i < mesh->mNumFaces; i++)
{
aiFace& face = mesh->mFaces[i];
for (unsigned int idx = 0; idx < face.mNumIndices; idx++)
for (_uint idx = 0; idx < face.mNumIndices; idx++)
saveMesh.Indices.push_back(face.mIndices[idx]);
}
@@ -580,11 +606,12 @@ bool CModel::SaveAssimpModel(const _char* filename)
SaveNodeRecursive(m_pAIScene->mRootNode, allNodes, -1);
modelData.AnimationCount = m_pAIScene->mNumAnimations;
for (unsigned int i = 0; i < modelData.AnimationCount; i++)
for (_uint i = 0; i < modelData.AnimationCount; i++)
{
aiAnimation* Anim = m_pAIScene->mAnimations[i];
SaveAnimation saveAnim{};
strcpy_s(saveAnim.Name, Anim->mName.C_Str());
saveAnim.AnimName = Anim->mName.C_Str();
saveAnim.AnimNameSize = (_int)saveAnim.AnimName.size() + 1;
saveAnim.mDuration = (_float)Anim->mDuration;
saveAnim.mTicksPerSecond = (_float)Anim->mTicksPerSecond;
saveAnim.ChannelCount = Anim->mNumChannels;
@@ -592,8 +619,8 @@ bool CModel::SaveAssimpModel(const _char* filename)
saveAnim.Channels.resize(Anim->mNumChannels);
for (size_t j = 0; j < saveAnim.ChannelCount; j++)
{
strcpy_s(saveAnim.Channels[j].Name, sizeof(saveAnim.Channels[j].Name),
Anim->mChannels[j]->mNodeName.C_Str());
saveAnim.Channels[j].ChannelName = Anim->mChannels[j]->mNodeName.C_Str();
saveAnim.Channels[j].ChannelNameSize = (_int)saveAnim.Channels[j].ChannelName.size();
saveAnim.Channels[j].ScalingKeyCount = Anim->mChannels[j]->mNumScalingKeys;
saveAnim.Channels[j].RotationKeyCount = Anim->mChannels[j]->mNumRotationKeys;
@@ -645,7 +672,8 @@ bool CModel::SaveAssimpModel(const _char* filename)
for (auto& mesh : modelData.Meshes)
{
fwrite(&mesh.Name, sizeof(mesh.Name), 1, fp);
fwrite(&mesh.MeshNameSize, sizeof(_uint), 1, fp);
fwrite(mesh.MeshName.data(), 1, mesh.MeshNameSize, fp);
fwrite(&mesh.VertexCount, sizeof(_uint), 1, fp);
fwrite(&mesh.IndexCount, sizeof(_uint), 1, fp);
fwrite(&mesh.MaterialIndex, sizeof(_uint), 1, fp);
@@ -655,13 +683,14 @@ bool CModel::SaveAssimpModel(const _char* filename)
fwrite(mesh.Indices.data(), sizeof(_uint), mesh.IndexCount, fp);
for (auto& bone : mesh.Bones)
{
fwrite(&bone.Name, sizeof(bone.Name), 1, fp);
fwrite(&bone.BoneNameSize, sizeof(_uint), 1, fp);
fwrite(bone.BoneName.data(), 1, bone.BoneNameSize, fp);
fwrite(&bone.OffsetMatrix, sizeof(XMFLOAT4X4), 1, fp);
fwrite(&bone.WeightsCount, sizeof(_uint), 1, fp);
for (auto& Weights : bone.Weights)
{
fwrite(&Weights.VertexId, sizeof(_uint), 1, fp);
fwrite(&Weights.Weight, sizeof(float), 1, fp);
fwrite(&Weights.Weight, sizeof(_float), 1, fp);
}
}
}
@@ -669,26 +698,29 @@ bool CModel::SaveAssimpModel(const _char* filename)
for (auto& node : allNodes)
{
fwrite(node.Name, sizeof(node.Name), 1, fp);
fwrite(&node.NodeNameSize, sizeof(_uint), 1, fp);
fwrite(node.NodeName.data(), 1, node.NodeNameSize, fp);
fwrite(&node.ParentIndex, sizeof(int), 1, fp);
fwrite(&node.Transformation, sizeof(XMFLOAT4X4), 1, fp);
fwrite(&node.ChildrenCount, sizeof(_uint), 1, fp);
for (auto child : node.ChildrenIndices)
{
fwrite(&child, sizeof(int), 1, fp);
fwrite(&child, sizeof(_int), 1, fp);
}
}
for (auto& Anim : modelData.Animations)
{
fwrite(Anim.Name, sizeof(Anim.Name), 1, fp);
fwrite(&Anim.AnimNameSize, sizeof(_uint), 1, fp);
fwrite(Anim.AnimName.data(), 1, Anim.AnimNameSize, fp);
fwrite(&Anim.mDuration, sizeof(_float), 1, fp);
fwrite(&Anim.mTicksPerSecond, sizeof(_float), 1, fp);
fwrite(&Anim.ChannelCount, sizeof(_uint), 1, fp);
for (size_t i = 0; i < Anim.ChannelCount; i++)
{
fwrite(Anim.Channels[i].Name, sizeof(Anim.Channels[i].Name), 1, fp);
fwrite(&Anim.Channels[i].ChannelNameSize, sizeof(_uint), 1, fp);
fwrite(Anim.Channels[i].ChannelName.data(), 1, Anim.Channels[i].ChannelNameSize, fp);
fwrite(&Anim.Channels[i].ScalingKeyCount, sizeof(_uint), 1, fp);
fwrite(Anim.Channels[i].ScalingKeys.data(), sizeof(SaveKeyFrameVec), Anim.Channels[i].ScalingKeyCount, fp);
@@ -711,7 +743,7 @@ bool CModel::SaveAssimpModel(const _char* filename)
{
_uint len = static_cast<_uint>(path.size());
fwrite(&len, sizeof(_uint), 1, fp);
fwrite(path.c_str(), sizeof(char), len, fp);
fwrite(path.c_str(), sizeof(_char), len, fp);
}
}
}
@@ -723,7 +755,8 @@ bool CModel::SaveAssimpModel(const _char* filename)
_int CModel::SaveNodeRecursive(const aiNode* pAINode, std::vector<SaveNode>& outNodes, _int parentIndex)
{
SaveNode node{};
strcpy_s(node.Name, sizeof(node.Name), pAINode->mName.C_Str());
node.NodeName = pAINode->mName.C_Str();
node.NodeNameSize = (_uint)node.NodeName.size() + 1;
node.ParentIndex = parentIndex;
const aiMatrix4x4& m = pAINode->mTransformation;
@@ -739,30 +772,17 @@ _int CModel::SaveNodeRecursive(const aiNode* pAINode, std::vector<SaveNode>& out
node.ChildrenCount = pAINode->mNumChildren;
node.ChildrenIndices.resize(node.ChildrenCount);
int currentIndex = static_cast<int>(outNodes.size());
_int currentIndex = static_cast<_int>(outNodes.size());
outNodes.push_back(node);
for (size_t i = 0; i < pAINode->mNumChildren; i++)
{
int childIndex = SaveNodeRecursive(pAINode->mChildren[i], outNodes, currentIndex);
_int childIndex = SaveNodeRecursive(pAINode->mChildren[i], outNodes, currentIndex);
outNodes[currentIndex].ChildrenIndices[i] = childIndex;
}
return currentIndex;
}
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
{
CModel* pInstance = new CModel(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype(pModelFilePath, eType, PreTransformMatrix, iRootBoneIndex)))
{
MSG_BOX("Failed to Created : CModel");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
{
_uint iFlag = {};
@@ -815,19 +835,11 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma
return S_OK;
}
HRESULT CModel::Initialize_Prototype(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex)
{
return Assimp_Model_Load(pModelFilePath, eType, PreTransformMatrix, iRootBoneIndex);
}
#endif // EDITOR_PROJECT
HRESULT CModel::Initialize_Prototype()
{
return S_OK;
}
HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix)
{
m_eType = eType;
_char szTextureFileName[MAX_PATH] = {};
_char szDir[MAX_PATH] = {};
_char szName[MAX_PATH] = {};
@@ -851,28 +863,37 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
}
m_pSaveModel = m_pGameInstance->Load_SaveModel(pModelFilePath);
m_eType = eType;
XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix);
Ready_Bones(m_pSaveModel->Nodes, 0, -1);
if (FAILED(Ready_Meshes()))
if (FAILED(Ready_Meshes())) {
return E_FAIL;
}
if (FAILED(Ready_Materials(pModelFilePath)))
if (FAILED(Ready_Materials(pModelFilePath))) {
return E_FAIL;
}
if (FAILED(Ready_Animations()))
if (FAILED(Ready_Animations())) {
return E_FAIL;
}
if (MODEL::ENVIROMENT == m_eType) {
m_pGameInstance->LoadTriMeshes(pModelFilePath, m_TriMeshes);
for (_uint i = 0; i < m_iNumMeshes; ++i) {
m_pGameInstance->RegistTriMesh(m_Meshes[i]->Get_Name(), m_TriMeshes[i]);
}
}
return S_OK;
}
bool CModel::LoadData(const _char* filename)
_bool CModel::LoadData(const _char* filename)
{
FILE* fp = nullptr;
fopen_s(&fp, filename, "rb");
@@ -888,7 +909,11 @@ bool CModel::LoadData(const _char* filename)
for (_uint i = 0; i < NewModel.MeshCount; i++)
{
SaveMesh mesh{};
fread(&mesh.Name, sizeof(mesh.Name), 1, fp);
fread(&mesh.MeshNameSize, sizeof(_uint), 1, fp);
mesh.MeshName.resize(mesh.MeshNameSize);
fread(mesh.MeshName.data(), 1, mesh.MeshNameSize, fp);
fread(&mesh.VertexCount, sizeof(_uint), 1, fp);
fread(&mesh.IndexCount, sizeof(_uint), 1, fp);
fread(&mesh.MaterialIndex, sizeof(_uint), 1, fp);
@@ -903,11 +928,13 @@ bool CModel::LoadData(const _char* filename)
mesh.Bones.resize(mesh.BoneCount);
for (size_t i = 0; i < mesh.BoneCount; i++)
{
fread(&mesh.Bones[i].Name, sizeof(mesh.Bones[i].Name), 1, fp);
fread(&mesh.Bones[i].BoneNameSize, sizeof(_uint), 1, fp);
mesh.Bones[i].BoneName.resize(mesh.Bones[i].BoneNameSize);
fread(mesh.Bones[i].BoneName.data(), 1, mesh.Bones[i].BoneNameSize, fp);
fread(&mesh.Bones[i].OffsetMatrix, sizeof(XMFLOAT4X4), 1, fp);
fread(&mesh.Bones[i].WeightsCount, sizeof(_uint), 1, fp);
mesh.Bones[i].Weights.resize(mesh.Bones[i].WeightsCount);
for (size_t j = 0;j < mesh.Bones[i].WeightsCount; j++)
for (size_t j = 0; j < mesh.Bones[i].WeightsCount; j++)
{
fread(&mesh.Bones[i].Weights[j].VertexId, sizeof(_uint), 1, fp);
fread(&mesh.Bones[i].Weights[j].Weight, sizeof(_float), 1, fp);
@@ -919,28 +946,35 @@ bool CModel::LoadData(const _char* filename)
NewModel.Nodes.resize(NewModel.NodeCount);
for (size_t i = 0; i < NewModel.NodeCount; i++)
{
fread(NewModel.Nodes[i].Name, sizeof(NewModel.Nodes[i].Name), 1, fp);
fread(&NewModel.Nodes[i].NodeNameSize, sizeof(_uint), 1, fp);
NewModel.Nodes[i].NodeName.resize(NewModel.Nodes[i].NodeNameSize);
fread(NewModel.Nodes[i].NodeName.data(), 1, NewModel.Nodes[i].NodeNameSize, fp);
fread(&NewModel.Nodes[i].ParentIndex, sizeof(int), 1, fp);
fread(&NewModel.Nodes[i].Transformation, sizeof(XMFLOAT4X4), 1, fp);
fread(&NewModel.Nodes[i].ChildrenCount, sizeof(_uint), 1, fp);
NewModel.Nodes[i].ChildrenIndices.resize(NewModel.Nodes[i].ChildrenCount);
for (size_t j = 0; j < NewModel.Nodes[i].ChildrenCount; j++)
{
fread(&NewModel.Nodes[i].ChildrenIndices[j], sizeof(int), 1, fp);
fread(&NewModel.Nodes[i].ChildrenIndices[j], sizeof(_int), 1, fp);
}
}
for (size_t i = 0; i < NewModel.AnimationCount; i++)
{
SaveAnimation saveAnim = {};
fread(&saveAnim.Name, sizeof(saveAnim.Name), 1, fp);
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].Name, sizeof(saveAnim.Channels[j].Name), 1, fp);
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);
@@ -973,11 +1007,11 @@ bool CModel::LoadData(const _char* filename)
fread(&len, sizeof(_uint), 1, fp);
std::string temp;
temp.resize(len);
fread(&temp[0], sizeof(char), len, fp);
fread(&temp[0], sizeof(_char), len, fp);
mat.Path[k][j] = temp;
}
}
NewModel.Materials.push_back(mat);
}
@@ -1070,20 +1104,7 @@ HRESULT CModel::Ready_Animations()
return S_OK;
}
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext)
{
CModel* pInstance = new CModel(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype()))
{
MSG_BOX("Failed to Created : CModel");
SAFE_RELEASE(pInstance);
}
return pInstance;
}
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath,_fmatrix PreTransformMatrix)
CModel* CModel::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix)
{
CModel* pInstance = new CModel(pDevice, pContext);
+148 -19
View File
@@ -79,7 +79,6 @@ const PSX::PxRigidStatic* CPhysX_Manager::Add_StaticActor(CRigidBody& RigidBody)
pPxMeshGeometry = iter->second;
}
PSX::PxRigidStatic* pActor = m_pPhysics->createRigidStatic(pxWorldMatrix);
PSX::PxShape* pShape = PSX::PxRigidActorExt::createExclusiveShape(*pActor, *pPxMeshGeometry, *RigidBody.Get_PxMaterial());
@@ -122,21 +121,139 @@ PSX::PxShape* CPhysX_Manager::Create_Shape(ACTOR eType, _float3& vhalfGeometryIn
return pShape;
}
HRESULT CPhysX_Manager::Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh)
{
PSX::PxTriangleMesh* pTriangleMesh = pMesh->ConvertToPxMesh(m_pCookingParam);
if (nullptr != pTriangleMesh) {
m_TriangleMeshes.emplace(wstrMeshKey, pTriangleMesh);
PSX::PxTriangleMeshGeometry* pGeometry = new PSX::PxTriangleMeshGeometry(pTriangleMesh);
pGeometry->meshFlags |= PSX::PxMeshGeometryFlag::eDOUBLE_SIDED;
m_TriangleMeshGeometry.emplace(wstrMeshKey, pGeometry);
return S_OK;
}
return E_FAIL;
void CPhysX_Manager::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh) {
m_TriangleMeshes.emplace(CMyTools::ToWstring(pName), pPxTriMesh);
PSX::PxTriangleMeshGeometry* pGeometry = new PSX::PxTriangleMeshGeometry(pPxTriMesh);
pGeometry->meshFlags |= PSX::PxMeshGeometryFlag::eDOUBLE_SIDED;
m_TriangleMeshGeometry.emplace(CMyTools::ToWstring(pName), pGeometry);
}
HRESULT CPhysX_Manager::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix)
{
for (size_t i = 0; i < Meshes.size(); ++i)
{
PSX::PxTriangleMesh* pTriangleMesh = Meshes[i]->ConvertToPxMesh(m_pCookingParam, m_pPhysics, WorldMatrix);
PX_ASSERT(pTriangleMesh);
PX_ASSERT(pTriangleMesh->getReferenceCount() == 1);
if (nullptr == pTriangleMesh) {
return E_FAIL;
}
pxTriMeshes.push_back(pTriangleMesh);
}
pxTriMeshes.shrink_to_fit();
return S_OK;
}
HRESULT CPhysX_Manager::SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
{
filesystem::path pathPhysX = pPath;
pathPhysX.replace_extension(".Pxml");
if (TriMeshes.empty()){
return E_FAIL;
}
filesystem::create_directories(pathPhysX.parent_path());
PSX::PxSerializationRegistry* pSerializationRegistry = PSX::PxSerialization::createSerializationRegistry(*m_pPhysics);
PSX::PxCollection* pCollections = PxCreateCollection();
if (nullptr == pCollections) {
pSerializationRegistry->release();
assert(pCollections);
return E_FAIL;
}
for (PSX::PxTriangleMesh* pTriMesh : TriMeshes) {
pCollections->add(*pTriMesh);
}
PSX::PxSerialization::complete(*pCollections, *pSerializationRegistry);
PSX::PxDefaultFileOutputStream out(pathPhysX.string().c_str());
PSX::PxCollection* extRefs = PxCreateCollection();
const _bool ok = PSX::PxSerialization::serializeCollectionToXml(out, *pCollections, *pSerializationRegistry, m_pCookingParam, extRefs);
extRefs->release();
pCollections->release();
pSerializationRegistry->release();
assert(ok);
return (ok ? S_OK : E_FAIL);
}
HRESULT CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
{
filesystem::path pathPhysX = pPath;
pathPhysX.replace_extension(".Pxml");
PSX::PxSerializationRegistry* pSerializationRegistry = PSX::PxSerialization::createSerializationRegistry(*m_pPhysics);
PSX::PxDefaultFileInputData InputData(pathPhysX.string().c_str());
PSX::PxCollection* extRefs = PxCreateCollection();
PSX::PxCollection* pCollections = PSX::PxSerialization::createCollectionFromXml(InputData, *m_pCookingParam, *pSerializationRegistry, extRefs);
if (nullptr == pCollections) {
extRefs->release();
pSerializationRegistry->release();
assert(pCollections);
return E_FAIL;
}
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 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)
{
map<_wstring, PSX::PxTriangleMesh*>::iterator iter = m_TriangleMeshes.find(wstrMeshKey);
@@ -279,6 +396,7 @@ HRESULT CPhysX_Manager::Initialize()
m_pPhysics = PxCreatePhysics(PX_PHYSICS_VERSION, *m_pFoundation, m_ToleranceScale, true, m_pPvd);
m_pCookingParam = new PSX::PxCookingParams(m_pPhysics->getTolerancesScale());
m_pCookingParam->meshPreprocessParams |= PSX::PxMeshPreprocessingFlag::eWELD_VERTICES;
PSX::PxSceneDesc sceneDesc = { m_pPhysics->getTolerancesScale() };
sceneDesc.gravity = PSX::PxVec3(0.f, -GRAVITY, 0.f);
@@ -299,7 +417,7 @@ HRESULT CPhysX_Manager::Initialize()
}
m_pScene = m_pPhysics->createScene(sceneDesc);
m_pCCTManager = PxCreateControllerManager(*m_pScene);
m_pCCTManager->setOverlapRecoveryModule(false);
}
// µð¹ö±×¼­¹öÀÇ Å¬¶ó ¼¼ÆÃ
@@ -310,15 +428,17 @@ HRESULT CPhysX_Manager::Initialize()
pPvdClient->setScenePvdFlag(PSX::PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES, true);
}
//physx::PxMaterial* pMaterial = m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f);
//physx::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 0), *pMaterial);
// m_pScene->overlap();??????
#ifdef 기무리
physx::PxMaterial* pMaterial = m_pPhysics->createMaterial(0.5f, 0.5f, 0.6f);
//physx::PxRigidStatic* pGroundPlane = PxCreatePlane(*m_pPhysics, physx::PxPlane(0, 1, 0, 90), *pMaterial);
//m_pScene->addActor(*pGroundPlane);
//{
// float halfExtent = .5f;
// physx::PxShape* shape = m_pPhysics->createShape(physx::PxSphereGeometry(halfExtent), *pMaterial);
// physx::PxU32 size = 100;
// physx::PxU32 size = 30;
// physx::PxTransform pxTransform(physx::PxVec3(0));
// for (physx::PxU32 i = 0; i < size; i++) {
@@ -331,6 +451,10 @@ HRESULT CPhysX_Manager::Initialize()
// }
// }
//}
//pMaterial->release();
#endif // 기무리
return S_OK;
}
@@ -381,6 +505,10 @@ void CPhysX_Manager::Free()
if (nullptr != m_pCookingParam) {
Safe_Delete(m_pCookingParam);
}
if (nullptr != m_pCCTManager) {
m_pCCTManager->release();
m_pCCTManager = nullptr;
}
if (nullptr != m_pScene) {
m_pScene->release(); m_pScene = nullptr;
@@ -395,6 +523,7 @@ void CPhysX_Manager::Free()
}
if (nullptr != m_pPvd) {
m_pPvd->disconnect();
m_pPvd->release(); m_pPvd = nullptr;
}
+3 -3
View File
@@ -14,7 +14,7 @@ CRigidBody::CRigidBody(const CRigidBody& rhs):
m_eActorType(rhs.m_eActorType),
m_vhalfGeometryInfo(rhs.m_vhalfGeometryInfo),
m_pShape(rhs.m_pShape),
m_pMeshKey(rhs.m_pMeshKey),
m_wstrMeshKey(rhs.m_wstrMeshKey),
m_bExclusive(rhs.m_bExclusive),
m_bKinematic(rhs.m_bKinematic)
{
@@ -44,9 +44,8 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
break;
case ACTOR::TRIANGLEMESH:
{
m_pGameInstance->Create_TriangleMesh(Desc.tRigidStaticDesc.pMeshKey, Desc.tRigidStaticDesc.pMesh);
m_pMaterial = m_pGameInstance->Get_Material(Desc.tRigidDynamicDesc.vMatInfo);
m_pMeshKey = Desc.tRigidStaticDesc.pMeshKey;
m_wstrMeshKey = CMyTools::ToWstring(Desc.tRigidStaticDesc.szMeshName);
}
break;
case ACTOR::HEIGHTFIELD:
@@ -54,6 +53,7 @@ HRESULT CRigidBody::Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc)
default:
break;
}
return S_OK;
return S_OK;
}
+3 -24
View File
@@ -39,26 +39,7 @@ _uint CTexture::Get_Size()
return (_uint)m_SRVs.size();
}
_bool CTexture::Compare_GroupName(_wstring wstrGroupName)
{
return m_wstrPrototypeName == wstrGroupName;
}
#ifdef _DEBUG
void CTexture::HoverName()
{
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip(); // 툴팁 창 시작
ImGui::TextUnformatted(CMyTools::ToString(m_wstrPrototypeName).c_str()); // 텍스트 출력 (Text 대신 Unformatted 추천)
ImGui::EndTooltip(); // 툴팁 창 종료
}
}
#endif
HRESULT CTexture::Initialize_Prototype(TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures, _wstring wstrPrototypeName)
HRESULT CTexture::Initialize_Prototype(TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures)
{
switch (eType)
{
@@ -84,8 +65,6 @@ HRESULT CTexture::Initialize_Prototype(TEXTURE_LOAD_TYPE eType, const _tchar* pT
break;
}
m_wstrPrototypeName = wstrPrototypeName;
return S_OK;
}
@@ -203,11 +182,11 @@ HRESULT CTexture::ParseTexturePathToSRVs(const _tchar* pTextureFolderPath)
return S_OK;
}
CTexture* CTexture::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures, _wstring wstrGroupName)
CTexture* CTexture::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures)
{
CTexture* pInstance = new CTexture(pDevice, pContext);
if (FAILED(pInstance->Initialize_Prototype(eType, pTextureFilePath, iNumTextures, wstrGroupName)))
if (FAILED(pInstance->Initialize_Prototype(eType, pTextureFilePath, iNumTextures)))
{
MSG_BOX("Failed to Created : CTexture");
SAFE_RELEASE(pInstance);
@@ -28,7 +28,6 @@ class ENGINE_DLL CAnimation : public CBase
void Set_AnimSpeed(_float fSpeed) { m_fAnimSpeed = fSpeed; }
_float Get_AnimSpeed() { return m_fAnimSpeed; }
#ifdef EDITOR_PROJECT
private:
HRESULT Initialize(const vector<class CBone*>& Bones, const aiAnimation* pAIAnimation);
+1 -1
View File
@@ -15,7 +15,7 @@ class ENGINE_DLL CBase abstract
_uint AddRef();
_uint Release();
private:
protected:
_uint m_iRefCnt = {};
public:
@@ -1,27 +1,81 @@
#pragma once
#include "Base.h"
#include "Component.h"
NS_BEGIN(Engine)
class CCharacter_Controller final : public CBase
class CTransform;
class ENGINE_DLL CCharacter_Controller final :
public CComponent
{
/* dev-treadmill.tistory.com/158 */
/* dev-treadmill.tistory.com/159 */
public:
#pragma region STRUCT
struct CapsuleInfo
{
_float fRadius;
_float fHeight;
PSX::PxCapsuleClimbingMode::Enum eClimbingMode; // 기본 (eEASY, stepOffset 값이 무제한), (eCONSTRAINED, stepOffset 값이 제대로 먹음)
};
typedef struct tagCharacter_ControllerDesc
{
CTransform* pTransform = { nullptr };
ACTOR eBodyType = { ACTOR::END };
_float fContactOffset = { 0.f };
_float3 fMaterial = { 0.5f, 0.5f, 0.6f };
_bool bAutoStepping = { false }; // 계단 높이 타게 할건지 // 박스 콜라이더는 생각한대로 되는데 캡슐은 바닥의 구체 때문에 예상보다 더 높은 곳까지 오를 수 있음
_float fStepOffset = { 0.05f }; // 허용가능한 계단 높이, 작게 유지하는게 좋음
function<void()> funcHitCallback = { nullptr };
function<void()> funcBehaviorCallback = { nullptr };
// 타고 올라갈 수 없는 경사면의 각도를 정의함. 0.f 면 비활성화 됨
// _float fSlopeLimit = { 코사인각도 };
union
{
_float3 vBoxSize; // 박스는 AABB임
CapsuleInfo tCapsuleInfo;
};
}Character_Controller_DESC;
#pragma endregion
private:
CCharacter_Controller(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CCharacter_Controller(const CCharacter_Controller& rhs);
virtual ~CCharacter_Controller() = default;
public:
_float Get_ContactOffset() const { return m_pController->getContactOffset(); }
void Set_ContactOffset(_float fValue) const { return m_pController->setContactOffset((PSX::PxF32)fValue); }
void Move(_float fTimeDelta); // 이동
void Set_Position(_fvector vNewPos); // 순간이동
_float3 Get_FootPosition(); // ContactOffset이 고려된 발바닥 위치( 실제보다 더 아래에 위치한다는 뜻 )
void Resize_Volume(_float fHeight); // 높이를 수정하고 바닥에 붙임
void Modify_Volume(_float3 fVolume);
_float3 Get_Volume();
private:
class CGameInstance* m_pGameInstance = { nullptr };
ID3D11Device* m_pDevice = { nullptr };
ID3D11DeviceContext* m_pContext = { nullptr };
PSX::PxScene* m_pScene = { nullptr };
ACTOR m_eBodyType = { ACTOR::END };
PSX::PxController* m_pController = { nullptr };
CTransform* m_pTransform = { nullptr };
_bool m_bAutoStepping = { false };
_float m_fSlopeLimit = { 0.f }; // cosf
function<void()> m_funcHitCallback = { nullptr };
function<void()> m_funcBehaviorCallback = { nullptr };
PSX::PxControllerCollisionFlags m_eBeforeCollisionFlags = {};;
private:
HRESULT Initialize(PSX::PxScene* pScene);
virtual HRESULT Initialize_Prototype() override;
virtual HRESULT Initialize(void* pArg) override;
_bool Check_Overlap();
public:
static CCharacter_Controller* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, PSX::PxScene* pScene);
static CCharacter_Controller* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override;
virtual void Free() override;
virtual void Describe_Entity() override;
};
NS_END
+11 -13
View File
@@ -13,16 +13,16 @@ class ENGINE_DLL CComputeShader final : public CBase
public:
HRESULT Initialize(const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[]);
HRESULT Initialize(const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iOutputStructStride, _uint iInputStructStride[]);
public:
vector<D3D11_MAPPED_SUBRESOURCE> Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer = nullptr);
void Bind_OutPut_SRV(_uint iIndex, _uint iBufferIndex);
D3D11_MAPPED_SUBRESOURCE Dispatch(_uint iSRVIndex, _uint iUAVIndex, _float3 vGroupCount, ID3D11Buffer** ppBuffers, ID3D11Buffer* pConstantBuffer = nullptr);
void Bind_OutPut_SRV(_uint iIndex);
private:
void Bind_SRV(_uint iIndex);
void Bind_UAV(_uint iIndex);
void Reset();
HRESULT CreateBuffer(_uint iNumElement, _uint iInputStructStride[], _uint iOuputStructStride[]);
HRESULT CreateBuffer(_uint iNumElement, _uint iNumInputBuffer, _uint iStructStride[]);
HRESULT CreateResurceViews(_uint iNumElement, _uint iNumInputBuffer);
HRESULT CreateComputeShader(const _tchar* pShaderFilePath, const _char* pStartFunctionName);
@@ -33,26 +33,24 @@ class ENGINE_DLL CComputeShader final : public CBase
private:
vector<ID3D11ShaderResourceView*> m_pInputSRV = {};
vector<ID3D11UnorderedAccessView*> m_pOutputUAV = {};
vector< ID3D11ShaderResourceView*> m_pOutputSRV = {};
ID3D11UnorderedAccessView* m_pOutputUAV = nullptr;
vector<ID3D11Buffer*> m_pInputBuffer = {};
vector<ID3D11Buffer*> m_pOutputBuffer = {};
vector<ID3D11Buffer*> m_pInputStagingBuffer = {};
vector<ID3D11Buffer*> m_pOutputStagingBuffer = {};
ID3D11Buffer* m_pOutputBuffer = nullptr;
vector<ID3D11Buffer*> m_pStagingBuffer = {};
ID3D11Buffer* m_pOutputStagingBuffer = {};
ID3D11ComputeShader* m_pComputeShader = nullptr;
ID3D11ShaderResourceView* m_pOutputSRV = { nullptr };
private:
_uint m_iNumElement = 0; // 인수 개수
_uint m_iNumInputBuffer = 0; // 인풋 버퍼의 개수
_uint m_iNumOutputBuffer = 0; // ÀÎDz ¹öÆÛÀÇ °³¼ö
_uint m_iOutputStructStride = 0; // µ¥ÀÌÅÍ Å©±â
public:
static CComputeShader* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iNumOutputBuffer, _uint iInputStructStride[], _uint iOutputStructStride[]);
static CComputeShader* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _tchar* pShaderFilePath, const _char* pStartFunctionName, _uint iNumElement, _uint iNumInputBuffer, _uint iOutputStructStride, _uint iInputStructStride[]);
virtual void Free() override;
};
@@ -69,4 +69,12 @@ enum aiTextureType {
};
#endif // !EDITOR_PROJECT
enum class PHYSX_KIND {
NOT_DEFINED = 0,
CCTActor = 1,
OBSTACLEActor = 2,
BODY_STATIC = 3,
BODY_DYNAMIC = 4,
};
NS_END
@@ -47,4 +47,17 @@ unsigned long Safe_Release(T& pInstance)
return dwRefCnt;
}
static void GUIHelpMarker(const char* desc)
{
GUI::SameLine();
GUI::TextDisabled("(?)");
if (GUI::BeginItemTooltip())
{
GUI::PushTextWrapPos(GUI::GetFontSize() * 35.0f);
GUI::TextUnformatted((_string("u8") + desc).c_str());
GUI::PopTextWrapPos();
GUI::EndTooltip();
}
}
NS_END
@@ -91,6 +91,7 @@ constexpr unsigned int g_iMaxShadowHeight = 9216;
#endif // !AI_TEXTURE_TYPE_MAX
#define ENUM_CLASS(ENUM) static_cast<unsigned int>(ENUM)
#define KR_CSTR(str) reinterpret_cast<const char*>(u8##str)
#ifndef MSG_BOX
#define MSG_BOX(_message) MessageBox(NULL, TEXT(_message), L"System Message", MB_OK)
+103 -76
View File
@@ -4,12 +4,12 @@ NS_BEGIN(Engine)
typedef struct tagEngineDesc
{
HINSTANCE hInstance;
HWND hWnd;
_uint iNumLevels;
_uint iNumCollidableGroup;
_uint iStaticLevel;
_uint iWinSizeX, iWinSizeY;
HINSTANCE hInstance = {};
HWND hWnd = {};
_uint iNumLevels = {};
_uint iNumCollidableGroup = {};
_uint iStaticLevel = {};
_uint iWinSizeX, iWinSizeY = {};
}ENGINE_DESC;
typedef struct tagModelDesc {
@@ -24,35 +24,35 @@ typedef struct tagModelDesc {
typedef struct tagKeyFrame
{
XMFLOAT3 vScale;
XMFLOAT4 vRotation;
XMFLOAT3 vTranslation;
float fTrackPosition;
XMFLOAT3 vScale = {};
XMFLOAT4 vRotation = {};
XMFLOAT3 vTranslation = {};
_float fTrackPosition = {};
}KEYFRAME;
struct LERPDESC {
_int iSlot;
tagKeyFrame tagKeyFrame;
_int iSlot = {};
tagKeyFrame tagKeyFrame = {};
};
typedef struct tagLightDesc
{
LIGHT eType;
_float4 vDiffuse;
_float4 vAmbient;
_float4 vSpecular;
LIGHT eType = {};
_float4 vDiffuse = {};
_float4 vAmbient = {};
_float4 vSpecular = {};
_float4 vDirection;
_float4 vPosition;
_float fRange;
_float2 vSpotAngles;
_float4 vDirection = {};
_float4 vPosition = {};
_float fRange = {};
_float2 vSpotAngles = {};
}LIGHT_DESC;
typedef struct tagShadowLight
{
_float4 vEye, vAt;
_float fWidth, fHeight, fNear, fFar;
_float4 vEye{}, vAt{};
_float fWidth{}, fHeight{}, fNear{}, fFar{};
}SHADOW_LIGHT_DESC;
struct SaveVertex
@@ -73,35 +73,41 @@ struct SaveVertex
struct SaveBoneWeight
{
unsigned int VertexId;
float Weight;
unsigned int VertexId = {};
float Weight = {};
};
struct SaveBone
{
char Name[64];
string BoneName;
unsigned int BoneNameSize = {};
XMFLOAT4X4 OffsetMatrix;
int BoneIndex;
unsigned int WeightsCount;
vector<SaveBoneWeight>Weights;
int BoneIndex = {};
unsigned int WeightsCount = {};
vector<SaveBoneWeight>Weights = {};
};
struct SaveNode
{
char Name[64];
int ParentIndex;
unsigned int ChildrenCount;
string NodeName;
unsigned int NodeNameSize = {};
int ParentIndex = {};
unsigned int ChildrenCount = {};
XMFLOAT4X4 Transformation;
vector<int> ChildrenIndices;
};
struct SaveMesh
{
char Name[64];
unsigned int VertexCount;
unsigned int IndexCount;
unsigned int MaterialIndex;
unsigned int BoneCount;
string MeshName;
unsigned int MeshNameSize = {};
unsigned int VertexCount = {};
unsigned int IndexCount = {};
unsigned int MaterialIndex = {};
unsigned int BoneCount = {};
vector<SaveVertex> Vertices;
vector<unsigned int> Indices;
@@ -129,7 +135,9 @@ struct SaveKeyFrameRotation
struct SaveChannel
{
char Name[64] = { };
string ChannelName;
unsigned int ChannelNameSize = {};
unsigned int ScalingKeyCount = { };
unsigned int RotationKeyCount = { };
unsigned int PositionKeyCount = { };
@@ -141,40 +149,45 @@ struct SaveChannel
struct SaveAnimation
{
char Name[128];
float mDuration;
float mTicksPerSecond;
unsigned int ChannelCount;
string AnimName;
unsigned int AnimNameSize = {};
float mDuration = {};
float mTicksPerSecond = {};
unsigned int ChannelCount = {};
vector<SaveChannel> Channels;
};
struct SaveModel
{
unsigned int MeshCount;
unsigned int MaterialCount;
unsigned int AnimationCount;
unsigned int NodeCount;
unsigned int MeshCount = {};
unsigned int MaterialCount = {};
unsigned int AnimationCount = {};
unsigned int NodeCount = {};
vector<SaveMesh> Meshes;
vector<SaveMaterial> Materials;
vector<SaveAnimation> Animations;
vector<SaveNode>Nodes;
};
#pragma region VTX
typedef struct tagVertexInstance_Particle
{
_float4 vRight;
_float4 vUp;
_float4 vLook;
_float4 vTranslation;
_float4 vRight = {};
_float4 vUp = {};
_float4 vLook = {};
_float4 vTranslation = {};
_float2 vLifeTime;
_float2 vLifeTime = {};
}VTX_INSTANCE_PARTICLE;
typedef struct tagVertexBlock
{
_float3 vPosition;
_float3 vNormal;
_float3 vTexcoord;
_float3 vPosition = {};
_float3 vNormal = {};
_float3 vTexcoord = {};
static constexpr _uint iNumElements = { 3 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
@@ -186,8 +199,8 @@ typedef struct tagVertexBlock
}VTXBLOCK;
typedef struct tagVertexPosition {
_float3 vPosition;
_float3 vPosition = {};
static constexpr _uint iNumElements = { 1 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
@@ -196,9 +209,9 @@ typedef struct tagVertexPosition {
}VTXPOS;
typedef struct tagVertexPositionTexcoord {
_float3 vPosition;
_float2 vTexcoord;
_float3 vPosition = {};
_float2 vTexcoord = {};
static constexpr _uint iNumElements = { 2 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
@@ -208,10 +221,10 @@ typedef struct tagVertexPositionTexcoord {
}VTXPOSTEX;
typedef struct tagVertexPositionNormalTexcoord {
_float3 vPosition;
_float3 vNormal;
_float2 vTexcoord;
_float3 vPosition = {};
_float3 vNormal = {};
_float2 vTexcoord = {};
static constexpr _uint iNumElements = { 3 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
@@ -223,11 +236,11 @@ typedef struct tagVertexPositionNormalTexcoord {
typedef struct tagVertexMesh
{
_float3 vPosition;
_float3 vNormal;
_float3 vTangent;
_float3 vBinormal;
_float2 vTexcoord;
_float3 vPosition = {};
_float3 vNormal = {};
_float3 vTangent = {};
_float3 vBinormal = {};
_float2 vTexcoord = {};
static constexpr _uint iNumElements = { 5 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
@@ -241,14 +254,14 @@ typedef struct tagVertexMesh
typedef struct tagVertexAnimationMesh
{
_float3 vPosition;
_float3 vNormal;
_float3 vTangent;
_float3 vBinormal;
_float2 vTexcoord;
_float3 vPosition = {};
_float3 vNormal = {};
_float3 vTangent = {};
_float3 vBinormal = {};
_float2 vTexcoord = {};
XMUINT4 vBlendIndex;
_float4 vBlendWeight;
XMUINT4 vBlendIndex = {};
_float4 vBlendWeight = {};
static constexpr _uint iNumElements = { 7 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
@@ -264,7 +277,7 @@ typedef struct tagVertexAnimationMesh
typedef struct tagVertexPosInstanceParticleDesc
{
static constexpr unsigned int iNumElements = { 6 };
static constexpr _uint iNumElements = { 6 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
@@ -279,7 +292,7 @@ typedef struct tagVertexPosInstanceParticleDesc
typedef struct tagVertexModelInstanceParticleDesc
{
static constexpr unsigned int iNumElements = { 10 };
static constexpr _uint iNumElements = { 10 };
static constexpr D3D11_INPUT_ELEMENT_DESC Elements[] = {
{ "POSITION" , 0 , DXGI_FORMAT_R32G32B32_FLOAT , 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{ "NORMAL" , 0 , DXGI_FORMAT_R32G32B32_FLOAT , 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
@@ -295,4 +308,18 @@ typedef struct tagVertexModelInstanceParticleDesc
};
}VTX_MODEL_INSTANCE_PARTICLE;
#pragma endregion
typedef struct tagPhsXUserData {
PHYSX_KIND eKind = PHYSX_KIND::NOT_DEFINED;
class CGameObject* pOwner = { nullptr };
_float4x4 m_BeforeMatrix = { };
union {
class CRigidBody* pBody;
class CCharacter_Controller* pCharacter;
class CObstacle_Controller* pObstacle = { nullptr };
};
}PhsXUserData;
NS_END
+13 -5
View File
@@ -22,8 +22,6 @@ class ENGINE_DLL CGameInstance final : public CBase
_float Random_Float(_float fMin, _float fMax);
_int Random_Int(_int iMin, _int iMax);
void BillBoard(class CTransform* pTransform);
#pragma region GRAPHIC_DEVICE
public:
void Render_Begin(const _float4* pClearColor);
@@ -67,9 +65,9 @@ class ENGINE_DLL CGameInstance final : public CBase
}
template<typename T>
void Asset_Description(_uint iLevel, const _char* pComponentName, CComponent** ppOut, void* pDesc, class CGameObject* pOwner = nullptr, _wstring wstrGroupName = L"")
void Asset_Description(_uint iLevel, const _char* pComponentName, CComponent** ppOut, void* pDesc, class CGameObject* pOwner = nullptr)
{
return m_pPrototype_Manager->CPrototype_Manager::Asset_Description<T>(iLevel, pComponentName, ppOut, pDesc, pOwner, wstrGroupName);
return m_pPrototype_Manager->CPrototype_Manager::Asset_Description<T>(iLevel, pComponentName, ppOut, pDesc, pOwner);
}
#pragma endregion
@@ -180,10 +178,20 @@ class ENGINE_DLL CGameInstance final : public CBase
#pragma endregion
#pragma region PhysX_Manager
PSX::PxMaterial* Get_Material(_float3& vMatInfo);
HRESULT Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh);
void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh);
PSX::PxShape* Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive = false, PSX::PxShapeFlags ePxShapeFlag = PSX::PxShapeFlag::eVISUALIZATION | PSX::PxShapeFlag::eSCENE_QUERY_SHAPE | PSX::PxShapeFlag::eSIMULATION_SHAPE);
const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& 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);
HRESULT ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix);
HRESULT SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
HRESULT LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes); // 모델 불러왔던 경로에 그대로 있음
#pragma endregion
+25 -23
View File
@@ -10,13 +10,10 @@ class ENGINE_DLL CInstance_Model final : public CComponent
public:
typedef struct tagInstanceDesc
{
_int iNumInstance = {1}; // 인스턴스 개수
_bool isLoop = { true };
_bool isBillboard = { false};
_float2 vLifeTime = {1.f , 1.f}; // 라이프 타임 min , max
_float3 vSizeMin = {1.f, 1.f ,1.f}; // 사이즈 min xyz
_float3 vSizeMax = {1.f ,1.f ,1.f}; // 사이즈 max xyz
_int iNumInstance = {}; // 인스턴스 개수
_float2 vLifeTime = {}; // 라이프 타임 min , max
_float3 vSizeMin = {}; // 사이즈 min xyz
_float3 vSizeMax = {}; // 사이즈 max xyz
_float3 vRotationAngleMin = {}; // 로테이션 min x y z for angle
_float3 vRotationAngleMax = {};// 로테이션 max x y z for angle
_float2 vRotationSpeed = {}; // 로테이션 스피드 min , max
@@ -24,27 +21,19 @@ class ENGINE_DLL CInstance_Model final : public CComponent
_float3 vCenter = {}; // 센터 위치
_float3 vRange = {}; // 위치 범위
_float2 vMaskingUVMoveTime = {1.f, 1.f};
_float2 vDiffuseUVMoveTime = {1.f, 1.f};
_float2 vNoiseUVMoveTime = {1.f ,1.f};
_float2 vAniTime = {1.f , 1.f};
_float2 vMaskingUVMoveTime = {};
_float2 vDiffuseUVMoveTime = {};
_float2 vAniTime = {};
_float2 vAniIndex = {};
}INSTANCE_DESC;
typedef struct tagCSParticleDesc
{
_float4x4 CamViewInvMatrix = {};
_int isLoop = {};
_int isBillboard = {};
_int isPadding2 = {};
_int isPadding3 = {};
_float fTimeDelta = {};
_float fPadding = {};
_float fPadding2 = {};
_float fPadding3 = {};
_float fPadding4 = {};
}CS_PARTICLE_DESC;
@@ -60,13 +49,28 @@ class ENGINE_DLL CInstance_Model final : public CComponent
_float2 vMaskingUVMoveTime = {};
_float2 vDiffuseUVMoveTime = {};
_float2 vNoiseUVMoveTime = {};
_float2 vAniTime = {};
_float2 vAniIndex = {};
}CS_PARTICLE_VALUE_DESC;
struct ParticleOut
{
_float4 vRight = {};
_float4 vUp = {};
_float4 vLook = {};
_float4 vTranslation = {};
_float2 vLifeTime = {};
_float2 vMaskingUVMoveTime = {};
_float2 vDiffuseUVMoveTime = {};
_float2 vAniTime = {};
_float2 vAniIndex = {};
}CS_PARTICLE_OUT;
public:
CInstance_Model(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
CInstance_Model(const CInstance_Model& rhs);
@@ -84,14 +88,12 @@ class ENGINE_DLL CInstance_Model final : public CComponent
HRESULT Render(_uint iMeshIndx);
void Instane_Buffer_ReStruct();
_uint Get_NumMeshes() const { return m_iNumMeshes; }
HRESULT Bind_CS_Output(_uint Index , _uint iBufferIndex);
INSTANCE_DESC Get_EffectValue() { return m_InstanceDesc; }
HRESULT Bind_CS_Output(_uint Index);
private:
#ifdef EDITOR_PROJECT
HRESULT Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex);
HRESULT Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& PreTransformMatrix);
#endif
HRESULT Change_NumInstance();
HRESULT Create_Instance_Buffer(const INSTANCE_DESC* pDesc);
HRESULT Create_SubResource_Buffer();
+2 -1
View File
@@ -16,6 +16,7 @@ class ENGINE_DLL CMesh final : public CVIBuffer
return m_iMaterialIndex;
}
const _char* Get_Name() const { return m_szName; }
HRESULT Bind_BoneMatrices(const vector<class CBone*>& Bones, class CShader* pShader, const _char* pConstantName);
HRESULT Bind_BoneMatrices(_float4x4* pCombinedMatrices, class CShader* pShader, const _char* pConstantName);
HRESULT Render_Indexed(_uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation);
@@ -27,7 +28,7 @@ class ENGINE_DLL CMesh final : public CVIBuffer
public:
static CMesh* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, vector<class CBone*>& Bones, const aiMesh* pAIMesh, _fmatrix& PreTransformMatrix);
HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte);
PSX::PxTriangleMesh* ConvertToPxMesh(const PSX::PxCookingParams* pParam);
PSX::PxTriangleMesh* ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _fmatrix WorldMatrix);
#endif // EDITOR_PROJECT
public:
+6 -5
View File
@@ -31,6 +31,7 @@ class ENGINE_DLL CModel final : public CComponent
_int Get_RootBoneIndex() const { return m_iRootBoneIndex; }
const _float4x4* Get_BoneMatrixPtr(const _char* pBoneName) const;
_uint Get_NumMeshes() const { return m_iNumMeshes; }
const _char* Get_MeshName(_uint iIndex);
MODEL Get_Type() const { return m_eType; }
_matrix Get_BoneMatrix(_uint iBoneIndex);
@@ -56,16 +57,16 @@ class ENGINE_DLL CModel final : public CComponent
virtual HRESULT Render_Indexed(_uint iMeshIndex, _uint IndexCount, _uint StartIndexLocation, _uint BaseVertexLocation);
#ifdef EDITOR_PROJECT
HRESULT Initialize_Prototype(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex);
static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex);
HRESULT Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fmatrix& PreTransformMatrix, _uint iRootBoneIndex);
HRESULT Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& PreTransformMatrix);
HRESULT Ready_PhysXMeshes();
HRESULT Save_PhysXTriMeshes(const _char* pModelFilePath);
HRESULT Ready_Materials(const aiScene* pAIScene, const _char* pModelFilePath);
HRESULT Ready_Materials_FromFile(const aiScene* pAIScene, const _char* pModelFilePath);
HRESULT Ready_Animations(const aiScene* pAIScene);
HRESULT Ready_Bones(const aiNode* pAINode, _int iParentIndex);
// 바이너리
bool SaveAssimpModel(const _char* filename);
_bool SaveAssimpModel(const _char* filename);
_int SaveNodeRecursive(const aiNode* pAINode, std::vector<SaveNode>& outNodes, _int parentIndex);
//
#endif // EDITOR_PROJECT
@@ -83,6 +84,8 @@ class ENGINE_DLL CModel final : public CComponent
_uint m_iNumMeshes = {}; // 메쉬의 갯수
vector<class CMesh*> m_Meshes; // 메쉬의 벡터
_uint m_iNumPhysXMeshes = {}; // 피직스 메쉬의 갯수
vector<PSX::PxTriangleMesh*> m_TriMeshes = {}; // 피직스 메쉬의 갯수
_uint m_iNumMaterials = {}; // 머테리얼의 갯수
vector<class CMaterial*> m_Materials; // 머테리얼의 벡터
@@ -111,7 +114,6 @@ class ENGINE_DLL CModel final : public CComponent
//
private:
virtual HRESULT Initialize_Prototype() override;
// 바이너리
virtual HRESULT Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix);
bool LoadData(const _char* filename);
@@ -127,7 +129,6 @@ class ENGINE_DLL CModel final : public CComponent
//
public:
static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext);
// 바이너리
static CModel* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, MODEL eType, const _char* pModelFilePath, _fmatrix PreTransformMatrix = XMMatrixIdentity());
//
@@ -22,11 +22,15 @@ class CPhysX_Manager final : public CBase
const PSX::PxRigidDynamic* Add_DynamicActor(CRigidBody& RigidBody);
const PSX::PxRigidStatic* Add_StaticActor(CRigidBody& RigidBody);
void RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxTriMesh);
PSX::PxMaterial* Get_Material(_float3& vMatInfo);
PSX::PxShape* Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive, PSX::PxShapeFlags ePxShapeFlag);
HRESULT Create_TriangleMesh(const _wstring& wstrMeshKey, CMesh* pMesh);
HRESULT ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix);
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);
void Update(_float fTimeDelta);
@@ -35,7 +39,7 @@ class CPhysX_Manager final : public CBase
#pragma endregion
#pragma region CHARACTER_CONTROLLER
/* https://dev-treadmill.tistory.com/158 */
/* dev-treadmill.tistory.com/158 */
public:
PSX::PxController* Add_CapsuleController(PSX::PxCapsuleControllerDesc& Desc);
@@ -9,6 +9,7 @@
#include "Texture.h"
#include "Cell.h"
#include "Model.h"
#include "Character_Controller.h"
#include "Instance_Model.h"
@@ -70,7 +71,7 @@ class CPrototype_Manager final : public CBase
//만들고 선택할 시에 내 ppOut에 클론하는 기능을 담당
template<typename T>
void Asset_Description(_uint iLevel , const _char* pComponentName , CComponent** ppOut , void* pDesc , class CGameObject* pOwner = nullptr , _wstring wstrGroupName = L"")
void Asset_Description(_uint iLevel , const _char* pComponentName , CComponent** ppOut , void* pDesc , class CGameObject* pOwner = nullptr)
{
vector<const _char*> pComponentNames = {};
vector<_string> strNames = {};
@@ -100,28 +101,17 @@ class CPrototype_Manager final : public CBase
if (iter == m_pAssets[iLevel].end()) {
continue;
}
CTexture* pTexture = dynamic_cast<CTexture*>(iter->second);
if (pTexture == nullptr)
continue;
if (pTexture->Compare_GroupName(wstrGroupName) == false) // 그룹네임을 비교해서 같은 것만 띄울 수 있도록 한다 , Default시 L""
continue;
if (GUI::ImageButton(strName.c_str(), pTexture->Get_SRV(0), ImVec2(48, 48)))
if (GUI::ImageButton(strName.c_str(), dynamic_cast<CTexture*>(iter->second)->Get_SRV(0), ImVec2(48, 48)))
{
if (*ppOut != nullptr)
Safe_Release(*ppOut);
*ppOut = iter->second->Clone(pDesc, pOwner);
return;
}
pTexture->HoverName();
if ((iIndex++ + 1) % 4 != 0)
GUI::SameLine(); // 같은 줄에 이어서
+4 -5
View File
@@ -16,8 +16,7 @@ class ENGINE_DLL CRigidBody final : public CComponent
typedef struct tagRigidStatic_PrototypeDesc
{
_float3 vMatInfo;
const _tchar* pMeshKey = { nullptr };
CMesh* pMesh = { nullptr };
const _char* szMeshName = { } ;
}RIGID_STATIC_PROTOTYPEDESC;
typedef struct tagRigidDynamic_PrototypeDesc
{
@@ -37,7 +36,7 @@ class ENGINE_DLL CRigidBody final : public CComponent
};
}RIGIDBODY_PROTOTYPEDESC;
typedef struct tagRigidStatic_Desc {
const _tchar* pMeshKey = { nullptr };
const _char* szMeshName = { };
}RIGID_STATIC_DESC;
typedef struct tagRigidDynamic_Desc {
_float fDensity = { 1000.f };
@@ -68,7 +67,7 @@ class ENGINE_DLL CRigidBody final : public CComponent
public:
PSX::PxShape* Get_ShapePtr() const { return m_pShape; }
CTransform* Get_PxTransformPtr() const { return m_pTransform; }
const _tchar* Get_PxMeshKey() const { return m_pMeshKey; }
const _tchar* Get_PxMeshKey() const { return m_wstrMeshKey.c_str(); }
const PSX::PxMaterial* Get_PxMaterial() const { return m_pMaterial; }
_float Get_Density() const { return m_fDensity; }
@@ -84,7 +83,7 @@ class ENGINE_DLL CRigidBody final : public CComponent
_bool m_bKinematic = { false };
_bool m_bExclusive = { false };
_float m_fDensity = { 1000.f };
const _tchar* m_pMeshKey = { nullptr };
_wstring m_wstrMeshKey = { };
private:
HRESULT Initialize_Prototype(RIGIDBODY_PROTOTYPEDESC& Desc);
+3 -7
View File
@@ -18,13 +18,9 @@ class ENGINE_DLL CTexture final :
vector<ID3D11ShaderResourceView*>* Get_Texture() { return &m_SRVs; }
ID3D11ShaderResourceView* Get_SRV(_uint iTextureIndex);
_uint Get_Size();
_bool Compare_GroupName(_wstring wstrGroupName);
#ifdef _DEBUG
void HoverName();
#endif
private:
HRESULT Initialize_Prototype(TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures, _wstring wstrPrototypeName);
HRESULT Initialize_Prototype(TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures);
virtual HRESULT Initialize(void* pArg) override;
HRESULT Load_SRV(const _char* szPath, ID3D11ShaderResourceView** ppSRV);
@@ -33,9 +29,9 @@ class ENGINE_DLL CTexture final :
private:
vector<ID3D11ShaderResourceView*> m_SRVs = { };
_wstring m_wstrPrototypeName = {};
public:
static CTexture* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures , _wstring wstrPrototypeName = L"");
static CTexture* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, TEXTURE_LOAD_TYPE eType, const _tchar* pTextureFilePath, _uint iNumTextures);
virtual CComponent* Clone(void* pArg, class CGameObject* pOwner = nullptr) override;
virtual void Free() override;
virtual void Describe_Entity() override;