Add hand thrusters

This commit is contained in:
Philip Rosedale 2013-11-29 17:49:35 -08:00
parent abca79ea3e
commit 65ec91ec13
3 changed files with 36 additions and 3 deletions

View file

@ -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();
}
}
}
}

View file

@ -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;

View file

@ -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;
};