working on the input mapper problem for the offset rotations

This commit is contained in:
amantley 2018-11-07 17:32:23 -08:00
parent dfd0ce69cb
commit 6b4620b4a1
3 changed files with 18 additions and 4 deletions

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();
@ -2037,7 +2037,9 @@ controller::Pose MyAvatar::getControllerPoseInSensorFrame(controller::Action act
controller::Pose MyAvatar::getControllerPoseInWorldFrame(controller::Action action) const {
auto pose = getControllerPoseInSensorFrame(action);
qCDebug(interfaceapp) << "avatar sensor orientation " << pose.getRotation();
if (pose.valid) {
qCDebug(interfaceapp) << "sensor to world matrix orientation " << extractRotation(getSensorToWorldMatrix());
return pose.transform(getSensorToWorldMatrix());
} else {
return controller::Pose(); // invalid pose
@ -2047,6 +2049,7 @@ controller::Pose MyAvatar::getControllerPoseInWorldFrame(controller::Action acti
controller::Pose MyAvatar::getControllerPoseInAvatarFrame(controller::Action action) const {
auto pose = getControllerPoseInWorldFrame(action);
if (pose.valid) {
qCDebug(interfaceapp) << "avatar world orientation " << getWorldOrientation();
glm::mat4 invAvatarMatrix = glm::inverse(createMatFromQuatAndPos(getWorldOrientation(), getWorldPosition()));
return pose.transform(invAvatarMatrix);
} else {

View file

@ -119,11 +119,22 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
// input action is the highest priority source for head orientation.
auto avatarHeadPose = myAvatar->getControllerPoseInAvatarFrame(controller::Action::HEAD);
if (avatarHeadPose.isValid()) {
AnimPose previousHeadPose;
bool headUnfuckedWith = _rig.getAbsoluteJointPoseInRigFrame(_rig.indexOfJoint("Head"), previousHeadPose);
if (headUnfuckedWith) {
qCDebug(interfaceapp) << "unset head position " << previousHeadPose.trans();
qCDebug(interfaceapp) << "unset head rotation " << previousHeadPose.rot();
}
qCDebug(interfaceapp) << "neck joint offset " << jointOffsetMap[62];
qCDebug(interfaceapp) << "head joint avatar frame " << avatarHeadPose.getRotation();
AnimPose jointOffsetNeck(jointOffsetMap[62], glm::vec3());
AnimPose jointOffsetSpine2(jointOffsetMap[13], glm::vec3());
AnimPose testPose(glm::quat(0.7071f, 0.0f, 0.0f, 0.7071f), glm::vec3());
AnimPose pose(avatarHeadPose.getRotation(), avatarHeadPose.getTranslation());
params.primaryControllerPoses[Rig::PrimaryControllerType_Head] = jointOffsetSpine2.inverse() * jointOffsetNeck.inverse() * (avatarToRigPose * pose) * jointOffsetNeck * jointOffsetSpine2;
AnimPose newHeadRot = (avatarToRigPose * pose) * testPose;
AnimPose newHeadRot2(newHeadRot.rot(), avatarHeadPose.getTranslation());
AnimPose identityPose(glm::quat(1.0f,0.0f,0.0f,0.0f), glm::vec3(0.0f,0.57f,0.0f));
params.primaryControllerPoses[Rig::PrimaryControllerType_Head] = avatarToRigPose * pose;
params.primaryControllerFlags[Rig::PrimaryControllerType_Head] = (uint8_t)Rig::ControllerFlags::Enabled;
} else {
// even though full head IK is disabled, the rig still needs the head orientation to rotate the head up and
@ -234,7 +245,7 @@ void MySkeletonModel::updateRig(float deltaTime, glm::mat4 parentTransform) {
// set spine2 if we have hand controllers
qCDebug(interfaceapp) << "spine 2 joint offset " << jointOffsetMap[13];
if (false && myAvatar->getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).isValid() &&
if (myAvatar->getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).isValid() &&
myAvatar->getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).isValid() &&
!(params.primaryControllerFlags[Rig::PrimaryControllerType_Spine2] & (uint8_t)Rig::ControllerFlags::Enabled)) {

View file

@ -2078,7 +2078,7 @@ void Rig::setJointRotationOffsets(const QMap<QString, glm::quat>& offsets) {
int spine2Id = 13;
if (true){ //neckIndex != -1) {
_jointRotationOffsets.insert(neckId, glm::quat(0.0f, 0.7071f, 0.7071f, 0.0f) * glm::quat(0.5f, 0.5f, 0.5f, -0.5f) ); //glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f)
qCDebug(animation) << "multiplied quats are " << glm::quat(0.0f, 0.7071f, 0.7071f, 0.0f) * glm::quat(0.5f, 0.5f, 0.5f, -0.5f);
qCDebug(animation) << "multiplied quats are " << glm::quat(0.7071f, 0.0f, -0.7071f, 0.0f) * glm::quat(0.5f, 0.5f, 0.5f, -0.5f);
}
if (true){ //spine2Index != -1) {
_jointRotationOffsets.insert(spine2Id, glm::quat(0.5f, 0.5f, 0.5f, -0.5f));