From d6fc5de7d5819f23b6d8d8e122e8f80b2f7f61b9 Mon Sep 17 00:00:00 2001 From: kimmi Date: Wed, 11 Jun 2008 20:12:48 +0000 Subject: [PATCH] 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 --- code/ObjFileParser.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index b583e04df..d5386fe59 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -28,7 +28,12 @@ ObjFileParser::ObjFileParser(std::vector &Data, // Create the model instance to store all the 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_MaterialLib.push_back( DEFAULT_MATERIAL ); + m_pModel->m_MaterialMap[ DEFAULT_MATERIAL ] = m_pModel->m_pDefaultMaterial; + // Start parsing the file parseFile(); } @@ -288,6 +293,11 @@ void ObjFileParser::getFace() m_pModel->m_pCurrent->m_Faces.push_back(face); // 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 ); // Skip the rest of the line