Ref<Node> nodeRef = mAsset.nodes.Get(aib->mName.C_Str());
nodeRef->jointName = nodeRef->id; //"joint_" + std::to_string(idx_bone);
+ unsigned int jointNamesIndex;
bool addJointToJointNames = true;
for (int idx_joint = 0; idx_joint < skinRef->jointNames.size(); ++idx_joint) {
if (skinRef->jointNames[idx_joint]->jointName.compare(nodeRef->jointName) == 0) {
addJointToJointNames = false;
+ jointNamesIndex = idx_joint;
}
}
aiMatrix4x4 tmpMatrix4;
CopyValue(aib->mOffsetMatrix, tmpMatrix4);
inverseBindMatricesData.push_back(tmpMatrix4);
+ jointNamesIndex = inverseBindMatricesData.size() - 1;
}
// aib->mWeights =====> vertexWeightData
// A vertex can only have at most four joint weights. Ignore all others.
if (jointsPerVertex[vertexId] > 3) { continue; }
- vertexJointData[vertexId][jointsPerVertex[vertexId]] = idx_bone;
+ vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex;
vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight;
jointsPerVertex[vertexId] += 1;
CopyValue(inverseBindMatricesData[idx_joint], invBindMatrixData[idx_joint]);
}
-
Ref<Accessor> invBindMatrixAccessor = ExportData(*mAsset, skinName, b, inverseBindMatricesData.size(), invBindMatrixData, AttribType::MAT4, AttribType::MAT4, ComponentType_FLOAT);
if (invBindMatrixAccessor) skinRef->inverseBindMatrices = invBindMatrixAccessor;