Ver Fonte

first pass at collada metadata

RichardTea há 6 anos atrás
pai
commit
d66166675a
3 ficheiros alterados com 24 adições e 2 exclusões
  1. 6 0
      code/ColladaLoader.cpp
  2. 15 2
      code/ColladaParser.cpp
  3. 3 0
      code/ColladaParser.h

+ 6 - 0
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);
 

+ 15 - 2
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)

+ 3 - 0
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<std::string, aiString> AssetMetaData;
+        AssetMetaData mAssetMetaData;
+
         /** Collada file format version */
         Collada::FormatVersion mFormat;
     };