Merge branch 'master' into master
commit
3bf62cf6e4
|
@ -446,6 +446,24 @@ namespace glTF2 {
|
||||||
WriteAttrs(w, attrs, p.attributes.weight, "WEIGHTS", true);
|
WriteAttrs(w, attrs, p.attributes.weight, "WEIGHTS", true);
|
||||||
}
|
}
|
||||||
prim.AddMember("attributes", attrs, w.mAl);
|
prim.AddMember("attributes", attrs, w.mAl);
|
||||||
|
|
||||||
|
// targets for blendshapes
|
||||||
|
if (p.targets.size() > 0) {
|
||||||
|
Value tjs;
|
||||||
|
tjs.SetArray();
|
||||||
|
tjs.Reserve(unsigned(p.targets.size()), w.mAl);
|
||||||
|
for (unsigned int t = 0; t < p.targets.size(); ++t) {
|
||||||
|
Value tj;
|
||||||
|
tj.SetObject();
|
||||||
|
{
|
||||||
|
WriteAttrs(w, tj, p.targets[t].position, "POSITION");
|
||||||
|
WriteAttrs(w, tj, p.targets[t].normal, "NORMAL");
|
||||||
|
WriteAttrs(w, tj, p.targets[t].tangent, "TANGENT");
|
||||||
|
}
|
||||||
|
tjs.PushBack(tj, w.mAl);
|
||||||
|
}
|
||||||
|
prim.AddMember("targets", tjs, w.mAl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
primitives.PushBack(prim, w.mAl);
|
primitives.PushBack(prim, w.mAl);
|
||||||
}
|
}
|
||||||
|
|
|
@ -814,6 +814,47 @@ void glTF2Exporter::ExportMeshes()
|
||||||
if(aim->HasBones()) {
|
if(aim->HasBones()) {
|
||||||
ExportSkin(*mAsset, aim, m, b, skinRef, inverseBindMatricesData);
|
ExportSkin(*mAsset, aim, m, b, skinRef, inverseBindMatricesData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************** Targets for blendshapes ****************/
|
||||||
|
if (aim->mNumAnimMeshes > 0) {
|
||||||
|
p.targets.resize(aim->mNumAnimMeshes);
|
||||||
|
for (unsigned int am = 0; am < aim->mNumAnimMeshes; ++am) {
|
||||||
|
aiAnimMesh *pAnimMesh = aim->mAnimMeshes[am];
|
||||||
|
|
||||||
|
// position
|
||||||
|
if (pAnimMesh->HasPositions()) {
|
||||||
|
// NOTE: in gltf it is the diff stored
|
||||||
|
aiVector3D *pPositionDiff = new aiVector3D[pAnimMesh->mNumVertices];
|
||||||
|
for (unsigned int vt = 0; vt < pAnimMesh->mNumVertices; ++vt) {
|
||||||
|
pPositionDiff[vt] = pAnimMesh->mVertices[vt] - aim->mVertices[vt];
|
||||||
|
}
|
||||||
|
Ref<Accessor> v = ExportData(*mAsset, meshId, b,
|
||||||
|
pAnimMesh->mNumVertices, pPositionDiff,
|
||||||
|
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||||
|
if (v) {
|
||||||
|
p.targets[am].position.push_back(v);
|
||||||
|
}
|
||||||
|
delete[] pPositionDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// normal
|
||||||
|
if (pAnimMesh->HasNormals()) {
|
||||||
|
aiVector3D *pNormalDiff = new aiVector3D[pAnimMesh->mNumVertices];
|
||||||
|
for (unsigned int vt = 0; vt < pAnimMesh->mNumVertices; ++vt) {
|
||||||
|
pNormalDiff[vt] = pAnimMesh->mNormals[vt] - aim->mNormals[vt];
|
||||||
|
}
|
||||||
|
Ref<Accessor> v = ExportData(*mAsset, meshId, b,
|
||||||
|
pAnimMesh->mNumVertices, pNormalDiff,
|
||||||
|
AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
|
||||||
|
if (v) {
|
||||||
|
p.targets[am].normal.push_back(v);
|
||||||
|
}
|
||||||
|
delete[] pNormalDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tangent?
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue