joint offsets working. reset working. to do: handling extra joints

This commit is contained in:
amantley 2018-11-13 11:29:01 -08:00
parent bcd651a65d
commit f83edf4b7f
3 changed files with 10 additions and 11 deletions

View file

@ -33,7 +33,7 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
// add offsets for spine2 and the neck // add offsets for spine2 and the neck
static bool once = true; static bool once = true;
qCDebug(animation) << "the hfm model path is " << hfmModel.originalURL; 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") { //if (once && hfmModel.originalURL == "/angus/avatars/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd/pei_z_neckNexX_spine2NegY_fwd.fbx") {
once = false; once = false;
for (int i = 0; i < (int)hfmModel.meshes.size(); i++) { 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; qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset2 << " cluster " << cluster.jointIndex;
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3()); AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
//AnimPose localOffset(offset2, 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; qCDebug(animation) << "the new bind matrix num: " << cluster.jointIndex << cluster.inverseBindMatrix;
//if ((hfmModel.clusterBindMatrixOriginalValues.size() > i) && (hfmModel.clusterBindMatrixOriginalValues[i].contains(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][cluster.jointIndex]; qCDebug(animation) << "the saved orig matrix num: " << cluster.jointIndex << hfmModel.clusterBindMatrixOriginalValues[i][j];
//} }
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix); cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
} }
@ -80,7 +80,7 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
*/ */
} }
} }
} //}

View file

@ -349,7 +349,7 @@ public:
Extents meshExtents; Extents meshExtents;
QVector<HFMAnimationFrame> animationFrames; QVector<HFMAnimationFrame> animationFrames;
std::vector<QMap<int,glm::mat4>> clusterBindMatrixOriginalValues; std::vector<std::vector<glm::mat4>> clusterBindMatrixOriginalValues;
int getJointIndex(const QString& name) const { return jointIndices.value(name) - 1; } int getJointIndex(const QString& name) const { return jointIndices.value(name) - 1; }
QStringList getJointNames() const; QStringList getJointNames() const;

View file

@ -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(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)); //hfmModel.jointRotationOffsets.insert(62, glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f));
/*
for (int i = 0; i < (int)hfmModel.meshes.size(); i++) { for (int i = 0; i < (int)hfmModel.meshes.size(); i++) {
const HFMMesh& mesh = hfmModel.meshes.at(i); const HFMMesh& mesh = hfmModel.meshes.at(i);
QMap<int,glm::mat4> tempBindMat; vector<glm::mat4> tempBindMat;
for (int j = 0; j < mesh.clusters.size(); j++) { for (int j = 0; j < mesh.clusters.size(); j++) {
const HFMCluster& cluster = mesh.clusters.at(j); const HFMCluster& cluster = mesh.clusters.at(j);
tempBindMat.insert(cluster.jointIndex, cluster.inverseBindMatrix); tempBindMat.push_back(cluster.inverseBindMatrix);
//if(hfmModel.clusterBindMatrixOriginalValues[i]) //if(hfmModel.clusterBindMatrixOriginalValues[i])
//hfmModel.clusterBindMatrixOriginalValues[i].insert(cluster.jointIndex,Matrices::IDENTITY);// cluster.inverseBindMatrix; //hfmModel.clusterBindMatrixOriginalValues[i].insert(cluster.jointIndex,Matrices::IDENTITY);// cluster.inverseBindMatrix;
//glm::mat4 testMat = cluster.inverseBindMatrix; //glm::mat4 testMat = cluster.inverseBindMatrix;
} }
hfmModel.clusterBindMatrixOriginalValues.push_back(tempBindMat); hfmModel.clusterBindMatrixOriginalValues.push_back(tempBindMat);
} }
*/
return hfmModelPtr; return hfmModelPtr;
} }