Browse Source

update sync

Yingying Wang 5 years ago
parent
commit
97085c1c05

+ 2 - 1
code/AssetLib/glTF2/glTF2Asset.h

@@ -1,4 +1,4 @@
-/*
+/*
 Open Asset Import Library (assimp)
 Open Asset Import Library (assimp)
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 
 
@@ -1066,6 +1066,7 @@ public:
     } extensionsRequired;
     } extensionsRequired;
 
 
     AssetMetadata asset;
     AssetMetadata asset;
+    Value* extras = nullptr;
 
 
     // Dictionaries for each type of object
     // Dictionaries for each type of object
 
 

+ 5 - 1
code/AssetLib/glTF2/glTF2AssetWriter.inl

@@ -1,4 +1,4 @@
-/*
+/*
 Open Asset Import Library (assimp)
 Open Asset Import Library (assimp)
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 
 
@@ -616,6 +616,10 @@ namespace glTF2 {
         if (mAsset.scene) {
         if (mAsset.scene) {
             mDoc.AddMember("scene", mAsset.scene->index, mAl);
             mDoc.AddMember("scene", mAsset.scene->index, mAl);
         }
         }
+        
+        if(mAsset.extras) {
+            mDoc.AddMember("extras", *mAsset.extras, mAl);
+        }
     }
     }
 
 
     inline void AssetWriter::WriteFile(const char* path)
     inline void AssetWriter::WriteFile(const char* path)

+ 9 - 2
code/AssetLib/glTF2/glTF2Exporter.cpp

@@ -1,4 +1,4 @@
-/*
+/*
 Open Asset Import Library (assimp)
 Open Asset Import Library (assimp)
 ----------------------------------------------------------------------
 ----------------------------------------------------------------------
 
 
@@ -115,7 +115,14 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai
     ExportScene();
     ExportScene();
 
 
     ExportAnimations();
     ExportAnimations();
-
+    
+    // export extras
+    if(mProperties->HasPropertyCallback("extras"))
+    {
+        std::function<void*(void*)> ExportExtras = mProperties->GetPropertyCallback("extras");
+        mAsset->extras = (rapidjson::Value*)ExportExtras(0);
+    }
+    
     AssetWriter writer(*mAsset);
     AssetWriter writer(*mAsset);
 
 
     if (isBinary) {
     if (isBinary) {

+ 3 - 4
code/Common/Exporter.cpp

@@ -581,19 +581,18 @@ ExportProperties::ExportProperties(const ExportProperties &other)
 , mFloatProperties(other.mFloatProperties)
 , mFloatProperties(other.mFloatProperties)
 , mStringProperties(other.mStringProperties)
 , mStringProperties(other.mStringProperties)
 , mMatrixProperties(other.mMatrixProperties)
 , mMatrixProperties(other.mMatrixProperties)
-//wangyi 0608
 , mCallbackProperties(other.mCallbackProperties){
 , mCallbackProperties(other.mCallbackProperties){
     // empty
     // empty
 }
 }
 
 
-//wangyi 0608
-bool ExportProperties::SetPropertyCallback(const char *szName, std::function<void *(void *)> &f) {
+bool ExportProperties::SetPropertyCallback(const char *szName, const std::function<void *(void *)> &f) {
     return SetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, f);
     return SetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, f);
 }
 }
+
 std::function<void *(void *)> ExportProperties::GetPropertyCallback(const char *szName) const {
 std::function<void *(void *)> ExportProperties::GetPropertyCallback(const char *szName) const {
     return GetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, 0);
     return GetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, 0);
 }
 }
-//wangyi 0608
+
 bool ExportProperties::HasPropertyCallback(const char *szName) const {
 bool ExportProperties::HasPropertyCallback(const char *szName) const {
     return HasGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName);
     return HasGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName);
 }
 }

+ 3 - 5
include/assimp/Exporter.hpp

@@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 #include "cexport.h"
 #include "cexport.h"
 #include <map>
 #include <map>
-//wangyi 0608
 #include <functional>
 #include <functional>
 
 
 namespace Assimp {
 namespace Assimp {
@@ -332,7 +331,6 @@ public:
     typedef std::map<KeyType, ai_real> FloatPropertyMap;
     typedef std::map<KeyType, ai_real> FloatPropertyMap;
     typedef std::map<KeyType, std::string> StringPropertyMap;
     typedef std::map<KeyType, std::string> StringPropertyMap;
     typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
     typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
-    //wangyi 0608
     typedef std::map<KeyType, std::function<void *(void *)>> CallbackPropertyMap;
     typedef std::map<KeyType, std::function<void *(void *)>> CallbackPropertyMap;
 
 
 public:
 public:
@@ -392,8 +390,8 @@ public:
      * @see SetPropertyInteger()
      * @see SetPropertyInteger()
      */
      */
     bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
     bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
-
-    bool SetPropertyCallback(const char *szName, std::function<void *(void *)> &f);
+    
+    bool SetPropertyCallback(const char *szName, const std::function<void *(void *)> &f);
 
 
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Get a configuration property.
     /** Get a configuration property.
@@ -476,7 +474,7 @@ public:
     bool HasPropertyMatrix(const char *szName) const;
     bool HasPropertyMatrix(const char *szName) const;
 
 
     bool HasPropertyCallback(const char *szName) const;
     bool HasPropertyCallback(const char *szName) const;
-protected:
+
     /** List of integer properties */
     /** List of integer properties */
     IntPropertyMap mIntProperties;
     IntPropertyMap mIntProperties;