Merge pull request #3267 from thomasbiang/gltf2_targetNames_export
Gltf2 Export Target Names for Blendshapesissue_3165
commit
e6d5af6d76
|
@ -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)
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in New Issue