From 65ec91ec139c7f1ac577ce6462f6ac1daaa4a75b Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Fri, 29 Nov 2013 17:49:35 -0800 Subject: [PATCH] Add hand thrusters --- interface/src/avatar/Hand.cpp | 20 +++++++++++++++++++- interface/src/avatar/MyAvatar.cpp | 15 +++++++++++++++ libraries/avatars/src/HandData.h | 4 ++-- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 61aa30af21..d241b6a2fc 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -161,7 +161,25 @@ void Hand::render() { if (getPalms().size() > 0) { for (size_t i = 0; i < getPalms().size(); ++i) { PalmData& palm = getPalms()[i]; - //printf("buttons = %i\n", palm.getControllerButtons()); + // If FWD button(s) are pressed, render laser beam forward + const float POINTER_BEAM_LENGTH = 10.f; + if (palm.getControllerButtons() & BUTTON_FWD) { + FingerData& finger = palm.getFingers()[0]; + if (finger.isActive()) { + glm::vec3 palmPosition = palm.getPosition(); + glm::vec3 pointerPosition = palmPosition + glm::normalize(finger.getTipPosition() - palmPosition) * POINTER_BEAM_LENGTH; + glColor4f(1, 0, 0, 0.5); + glPushMatrix(); + glTranslatef(pointerPosition.x, pointerPosition.y, pointerPosition.z); + glutSolidSphere(0.05, 10, 10); + glPopMatrix(); + glLineWidth(2.0); + glBegin(GL_LINES); + glVertex3f(palmPosition.x, palmPosition.y, palmPosition.z); + glVertex3f(pointerPosition.x, pointerPosition.y, pointerPosition.z); + glEnd(); + } + } } } diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index baedb1bc6b..2836fab951 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -848,6 +848,21 @@ void MyAvatar::updateThrust(float deltaTime, Transmitter * transmitter) { up; } } + // Add thrust from hand controllers + const float THRUST_MAG_HAND_JETS = THRUST_MAG_FWD * 10.f; + for (size_t i = 0; i < getHand().getPalms().size(); ++i) { + PalmData& palm = getHand().getPalms()[i]; + if (palm.isActive()) { + if (palm.getControllerButtons() & BUTTON_FWD) { + FingerData& finger = palm.getFingers()[0]; + if (finger.isActive()) { + } + glm::vec3 thrustDirection = glm::normalize(finger.getTipPosition() - palm.getPosition()); + _thrust += thrustDirection * _scale * THRUST_MAG_HAND_JETS * _thrustMultiplier * deltaTime; + } + } + } + // Update speed brake status const float MIN_SPEED_BRAKE_VELOCITY = _scale * 0.4f; diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index ca8f97d40a..5dc42b4675 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -168,8 +168,8 @@ private: glm::vec3 _velocity; int _controllerButtons; - bool _isActive; // This has current valid data - int _leapID; // the Leap's serial id for this tracked object + bool _isActive; // This has current valid data + int _leapID; // the Leap's serial id for this tracked object int _numFramesWithoutData; // after too many frames without data, this tracked object assumed lost. HandData* _owningHandData; };