From d66166675a5845d8be78f7b8c42c00bb519df9d5 Mon Sep 17 00:00:00 2001 From: RichardTea <31507749+RichardTea@users.noreply.github.com> Date: Mon, 8 Apr 2019 17:11:50 +0100 Subject: [PATCH] first pass at collada metadata --- code/ColladaLoader.cpp | 6 ++++++ code/ColladaParser.cpp | 17 +++++++++++++++-- code/ColladaParser.h | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 6837dca4a..47a40f5d9 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -207,6 +207,12 @@ void ColladaLoader::InternReadFile( const std::string& pFile, aiScene* pScene, I 0, 0, 0, 1); } + // Store scene metadata + for (auto it = parser.mAssetMetaData.cbegin(); it != parser.mAssetMetaData.cend(); ++it) + { + pScene->mMetaData->Add((*it).first, (*it).second); + } + // store all meshes StoreSceneMeshes( pScene); diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 0fa59362b..c38d18283 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -264,9 +264,22 @@ void ColladaParser::ReadAssetInfo() // check element end TestClosing( "up_axis"); - } else + } + else if(IsElement("contributor")) { - SkipElement(); + // This has no data of its own, will get children next time through + } + else + { + const char* metadata_key = mReader->getNodeName(); + const char* metadata_value = TestTextContent(); + if (metadata_key != nullptr && metadata_value != nullptr) + { + aiString aistr; + aistr.Set(metadata_value); + mAssetMetaData.emplace(metadata_key, aistr); + } + //SkipElement(); } } else if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) diff --git a/code/ColladaParser.h b/code/ColladaParser.h index 232d85654..9fdca86c8 100644 --- a/code/ColladaParser.h +++ b/code/ColladaParser.h @@ -343,6 +343,9 @@ namespace Assimp /** Which is the up vector */ enum { UP_X, UP_Y, UP_Z } mUpDirection; + typedef std::map AssetMetaData; + AssetMetaData mAssetMetaData; + /** Collada file format version */ Collada::FormatVersion mFormat; };