diff --git a/code/AssetLib/glTF2/glTF2Asset.h b/code/AssetLib/glTF2/glTF2Asset.h index f79ddee87..51150480f 100644 --- a/code/AssetLib/glTF2/glTF2Asset.h +++ b/code/AssetLib/glTF2/glTF2Asset.h @@ -1,4 +1,4 @@ -/* +/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- @@ -1066,6 +1066,7 @@ public: } extensionsRequired; AssetMetadata asset; + Value* extras = nullptr; // Dictionaries for each type of object diff --git a/code/AssetLib/glTF2/glTF2AssetWriter.inl b/code/AssetLib/glTF2/glTF2AssetWriter.inl index d5b478e35..ff4e83743 100644 --- a/code/AssetLib/glTF2/glTF2AssetWriter.inl +++ b/code/AssetLib/glTF2/glTF2AssetWriter.inl @@ -1,4 +1,4 @@ -/* +/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- @@ -616,6 +616,10 @@ namespace glTF2 { if (mAsset.scene) { mDoc.AddMember("scene", mAsset.scene->index, mAl); } + + if(mAsset.extras) { + mDoc.AddMember("extras", *mAsset.extras, mAl); + } } inline void AssetWriter::WriteFile(const char* path) diff --git a/code/AssetLib/glTF2/glTF2Exporter.cpp b/code/AssetLib/glTF2/glTF2Exporter.cpp index 2359851f1..ec15aa034 100644 --- a/code/AssetLib/glTF2/glTF2Exporter.cpp +++ b/code/AssetLib/glTF2/glTF2Exporter.cpp @@ -1,4 +1,4 @@ -/* +/* Open Asset Import Library (assimp) ---------------------------------------------------------------------- @@ -115,7 +115,14 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai ExportScene(); ExportAnimations(); - + + // export extras + if(mProperties->HasPropertyCallback("extras")) + { + std::function ExportExtras = mProperties->GetPropertyCallback("extras"); + mAsset->extras = (rapidjson::Value*)ExportExtras(0); + } + AssetWriter writer(*mAsset); if (isBinary) { diff --git a/code/Common/Exporter.cpp b/code/Common/Exporter.cpp index 052f8d5f4..9d14e2c7b 100644 --- a/code/Common/Exporter.cpp +++ b/code/Common/Exporter.cpp @@ -581,19 +581,18 @@ ExportProperties::ExportProperties(const ExportProperties &other) , mFloatProperties(other.mFloatProperties) , mStringProperties(other.mStringProperties) , mMatrixProperties(other.mMatrixProperties) -//wangyi 0608 , mCallbackProperties(other.mCallbackProperties){ // empty } -//wangyi 0608 -bool ExportProperties::SetPropertyCallback(const char *szName, std::function &f) { +bool ExportProperties::SetPropertyCallback(const char *szName, const std::function &f) { return SetGenericProperty>(mCallbackProperties, szName, f); } + std::function ExportProperties::GetPropertyCallback(const char *szName) const { return GetGenericProperty>(mCallbackProperties, szName, 0); } -//wangyi 0608 + bool ExportProperties::HasPropertyCallback(const char *szName) const { return HasGenericProperty>(mCallbackProperties, szName); } diff --git a/include/assimp/Exporter.hpp b/include/assimp/Exporter.hpp index 7b0dfa7f9..6fcbafe92 100644 --- a/include/assimp/Exporter.hpp +++ b/include/assimp/Exporter.hpp @@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cexport.h" #include -//wangyi 0608 #include namespace Assimp { @@ -332,7 +331,6 @@ public: typedef std::map FloatPropertyMap; typedef std::map StringPropertyMap; typedef std::map MatrixPropertyMap; - //wangyi 0608 typedef std::map> CallbackPropertyMap; public: @@ -392,8 +390,8 @@ public: * @see SetPropertyInteger() */ bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue); - - bool SetPropertyCallback(const char *szName, std::function &f); + + bool SetPropertyCallback(const char *szName, const std::function &f); // ------------------------------------------------------------------- /** Get a configuration property. @@ -476,7 +474,7 @@ public: bool HasPropertyMatrix(const char *szName) const; bool HasPropertyCallback(const char *szName) const; -protected: + /** List of integer properties */ IntPropertyMap mIntProperties;