Add scene metadata for glTF2 files as allowed by the glTF2 specification.
parent
2f4fba0703
commit
36c8cdf3de
|
@ -922,6 +922,8 @@ struct Scene : public Object {
|
|||
std::string name;
|
||||
std::vector<Ref<Node>> nodes;
|
||||
|
||||
CustomExtension extensions;
|
||||
|
||||
Scene() {}
|
||||
void Read(Value &obj, Asset &r);
|
||||
};
|
||||
|
|
|
@ -1803,6 +1803,9 @@ inline void Scene::Read(Value &obj, Asset &r) {
|
|||
this->nodes.push_back(node);
|
||||
}
|
||||
}
|
||||
if (Value *extensions = FindObject(obj, "extensions")) {
|
||||
this->extensions = ReadExtensions("extensions", *extensions);
|
||||
}
|
||||
}
|
||||
|
||||
inline void Skin::Read(Value &obj, Asset &r) {
|
||||
|
|
|
@ -1498,7 +1498,8 @@ void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) {
|
|||
const bool hasVersion = !a.asset.version.empty();
|
||||
const bool hasGenerator = !a.asset.generator.empty();
|
||||
const bool hasCopyright = !a.asset.copyright.empty();
|
||||
if (hasVersion || hasGenerator || hasCopyright) {
|
||||
const bool hasSceneMetadata = a.scene->extensions;
|
||||
if (hasVersion || hasGenerator || hasCopyright || hasSceneMetadata) {
|
||||
mScene->mMetaData = new aiMetadata;
|
||||
if (hasVersion) {
|
||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version));
|
||||
|
@ -1509,6 +1510,9 @@ void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) {
|
|||
if (hasCopyright) {
|
||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_COPYRIGHT, aiString(a.asset.copyright));
|
||||
}
|
||||
if (hasSceneMetadata) {
|
||||
ParseExtensions(mScene->mMetaData, a.scene->extensions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue