Rave Glove demo: activation mode and stage (dark backdrop) drawing.

This commit is contained in:
Eric Johnston 2013-07-16 18:10:54 -07:00
parent 57a722a7bd
commit 39130aef58
3 changed files with 36 additions and 0 deletions

View file

@ -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());

View file

@ -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

View file

@ -46,9 +46,11 @@ public:
const std::vector<glm::vec3>& fingerRoots);
void setLeapHands (const std::vector<glm::vec3>& handPositions,
const std::vector<glm::vec3>& 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<HandBall> _leapBalls;
// private methods
void renderRaveGloveStage();
void renderHandSpheres();
void calculateGeometry();
};