From 52b33cb46607fad6ec28baac0a70d56161edd9bc Mon Sep 17 00:00:00 2001 From: Eric Johnston Date: Wed, 7 Aug 2013 16:19:54 -0700 Subject: [PATCH] Rave tweaks: Improvements to finger trails and hand rendering --- interface/src/avatar/Hand.cpp | 47 ++++++++++++++++++++---------- libraries/avatars/src/HandData.cpp | 7 ++--- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index a8939d8c1a..96b34d9aae 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -230,6 +230,8 @@ void Hand::renderLeapHands() { //const glm::vec3 handColor = _ballColor; const glm::vec3 handColor(1.0, 0.84, 0.66); // use the skin color + glDisable(GL_DEPTH_TEST); + glDepthMask(GL_FALSE); glPushMatrix(); // Draw the leap balls for (size_t i = 0; i < _leapFingerTipBalls.size(); i++) { @@ -270,12 +272,15 @@ void Hand::renderLeapHands() { Avatar::renderJointConnectingCone(root, tip, 0.05, 0.03); } } + glDepthMask(GL_TRUE); + glEnable(GL_DEPTH_TEST); glPopMatrix(); } void Hand::renderLeapFingerTrails() { // Draw the finger root cones + glDisable(GL_LIGHTING); for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; if (palm.isActive()) { @@ -287,12 +292,13 @@ void Hand::renderLeapFingerTrails() { for (int t = 0; t < numPositions; ++t) { const glm::vec3& center = finger.getTrailPosition(t); - const float halfWidth = 0.001f; + const float halfWidth = 0.004f; const glm::vec3 edgeDirection(1.0f, 0.0f, 0.0f); glm::vec3 edge0 = center + edgeDirection * halfWidth; glm::vec3 edge1 = center - edgeDirection * halfWidth; float alpha = 1.0f - ((float)t / (float)(numPositions - 1)); - glColor4f(1.0f, 0.0f, 0.0f, alpha); + alpha *= 0.25f; + glColor4f(1.0f, 1.0f, 1.0f, alpha); glVertex3fv((float*)&edge0); glVertex3fv((float*)&edge1); } @@ -301,6 +307,7 @@ void Hand::renderLeapFingerTrails() { } } } + glEnable(GL_LIGHTING); } @@ -322,25 +329,35 @@ void Hand::setLeapHands(const std::vector& handPositions, // call this soon after the geometry of the leap hands are set void Hand::updateRaveGloveEmitters() { + int emitterIndex = 0; for (size_t i = 0; i < NUM_FINGERS; i++) { _raveGloveParticleSystem.setEmitterActive(_raveGloveEmitter[i], false); } - for (size_t i = 0; i < _leapFingerTipBalls.size(); i++) { - if (i < NUM_FINGERS) { - glm::vec3 fingerDirection = _leapFingerTipBalls[i].position - _leapFingerRootBalls[i].position; - float fingerLength = glm::length(fingerDirection); - - if (fingerLength > 0.0f) { - fingerDirection /= fingerLength; - } else { - fingerDirection = IDENTITY_UP; + for (size_t palmIndex = 0; palmIndex < getNumPalms(); ++palmIndex) { + PalmData& palm = getPalms()[palmIndex]; + if (palm.isActive()) { + for (size_t f = 0; f < palm.getNumFingers(); ++f) { + FingerData& finger = palm.getFingers()[f]; + if (finger.isActive()) { + if (emitterIndex < NUM_FINGERS) { // safety, stop at the array size + glm::vec3 fingerDirection = finger.getTipPosition() - finger.getRootPosition(); + float fingerLength = glm::length(fingerDirection); + + if (fingerLength > 0.0f) { + fingerDirection /= fingerLength; + } else { + fingerDirection = IDENTITY_UP; + } + + _raveGloveParticleSystem.setEmitterActive (_raveGloveEmitter[emitterIndex], true); + _raveGloveParticleSystem.setEmitterPosition (_raveGloveEmitter[emitterIndex], finger.getTipPosition()); + _raveGloveParticleSystem.setEmitterDirection(_raveGloveEmitter[emitterIndex], fingerDirection); + } + } + emitterIndex++; } - - _raveGloveParticleSystem.setEmitterActive (_raveGloveEmitter[i], true); - _raveGloveParticleSystem.setEmitterPosition (_raveGloveEmitter[i], _leapFingerTipBalls[i].position); - _raveGloveParticleSystem.setEmitterDirection(_raveGloveEmitter[i], fingerDirection); } } } diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index 2f6e8aa560..e00854e2b5 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -55,7 +55,7 @@ _numFramesWithoutData(0), _owningPalmData(owningPalmData), _owningHandData(owningHandData) { - const int standardTrailLength = 30; + const int standardTrailLength = 10; setTrailLength(standardTrailLength); } @@ -222,9 +222,8 @@ void FingerData::updateTrail() { _tipTrailCurrentValidLength++; } else { - // It's not active, so just shorten the trail. - if (_tipTrailCurrentValidLength > 0) - _tipTrailCurrentValidLength--; + // It's not active, so just kill the trail. + _tipTrailCurrentValidLength = 0; } }