Merge pull request #3267 from thomasbiang/gltf2_targetNames_export

Gltf2 Export Target Names for Blendshapes
issue_3165
Kim Kulling 2020-06-14 09:57:10 +02:00 committed by GitHub
commit e6d5af6d76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -468,6 +468,22 @@ namespace glTF2 {
} }
obj.AddMember("primitives", primitives, w.mAl); obj.AddMember("primitives", primitives, w.mAl);
// targetNames
if (m.targetNames.size() > 0) {
Value extras;
extras.SetObject();
Value targetNames;
targetNames.SetArray();
targetNames.Reserve(unsigned(m.targetNames.size()), w.mAl);
for (unsigned int n = 0; n < m.targetNames.size(); ++n) {
std::string name = m.targetNames[n];
Value tname;
tname.SetString(name.c_str(), w.mAl);
targetNames.PushBack(tname, w.mAl);
}
extras.AddMember("targetNames", targetNames, w.mAl);
obj.AddMember("extras", extras, w.mAl);
}
} }
inline void Write(Value& obj, Node& n, AssetWriter& w) inline void Write(Value& obj, Node& n, AssetWriter& w)

View File

@ -824,9 +824,14 @@ void glTF2Exporter::ExportMeshes()
/*************** Targets for blendshapes ****************/ /*************** Targets for blendshapes ****************/
if (aim->mNumAnimMeshes > 0) { if (aim->mNumAnimMeshes > 0) {
bool bExportTargetNames = this->mProperties->HasPropertyBool("GLTF2_TARGETNAMES_EXP") &&
this->mProperties->GetPropertyBool("GLTF2_TARGETNAMES_EXP");
p.targets.resize(aim->mNumAnimMeshes); p.targets.resize(aim->mNumAnimMeshes);
for (unsigned int am = 0; am < aim->mNumAnimMeshes; ++am) { for (unsigned int am = 0; am < aim->mNumAnimMeshes; ++am) {
aiAnimMesh *pAnimMesh = aim->mAnimMeshes[am]; aiAnimMesh *pAnimMesh = aim->mAnimMeshes[am];
if (bExportTargetNames)
m->targetNames.push_back(pAnimMesh->mName.data);
// position // position
if (pAnimMesh->HasPositions()) { if (pAnimMesh->HasPositions()) {