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 QtQuick 2.5
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import stylesUit 1.0 import "../../styles-uit"
import "../../controls" import "../../controls"
import controlsUit 1.0 as HifiControls import "../../controls-uit" as HifiControls
import "." import "."

View file

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

View file

@ -31,8 +31,11 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
buildSkeletonFromJoints(joints, hfmModel.jointRotationOffsets); buildSkeletonFromJoints(joints, hfmModel.jointRotationOffsets);
// add offsets for spine2 and the neck // 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++) { for (int i = 0; i < (int)hfmModel.meshes.size(); i++) {
const HFMMesh& mesh = hfmModel.meshes.at(i); const HFMMesh& mesh = hfmModel.meshes.at(i);
for (int j = 0; j < mesh.clusters.size(); j++) { 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 // AJT: mutate bind pose! this allows us to oreint the skeleton back into the authored orientaiton before
// rendering, with no runtime overhead. // rendering, with no runtime overhead.
// this works if clusters match joints one for one. // 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) { if (cluster.jointIndex == 62) {
qCDebug(animation) << "Neck"; qCDebug(animation) << "Neck";
@ -55,14 +67,16 @@ AnimSkeleton::AnimSkeleton(const HFMModel& hfmModel) {
} }
if (cluster.jointIndex == 13) { if (cluster.jointIndex == 13) {
qCDebug(animation) << "Spine2"; qCDebug(animation) << "Spine2";
qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset1<< " cluster " << cluster.jointIndex; qCDebug(animation) << "found a joint offset to add " << cluster.jointIndex << " " << offset1 << " cluster " << cluster.jointIndex;
AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3()); AnimPose localOffset(hfmModel.jointRotationOffsets[cluster.jointIndex], glm::vec3());
//AnimPose localOffset(offset1, glm::vec3()); //AnimPose localOffset(offset1, glm::vec3());
cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix; cluster.inverseBindMatrix = (glm::mat4)localOffset.inverse() * cluster.inverseBindMatrix;
cluster.inverseBindTransform.evalFromRawMatrix(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++) { for (int k = 0; k < _jointsSize; k++) {
int parentIndex2 = getParentIndex(k); int parentIndex2 = getParentIndex(k);
if (jointOffsets.contains(k)) { if (jointOffsets.contains(k)) {
@ -261,6 +276,10 @@ void AnimSkeleton::buildSkeletonFromJoints(const std::vector<HFMJoint>& joints,
_relativeDefaultPoses.push_back(_absoluteDefaultPoses[k]); _relativeDefaultPoses.push_back(_absoluteDefaultPoses[k]);
} }
} }
// re-compute relative poses
//_relativeDefaultPoses = _absoluteDefaultPoses;
//convertAbsolutePosesToRelative(_relativeDefaultPoses);
for (int i = 0; i < _jointsSize; i++) { for (int i = 0; i < _jointsSize; 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; 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(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));
return hfmModelPtr; return hfmModelPtr;
} }