BUGFIX: Correct handling of default material usage (referenced, when given material was not found or no material library was specified).

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@62 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
kimmi 2008-07-02 20:41:30 +00:00
parent 0e125c2255
commit 600cd7a8f0
2 changed files with 7 additions and 2 deletions

View File

@ -14,6 +14,8 @@
namespace Assimp namespace Assimp
{ {
// -------------------------------------------------------------------
const std::string ObjFileParser::DEFAULT_MATERIAL = "defaultmaterial";
// ------------------------------------------------------------------- // -------------------------------------------------------------------
ObjFileParser::ObjFileParser(std::vector<char> &Data, ObjFileParser::ObjFileParser(std::vector<char> &Data,
@ -29,8 +31,8 @@ ObjFileParser::ObjFileParser(std::vector<char> &Data,
m_pModel = new ObjFile::Model(); m_pModel = new ObjFile::Model();
m_pModel->m_ModelName = strModelName; m_pModel->m_ModelName = strModelName;
const std::string DEFAULT_MATERIAL = "defaultmaterial";
m_pModel->m_pDefaultMaterial = new ObjFile::Material(); m_pModel->m_pDefaultMaterial = new ObjFile::Material();
m_pModel->m_pDefaultMaterial->MaterialName.Set( DEFAULT_MATERIAL );
m_pModel->m_MaterialLib.push_back( DEFAULT_MATERIAL ); m_pModel->m_MaterialLib.push_back( DEFAULT_MATERIAL );
m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial; m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial;
@ -332,7 +334,9 @@ void ObjFileParser::getMaterialDesc()
{ {
// Not found, use default material // Not found, use default material
m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial; m_pModel->m_pCurrentMaterial = m_pModel->m_pDefaultMaterial;
m_pModel->m_MaterialMap[ strName ] = m_pModel->m_pCurrentMaterial; m_pModel->m_pCurrentMesh = new ObjFile::Mesh();
m_pModel->m_Meshes.push_back( m_pModel->m_pCurrentMesh );
m_pModel->m_pCurrentMesh->m_uiMaterialIndex = getMaterialIndex( DEFAULT_MATERIAL );
} }
else else
{ {

View File

@ -98,6 +98,7 @@ private:
void extractExtension(const std::string strFile, std::string &strExt); void extractExtension(const std::string strFile, std::string &strExt);
private: private:
static const std::string DEFAULT_MATERIAL;/* = "defaultmaterial";*/
//! Absolute filepath to model //! Absolute filepath to model
std::string m_strAbsPath; std::string m_strAbsPath;
//! Iterator to current position in buffer //! Iterator to current position in buffer