[add] GerboldOllivander_Base
This commit is contained in:
@@ -92,7 +92,21 @@ HRESULT CModel::Bind_Material(_uint iMeshIndex, CShader* pShader)
|
||||
if (iMaterialIndex >= m_iNumMaterials) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return m_Materials[iMaterialIndex]->Bind_SRV(pShader);
|
||||
return m_Materials[iMaterialIndex]->Bind_SRV(pShader, m_eType);
|
||||
}
|
||||
|
||||
HRESULT CModel::Begin(_uint iMeshIndex, CShader* pShader)
|
||||
{
|
||||
if (iMeshIndex >= m_iNumMeshes) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
_uint iMaterialIndex = m_Meshes[iMeshIndex]->Get_MaterialIndex();
|
||||
|
||||
if (iMaterialIndex >= m_iNumMaterials) {
|
||||
return E_FAIL;
|
||||
}
|
||||
return pShader->Begin(m_Materials[iMaterialIndex]->Get_UsingPass());
|
||||
}
|
||||
|
||||
HRESULT CModel::Bind_BoneMatrices(_uint iMeshIndex, CShader* pShader, const _char* pConstantName)
|
||||
@@ -1429,7 +1443,9 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
||||
if (FAILED(Ready_Materials(pModelFilePath))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if (MODEL::PBR_ANIM == m_eType || MODEL::PBR_NONANIM == m_eType) {
|
||||
ParseMaterialXml(pModelFilePath);
|
||||
}
|
||||
if (FAILED(Ready_Animations(m_Bones))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
@@ -1464,6 +1480,9 @@ HRESULT CModel::Initialize_Prototype(MODEL eType, const _char* pModelFilePath, _
|
||||
if (FAILED(Ready_Materials(pModelFilePath))) {
|
||||
return E_FAIL;
|
||||
}
|
||||
if (MODEL::PBR_ANIM == m_eType || MODEL::PBR_NONANIM == m_eType) {
|
||||
ParseMaterialXml(pModelFilePath);
|
||||
}
|
||||
|
||||
if (FAILED(Ready_Animations(m_Bones))) {
|
||||
return E_FAIL;
|
||||
@@ -1502,6 +1521,38 @@ void CModel::LoadAdditionalAnimations(const char* ModelFilePath)
|
||||
}
|
||||
}
|
||||
|
||||
void CModel::ParseMaterialXml(const _char* pFilePath)
|
||||
{
|
||||
filesystem::path xmlFilePath = pFilePath;
|
||||
xmlFilePath.replace_extension(".xml");
|
||||
|
||||
tinyxml2::XMLDocument xmlDoc;
|
||||
if (xmlDoc.LoadFile(xmlFilePath.string().c_str()) != tinyxml2::XML_SUCCESS){
|
||||
return;
|
||||
}
|
||||
|
||||
tinyxml2::XMLElement* root = xmlDoc.FirstChildElement("Material");
|
||||
if (root == nullptr){
|
||||
return;
|
||||
}
|
||||
|
||||
_int iVisitIndex = 0;
|
||||
|
||||
for (tinyxml2::XMLElement* pElement = root->FirstChildElement();
|
||||
pElement != nullptr;
|
||||
pElement = pElement->NextSiblingElement(), ++iVisitIndex)
|
||||
{
|
||||
_int iOrderIndex = iVisitIndex;
|
||||
|
||||
const _char* szShaderIndex = pElement->Attribute("ShaderIndex");
|
||||
_int iShaderIndex = -1;
|
||||
if (szShaderIndex != nullptr) {
|
||||
iShaderIndex = atoi(szShaderIndex);
|
||||
}
|
||||
|
||||
m_Materials[iOrderIndex]->Set_UsingPass(iShaderIndex);
|
||||
}
|
||||
}
|
||||
|
||||
_bool CModel::LoadData(const _char* filename)
|
||||
{
|
||||
@@ -1913,6 +1964,13 @@ void CModel::Free()
|
||||
void CModel::Describe_Entity()
|
||||
{
|
||||
GUI::Begin("Model_Desc");
|
||||
if (GUI::CollapsingHeader("ModelAnimations")) {
|
||||
for (_uint i = 0; i < m_iNumAnimations; ++i) {
|
||||
if (GUI::Button(m_Animations[i]->Get_Name().c_str())) {
|
||||
Set_AnimationIndex(i, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GUI::Button("SaveAnimIndexWithName")) {
|
||||
_wstring wstrPath = TEXT("../Bin/AnimIndex.txt");
|
||||
HANDLE hFile = CreateFile(wstrPath.c_str(),
|
||||
|
||||
Reference in New Issue
Block a user