[add] 피직스 메시 저장옵션 추가
[add] 월드행렬 곱 추가
This commit is contained in:
Binary file not shown.
@@ -491,10 +491,9 @@ HRESULT CLoader::Loading_For_PhysXLevel()
|
||||
m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("PHYSX_DYNAMIC_BOX"), CRigidBody::Create(m_pDevice, m_pContext, Desc));
|
||||
}
|
||||
|
||||
|
||||
if (FAILED(m_pGameInstance->Add_Asset_Prototype(g_iStaticLevel, TEXT("Prototype_Component_River_Col_Model"),
|
||||
//CModel::Create(m_pDevice, m_pContext, MODEL::ENVIROMENT, "../Bin/Resources/Models/River/River.fbx", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity())))){
|
||||
CModel::Create(m_pDevice, m_pContext, MODEL::ENVIROMENT, "../Bin/Resources/Models/River/River.bin", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity())))){
|
||||
CModel::Create(m_pDevice, m_pContext, MODEL::ENVIROMENT, "../Bin/Resources/Models/River/River.fbx", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity())))){
|
||||
//CModel::Create(m_pDevice, m_pContext, MODEL::ENVIROMENT, "../Bin/Resources/Models/River/River.bin", XMMatrixScaling(0.001f, 0.001f, 0.001f) * XMMatrixIdentity())))){
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -575,15 +575,15 @@ void CGameInstance::ReleaseController(_uint iControllerIndex)
|
||||
{
|
||||
m_pPhysX_Manager->ReleaseController(iControllerIndex);
|
||||
}
|
||||
HRESULT CGameInstance::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes)
|
||||
HRESULT CGameInstance::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes, _fmatrix WorldMatrix)
|
||||
{
|
||||
return m_pPhysX_Manager->ConvertToTriMeshes(Meshes, pxTriMeshes);
|
||||
return m_pPhysX_Manager->ConvertToTriMeshes(Meshes, pxTriMeshes, WorldMatrix);
|
||||
}
|
||||
_bool CGameInstance::SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
HRESULT CGameInstance::SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
{
|
||||
return m_pPhysX_Manager->SaveTriMeshes(pPath, TriMeshes);
|
||||
}
|
||||
_bool CGameInstance::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
HRESULT CGameInstance::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
{
|
||||
return m_pPhysX_Manager->LoadTriMeshes(pPath, TriMeshes);
|
||||
}
|
||||
|
||||
@@ -607,16 +607,16 @@ HRESULT CMesh::SaveAsBinary(HANDLE hFile, DWORD& dwByte)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX)
|
||||
PSX::PxTriangleMesh* CMesh::ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _fmatrix WorldMatrix)
|
||||
{
|
||||
PSX::PxTriangleMeshDesc tMeshDesc;
|
||||
vector<PSX::PxVec3> Vertices;
|
||||
vector<PSX::PxU32> Triangles;
|
||||
PSX::PxTriangleMeshDesc tMeshDesc = {};
|
||||
vector<PSX::PxVec3> Vertices = {};
|
||||
vector<PSX::PxU32> Triangles = {};
|
||||
{
|
||||
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);
|
||||
XMVector3TransformCoordStream(reinterpret_cast<XMFLOAT3*>(Vertices.data()), sizeof(PSX::PxVec3), (_float3*)m_pVertexPositions, sizeof(_float3), m_iNumVertices, WorldMatrix);
|
||||
tMeshDesc.points.data = Vertices.data();
|
||||
}
|
||||
{
|
||||
|
||||
@@ -345,17 +345,28 @@ HRESULT CModel::Ready_Meshes(MODEL eType, const aiScene* pAIScene, _fmatrix& Pre
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CModel::Ready_PhysXMeshes(MODEL eType)
|
||||
HRESULT CModel::Ready_PhysXMeshes()
|
||||
{
|
||||
m_iNumPhysXMeshes = m_iNumMeshes;
|
||||
|
||||
m_TriMeshes.reserve(m_iNumMeshes);
|
||||
|
||||
m_pGameInstance->ConvertToTriMeshes(m_Meshes, m_TriMeshes);
|
||||
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;
|
||||
@@ -810,9 +821,6 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma
|
||||
if (FAILED(Ready_Materials_FromFile(m_pAIScene, pModelFilePath))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (FAILED(Ready_PhysXMeshes(eType))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -847,6 +855,7 @@ HRESULT CModel::Initialize_Prototype()
|
||||
|
||||
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] = {};
|
||||
@@ -855,12 +864,13 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
||||
|
||||
if (strcmp(".bin", szEXT) == 0)
|
||||
{
|
||||
_char Temp[256];
|
||||
strcpy_s(Temp, szDir);
|
||||
strcat_s(Temp, szName);
|
||||
strcat_s(Temp, ".bin");
|
||||
LoadData(pModelFilePath);
|
||||
m_pGameInstance->LoadTriMeshes(pModelFilePath, m_TriMeshes);
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strcmp(".fbx", szEXT) == 0)
|
||||
{
|
||||
@@ -870,17 +880,12 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
||||
strcat_s(Temp, ".bin");
|
||||
Assimp_Model_Load(pModelFilePath, eType, PreTransformMatrix, 0);
|
||||
SaveAssimpModel(Temp);
|
||||
m_pGameInstance->SaveTriMeshes(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;
|
||||
}
|
||||
m_pSaveModel = m_pGameInstance->Load_SaveModel(pModelFilePath);
|
||||
|
||||
|
||||
m_eType = eType;
|
||||
XMStoreFloat4x4(&m_PreTransformMatrix, PreTransformMatrix);
|
||||
|
||||
Ready_Bones(m_pSaveModel->Nodes, 0, -1);
|
||||
@@ -897,9 +902,6 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
for (_uint i = 0; i < m_iNumMeshes; ++i) {
|
||||
m_pGameInstance->RegistTriMesh(m_Meshes[i]->Get_Name(), m_TriMeshes[i]);
|
||||
}
|
||||
|
||||
|
||||
return S_OK;
|
||||
|
||||
@@ -129,11 +129,11 @@ void CPhysX_Manager::RegistTriMesh(const _char* pName, PSX::PxTriangleMesh* pPxT
|
||||
m_TriangleMeshGeometry.emplace(CMyTools::ToWstring(pName), pGeometry);
|
||||
}
|
||||
|
||||
HRESULT CPhysX_Manager::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<PSX::PxTriangleMesh*>& pxTriMeshes)
|
||||
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);
|
||||
PSX::PxTriangleMesh* pTriangleMesh = Meshes[i]->ConvertToPxMesh(m_pCookingParam, m_pPhysics, WorldMatrix);
|
||||
if (nullptr == pTriangleMesh) {
|
||||
return E_FAIL;
|
||||
}
|
||||
@@ -144,23 +144,22 @@ HRESULT CPhysX_Manager::ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
_bool CPhysX_Manager::SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
HRESULT CPhysX_Manager::SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
{
|
||||
filesystem::path pathPhysX = pPath;
|
||||
pathPhysX.replace_extension(".xml");
|
||||
pathPhysX.replace_extension(".Pxml");
|
||||
if (TriMeshes.empty()){
|
||||
return false;
|
||||
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 false;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
for (PSX::PxTriangleMesh* pTriMesh : TriMeshes) {
|
||||
@@ -171,32 +170,30 @@ _bool CPhysX_Manager::SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMe
|
||||
PSX::PxDefaultFileOutputStream out(pathPhysX.string().c_str());
|
||||
PSX::PxCollection* extRefs = PxCreateCollection();
|
||||
const _bool ok = PSX::PxSerialization::serializeCollectionToXml(out, *pCollections, *pSerializationRegistry, m_pCookingParam, extRefs);
|
||||
//const _bool ok = PSX::PxSerialization::serializeCollectionToBinary(out, *pCollections, *pSerializationRegistry, extRefs);
|
||||
|
||||
extRefs->release();
|
||||
pCollections->release();
|
||||
pSerializationRegistry->release();
|
||||
assert(ok);
|
||||
return ok;
|
||||
return (ok ? S_OK : E_FAIL);
|
||||
}
|
||||
|
||||
_bool CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
HRESULT CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes)
|
||||
{
|
||||
filesystem::path pathPhysX = pPath;
|
||||
pathPhysX.replace_extension(".xml");
|
||||
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::createCollectionFromBinary(&InputData, *pSerializationRegistry, extRefs);
|
||||
PSX::PxCollection* pCollections = PSX::PxSerialization::createCollectionFromXml(InputData, *m_pCookingParam, *pSerializationRegistry, extRefs);
|
||||
if (nullptr == pCollections) {
|
||||
extRefs->release();
|
||||
pSerializationRegistry->release();
|
||||
assert(pCollections);
|
||||
return false;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
const PSX::PxU32 iNumTriMeshes = pCollections->getNbObjects();
|
||||
@@ -214,9 +211,47 @@ _bool CPhysX_Manager::LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMe
|
||||
extRefs->release();
|
||||
pCollections->release();
|
||||
pSerializationRegistry->release();
|
||||
return true;
|
||||
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);
|
||||
|
||||
@@ -189,9 +189,9 @@ class ENGINE_DLL CGameInstance final : public CBase
|
||||
PSX::PxController* Get_Controller(_uint iControllerIndex);
|
||||
void ReleaseController(_uint iControllerIndex);
|
||||
|
||||
HRESULT ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes);
|
||||
_bool SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
_bool LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
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
|
||||
|
||||
|
||||
|
||||
@@ -28,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::PxPhysics* pPhysX);
|
||||
PSX::PxTriangleMesh* ConvertToPxMesh(const PSX::PxCookingParams* pParam, PSX::PxPhysics* pPhysX, _fmatrix WorldMatrix);
|
||||
#endif // EDITOR_PROJECT
|
||||
|
||||
public:
|
||||
|
||||
@@ -61,7 +61,8 @@ class ENGINE_DLL CModel final : public CComponent
|
||||
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(MODEL eType);
|
||||
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);
|
||||
|
||||
@@ -27,9 +27,10 @@ class CPhysX_Manager final : public CBase
|
||||
PSX::PxMaterial* Get_Material(_float3& vMatInfo);
|
||||
PSX::PxShape* Create_Shape(ACTOR eType, _float3& vhalfGeometryInfo, PSX::PxMaterial& pxMaterial, _bool bExclusive, PSX::PxShapeFlags ePxShapeFlag);
|
||||
|
||||
HRESULT ConvertToTriMeshes(vector<class CMesh*>& Meshes, vector<class PSX::PxTriangleMesh*>& pxTriMeshes);
|
||||
_bool SaveTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
_bool LoadTriMeshes(const _char* pPath, vector<PSX::PxTriangleMesh*>& TriMeshes);
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user