diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index eb6c73ce7..3c13db894 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -446,10 +446,12 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref& meshRef, Ref 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; } } @@ -460,6 +462,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref& meshRef, RefmOffsetMatrix, tmpMatrix4); inverseBindMatricesData.push_back(tmpMatrix4); + jointNamesIndex = inverseBindMatricesData.size() - 1; } // aib->mWeights =====> vertexWeightData @@ -470,7 +473,7 @@ void ExportSkin(Asset& mAsset, const aiMesh* aim, Ref& meshRef, Ref 3) { continue; } - vertexJointData[vertexId][jointsPerVertex[vertexId]] = idx_bone; + vertexJointData[vertexId][jointsPerVertex[vertexId]] = jointNamesIndex; vertexWeightData[vertexId][jointsPerVertex[vertexId]] = vertWeight; jointsPerVertex[vertexId] += 1; @@ -727,7 +730,6 @@ void glTFExporter::ExportMeshes() CopyValue(inverseBindMatricesData[idx_joint], invBindMatrixData[idx_joint]); } - Ref invBindMatrixAccessor = ExportData(*mAsset, skinName, b, inverseBindMatricesData.size(), invBindMatrixData, AttribType::MAT4, AttribType::MAT4, ComponentType_FLOAT); if (invBindMatrixAccessor) skinRef->inverseBindMatrices = invBindMatrixAccessor;