From 85b94ff71cf6681a4704f85b10bdd723dfb9ec89 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 16 May 2014 09:20:15 -0700 Subject: [PATCH] added dead zone to pitch in hydra move, animated models show up where you are --- examples/animatedModelExample.js | 10 +++++----- examples/hydraMove.js | 24 ++++++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/examples/animatedModelExample.js b/examples/animatedModelExample.js index 5199eb419f..3fb4ae8bd4 100644 --- a/examples/animatedModelExample.js +++ b/examples/animatedModelExample.js @@ -21,9 +21,9 @@ var roll = 0.0; var rotation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll) var originalProperties = { - position: { x: 10, - y: 0, - z: 0 }, + position: { x: MyAvatar.position.x, + y: MyAvatar.position.y, + z: MyAvatar.position.z }, radius : 1, @@ -58,9 +58,9 @@ function moveModel(deltaTime) { if (animationFPS == 30) { animationFPS = 10; } else if (animationFPS == 10) { - animationFPS = 60; + animationFPS = 10; } else if (animationFPS == 60) { - animationFPS = 30; + animationFPS = 10; } print("animationFPS=" + animationFPS); isPlaying = true; diff --git a/examples/hydraMove.js b/examples/hydraMove.js index 638e5fe226..3a11fa0b5e 100644 --- a/examples/hydraMove.js +++ b/examples/hydraMove.js @@ -145,20 +145,28 @@ function handleGrabBehavior(deltaTime) { // add some rotation... var deltaRotation = getGrabRotation(); - var GRAB_CONTROLLER_PITCH_SCALING = 2.5; - var GRAB_CONTROLLER_YAW_SCALING = 2.5; - var GRAB_CONTROLLER_ROLL_SCALING = 2.5; + var PITCH_SCALING = 2.0; + var PITCH_DEAD_ZONE = 2.0; + var YAW_SCALING = 2.0; + var ROLL_SCALING = 2.0; + var euler = Quat.safeEulerAngles(deltaRotation); + print("dx: " + euler.x); + // Adjust body yaw by roll from controller - var orientation = Quat.multiply(Quat.angleAxis(((euler.y * GRAB_CONTROLLER_YAW_SCALING) + - (euler.z * GRAB_CONTROLLER_ROLL_SCALING)) * deltaTime, {x:0, y: 1, z:0}), MyAvatar.orientation); + var orientation = Quat.multiply(Quat.angleAxis(((euler.y * YAW_SCALING) + + (euler.z * ROLL_SCALING)) * deltaTime, {x:0, y: 1, z:0}), MyAvatar.orientation); MyAvatar.orientation = orientation; // Adjust head pitch from controller - MyAvatar.headPitch = MyAvatar.headPitch + (euler.x * GRAB_CONTROLLER_PITCH_SCALING * deltaTime); - - // Add some camera roll proportional to the rate of turn (so it feels like an airplane or roller coaster) + var pitch = 0.0; + if (Math.abs(euler.x) > PITCH_DEAD_ZONE) { + pitch = (euler.x < 0.0) ? (euler.x + PITCH_DEAD_ZONE) : (euler.x - PITCH_DEAD_ZONE); + } + MyAvatar.headPitch = MyAvatar.headPitch + (pitch * PITCH_SCALING * deltaTime); + + // TODO: Add some camera roll proportional to the rate of turn (so it feels like an airplane or roller coaster) }