Add Copyright common metadata to glTF importer/exporter
Technically this only exists in glTF v2 but may as well include in bothpull/2820/head
parent
f498a395e4
commit
986b67801d
|
@ -627,6 +627,9 @@ namespace glTF {
|
||||||
asset.SetObject();
|
asset.SetObject();
|
||||||
asset.AddMember("version", Value(mAsset.asset.version, mAl).Move(), mAl);
|
asset.AddMember("version", Value(mAsset.asset.version, mAl).Move(), mAl);
|
||||||
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);
|
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);
|
||||||
|
if (!mAsset.asset.copyright.empty())
|
||||||
|
asset.AddMember("copyright", Value(mAsset.asset.copyright, mAl).Move(), mAl);
|
||||||
|
|
||||||
mDoc.AddMember("asset", asset, mAl);
|
mDoc.AddMember("asset", asset, mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "glTF/glTFAssetWriter.h"
|
#include "glTF/glTFAssetWriter.h"
|
||||||
#include "PostProcessing/SplitLargeMeshes.h"
|
#include "PostProcessing/SplitLargeMeshes.h"
|
||||||
|
|
||||||
|
#include <assimp/commonMetaData.h>
|
||||||
#include <assimp/Exceptional.h>
|
#include <assimp/Exceptional.h>
|
||||||
#include <assimp/StringComparison.h>
|
#include <assimp/StringComparison.h>
|
||||||
#include <assimp/ByteSwapper.h>
|
#include <assimp/ByteSwapper.h>
|
||||||
|
@ -873,6 +874,12 @@ void glTFExporter::ExportMetadata()
|
||||||
aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionRevision());
|
aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionRevision());
|
||||||
|
|
||||||
asset.generator = buffer;
|
asset.generator = buffer;
|
||||||
|
|
||||||
|
// Copyright
|
||||||
|
aiString copyright_str;
|
||||||
|
if (mScene->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, copyright_str)) {
|
||||||
|
asset.copyright = copyright_str.C_Str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animation>& animRef, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond)
|
inline void ExtractAnimationData(Asset& mAsset, std::string& animId, Ref<Animation>& animRef, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond)
|
||||||
|
|
|
@ -703,7 +703,8 @@ void glTFImporter::ImportCommonMetadata(glTF::Asset& a)
|
||||||
ai_assert(mScene->mMetaData == nullptr);
|
ai_assert(mScene->mMetaData == nullptr);
|
||||||
const bool hasVersion = !a.asset.version.empty();
|
const bool hasVersion = !a.asset.version.empty();
|
||||||
const bool hasGenerator = !a.asset.generator.empty();
|
const bool hasGenerator = !a.asset.generator.empty();
|
||||||
if (hasVersion || hasGenerator)
|
const bool hasCopyright = !a.asset.copyright.empty();
|
||||||
|
if (hasVersion || hasGenerator || hasCopyright)
|
||||||
{
|
{
|
||||||
mScene->mMetaData = new aiMetadata;
|
mScene->mMetaData = new aiMetadata;
|
||||||
if (hasVersion)
|
if (hasVersion)
|
||||||
|
@ -714,6 +715,10 @@ void glTFImporter::ImportCommonMetadata(glTF::Asset& a)
|
||||||
{
|
{
|
||||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
||||||
}
|
}
|
||||||
|
if (hasCopyright)
|
||||||
|
{
|
||||||
|
mScene->mMetaData->Add(AI_METADATA_SOURCE_COPYRIGHT, aiString(a.asset.copyright));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -720,6 +720,8 @@ namespace glTF2 {
|
||||||
asset.SetObject();
|
asset.SetObject();
|
||||||
asset.AddMember("version", Value(mAsset.asset.version, mAl).Move(), mAl);
|
asset.AddMember("version", Value(mAsset.asset.version, mAl).Move(), mAl);
|
||||||
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);
|
asset.AddMember("generator", Value(mAsset.asset.generator, mAl).Move(), mAl);
|
||||||
|
if (!mAsset.asset.copyright.empty())
|
||||||
|
asset.AddMember("copyright", Value(mAsset.asset.copyright, mAl).Move(), mAl);
|
||||||
mDoc.AddMember("asset", asset, mAl);
|
mDoc.AddMember("asset", asset, mAl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "glTF2/glTF2AssetWriter.h"
|
#include "glTF2/glTF2AssetWriter.h"
|
||||||
#include "PostProcessing/SplitLargeMeshes.h"
|
#include "PostProcessing/SplitLargeMeshes.h"
|
||||||
|
|
||||||
|
#include <assimp/commonMetaData.h>
|
||||||
#include <assimp/Exceptional.h>
|
#include <assimp/Exceptional.h>
|
||||||
#include <assimp/StringComparison.h>
|
#include <assimp/StringComparison.h>
|
||||||
#include <assimp/ByteSwapper.h>
|
#include <assimp/ByteSwapper.h>
|
||||||
|
@ -996,6 +997,12 @@ void glTF2Exporter::ExportMetadata()
|
||||||
aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionRevision());
|
aiGetVersionMajor(), aiGetVersionMinor(), aiGetVersionRevision());
|
||||||
|
|
||||||
asset.generator = buffer;
|
asset.generator = buffer;
|
||||||
|
|
||||||
|
// Copyright
|
||||||
|
aiString copyright_str;
|
||||||
|
if (mScene->mMetaData->Get(AI_METADATA_SOURCE_COPYRIGHT, copyright_str)) {
|
||||||
|
asset.copyright = copyright_str.C_Str();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Ref<Accessor> GetSamplerInputRef(Asset& asset, std::string& animId, Ref<Buffer>& buffer, std::vector<float>& times)
|
inline Ref<Accessor> GetSamplerInputRef(Asset& asset, std::string& animId, Ref<Buffer>& buffer, std::vector<float>& times)
|
||||||
|
|
|
@ -1306,7 +1306,8 @@ void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) {
|
||||||
ai_assert(mScene->mMetaData == nullptr);
|
ai_assert(mScene->mMetaData == nullptr);
|
||||||
const bool hasVersion = !a.asset.version.empty();
|
const bool hasVersion = !a.asset.version.empty();
|
||||||
const bool hasGenerator = !a.asset.generator.empty();
|
const bool hasGenerator = !a.asset.generator.empty();
|
||||||
if (hasVersion || hasGenerator)
|
const bool hasCopyright = !a.asset.copyright.empty();
|
||||||
|
if (hasVersion || hasGenerator || hasCopyright)
|
||||||
{
|
{
|
||||||
mScene->mMetaData = new aiMetadata;
|
mScene->mMetaData = new aiMetadata;
|
||||||
if (hasVersion)
|
if (hasVersion)
|
||||||
|
@ -1317,6 +1318,10 @@ void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) {
|
||||||
{
|
{
|
||||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
||||||
}
|
}
|
||||||
|
if (hasCopyright)
|
||||||
|
{
|
||||||
|
mScene->mMetaData->Add(AI_METADATA_SOURCE_COPYRIGHT, aiString(a.asset.copyright));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue