mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 18:44:00 +02:00
Add button detection for hydra controller to palmData
This commit is contained in:
parent
9680941500
commit
abca79ea3e
5 changed files with 31 additions and 2 deletions
|
@ -157,6 +157,15 @@ void Hand::render() {
|
|||
}
|
||||
}
|
||||
|
||||
// If hand controller buttons pressed, render stuff
|
||||
if (getPalms().size() > 0) {
|
||||
for (size_t i = 0; i < getPalms().size(); ++i) {
|
||||
PalmData& palm = getPalms()[i];
|
||||
//printf("buttons = %i\n", palm.getControllerButtons());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ enum RaveLightsSetting {
|
|||
RAVE_LIGHTS_PARTICLES
|
||||
};
|
||||
|
||||
|
||||
class Avatar;
|
||||
class ProgramObject;
|
||||
|
||||
|
@ -46,7 +47,7 @@ public:
|
|||
bool isCollidable; // whether or not the ball responds to collisions
|
||||
float touchForce; // a scalar determining the amount that the cursor (or hand) is penetrating the ball
|
||||
};
|
||||
|
||||
|
||||
void init();
|
||||
void reset();
|
||||
void simulate(float deltaTime, bool isMine);
|
||||
|
@ -62,7 +63,7 @@ public:
|
|||
// getters
|
||||
const glm::vec3& getLeapFingerTipBallPosition (int ball) const { return _leapFingerTipBalls [ball].position;}
|
||||
const glm::vec3& getLeapFingerRootBallPosition(int ball) const { return _leapFingerRootBalls[ball].position;}
|
||||
|
||||
|
||||
private:
|
||||
// disallow copies of the Hand, copy of owning Avatar is disallowed too
|
||||
Hand(const Hand&);
|
||||
|
@ -72,6 +73,8 @@ private:
|
|||
float _raveGloveClock;
|
||||
bool _raveGloveInitialized;
|
||||
int _raveGloveEmitter[NUM_FINGERS];
|
||||
|
||||
int _controllerButtons; /// Button states read from hand-held controllers
|
||||
|
||||
Avatar* _owningAvatar;
|
||||
float _renderAlpha;
|
||||
|
|
|
@ -66,6 +66,9 @@ void SixenseManager::update(float deltaTime) {
|
|||
// Compute current velocity from position change
|
||||
palm.setVelocity((position - palm.getPosition()) / deltaTime);
|
||||
|
||||
// Read controller buttons into the hand
|
||||
palm.setControllerButtons(data.buttons);
|
||||
|
||||
// Adjust for distance between acquisition 'orb' and the user's torso
|
||||
// (distance to the right of body center, distance below torso, distance behind torso)
|
||||
const glm::vec3 SPHERE_TO_TORSO(-250.f, -300.f, -300.f);
|
||||
|
|
|
@ -37,6 +37,8 @@ PalmData& HandData::addNewPalm() {
|
|||
PalmData::PalmData(HandData* owningHandData) :
|
||||
_rawPosition(0, 0, 0),
|
||||
_rawNormal(0, 1, 0),
|
||||
_velocity(0, 0, 0),
|
||||
_controllerButtons(0),
|
||||
_isActive(false),
|
||||
_leapID(LEAPID_INVALID),
|
||||
_numFramesWithoutData(0),
|
||||
|
|
|
@ -41,6 +41,12 @@ enum RaveGloveEffectsMode
|
|||
NUM_RAVE_GLOVE_EFFECTS_MODES
|
||||
};
|
||||
|
||||
const int BUTTON_1 = 32;
|
||||
const int BUTTON_2 = 64;
|
||||
const int BUTTON_3 = 8;
|
||||
const int BUTTON_4 = 16;
|
||||
const int BUTTON_FWD = 128;
|
||||
|
||||
class HandData {
|
||||
public:
|
||||
HandData(AvatarData* owningAvatar);
|
||||
|
@ -150,12 +156,18 @@ public:
|
|||
void incrementFramesWithoutData() { _numFramesWithoutData++; }
|
||||
void resetFramesWithoutData() { _numFramesWithoutData = 0; }
|
||||
int getFramesWithoutData() const { return _numFramesWithoutData; }
|
||||
|
||||
// Controller buttons
|
||||
void setControllerButtons(int controllerButtons) { _controllerButtons = controllerButtons; }
|
||||
int getControllerButtons() { return _controllerButtons; }
|
||||
|
||||
private:
|
||||
std::vector<FingerData> _fingers;
|
||||
glm::vec3 _rawPosition;
|
||||
glm::vec3 _rawNormal;
|
||||
glm::vec3 _velocity;
|
||||
int _controllerButtons;
|
||||
|
||||
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.
|
||||
|
|
Loading…
Reference in a new issue