extra callback

This commit is contained in:
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);
}