From e6a8c79f9fde066c95c3fd3137f139bfee93c31c Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Wed, 7 May 2014 16:51:22 -0700 Subject: [PATCH] Added more arrow controls to move camera when in mirror mode, new guitar chords. --- examples/airGuitar.js | 21 +++++++++++++++------ interface/src/Application.cpp | 28 ++++++++++++++++++++++------ interface/src/Application.h | 2 ++ 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/examples/airGuitar.js b/examples/airGuitar.js index a54ef82e7e..08898579a7 100644 --- a/examples/airGuitar.js +++ b/examples/airGuitar.js @@ -27,9 +27,18 @@ function vMinus(a, b) { // First, load two percussion sounds to be used on the sticks -var chord1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+A.raw"); -var chord2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+B.raw"); -var chord3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+E.raw"); +var guitarType = 2; + +if (guitarType == 1) { + var chord1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+A.raw"); + var chord2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+B.raw"); + var chord3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Nylon+E.raw"); +} else { + var chord1 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+A+short.raw"); + var chord2 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+B+short.raw"); + var chord3 = new Sound("https://s3-us-west-1.amazonaws.com/highfidelity-public/sounds/Guitars/Guitar+-+Metal+E+short.raw"); +} + var whichChord = chord1; @@ -56,7 +65,7 @@ function checkHands(deltaTime) { if (palm == strumHand) { - var STRUM_HEIGHT_ABOVE_PELVIS = 0.15; + var STRUM_HEIGHT_ABOVE_PELVIS = -0.30; var strumTriggerHeight = myPelvis.y + STRUM_HEIGHT_ABOVE_PELVIS; //printVector(position); if ((position.y < strumTriggerHeight) && (lastPosition.y >= strumTriggerHeight)) { @@ -72,9 +81,9 @@ function checkHands(deltaTime) { // This is the chord controller var distanceFromPelvis = Vec3.length(Vec3.subtract(position, myPelvis)); //print(distanceFromPelvis); - if (distanceFromPelvis > 0.50) { + if (distanceFromPelvis > 0.63) { whichChord = chord3; - } else if (distanceFromPelvis > 0.35) { + } else if (distanceFromPelvis > 0.55) { whichChord = chord2; } else { whichChord = chord1; diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 10f113ad11..e4adb38cd4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -572,8 +572,8 @@ void Application::paintGL() { glm::vec3 eyePosition = _myAvatar->getHead()->calculateAverageEyePosition(); float headHeight = eyePosition.y - _myAvatar->getPosition().y; _myCamera.setDistance(MIRROR_FULLSCREEN_DISTANCE * _myAvatar->getScale() * _scaleMirror); - _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight, 0)); - _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI, 0.0f))); + _myCamera.setTargetPosition(_myAvatar->getPosition() + glm::vec3(0, headHeight + (_raiseMirror * _myAvatar->getScale()), 0)); + _myCamera.setTargetRotation(_myAvatar->getWorldAlignedOrientation() * glm::quat(glm::vec3(0.0f, PI + _rotateMirror, 0.0f))); // if the head would intersect the near clip plane, we must push the camera out glm::vec3 relativePosition = glm::inverse(_myCamera.getTargetRotation()) * @@ -870,7 +870,11 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_Up: if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { - _scaleMirror *= 0.95; + if (!isShifted) { + _scaleMirror *= 0.95f; + } else { + _raiseMirror += 0.05f; + } } else { _myAvatar->setDriveKeys(isShifted ? UP : FWD, 1.f); } @@ -878,18 +882,30 @@ void Application::keyPressEvent(QKeyEvent* event) { case Qt::Key_Down: if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { - _scaleMirror *= 1.05; + if (!isShifted) { + _scaleMirror *= 1.05f; + } else { + _raiseMirror -= 0.05f; + } } else { _myAvatar->setDriveKeys(isShifted ? DOWN : BACK, 1.f); } break; case Qt::Key_Left: - _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.f); + if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { + _rotateMirror += PI / 20.f; + } else { + _myAvatar->setDriveKeys(isShifted ? LEFT : ROT_LEFT, 1.f); + } break; case Qt::Key_Right: - _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.f); + if (_myCamera.getMode() == CAMERA_MODE_MIRROR) { + _rotateMirror -= PI / 20.f; + } else { + _myAvatar->setDriveKeys(isShifted ? RIGHT : ROT_RIGHT, 1.f); + } break; case Qt::Key_I: diff --git a/interface/src/Application.h b/interface/src/Application.h index 1d38a11357..54e6bcdcac 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -457,6 +457,8 @@ private: glm::mat4 _projectionMatrix; float _scaleMirror; + float _rotateMirror; + float _raiseMirror; glm::mat4 _shadowMatrix;