From 931f0489bd11eff4f8efa7330c8891c4b595f87b Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Tue, 26 Nov 2013 14:21:32 -0800 Subject: [PATCH] Properly parse 'mg' keyword in .obj files The 'mg' keyword is currently being interpreted as a material library keyword, when it really refers to the merging group. Handle this case, in effect ignoring the keyword as merging groups are currently unsupported. --- code/ObjFileParser.cpp | 16 ++++++++++++++-- code/ObjFileParser.h | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index ef3deb20f..02b95ee64 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -149,9 +149,12 @@ void ObjFileParser::parseFile() } break; - case 'm': // Parse a material library + case 'm': // Parse a material library or merging group ('mg') { - getMaterialLib(); + if (*(m_DataIt + 1) == 'g') + getGroupNumberAndResolution(); + else + getMaterialLib(); } break; @@ -609,6 +612,15 @@ void ObjFileParser::getGroupNumber() m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); } +// ------------------------------------------------------------------- +// Not supported +void ObjFileParser::getGroupNumberAndResolution() +{ + // Not used + + m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); +} + // ------------------------------------------------------------------- // Stores values for a new object instance, name will be used to // identify it. diff --git a/code/ObjFileParser.h b/code/ObjFileParser.h index 1a9a1b498..c5effcfed 100644 --- a/code/ObjFileParser.h +++ b/code/ObjFileParser.h @@ -102,6 +102,8 @@ private: void getGroupName(); /// Gets the group number from file. void getGroupNumber(); + /// Gets the group number and resolution from file. + void getGroupNumberAndResolution(); /// Returns the index of the material. Is -1 if not material was found. int getMaterialIndex( const std::string &strMaterialName ); /// Parse object name