BUGFIX: Add defaultmaterial to obj-model data structure, when no materials are loaded

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@58 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
kimmi 2008-06-11 20:12:48 +00:00
parent e834a044db
commit d6fc5de7d5
1 changed files with 11 additions and 1 deletions

View File

@ -29,6 +29,11 @@ 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_MaterialLib.push_back( DEFAULT_MATERIAL );
m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial;
// Start parsing the file // Start parsing the file
parseFile(); parseFile();
} }
@ -288,6 +293,11 @@ void ObjFileParser::getFace()
m_pModel->m_pCurrent->m_Faces.push_back(face); m_pModel->m_pCurrent->m_Faces.push_back(face);
// Assign face to mesh // Assign face to mesh
if ( NULL == m_pModel->m_pCurrentMesh )
{
m_pModel->m_pCurrentMesh = new ObjFile::Mesh();
m_pModel->m_Meshes.push_back( m_pModel->m_pCurrentMesh );
}
m_pModel->m_pCurrentMesh->m_Faces.push_back( face ); m_pModel->m_pCurrentMesh->m_Faces.push_back( face );
// Skip the rest of the line // Skip the rest of the line