glTF2 support targetNames

pull/3149/head
Timur Umayev 2020-04-15 00:31:27 +01:00
parent 9b694a8645
commit 69f8d47941
3 changed files with 16 additions and 0 deletions

View File

@ -720,6 +720,7 @@ struct Mesh : public Object {
std::vector<Primitive> primitives;
std::vector<float> weights;
std::vector<std::string> targetNames;
Mesh() {}

View File

@ -1026,6 +1026,18 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
}
}
}
if (Value* extras = FindObject(pJSON_Object, "extras")) {
if (Value* curTargetNames = FindArray(*extras, "targetNames")) {
this->targetNames.resize(curTargetNames->Size());
for (unsigned int i = 0; i < curTargetNames->Size(); ++i) {
Value& targetNameValue = (*curTargetNames)[i];
if (targetNameValue.IsString()) {
this->targetNames[i] = targetNameValue.GetString();
}
}
}
}
}
inline void Camera::Read(Value &obj, Asset & /*r*/) {

View File

@ -472,6 +472,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) {
if (mesh.weights.size() > i) {
aiAnimMesh.mWeight = mesh.weights[i];
}
if (mesh.targetNames.size() > i) {
aiAnimMesh.mName = mesh.targetNames[i];
}
}
}