|
@@ -264,14 +264,19 @@ void ColladaParser::ReadAssetInfo()
|
|
|
|
|
|
// check element end
|
|
|
TestClosing( "up_axis");
|
|
|
- } else
|
|
|
+ }
|
|
|
+ else if(IsElement("contributor"))
|
|
|
{
|
|
|
- SkipElement();
|
|
|
+ ReadContributorInfo();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ReadMetaDataItem(mAssetMetaData);
|
|
|
}
|
|
|
}
|
|
|
else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
|
|
|
{
|
|
|
- if( strcmp( mReader->getNodeName(), "asset") != 0)
|
|
|
+ if (strcmp( mReader->getNodeName(), "asset") != 0)
|
|
|
ThrowException( "Expected end of <asset> element.");
|
|
|
|
|
|
break;
|
|
@@ -279,6 +284,75 @@ void ColladaParser::ReadAssetInfo()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// ------------------------------------------------------------------------------------------------
|
|
|
+// Reads the contributor info
|
|
|
+void ColladaParser::ReadContributorInfo()
|
|
|
+{
|
|
|
+ if (mReader->isEmptyElement())
|
|
|
+ return;
|
|
|
+
|
|
|
+ while (mReader->read())
|
|
|
+ {
|
|
|
+ if (mReader->getNodeType() == irr::io::EXN_ELEMENT)
|
|
|
+ {
|
|
|
+ ReadMetaDataItem(mAssetMetaData);
|
|
|
+ }
|
|
|
+ else if (mReader->getNodeType() == irr::io::EXN_ELEMENT_END)
|
|
|
+ {
|
|
|
+ if (strcmp(mReader->getNodeName(), "contributor") != 0)
|
|
|
+ ThrowException("Expected end of <contributor> element.");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ------------------------------------------------------------------------------------------------
|
|
|
+// Reads a single string metadata item
|
|
|
+void ColladaParser::ReadMetaDataItem(StringMetaData &metadata)
|
|
|
+{
|
|
|
+ // Metadata such as created, keywords, subject etc
|
|
|
+ const char* key_char = mReader->getNodeName();
|
|
|
+ if (key_char != nullptr)
|
|
|
+ {
|
|
|
+ const std::string key_str(key_char);
|
|
|
+ const char* value_char = TestTextContent();
|
|
|
+ if (value_char != nullptr)
|
|
|
+ {
|
|
|
+ std::string camel_key_str = key_str;
|
|
|
+ ToCamelCase(camel_key_str);
|
|
|
+ aiString aistr;
|
|
|
+ aistr.Set(value_char);
|
|
|
+ metadata.emplace(camel_key_str, aistr);
|
|
|
+ TestClosing(key_str.c_str());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ SkipElement();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ SkipElement();
|
|
|
+}
|
|
|
+
|
|
|
+// ------------------------------------------------------------------------------------------------
|
|
|
+// Convert underscore_seperated to CamelCase: "authoring_tool" becomes "AuthoringTool"
|
|
|
+void ColladaParser::ToCamelCase(std::string &text)
|
|
|
+{
|
|
|
+ if (text.empty())
|
|
|
+ return;
|
|
|
+ // Capitalise first character
|
|
|
+ text[0] = ToUpper(text[0]);
|
|
|
+ for (auto it = text.begin(); it != text.end(); /*iterated below*/)
|
|
|
+ {
|
|
|
+ if ((*it) == '_')
|
|
|
+ {
|
|
|
+ it = text.erase(it);
|
|
|
+ if (it != text.end())
|
|
|
+ (*it) = ToUpper(*it);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ ++it;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
|
// Reads the animation clips
|
|
|
void ColladaParser::ReadAnimationClipLibrary()
|