extra callback

pull/3280/head
ywang 2020-06-11 17:37:06 -07:00
parent f57e7221c0
commit e65434bf82
5 changed files with 14 additions and 22 deletions

View File

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

View File

@ -1,4 +1,4 @@
/*
/*
Open Asset Import Library (assimp)
----------------------------------------------------------------------
@ -600,6 +600,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)

View File

@ -116,17 +116,11 @@ glTF2Exporter::glTF2Exporter(const char* filename, IOSystem* pIOSystem, const ai
ExportAnimations();
//wangyi 0608
// export extras
if(mProperties->HasPropertyCallback("extras"))
{
std::function<void*(void*)> ExportExtras = mProperties->GetPropertyCallback("extras");
char* ret = (char*)ExportExtras((void*)mAsset.get());
Document extrasD;
extrasD.Parse(ret);
std::string strHello = extrasD["hello"].GetString();
printf("wangyi 0608 ret: %s\r\n", ret);
mAsset->extras = (rapidjson::Value*)ExportExtras(0);
}
AssetWriter writer(*mAsset);

View File

@ -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, const std::function<void *(void *)> &f) {
return SetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, f);
}
std::function<void *(void *)> ExportProperties::GetPropertyCallback(const char *szName) const {
return GetGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName, 0);
}
//wangyi 0608
bool ExportProperties::HasPropertyCallback(const char *szName) const {
return HasGenericProperty<std::function<void *(void *)>>(mCallbackProperties, szName);
}

View File

@ -54,7 +54,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "cexport.h"
#include <map>
//wangyi 0608
#include <functional>
namespace Assimp {
@ -332,7 +331,6 @@ public:
typedef std::map<KeyType, ai_real> FloatPropertyMap;
typedef std::map<KeyType, std::string> StringPropertyMap;
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
//wangyi 0608
typedef std::map<KeyType, std::function<void *(void *)>> CallbackPropertyMap;
public:
@ -393,7 +391,6 @@ public:
*/
bool SetPropertyMatrix(const char *szName, const aiMatrix4x4 &sValue);
//wangyi 0608
bool SetPropertyCallback(const char *szName, const std::function<void *(void *)> &f);
// -------------------------------------------------------------------
@ -448,7 +445,6 @@ public:
const aiMatrix4x4 GetPropertyMatrix(const char *szName,
const aiMatrix4x4 &sErrorReturn = aiMatrix4x4()) const;
//wangyi 0608
std::function<void *(void *)> GetPropertyCallback(const char* szName) const;
// -------------------------------------------------------------------
@ -477,7 +473,6 @@ public:
*/
bool HasPropertyMatrix(const char *szName) const;
//wangyi 0608
bool HasPropertyCallback(const char *szName) const;
protected:
@ -493,7 +488,6 @@ protected:
/** List of Matrix properties */
MatrixPropertyMap mMatrixProperties;
//wangyi 0608
CallbackPropertyMap mCallbackProperties;
};