changes to get the engineer working

This commit is contained in:
amantley 2018-11-09 15:10:14 -08:00
parent fd365b5509
commit 5bb2378cd9
4 changed files with 27 additions and 8 deletions

View file

@ -9,9 +9,9 @@
import QtQuick 2.5
import QtGraphicalEffects 1.0
import stylesUit 1.0
import "../../styles-uit"
import "../../controls"
import controlsUit 1.0 as HifiControls
import "../../controls-uit" as HifiControls
import "."

View file

@ -431,7 +431,7 @@ void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
_wasPushing = _isPushing = _isBraking = false;
_follow.deactivate();
if (andReload) {
//_skeletonModel->reset();
_skeletonModel->reset();
}
if (andHead) { // which drives camera in desktop
getHead()->reset();

View file

@ -31,8 +31,11 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
buildSkeletonFromJoints(joints, hfmModel.jointRotationOffsets);
// 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/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++) {
const HFMMesh& mesh = hfmModel.meshes.at(i);
for (int j = 0; j < mesh.clusters.size(); j++) {
@ -44,6 +47,15 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
// AJT: mutate bind pose! this allows us to oreint the skeleton back into the authored orientaiton before
// rendering, with no runtime overhead.
// this works if clusters match joints one for one.
if (hfmModel.jointRotationOffsets.contains(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(offset2, glm::vec3());
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
}
/*
if (cluster.jointIndex == 62) {
qCDebug(animation) << "Neck";
@ -61,6 +73,8 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
cluster.inverseBindTransform.evalFromRawMatrix(cluster.inverseBindMatrix);
}
*/
}
}
}
@ -247,6 +261,7 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
}
}
for (int k = 0; k < _jointsSize; k++) {
int parentIndex2 = getParentIndex(k);
if (jointOffsets.contains(k)) {
@ -262,6 +277,10 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
}
}
// re-compute relative poses
//_relativeDefaultPoses = _absoluteDefaultPoses;
//convertAbsolutePosesToRelative(_relativeDefaultPoses);
for (int i = 0; i < _jointsSize; i++) {
_jointIndicesByName[_joints[i].name] = i;

View file

@ -2031,8 +2031,8 @@ HFMModel* FBXReader::extractHFMModel(const QVariantHash& mapping, const QString&
}
qCDebug(modelformat) << "Joint Rotation Offset added to Rig._jointRotationOffsets : " << " jointName: " << jointName << " jointIndex: " << jointIndex << " rotation offset: " << rotationOffset;
}
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(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));
return hfmModelPtr;
}