From 373d2f0532e5f4c4bd0fb6aa715500d9dc81121a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Tue, 7 Oct 2014 14:50:29 -0700 Subject: [PATCH 1/2] Work-around for right hand roll on Windows is no longer needed --- examples/leapHands.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/examples/leapHands.js b/examples/leapHands.js index 1095a9f4dc..3352ea243b 100644 --- a/examples/leapHands.js +++ b/examples/leapHands.js @@ -31,7 +31,6 @@ var leapHands = (function () { CALIBRATED = 2, CALIBRATION_TIME = 1000, // milliseconds PI = 3.141593, - isWindows, avatarScale, avatarFaceModelURL, avatarSkeletonModelURL, @@ -132,9 +131,6 @@ var leapHands = (function () { if (hands[0].controller.isActive() && hands[1].controller.isActive()) { leapHandHeight = (hands[0].controller.getAbsTranslation().y + hands[1].controller.getAbsTranslation().y) / 2.0; - - // TODO: Temporary detection of Windows to work around Leap Controller problem. - isWindows = (hands[1].controller.getAbsRotation().z > (0.25 * PI)); } else { calibrationStatus = UNCALIBRATED; return; @@ -398,12 +394,6 @@ var leapHands = (function () { handPitch = 2.0 * -wristAbsRotation.x; handYaw = 2.0 * wristAbsRotation.y; - // TODO: Leap Motion controller's right-hand roll calculation only works if physical hand is upside down. - // Approximate fix is to add a fudge factor. - if (h === 1 && isWindows) { - handRoll = handRoll + 0.6 * PI; - } - // Hand position and orientation ... if (h === 0) { handRotation = Quat.multiply(Quat.angleAxis(-90.0, { x: 0, y: 1, z: 0 }), From a3cce3ae2286e8f39bda7f05597da2caeecfb169 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 8 Oct 2014 10:11:18 -0700 Subject: [PATCH 2/2] Fix Leap hand roll --- examples/leapHands.js | 48 +++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/examples/leapHands.js b/examples/leapHands.js index 3352ea243b..222c0e4cf1 100644 --- a/examples/leapHands.js +++ b/examples/leapHands.js @@ -30,7 +30,6 @@ var leapHands = (function () { CALIBRATING = 1, CALIBRATED = 2, CALIBRATION_TIME = 1000, // milliseconds - PI = 3.141593, avatarScale, avatarFaceModelURL, avatarSkeletonModelURL, @@ -314,11 +313,7 @@ var leapHands = (function () { j, side, handOffset, - handRoll, - handPitch, - handYaw, handRotation, - wristAbsRotation, locRotation, cameraOrientation, inverseAvatarOrientation; @@ -357,20 +352,22 @@ var leapHands = (function () { handOffset.x = -handOffset.x; // Hand rotation in camera coordinates ... - // TODO: 2.0* scale factors should not be necessary; Leap Motion controller code needs investigating. - handRoll = 2.0 * -hands[h].controller.getAbsRotation().z; - wristAbsRotation = wrists[h].controller.getAbsRotation(); - handPitch = 2.0 * wristAbsRotation.x - PI / 2.0; - handYaw = 2.0 * -wristAbsRotation.y; - // TODO: Roll values only work if hand is upside down; Leap Motion controller code needs investigating. - handRoll = PI + handRoll; + handRotation = wrists[h].controller.getAbsRotation(); + handRotation = { + x: handRotation.z, + y: handRotation.y, + z: handRotation.x, + w: handRotation.w + }; if (h === 0) { - handRotation = Quat.multiply(Quat.angleAxis(-90.0, { x: 0, y: 1, z: 0 }), - Quat.fromVec3Radians({ x: handRoll, y: handYaw, z: -handPitch })); + handRotation.x = -handRotation.x; + handRotation = Quat.multiply(Quat.angleAxis(90.0, { x: 1, y: 0, z: 0 }), handRotation); + handRotation = Quat.multiply(Quat.angleAxis(90.0, { x: 0, y: 0, z: 1 }), handRotation); } else { - handRotation = Quat.multiply(Quat.angleAxis(90.0, { x: 0, y: 1, z: 0 }), - Quat.fromVec3Radians({ x: -handRoll, y: handYaw, z: handPitch })); + handRotation.z = -handRotation.z; + handRotation = Quat.multiply(Quat.angleAxis(90.0, { x: 1, y: 0, z: 0 }), handRotation); + handRotation = Quat.multiply(Quat.angleAxis(-90.0, { x: 0, y: 0, z: 1 }), handRotation); } // Hand rotation in avatar coordinates ... @@ -388,19 +385,22 @@ var leapHands = (function () { z: hands[h].zeroPosition.z - handOffset.z }; - // TODO: 2.0* scale factors should not be necessary; Leap Motion controller code needs investigating. - handRoll = 2.0 * -hands[h].controller.getAbsRotation().z; - wristAbsRotation = wrists[h].controller.getAbsRotation(); - handPitch = 2.0 * -wristAbsRotation.x; - handYaw = 2.0 * wristAbsRotation.y; + handRotation = wrists[h].controller.getAbsRotation(); + handRotation = { + x: handRotation.z, + y: handRotation.y, + z: handRotation.x, + w: handRotation.w + }; - // Hand position and orientation ... if (h === 0) { + handRotation.x = -handRotation.x; handRotation = Quat.multiply(Quat.angleAxis(-90.0, { x: 0, y: 1, z: 0 }), - Quat.fromVec3Radians({ x: handRoll, y: handYaw, z: -handPitch })); + handRotation); } else { + handRotation.z = -handRotation.z; handRotation = Quat.multiply(Quat.angleAxis(90.0, { x: 0, y: 1, z: 0 }), - Quat.fromVec3Radians({ x: -handRoll, y: handYaw, z: handPitch })); + handRotation); } }