From 39130aef58424cd36e20cf04d2041989df91dc32 Mon Sep 17 00:00:00 2001 From: Eric Johnston Date: Tue, 16 Jul 2013 18:10:54 -0700 Subject: [PATCH] Rave Glove demo: activation mode and stage (dark backdrop) drawing. --- interface/src/Application.cpp | 1 + interface/src/Hand.cpp | 31 +++++++++++++++++++++++++++++++ interface/src/Hand.h | 4 ++++ 3 files changed, 36 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 1bfba999b1..791353abdb 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2033,6 +2033,7 @@ void Application::update(float deltaTime) { // Leap finger-sensing device LeapManager::enableFakeFingers(_simulateLeapHand->isChecked() || _testRaveGlove->isChecked()); LeapManager::nextFrame(); + _myAvatar.getHand().setRaveGloveActive(_testRaveGlove->isChecked()); _myAvatar.getHand().setLeapFingers(LeapManager::getFingerTips(), LeapManager::getFingerRoots()); _myAvatar.getHand().setLeapHands(LeapManager::getHandPositions(), LeapManager::getHandNormals()); diff --git a/interface/src/Hand.cpp b/interface/src/Hand.cpp index 29a2c32bf1..d0ff0abd5a 100755 --- a/interface/src/Hand.cpp +++ b/interface/src/Hand.cpp @@ -74,12 +74,43 @@ void Hand::render(bool lookingInMirror) { calculateGeometry(); + if (_isRaveGloveActive) + renderRaveGloveStage(); + glEnable(GL_DEPTH_TEST); glEnable(GL_RESCALE_NORMAL); renderHandSpheres(); } +void Hand::renderRaveGloveStage() { + if (_owningAvatar && _owningAvatar->isMyAvatar()) { + Head& head = _owningAvatar->getHead(); + glm::quat headOrientation = head.getOrientation(); + glm::vec3 headPosition = head.getPosition(); + float scale = 100.0f; + glm::vec3 vc = headOrientation * glm::vec3( 0.0f, 0.0f, -30.0f) + headPosition; + glm::vec3 v0 = headOrientation * (glm::vec3(-1.0f, -1.0f, 0.0f) * scale) + vc; + glm::vec3 v1 = headOrientation * (glm::vec3( 1.0f, -1.0f, 0.0f) * scale) + vc; + glm::vec3 v2 = headOrientation * (glm::vec3( 1.0f, 1.0f, 0.0f) * scale) + vc; + glm::vec3 v3 = headOrientation * (glm::vec3(-1.0f, 1.0f, 0.0f) * scale) + vc; + + glDisable(GL_DEPTH_TEST); + glEnable(GL_BLEND); + glBegin(GL_TRIANGLE_FAN); + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + glVertex3fv((float*)&vc); + glColor4f(0.0f, 0.0f, 0.0f, 0.5f); + glVertex3fv((float*)&v0); + glVertex3fv((float*)&v1); + glVertex3fv((float*)&v2); + glVertex3fv((float*)&v3); + glVertex3fv((float*)&v0); + glEnd(); + glEnable(GL_DEPTH_TEST); + } +} + void Hand::renderHandSpheres() { glPushMatrix(); // Draw the leap balls diff --git a/interface/src/Hand.h b/interface/src/Hand.h index 1c25c85fbc..e1b0dc9ff0 100755 --- a/interface/src/Hand.h +++ b/interface/src/Hand.h @@ -46,9 +46,11 @@ public: const std::vector& fingerRoots); void setLeapHands (const std::vector& handPositions, const std::vector& handNormals); + void setRaveGloveActive(bool active) { _isRaveGloveActive = active; } // getters const glm::vec3& getLeapBallPosition (int ball) const { return _leapBalls[ball].position;} + bool isRaveGloveActive () const { return _isRaveGloveActive; } // position conversion glm::vec3 leapPositionToWorldPosition(const glm::vec3& leapPosition); @@ -61,12 +63,14 @@ private: Avatar* _owningAvatar; float _renderAlpha; bool _lookingInMirror; + bool _isRaveGloveActive; glm::vec3 _ballColor; glm::vec3 _position; glm::quat _orientation; std::vector _leapBalls; // private methods + void renderRaveGloveStage(); void renderHandSpheres(); void calculateGeometry(); };