mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 07:19:05 +02:00
Drive with trigger pointing
This commit is contained in:
parent
65ec91ec13
commit
a9139b05e8
4 changed files with 17 additions and 26 deletions
|
@ -157,17 +157,20 @@ void Hand::render() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If hand controller buttons pressed, render stuff
|
// If hand controller buttons pressed, render stuff as needed
|
||||||
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];
|
||||||
// If FWD button(s) are pressed, render laser beam forward
|
// If trigger pulled, thrust in that direction and draw beam
|
||||||
const float POINTER_BEAM_LENGTH = 10.f;
|
const float MAX_THRUSTER_BEAM_LENGTH = 5.f;
|
||||||
if (palm.getControllerButtons() & BUTTON_FWD) {
|
if (palm.getTrigger() > 0.f) {
|
||||||
FingerData& finger = palm.getFingers()[0];
|
FingerData& finger = palm.getFingers()[0];
|
||||||
if (finger.isActive()) {
|
if (finger.isActive() && (palm.getTrigger() > 0.f)) {
|
||||||
|
printf("trigger = %.2f\n", palm.getTrigger());
|
||||||
glm::vec3 palmPosition = palm.getPosition();
|
glm::vec3 palmPosition = palm.getPosition();
|
||||||
glm::vec3 pointerPosition = palmPosition + glm::normalize(finger.getTipPosition() - palmPosition) * POINTER_BEAM_LENGTH;
|
glm::vec3 pointerPosition = palmPosition +
|
||||||
|
glm::normalize(finger.getTipPosition() - palmPosition) *
|
||||||
|
(0.01f + palm.getTrigger()) * MAX_THRUSTER_BEAM_LENGTH;
|
||||||
glColor4f(1, 0, 0, 0.5);
|
glColor4f(1, 0, 0, 0.5);
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(pointerPosition.x, pointerPosition.y, pointerPosition.z);
|
glTranslatef(pointerPosition.x, pointerPosition.y, pointerPosition.z);
|
||||||
|
|
|
@ -849,21 +849,20 @@ void MyAvatar::updateThrust(float deltaTime, Transmitter * transmitter) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add thrust from hand controllers
|
// Add thrust from hand controllers
|
||||||
const float THRUST_MAG_HAND_JETS = THRUST_MAG_FWD * 10.f;
|
const float THRUST_MAG_HAND_JETS = THRUST_MAG_FWD * 100.f;
|
||||||
for (size_t i = 0; i < getHand().getPalms().size(); ++i) {
|
for (size_t i = 0; i < getHand().getPalms().size(); ++i) {
|
||||||
PalmData& palm = getHand().getPalms()[i];
|
PalmData& palm = getHand().getPalms()[i];
|
||||||
if (palm.isActive()) {
|
if (palm.isActive()) {
|
||||||
if (palm.getControllerButtons() & BUTTON_FWD) {
|
if (palm.getTrigger() > 0.f) {
|
||||||
FingerData& finger = palm.getFingers()[0];
|
FingerData& finger = palm.getFingers()[0];
|
||||||
if (finger.isActive()) {
|
if (finger.isActive()) {
|
||||||
}
|
}
|
||||||
glm::vec3 thrustDirection = glm::normalize(finger.getTipPosition() - palm.getPosition());
|
glm::vec3 thrustDirection = glm::normalize(finger.getTipPosition() - palm.getPosition());
|
||||||
_thrust += thrustDirection * _scale * THRUST_MAG_HAND_JETS * _thrustMultiplier * deltaTime;
|
_thrust += thrustDirection * _scale * THRUST_MAG_HAND_JETS * palm.getTrigger() * _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;
|
||||||
if ((glm::length(_thrust) == 0.0f) && _isThrustOn && (glm::length(_velocity) > MIN_SPEED_BRAKE_VELOCITY)) {
|
if ((glm::length(_thrust) == 0.0f) && _isThrustOn && (glm::length(_velocity) > MIN_SPEED_BRAKE_VELOCITY)) {
|
||||||
|
|
|
@ -42,22 +42,6 @@ void SixenseManager::update(float deltaTime) {
|
||||||
sixenseControllerData data;
|
sixenseControllerData data;
|
||||||
sixenseGetNewestData(i, &data);
|
sixenseGetNewestData(i, &data);
|
||||||
|
|
||||||
// drive avatar with joystick and triggers
|
|
||||||
if (data.controller_index) {
|
|
||||||
avatar->setDriveKeys(ROT_LEFT, qMax(0.0f, -data.joystick_x));
|
|
||||||
avatar->setDriveKeys(ROT_RIGHT, qMax(0.0f, data.joystick_x));
|
|
||||||
avatar->setDriveKeys(ROT_UP, qMax(0.0f, data.joystick_y));
|
|
||||||
avatar->setDriveKeys(ROT_DOWN, qMax(0.0f, -data.joystick_y));
|
|
||||||
avatar->setDriveKeys(UP, data.trigger);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
avatar->setDriveKeys(FWD, qMax(0.0f, data.joystick_y));
|
|
||||||
avatar->setDriveKeys(BACK, qMax(0.0f, -data.joystick_y));
|
|
||||||
avatar->setDriveKeys(LEFT, qMax(0.0f, -data.joystick_x));
|
|
||||||
avatar->setDriveKeys(RIGHT, qMax(0.0f, data.joystick_x));
|
|
||||||
avatar->setDriveKeys(DOWN, data.trigger);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set palm position and normal based on Hydra position/orientation
|
// Set palm position and normal based on Hydra position/orientation
|
||||||
PalmData palm(&hand);
|
PalmData palm(&hand);
|
||||||
palm.setActive(true);
|
palm.setActive(true);
|
||||||
|
@ -68,6 +52,7 @@ void SixenseManager::update(float deltaTime) {
|
||||||
|
|
||||||
// Read controller buttons into the hand
|
// Read controller buttons into the hand
|
||||||
palm.setControllerButtons(data.buttons);
|
palm.setControllerButtons(data.buttons);
|
||||||
|
palm.setTrigger(data.trigger);
|
||||||
|
|
||||||
// Adjust for distance between acquisition 'orb' and the user's torso
|
// Adjust for distance between acquisition 'orb' and the user's torso
|
||||||
// (distance to the right of body center, distance below torso, distance behind torso)
|
// (distance to the right of body center, distance below torso, distance behind torso)
|
||||||
|
|
|
@ -161,12 +161,16 @@ public:
|
||||||
void setControllerButtons(int controllerButtons) { _controllerButtons = controllerButtons; }
|
void setControllerButtons(int controllerButtons) { _controllerButtons = controllerButtons; }
|
||||||
int getControllerButtons() { return _controllerButtons; }
|
int getControllerButtons() { return _controllerButtons; }
|
||||||
|
|
||||||
|
void setTrigger(float trigger) { _trigger = trigger; }
|
||||||
|
float getTrigger() { return _trigger; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<FingerData> _fingers;
|
std::vector<FingerData> _fingers;
|
||||||
glm::vec3 _rawPosition;
|
glm::vec3 _rawPosition;
|
||||||
glm::vec3 _rawNormal;
|
glm::vec3 _rawNormal;
|
||||||
glm::vec3 _velocity;
|
glm::vec3 _velocity;
|
||||||
int _controllerButtons;
|
int _controllerButtons;
|
||||||
|
float _trigger;
|
||||||
|
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue