mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:38:02 +02:00
Merge branch 'master' of https://github.com/worklist/hifi into master-old
This commit is contained in:
commit
98ae23a72c
6 changed files with 73 additions and 15 deletions
|
@ -1677,6 +1677,8 @@ void Application::initMenu() {
|
||||||
(_renderCoverageMapV2 = debugMenu->addAction("Render Coverage Map V2"))->setCheckable(true);
|
(_renderCoverageMapV2 = debugMenu->addAction("Render Coverage Map V2"))->setCheckable(true);
|
||||||
_renderCoverageMapV2->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_P);
|
_renderCoverageMapV2->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::Key_P);
|
||||||
|
|
||||||
|
(_simulateLeapHand = debugMenu->addAction("Simulate Leap Hand"))->setCheckable(true);
|
||||||
|
(_testRaveGlove = debugMenu->addAction("Test RaveGlove"))->setCheckable(true);
|
||||||
|
|
||||||
QMenu* settingsMenu = menuBar->addMenu("Settings");
|
QMenu* settingsMenu = menuBar->addMenu("Settings");
|
||||||
(_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true);
|
(_settingsAutosave = settingsMenu->addAction("Autosave"))->setCheckable(true);
|
||||||
|
@ -1935,6 +1937,7 @@ void Application::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leap finger-sensing device
|
// Leap finger-sensing device
|
||||||
|
LeapManager::enableFakeFingers(_simulateLeapHand->isChecked() || _testRaveGlove->isChecked());
|
||||||
LeapManager::nextFrame();
|
LeapManager::nextFrame();
|
||||||
_myAvatar.getHand().setLeapFingers(LeapManager::getFingerTips(), LeapManager::getFingerRoots());
|
_myAvatar.getHand().setLeapFingers(LeapManager::getFingerTips(), LeapManager::getFingerRoots());
|
||||||
_myAvatar.getHand().setLeapHands(LeapManager::getHandPositions(), LeapManager::getHandNormals());
|
_myAvatar.getHand().setLeapHands(LeapManager::getHandPositions(), LeapManager::getHandNormals());
|
||||||
|
|
|
@ -262,6 +262,9 @@ private:
|
||||||
|
|
||||||
QAction* _renderCoverageMapV2;
|
QAction* _renderCoverageMapV2;
|
||||||
QAction* _renderCoverageMap;
|
QAction* _renderCoverageMap;
|
||||||
|
|
||||||
|
QAction* _simulateLeapHand; // When there's no Leap, use this to pretend there is one and feed fake hand data
|
||||||
|
QAction* _testRaveGlove; // Test fancy sparkle-rave-glove mode
|
||||||
|
|
||||||
BandwidthMeter _bandwidthMeter;
|
BandwidthMeter _bandwidthMeter;
|
||||||
BandwidthDialog* _bandwidthDialog;
|
BandwidthDialog* _bandwidthDialog;
|
||||||
|
|
|
@ -50,6 +50,9 @@ public:
|
||||||
// getters
|
// getters
|
||||||
const glm::vec3& getLeapBallPosition (int ball) const { return _leapBalls[ball].position;}
|
const glm::vec3& getLeapBallPosition (int ball) const { return _leapBalls[ball].position;}
|
||||||
|
|
||||||
|
// position conversion
|
||||||
|
glm::vec3 leapPositionToWorldPosition(const glm::vec3& leapPosition);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// disallow copies of the Hand, copy of owning Avatar is disallowed too
|
// disallow copies of the Hand, copy of owning Avatar is disallowed too
|
||||||
Hand(const Hand&);
|
Hand(const Hand&);
|
||||||
|
@ -66,7 +69,6 @@ private:
|
||||||
// private methods
|
// private methods
|
||||||
void renderHandSpheres();
|
void renderHandSpheres();
|
||||||
void calculateGeometry();
|
void calculateGeometry();
|
||||||
glm::vec3 leapPositionToWorldPosition(const glm::vec3& leapPosition);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,9 +12,14 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
bool LeapManager::_libraryExists = false;
|
bool LeapManager::_libraryExists = false;
|
||||||
|
bool LeapManager::_doFakeFingers = false;
|
||||||
Leap::Controller* LeapManager::_controller = NULL;
|
Leap::Controller* LeapManager::_controller = NULL;
|
||||||
HifiLeapListener* LeapManager::_listener = NULL;
|
HifiLeapListener* LeapManager::_listener = NULL;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
glm::vec3 fakeHandOffset(0.0f, 50.0f, 50.0f);
|
||||||
|
} // end anonymous namespace
|
||||||
|
|
||||||
class HifiLeapListener : public Leap::Listener {
|
class HifiLeapListener : public Leap::Listener {
|
||||||
public:
|
public:
|
||||||
HifiLeapListener() {}
|
HifiLeapListener() {}
|
||||||
|
@ -76,47 +81,87 @@ void LeapManager::terminate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeapManager::nextFrame() {
|
void LeapManager::nextFrame() {
|
||||||
if (_listener && _controller)
|
if (controllersExist()) {
|
||||||
_listener->onFrame(*_controller);
|
_listener->onFrame(*_controller);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LeapManager::enableFakeFingers(bool enable) {
|
||||||
|
_doFakeFingers = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LeapManager::controllersExist() {
|
||||||
|
return _listener && _controller && _controller->devices().count() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<glm::vec3>& LeapManager::getFingerTips() {
|
const std::vector<glm::vec3>& LeapManager::getFingerTips() {
|
||||||
if (_listener) {
|
if (controllersExist()) {
|
||||||
return _listener->fingerTips;
|
return _listener->fingerTips;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
static std::vector<glm::vec3> empty;
|
static std::vector<glm::vec3> stubData;
|
||||||
return empty;
|
stubData.clear();
|
||||||
|
if (_doFakeFingers) {
|
||||||
|
// Simulated data
|
||||||
|
float scale = 1.5f;
|
||||||
|
stubData.push_back(glm::vec3( -60.0f, 0.0f, -40.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( -20.0f, 0.0f, -60.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( 20.0f, 0.0f, -60.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( 60.0f, 0.0f, -40.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( -50.0f, 0.0f, 30.0f) * scale + fakeHandOffset);
|
||||||
|
}
|
||||||
|
return stubData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<glm::vec3>& LeapManager::getFingerRoots() {
|
const std::vector<glm::vec3>& LeapManager::getFingerRoots() {
|
||||||
if (_listener) {
|
if (controllersExist()) {
|
||||||
return _listener->fingerRoots;
|
return _listener->fingerRoots;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
static std::vector<glm::vec3> empty;
|
static std::vector<glm::vec3> stubData;
|
||||||
return empty;
|
stubData.clear();
|
||||||
|
if (_doFakeFingers) {
|
||||||
|
// Simulated data
|
||||||
|
float scale = 0.75f;
|
||||||
|
stubData.push_back(glm::vec3( -60.0f, 0.0f, -40.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( -20.0f, 0.0f, -60.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( 20.0f, 0.0f, -60.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( 60.0f, 0.0f, -40.0f) * scale + fakeHandOffset);
|
||||||
|
stubData.push_back(glm::vec3( -50.0f, 0.0f, 30.0f) * scale + fakeHandOffset);
|
||||||
|
}
|
||||||
|
return stubData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<glm::vec3>& LeapManager::getHandPositions() {
|
const std::vector<glm::vec3>& LeapManager::getHandPositions() {
|
||||||
if (_listener) {
|
if (controllersExist()) {
|
||||||
return _listener->handPositions;
|
return _listener->handPositions;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
static std::vector<glm::vec3> empty;
|
static std::vector<glm::vec3> stubData;
|
||||||
return empty;
|
stubData.clear();
|
||||||
|
if (_doFakeFingers) {
|
||||||
|
// Simulated data
|
||||||
|
glm::vec3 handOffset(0.0f, 50.0f, 50.0f);
|
||||||
|
stubData.push_back(glm::vec3( 0.0f, 0.0f, 0.0f) + fakeHandOffset);
|
||||||
|
}
|
||||||
|
return stubData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<glm::vec3>& LeapManager::getHandNormals() {
|
const std::vector<glm::vec3>& LeapManager::getHandNormals() {
|
||||||
if (_listener) {
|
if (controllersExist()) {
|
||||||
return _listener->handNormals;
|
return _listener->handNormals;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
static std::vector<glm::vec3> empty;
|
static std::vector<glm::vec3> stubData;
|
||||||
return empty;
|
stubData.clear();
|
||||||
|
if (_doFakeFingers) {
|
||||||
|
// Simulated data
|
||||||
|
stubData.push_back(glm::vec3(0.0f, 1.0f, 0.0f));
|
||||||
|
}
|
||||||
|
return stubData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,9 @@ namespace Leap {
|
||||||
|
|
||||||
class LeapManager {
|
class LeapManager {
|
||||||
public:
|
public:
|
||||||
static void nextFrame(); // called once per frame to get new Leap data
|
static void nextFrame(); // called once per frame to get new Leap data
|
||||||
|
static bool controllersExist(); // Returns true if there's at least one active Leap plugged in
|
||||||
|
static void enableFakeFingers(bool enable); // put fake data in if there's no Leap plugged in
|
||||||
static const std::vector<glm::vec3>& getFingerTips();
|
static const std::vector<glm::vec3>& getFingerTips();
|
||||||
static const std::vector<glm::vec3>& getFingerRoots();
|
static const std::vector<glm::vec3>& getFingerRoots();
|
||||||
static const std::vector<glm::vec3>& getHandPositions();
|
static const std::vector<glm::vec3>& getHandPositions();
|
||||||
|
@ -31,6 +33,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool _libraryExists; // The library is present, so we won't crash if we call it.
|
static bool _libraryExists; // The library is present, so we won't crash if we call it.
|
||||||
|
static bool _doFakeFingers;
|
||||||
static Leap::Controller* _controller;
|
static Leap::Controller* _controller;
|
||||||
static HifiLeapListener* _listener;
|
static HifiLeapListener* _listener;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,8 @@ class HandData {
|
||||||
public:
|
public:
|
||||||
HandData(AvatarData* owningAvatar);
|
HandData(AvatarData* owningAvatar);
|
||||||
|
|
||||||
|
// These methods return the positions in Leap-relative space.
|
||||||
|
// To convert to world coordinates, use Hand::leapPositionToWorldPosition.
|
||||||
const std::vector<glm::vec3>& getFingerTips() const { return _fingerTips; }
|
const std::vector<glm::vec3>& getFingerTips() const { return _fingerTips; }
|
||||||
const std::vector<glm::vec3>& getFingerRoots() const { return _fingerRoots; }
|
const std::vector<glm::vec3>& getFingerRoots() const { return _fingerRoots; }
|
||||||
const std::vector<glm::vec3>& getHandPositions() const { return _handPositions; }
|
const std::vector<glm::vec3>& getHandPositions() const { return _handPositions; }
|
||||||
|
|
Loading…
Reference in a new issue