mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:17:34 +02:00
Add hand thrusters
This commit is contained in:
parent
abca79ea3e
commit
65ec91ec13
3 changed files with 36 additions and 3 deletions
|
@ -161,7 +161,25 @@ void Hand::render() {
|
||||||
if (getPalms().size() > 0) {
|
if (getPalms().size() > 0) {
|
||||||
for (size_t i = 0; i < getPalms().size(); ++i) {
|
for (size_t i = 0; i < getPalms().size(); ++i) {
|
||||||
PalmData& palm = getPalms()[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();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -848,6 +848,21 @@ void MyAvatar::updateThrust(float deltaTime, Transmitter * transmitter) {
|
||||||
up;
|
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
|
// Update speed brake status
|
||||||
const float MIN_SPEED_BRAKE_VELOCITY = _scale * 0.4f;
|
const float MIN_SPEED_BRAKE_VELOCITY = _scale * 0.4f;
|
||||||
|
|
|
@ -168,8 +168,8 @@ private:
|
||||||
glm::vec3 _velocity;
|
glm::vec3 _velocity;
|
||||||
int _controllerButtons;
|
int _controllerButtons;
|
||||||
|
|
||||||
bool _isActive; // This has current valid data
|
bool _isActive; // This has current valid data
|
||||||
int _leapID; // the Leap's serial id for this tracked object
|
int _leapID; // the Leap's serial id for this tracked object
|
||||||
int _numFramesWithoutData; // after too many frames without data, this tracked object assumed lost.
|
int _numFramesWithoutData; // after too many frames without data, this tracked object assumed lost.
|
||||||
HandData* _owningHandData;
|
HandData* _owningHandData;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue