diff --git a/code/FBXDocument.cpp b/code/FBXDocument.cpp index ae77bcafb..cf3410c49 100644 --- a/code/FBXDocument.cpp +++ b/code/FBXDocument.cpp @@ -327,6 +327,35 @@ void ReadVectorDataArray(std::vector& out, const Element& el) out.push_back(static_cast(ival)); } } + + +// ------------------------------------------------------------------------------------------------ +// fetch a property table and the corresponding property template +boost::shared_ptr GetPropertyTable(const Document& doc, + const std::string& templateName, + const Element &element, + const Scope& sc) +{ + const Element* const Properties70 = sc["Properties70"]; + boost::shared_ptr templateProps = boost::shared_ptr(NULL); + if(templateName.length()) { + PropertyTemplateMap::const_iterator it = doc.Templates().find(templateName); + if(it != doc.Templates().end()) { + templateProps = (*it).second; + } + } + + if(!Properties70) { + DOMWarning("material property table (Properties70) not found",&element); + if(templateProps) { + return templateProps; + } + else { + return boost::make_shared(); + } + } + return boost::make_shared(*Properties70,templateProps); +} } // !Util using namespace Util; diff --git a/code/FBXDocumentUtil.h b/code/FBXDocumentUtil.h index 8363138b6..f1656944a 100644 --- a/code/FBXDocumentUtil.h +++ b/code/FBXDocumentUtil.h @@ -91,6 +91,14 @@ void ReadVectorDataArray(std::vector& out, const Element& el); // read an array of uints void ReadVectorDataArray(std::vector& out, const Element& el); + + +// fetch a property table and the corresponding property template +boost::shared_ptr GetPropertyTable(const Document& doc, + const std::string& templateName, + const Element &element, + const Scope& sc); + } //!Util } //!FBX } //!Assimp diff --git a/code/FBXMaterial.cpp b/code/FBXMaterial.cpp index 27ab2d07c..74761b98a 100644 --- a/code/FBXMaterial.cpp +++ b/code/FBXMaterial.cpp @@ -65,7 +65,6 @@ Material::Material(const Element& element, const Document& doc, const std::strin const Element* const ShadingModel = sc["ShadingModel"]; const Element* const MultiLayer = sc["MultiLayer"]; - const Element* const Properties70 = sc["Properties70"]; if(MultiLayer) { multilayer = !!ParseTokenAsInt(GetRequiredToken(*MultiLayer,0)); @@ -92,26 +91,7 @@ Material::Material(const Element& element, const Document& doc, const std::strin DOMWarning("shading mode not recognized: " + shading,&element); } - boost::shared_ptr templateProps = boost::shared_ptr(NULL); - if(templateName.length()) { - PropertyTemplateMap::const_iterator it = doc.Templates().find(templateName); - if(it != doc.Templates().end()) { - templateProps = (*it).second; - } - } - - if(!Properties70) { - DOMWarning("material property table (Properties70) not found",&element); - if(templateProps) { - props = templateProps; - } - else { - props = boost::make_shared(); - } - } - else { - props = boost::make_shared(*Properties70,templateProps); - } + props = GetPropertyTable(doc,templateName,element,sc); }