From f83edf4b7ffa373c8bac88214eb1b0771ca26194 Mon Sep 17 00:00:00 2001 From: amantley Date: Tue, 13 Nov 2018 11:29:01 -0800 Subject: [PATCH] joint offsets working. reset working. to do: handling extra joints --- libraries/animation/src/AnimSkeleton.cpp | 12 ++++++------ libraries/fbx/src/FBX.h | 2 +- libraries/fbx/src/FBXReader.cpp | 7 +++---- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libraries/animation/src/AnimSkeleton.cpp b/libraries/animation/src/AnimSkeleton.cpp index aec4ae6dda..790c898674 100644 --- a/libraries/animation/src/AnimSkeleton.cpp +++ b/libraries/animation/src/AnimSkeleton.cpp @@ -33,7 +33,7 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) { // add offsets for spine2 and the neck static bool once = true; qCDebug(animation) << "the hfm model path is " << hfmModel.originalURL; - if (once && hfmModel.originalURL == "/angus/avatars/engineer_hifinames/engineer_hifinames/engineer_hifinames.fbx") { + //if (once && hfmModel.originalURL == "/angus/avatars/engineer_hifinames/engineer_hifinames/engineer_hifinames.fbx") { //if (once && hfmModel.originalURL == "/angus/avatars/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd.fbx") { once = false; for (int i = 0; i < (int)hfmModel.meshes.size(); i++) { @@ -51,11 +51,11 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) { qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset2 << " cluster " << cluster.jointIndex; AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3()); //AnimPose localOffset(offset2, glm::vec3()); - cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix; + cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * hfmModel.clusterBindMatrixOriginalValues[i][j]; qCDebug(animation) << "the new bind matrix num: " << cluster.jointIndex << cluster.inverseBindMatrix; - //if ((hfmModel.clusterBindMatrixOriginalValues.size() > i) && (hfmModel.clusterBindMatrixOriginalValues[i].contains(cluster.jointIndex))) { - // qCDebug(animation) << "the saved orig matrix num: " << cluster.jointIndex << hfmModel.clusterBindMatrixOriginalValues[i][cluster.jointIndex]; - //} + if ((hfmModel.clusterBindMatrixOriginalValues.size() > i) && (hfmModel.clusterBindMatrixOriginalValues[i].size() > cluster.jointIndex)) { + qCDebug(animation) << "the saved orig matrix num: " << cluster.jointIndex << hfmModel.clusterBindMatrixOriginalValues[i][j]; + } cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix); } @@ -80,7 +80,7 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) { */ } } - } + //} diff --git a/libraries/fbx/src/FBX.h b/libraries/fbx/src/FBX.h index 342f3c456a..943db4b7fe 100644 --- a/libraries/fbx/src/FBX.h +++ b/libraries/fbx/src/FBX.h @@ -349,7 +349,7 @@ public: Extents meshExtents; QVector animationFrames; - std::vector> clusterBindMatrixOriginalValues; + std::vector> clusterBindMatrixOriginalValues; int getJointIndex(const QString& name) const { return jointIndices.value(name) - 1; } QStringList getJointNames() const; diff --git a/libraries/fbx/src/FBXReader.cpp b/libraries/fbx/src/FBXReader.cpp index ed5e349957..7a49874abb 100644 --- a/libraries/fbx/src/FBXReader.cpp +++ b/libraries/fbx/src/FBXReader.cpp @@ -2033,20 +2033,19 @@ HFMModel* FBXReader::extractHFMModel(const QVariantHash& mapping, const QString& } //hfmModel.jointRotationOffsets.insert(13, glm::quat(0.5f, 0.5f, 0.5f, -0.5f)); //hfmModel.jointRotationOffsets.insert(62, glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f)); - /* + for (int i = 0; i < (int)hfmModel.meshes.size(); i++) { const HFMMesh& mesh = hfmModel.meshes.at(i); - QMap tempBindMat; + vector tempBindMat; for (int j = 0; j < mesh.clusters.size(); j++) { const HFMCluster& cluster = mesh.clusters.at(j); - tempBindMat.insert(cluster.jointIndex, cluster.inverseBindMatrix); + tempBindMat.push_back(cluster.inverseBindMatrix); //if(hfmModel.clusterBindMatrixOriginalValues[i]) //hfmModel.clusterBindMatrixOriginalValues[i].insert(cluster.jointIndex,Matrices::IDENTITY);// cluster.inverseBindMatrix; //glm::mat4 testMat = cluster.inverseBindMatrix; } hfmModel.clusterBindMatrixOriginalValues.push_back(tempBindMat); } - */ return hfmModelPtr; }