Merge pull request #3149 from timuber/master

Add support for glTF2 targetNames
pull/3161/head
Kim Kulling 2020-04-20 14:52:53 +02:00 committed by GitHub
commit 69bdebf3ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 0 deletions

View File

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

View File

@ -1034,6 +1034,19 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) {
} }
} }
} }
Value *extras = FindObject(pJSON_Object, "extras");
if (nullptr != 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*/) { 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) { if (mesh.weights.size() > i) {
aiAnimMesh.mWeight = mesh.weights[i]; aiAnimMesh.mWeight = mesh.weights[i];
} }
if (mesh.targetNames.size() > i) {
aiAnimMesh.mName = mesh.targetNames[i];
}
} }
} }