[fix] Material Component
This commit is contained in:
@@ -270,6 +270,7 @@
|
||||
<ClCompile Include="..\Private\VIBuffer_Cube.cpp" />
|
||||
<ClCompile Include="..\Private\Instance_Model.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer_Rect.cpp" />
|
||||
<ClCompile Include="..\Private\VIBuffer_Terrain.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Public\Animation.h" />
|
||||
@@ -473,6 +474,7 @@
|
||||
<ClInclude Include="..\Public\VIBuffer_Cube.h" />
|
||||
<ClInclude Include="..\Public\Instance_Model.h" />
|
||||
<ClInclude Include="..\Public\VIBuffer_Rect.h" />
|
||||
<ClInclude Include="..\Public\VIBuffer_Terrain.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Bin\Resources\ShaderFiles\Engine_Shader_Defines.hlsli" />
|
||||
|
||||
@@ -423,6 +423,9 @@
|
||||
<ClCompile Include="..\Private\ComputeShader.cpp">
|
||||
<Filter>01.Utility\06.ComputeShader</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\Private\VIBuffer_Terrain.cpp">
|
||||
<Filter>02.Element\02.Component\02.VIBuffer\Terrain</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\Public\Base.h">
|
||||
@@ -983,6 +986,9 @@
|
||||
<ClInclude Include="..\public\Picking.h">
|
||||
<Filter>01.Utility\06. Picking</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\Public\VIBuffer_Terrain.h">
|
||||
<Filter>02.Element\02.Component\02.VIBuffer\Terrain</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\Public\Assimp\color4.inl">
|
||||
|
||||
@@ -90,12 +90,12 @@ HRESULT CMaterial::Initialize(const _char* pModelFilePath, const aiMaterial* pAI
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CMaterial::Initialize(const _char* pMaterialFilePath)
|
||||
HRESULT CMaterial::Initialize(const _char* pMaterialFilePath, const _char* pTextureFilePath)
|
||||
{
|
||||
_char szTextureFilePath[MAX_PATH] = {};
|
||||
_char szMaterialFilePath[MAX_PATH] = {};
|
||||
|
||||
strcpy_s(szTextureFilePath, "../Bin/Resources/Models/");
|
||||
strcpy_s(szTextureFilePath, pTextureFilePath);
|
||||
|
||||
strcpy_s(szMaterialFilePath, pMaterialFilePath);
|
||||
strcat_s(szMaterialFilePath, ".props.txt");
|
||||
@@ -114,7 +114,8 @@ HRESULT CMaterial::Read_MaterialFile(const _char* pMaterialFilePath, const _char
|
||||
if (!file.is_open())
|
||||
{
|
||||
MSG_BOX("Failed to Open Materail File");
|
||||
return E_FAIL;
|
||||
//return E_FAIL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
_char szTextureFilePath[MAX_PATH] = {};
|
||||
@@ -250,18 +251,28 @@ HRESULT CMaterial::Add_Texture(const _char* pTextureFolderPath, string& FileType
|
||||
eTexture = aiTextureType::aiTextureType_DIFFUSE;
|
||||
else if (!strcmp(FileType.c_str(), "N"))
|
||||
eTexture = aiTextureType::aiTextureType_NORMALS;
|
||||
else if (!strcmp(FileType.c_str(), "normal"))
|
||||
eTexture = aiTextureType::aiTextureType_NORMALS;
|
||||
else if (!strcmp(FileType.c_str(), "MRO"))
|
||||
eTexture = aiTextureType::aiTextureType_METALNESS;
|
||||
else if (!strcmp(FileType.c_str(), "MROH"))
|
||||
eTexture = aiTextureType::aiTextureType_METALNESS;
|
||||
else if (!strcmp(FileType.c_str(), "MROA'"))
|
||||
else if (!strcmp(FileType.c_str(), "MROA"))
|
||||
eTexture = aiTextureType::aiTextureType_DIFFUSE_ROUGHNESS;
|
||||
else if (!strcmp(FileType.c_str(), "SRO"))
|
||||
eTexture = aiTextureType::aiTextureType_AMBIENT_OCCLUSION;
|
||||
eTexture = aiTextureType::aiTextureType_SPECULAR;
|
||||
else if (!strcmp(FileType.c_str(), "SROH"))
|
||||
eTexture = aiTextureType::aiTextureType_AMBIENT_OCCLUSION;
|
||||
else if (!strcmp(FileType.c_str(), "HDR'"))
|
||||
eTexture = aiTextureType::aiTextureType_DISPLACEMENT;
|
||||
eTexture = aiTextureType::aiTextureType_SPECULAR;
|
||||
else if (!strcmp(FileType.c_str(), "SROA"))
|
||||
eTexture = aiTextureType::aiTextureType_SPECULAR;
|
||||
else if (!strcmp(FileType.c_str(), "HDR"))
|
||||
return S_OK;
|
||||
else if (!strcmp(FileType.c_str(), "MSK"))
|
||||
eTexture = aiTextureType::aiTextureType_MAYA_BASE;
|
||||
else if (!strcmp(FileType.c_str(), "basecolor"))
|
||||
eTexture = aiTextureType::aiTextureType_DIFFUSE;
|
||||
else if (!strcmp(FileType.c_str(), "E"))
|
||||
eTexture = aiTextureType::aiTextureType_EMISSIVE;
|
||||
else
|
||||
{
|
||||
MSG_BOX("Failed to Path Material Texture Type");
|
||||
@@ -337,9 +348,18 @@ CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContex
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const _char* pMaterialName)
|
||||
|
||||
CMaterial* CMaterial::Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pMaterialFilePath, const _char* pTextureFilePath)
|
||||
{
|
||||
return nullptr;
|
||||
CMaterial* pInstance = new CMaterial(pDevice, pContext);
|
||||
|
||||
if (FAILED(pInstance->Initialize(pMaterialFilePath, pTextureFilePath)))
|
||||
{
|
||||
MSG_BOX("Failed to Created : CMaterial");
|
||||
SAFE_RELEASE(pInstance);
|
||||
}
|
||||
|
||||
return pInstance;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -338,6 +338,11 @@ HRESULT CModel::Ready_Materials_FromFile(const aiScene* pAIScene, const _char* p
|
||||
_char szFileName[MAX_PATH] = {};
|
||||
_char szMeshFilePath[MAX_PATH] = {};
|
||||
vector<_string> MaterialFilePathes;
|
||||
string strFolderPath = pModelFilePath;
|
||||
|
||||
size_t iFolderPos = strFolderPath.find("Environment");
|
||||
|
||||
strFolderPath = strFolderPath.substr(0, iFolderPos);
|
||||
|
||||
_splitpath_s(pModelFilePath, szDrive, MAX_PATH, szDir, MAX_PATH, szFileName, MAX_PATH, nullptr, 0);
|
||||
|
||||
@@ -380,12 +385,12 @@ HRESULT CModel::Ready_Materials_FromFile(const aiScene* pAIScene, const _char* p
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
string strPath = "../Bin/Resources/Models/" + strText.substr(iBeginIndex, iEndIndex - iBeginIndex);
|
||||
string strPath = strFolderPath + strText.substr(iBeginIndex, iEndIndex - iBeginIndex);
|
||||
MaterialFilePathes.push_back(strPath);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < m_iNumMaterials; ++i) {
|
||||
CMaterial* pMaterial = CMaterial::Create(m_pDevice, m_pContext, MaterialFilePathes[i].c_str(), pAIScene->mMaterials[i]->GetName().C_Str());
|
||||
CMaterial* pMaterial = CMaterial::Create(m_pDevice, m_pContext, MaterialFilePathes[i].c_str(), strFolderPath.c_str());
|
||||
if (nullptr == pMaterial) {
|
||||
return E_FAIL;
|
||||
}
|
||||
@@ -760,7 +765,9 @@ HRESULT CModel::Assimp_Model_Load(const _char* pModelFilePath, MODEL eType, _fma
|
||||
#pragma region Material
|
||||
if (MODEL::ENVIROMENT == eType)
|
||||
{
|
||||
|
||||
if (FAILED(Ready_Materials_FromFile(m_pAIScene, pModelFilePath))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -24,12 +24,12 @@ class ENGINE_DLL CMaterial final : public CBase
|
||||
#ifdef EDITOR_PROJECT
|
||||
public:
|
||||
static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const aiMaterial* pAIMaterial);
|
||||
static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pModelFilePath, const _char* pMaterialName);
|
||||
static CMaterial* Create(ID3D11Device* pDevice, ID3D11DeviceContext* pContext, const _char* pMaterialFilePath, const _char* pTextureFilePath);
|
||||
HRESULT SaveAsBinary(HANDLE hFile, DWORD& dwByte);
|
||||
private:
|
||||
vector<string> m_strPath[AI_TEXTURE_TYPE_MAX];
|
||||
HRESULT Initialize(const _char* pModelFilePath, const aiMaterial* pAIMaterial);
|
||||
HRESULT Initialize(const _char* pMaterialFilePath);
|
||||
HRESULT Initialize(const _char* pMaterialFilePath, const _char* pTextureFilePath);
|
||||
HRESULT Read_MaterialFile(const _char* pMaterialFilePath, const _char* pTextureFolderPath);
|
||||
HRESULT Add_Texture(const _char* pTextureFolderPath, string& FileType);
|
||||
#endif // EDITOR_PROJECT
|
||||
|
||||
@@ -51,6 +51,7 @@ using namespace DirectX;
|
||||
#include <cassert>
|
||||
#include <random>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user