From 0e0561bb24bfbf93f62b71ef18276e15d8c415fa Mon Sep 17 00:00:00 2001 From: amantley Date: Thu, 23 Aug 2018 17:59:18 -0700 Subject: [PATCH] latest rotate code --- interface/src/avatar/MyAvatar.cpp | 20 +++++++++++++++----- scripts/developer/rotateApp.js | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 6211e6f0d8..8d9c503e5e 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -462,7 +462,7 @@ void MyAvatar::update(float deltaTime) { setCurrentStandingHeight(computeStandingHeightMode(getControllerPoseInAvatarFrame(controller::Action::HEAD))); setAverageHeadRotation(computeAverageHeadRotation(getControllerPoseInAvatarFrame(controller::Action::HEAD))); - + computeHandAzimuth(); #ifdef DEBUG_DRAW_HMD_MOVING_AVERAGE @@ -473,6 +473,14 @@ void MyAvatar::update(float deltaTime) { glm::vec3 worldFacing = transformVectorFast(getSensorToWorldMatrix(), glm::vec3(_headControllerFacing.x, 0.0f, _headControllerFacing.y)); DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacing, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f)); DebugDraw::getInstance().drawRay(worldHeadPos, worldHeadPos + worldFacingAverage, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f)); + + // draw hand azimuth vector + + glm::vec3 worldRHandAzimuth = transformPoint(getTransform().getMatrix(), getControllerPoseInAvatarFrame(controller::Action::RIGHT_HAND).getTranslation()); + glm::vec3 worldLHandAzimuth = transformPoint(getTransform().getMatrix(), getControllerPoseInAvatarFrame(controller::Action::LEFT_HAND).getTranslation()); + qCDebug(interfaceapp) << "the right hand in avatar space" << worldRHandAzimuth << " " << getWorldPosition(); + DebugDraw::getInstance().drawRay(getWorldPosition(), worldRHandAzimuth, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f)); + DebugDraw::getInstance().drawRay(getWorldPosition(), worldLHandAzimuth, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f)); } #endif @@ -802,11 +810,13 @@ void MyAvatar::updateFromHMDSensorMatrix(const glm::mat4& hmdSensorMatrix) { } void MyAvatar::computeHandAzimuth() { - controller::Pose leftHandPoseAvatarSpace = getLeftHandPose(); - controller::Pose rightHandPoseAvatarSpace = getRightHandPose(); + auto leftHandPoseAvatarSpace = getLeftHandPose(); + auto rightHandPoseAvatarSpace = getRightHandPose(); glm::vec3 localLookat(0.0f, 0.0f, 1.0f); - glm::vec3 rightHandRigSpace = rightHandPoseAvatarSpace.rotation * localLookat; - glm::vec3 lefttHandRigSpace = leftHandPoseAvatarSpace.rotation * localLookat; + glm::vec3 rightHandRigSpace = rightHandPoseAvatarSpace.translation;// transformVectorFast(getTransform().getMatrix(), rightHandPoseAvatarSpace.translation); + glm::vec3 leftHandRigSpace = leftHandPoseAvatarSpace.translation;// transformVectorFast(getTransform().getMatrix(), leftHandPoseAvatarSpace.translation); + + //qCDebug(interfaceapp) << "the right hand in avatar space" << rightHandRigSpace; _hipToHandController = glm::vec2(rightHandRigSpace.x, rightHandRigSpace.z); diff --git a/scripts/developer/rotateApp.js b/scripts/developer/rotateApp.js index 60d78d66d9..e4080c9bb0 100644 --- a/scripts/developer/rotateApp.js +++ b/scripts/developer/rotateApp.js @@ -320,7 +320,7 @@ function computeHandAzimuths(timeElapsed) { // put a hard max on this easing function. var rotateAngle = ((Math.cos((leftRightMidpoint / 180.0) * Math.PI) + 2.0)/3.0) * leftRightMidpoint; - print("rotate angle " + rotateAngle); + //print("rotate angle " + rotateAngle); return Quat.fromVec3Degrees({ x: 0, y: rotateAngle, z: 0 });