From 600cd7a8f045ecbb9c99a15f49c774161edb3ca4 Mon Sep 17 00:00:00 2001 From: kimmi Date: Wed, 2 Jul 2008 20:41:30 +0000 Subject: [PATCH] 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 --- code/ObjFileParser.cpp | 8 ++++++-- code/ObjFileParser.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index a13a82e0d..5ee1b8ac1 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -14,6 +14,8 @@ namespace Assimp { +// ------------------------------------------------------------------- +const std::string ObjFileParser::DEFAULT_MATERIAL = "defaultmaterial"; // ------------------------------------------------------------------- ObjFileParser::ObjFileParser(std::vector &Data, @@ -29,8 +31,8 @@ ObjFileParser::ObjFileParser(std::vector &Data, m_pModel = new ObjFile::Model(); m_pModel->m_ModelName = strModelName; - const std::string DEFAULT_MATERIAL = "defaultmaterial"; 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_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial; @@ -332,7 +334,9 @@ void ObjFileParser::getMaterialDesc() { // Not found, use default material 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 { diff --git a/code/ObjFileParser.h b/code/ObjFileParser.h index 4ddf384ff..dc18bd720 100644 --- a/code/ObjFileParser.h +++ b/code/ObjFileParser.h @@ -98,6 +98,7 @@ private: void extractExtension(const std::string strFile, std::string &strExt); private: + static const std::string DEFAULT_MATERIAL;/* = "defaultmaterial";*/ //! Absolute filepath to model std::string m_strAbsPath; //! Iterator to current position in buffer