From a7dacec63d58049500ac36c3aeafa8f56bd1d2b1 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 5 Dec 2013 13:36:00 -0800 Subject: [PATCH 1/6] =?UTF-8?q?Don=E2=80=99t=20render=20collision=20if=20n?= =?UTF-8?q?ot=20own=20avatar,=20=20don=E2=80=99t=20check=20for=20collision?= =?UTF-8?q?s=20with=20voxel=20tree=20if=20not=20me.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface/src/avatar/Avatar.cpp | 2 +- interface/src/avatar/Hand.cpp | 191 +++++++++++++++--------------- interface/src/avatar/Hand.h | 2 +- interface/src/avatar/MyAvatar.cpp | 2 +- 4 files changed, 100 insertions(+), 97 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 0db3e6e3ee..85fed15911 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -785,7 +785,7 @@ void Avatar::renderBody(bool forceRenderHead) { _head.render(alpha, false); } } - _hand.render(); + _hand.render(false); } void Avatar::getSkinColors(glm::vec3& lighter, glm::vec3& darker) { diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 83843eb827..35b8f167cc 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -70,56 +70,58 @@ void Hand::simulate(float deltaTime, bool isMine) { updateRaveGloveParticles(deltaTime); } - // Create a voxel at fingertip if controller button is pressed - const float FINGERTIP_VOXEL_SIZE = 0.0125; - for (size_t i = 0; i < getNumPalms(); ++i) { - PalmData& palm = getPalms()[i]; - if (palm.isActive()) { - FingerData& finger = palm.getFingers()[0]; // Sixense has only one finger - glm::vec3 fingerTipPosition = finger.getTipPosition(); - if (palm.getControllerButtons() & BUTTON_1) { - if (glm::length(fingerTipPosition - _lastFingerAddVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) { - QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value(); - Application::getInstance()->makeVoxel(fingerTipPosition, - FINGERTIP_VOXEL_SIZE, - paintColor.red(), - paintColor.green(), - paintColor.blue(), - true); - _lastFingerAddVoxel = fingerTipPosition; + if (isMine) { + // Create a voxel at fingertip if controller button is pressed + const float FINGERTIP_VOXEL_SIZE = 0.0125; + for (size_t i = 0; i < getNumPalms(); ++i) { + PalmData& palm = getPalms()[i]; + if (palm.isActive()) { + FingerData& finger = palm.getFingers()[0]; // Sixense has only one finger + glm::vec3 fingerTipPosition = finger.getTipPosition(); + if (palm.getControllerButtons() & BUTTON_1) { + if (glm::length(fingerTipPosition - _lastFingerAddVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) { + QColor paintColor = Menu::getInstance()->getActionForOption(MenuOption::VoxelPaintColor)->data().value(); + Application::getInstance()->makeVoxel(fingerTipPosition, + FINGERTIP_VOXEL_SIZE, + paintColor.red(), + paintColor.green(), + paintColor.blue(), + true); + _lastFingerAddVoxel = fingerTipPosition; + } + } else if (palm.getControllerButtons() & BUTTON_2) { + if (glm::length(fingerTipPosition - _lastFingerDeleteVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) { + Application::getInstance()->removeVoxel(fingerTipPosition, FINGERTIP_VOXEL_SIZE); + _lastFingerDeleteVoxel = fingerTipPosition; + } } - } else if (palm.getControllerButtons() & BUTTON_2) { - if (glm::length(fingerTipPosition - _lastFingerDeleteVoxel) > (FINGERTIP_VOXEL_SIZE / 2.f)) { - Application::getInstance()->removeVoxel(fingerTipPosition, FINGERTIP_VOXEL_SIZE); - _lastFingerDeleteVoxel = fingerTipPosition; - } - } - // Check if the finger is intersecting with a voxel in the client voxel tree - VoxelTreeElement* fingerNode = Application::getInstance()->getVoxels()->getVoxelEnclosing( - glm::vec3(fingerTipPosition / (float)TREE_SCALE)); - if (fingerNode) { - if (!palm.getIsCollidingWithVoxel()) { - // Collision has just started - palm.setIsCollidingWithVoxel(true); - handleVoxelCollision(&palm, fingerTipPosition, fingerNode, deltaTime); - // Set highlight voxel - VoxelDetail voxel; - glm::vec3 pos = fingerNode->getCorner(); - voxel.x = pos.x; - voxel.y = pos.y; - voxel.z = pos.z; - voxel.s = fingerNode->getScale(); - voxel.red = fingerNode->getColor()[0]; - voxel.green = fingerNode->getColor()[1]; - voxel.blue = fingerNode->getColor()[2]; - Application::getInstance()->setHighlightVoxel(voxel); - Application::getInstance()->setIsHighlightVoxel(true); - } - } else { - if (palm.getIsCollidingWithVoxel()) { - // Collision has just ended - palm.setIsCollidingWithVoxel(false); - Application::getInstance()->setIsHighlightVoxel(false); + // Check if the finger is intersecting with a voxel in the client voxel tree + VoxelTreeElement* fingerNode = Application::getInstance()->getVoxels()->getVoxelEnclosing( + glm::vec3(fingerTipPosition / (float)TREE_SCALE)); + if (fingerNode) { + if (!palm.getIsCollidingWithVoxel()) { + // Collision has just started + palm.setIsCollidingWithVoxel(true); + handleVoxelCollision(&palm, fingerTipPosition, fingerNode, deltaTime); + // Set highlight voxel + VoxelDetail voxel; + glm::vec3 pos = fingerNode->getCorner(); + voxel.x = pos.x; + voxel.y = pos.y; + voxel.z = pos.z; + voxel.s = fingerNode->getScale(); + voxel.red = fingerNode->getColor()[0]; + voxel.green = fingerNode->getColor()[1]; + voxel.blue = fingerNode->getColor()[2]; + Application::getInstance()->setHighlightVoxel(voxel); + Application::getInstance()->setIsHighlightVoxel(true); + } + } else { + if (palm.getIsCollidingWithVoxel()) { + // Collision has just ended + palm.setIsCollidingWithVoxel(false); + Application::getInstance()->setIsHighlightVoxel(false); + } } } } @@ -217,7 +219,7 @@ void Hand::setRaveGloveEffectsMode(QKeyEvent* event) { }; } -void Hand::render() { +void Hand::render( bool isMine) { _renderAlpha = 1.0; @@ -229,6 +231,7 @@ void Hand::render() { // Use mood lighting for the hand itself setRaveLights(RAVE_LIGHTS_AVATAR); } + renderLeapFingerTrails(); renderLeapHands(); } @@ -242,54 +245,54 @@ void Hand::render() { } } - // If hand/voxel collision has happened, render a little expanding sphere - if (_collisionAge > 0.f) { - float opacity = glm::clamp(1.f - (_collisionAge / _collisionDuration), 0.f, 1.f); - glColor4f(1, 0, 0, 0.5 * opacity); - glPushMatrix(); - glTranslatef(_collisionCenter.x, _collisionCenter.y, _collisionCenter.z); - glutSolidSphere(_collisionAge * 0.25f, 20, 20); - glPopMatrix(); - if (_collisionAge > _collisionDuration) { - _collisionAge = 0.f; + if (isMine) { + // If hand/voxel collision has happened, render a little expanding sphere + if (_collisionAge > 0.f) { + float opacity = glm::clamp(1.f - (_collisionAge / _collisionDuration), 0.f, 1.f); + glColor4f(1, 0, 0, 0.5 * opacity); + glPushMatrix(); + glTranslatef(_collisionCenter.x, _collisionCenter.y, _collisionCenter.z); + glutSolidSphere(_collisionAge * 0.25f, 20, 20); + glPopMatrix(); + if (_collisionAge > _collisionDuration) { + _collisionAge = 0.f; + } } - } + // If hand controller buttons pressed, render stuff as needed + if (getPalms().size() > 0) { + for (size_t i = 0; i < getPalms().size(); ++i) { + PalmData& palm = getPalms()[i]; + // If trigger pulled, thrust in that direction and draw beam + const float MAX_THRUSTER_BEAM_LENGTH = 5.f; + const float THRUSTER_MARKER_SIZE = 0.0125f; + if (palm.getJoystickY() != 0.f) { + FingerData& finger = palm.getFingers()[0]; + if (finger.isActive()) { + if (palm.getJoystickY() > 0.f) { + glColor3f(0, 1, 0); + } else { + glColor3f(1, 0, 0); + } + glm::vec3 palmPosition = palm.getPosition(); + glm::vec3 pointerPosition = palmPosition + + glm::normalize(finger.getTipPosition() - palmPosition) * + MAX_THRUSTER_BEAM_LENGTH; + glPushMatrix(); + glm::vec3 markerPosition = palmPosition + + glm::normalize(finger.getTipPosition() - palmPosition) * + MAX_THRUSTER_BEAM_LENGTH * + (0.5f + palm.getJoystickY() / 2.f); - - // If hand controller buttons pressed, render stuff as needed - if (getPalms().size() > 0) { - for (size_t i = 0; i < getPalms().size(); ++i) { - PalmData& palm = getPalms()[i]; - // If trigger pulled, thrust in that direction and draw beam - const float MAX_THRUSTER_BEAM_LENGTH = 5.f; - const float THRUSTER_MARKER_SIZE = 0.0125f; - if (palm.getJoystickY() != 0.f) { - FingerData& finger = palm.getFingers()[0]; - if (finger.isActive()) { - if (palm.getJoystickY() > 0.f) { - glColor3f(0, 1, 0); - } else { - glColor3f(1, 0, 0); + glTranslatef(markerPosition.x, markerPosition.y, markerPosition.z); + glutSolidSphere(THRUSTER_MARKER_SIZE, 10, 10); + glPopMatrix(); + glLineWidth(2.0); + glBegin(GL_LINES); + glVertex3f(palmPosition.x, palmPosition.y, palmPosition.z); + glVertex3f(pointerPosition.x, pointerPosition.y, pointerPosition.z); + glEnd(); } - glm::vec3 palmPosition = palm.getPosition(); - glm::vec3 pointerPosition = palmPosition + - glm::normalize(finger.getTipPosition() - palmPosition) * - MAX_THRUSTER_BEAM_LENGTH; - glPushMatrix(); - glm::vec3 markerPosition = palmPosition + - glm::normalize(finger.getTipPosition() - palmPosition) * - MAX_THRUSTER_BEAM_LENGTH * - (0.5f + palm.getJoystickY() / 2.f); - - glTranslatef(markerPosition.x, markerPosition.y, markerPosition.z); - glutSolidSphere(THRUSTER_MARKER_SIZE, 10, 10); - glPopMatrix(); - glLineWidth(2.0); - glBegin(GL_LINES); - glVertex3f(palmPosition.x, palmPosition.y, palmPosition.z); - glVertex3f(pointerPosition.x, pointerPosition.y, pointerPosition.z); - glEnd(); } } } diff --git a/interface/src/avatar/Hand.h b/interface/src/avatar/Hand.h index e4e9ad4b50..83d4a7f8a6 100755 --- a/interface/src/avatar/Hand.h +++ b/interface/src/avatar/Hand.h @@ -52,7 +52,7 @@ public: void init(); void reset(); void simulate(float deltaTime, bool isMine); - void render(); + void render(bool isMine); void renderRaveGloveStage(); void setRaveLights(RaveLightsSetting setting); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 1b1caac90f..833e6a4d4b 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -728,7 +728,7 @@ void MyAvatar::renderBody(bool forceRenderHead) { _head.render(alpha, false); } } - _hand.render(); + _hand.render(true); } void MyAvatar::updateThrust(float deltaTime, Transmitter * transmitter) { From 006472cb2492a1fc025fa2ceae0231c339745610 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 5 Dec 2013 15:56:55 -0800 Subject: [PATCH 2/6] tweaked RGB->Hz for drum to make piano --- interface/src/avatar/Hand.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 35b8f167cc..226ed65202 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -126,12 +126,12 @@ void Hand::simulate(float deltaTime, bool isMine) { } } } -} +} void Hand::handleVoxelCollision(PalmData* palm, const glm::vec3& fingerTipPosition, VoxelTreeElement* voxel, float deltaTime) { // Collision between finger and a voxel plays sound const float LOWEST_FREQUENCY = 100.f; - const float HERTZ_PER_RGB = 3.f; + const float HERTZ_PER_RGB = 2.f; const float DECAY_PER_SAMPLE = 0.0005f; const float DURATION_MAX = 2.0f; const float MIN_VOLUME = 0.1f; From a1027b7ddaacc72b54c31698dd253be75c1a62f3 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 5 Dec 2013 16:03:06 -0800 Subject: [PATCH 3/6] =?UTF-8?q?reverse=20Hz=20change=20because=20I?= =?UTF-8?q?=E2=80=99ve=20got=20some=20other=20stuff=20in=20there?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface/src/avatar/Hand.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 226ed65202..35b8f167cc 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -126,12 +126,12 @@ void Hand::simulate(float deltaTime, bool isMine) { } } } -} +} void Hand::handleVoxelCollision(PalmData* palm, const glm::vec3& fingerTipPosition, VoxelTreeElement* voxel, float deltaTime) { // Collision between finger and a voxel plays sound const float LOWEST_FREQUENCY = 100.f; - const float HERTZ_PER_RGB = 2.f; + const float HERTZ_PER_RGB = 3.f; const float DECAY_PER_SAMPLE = 0.0005f; const float DURATION_MAX = 2.0f; const float MIN_VOLUME = 0.1f; From 8d5dd4ec6d3cb5d368a7fe6f1d114d594a63517c Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 5 Dec 2013 16:44:41 -0800 Subject: [PATCH 4/6] remove the hardware directory --- hardware/head_hand/head_hand.pde | 81 -------------------------------- 1 file changed, 81 deletions(-) delete mode 100644 hardware/head_hand/head_hand.pde diff --git a/hardware/head_hand/head_hand.pde b/hardware/head_hand/head_hand.pde deleted file mode 100644 index 844f352e56..0000000000 --- a/hardware/head_hand/head_hand.pde +++ /dev/null @@ -1,81 +0,0 @@ -// -// Read Gyro and accelerometer data, send over serialUSB to computer for processing. -// -// Written by Philip, 2012, for High Fidelity, Inc. -// -// PIN WIRING: Connect input sensors to the channels in following manner -// -// AIN 10: Yaw Gyro (shaking your head 'no') -// AIN 16: Pitch Gyro (nodding your head 'yes') -// AIN 17: Roll Gyro (looking quizzical, tilting your head) -// AIN 18: Lateral acceleration (moving from side-to-side in front of your monitor) -// AIN 19: Up/Down acceleration (sitting up/ducking in front of your monitor) -// AIN 20: Forward/Back acceleration (Toward or away from your monitor) - -#define NUM_CHANNELS 6 -#define MSECS_PER_SAMPLE 10 - -#define LED_PIN 12 - -int inputPins[NUM_CHANNELS] = {10,16,17,18,19,20}; - -int LED = 0; -unsigned int samplesSent = 0; -unsigned int time; - -int measured[NUM_CHANNELS]; -float accumulate[NUM_CHANNELS]; - -int sampleCount = 0; - -void setup() -{ - int i; - for (i = 0; i < NUM_CHANNELS; i++) { - pinMode(inputPins[i], INPUT_ANALOG); - measured[i] = analogRead(inputPins[i]); - accumulate[i] = measured[i]; - } - pinMode(BOARD_LED_PIN, OUTPUT); - pinMode(LED_PIN,OUTPUT); - time = millis(); -} - -void loop() -{ - int i; - sampleCount++; - - for (i = 0; i < NUM_CHANNELS; i++) { - accumulate[i] += analogRead(inputPins[i]); - } - if ((millis() - time) >= MSECS_PER_SAMPLE) { - samplesSent++; - time = millis(); - for (i = 0; i < NUM_CHANNELS; i++) { - measured[i] = accumulate[i] / sampleCount; - SerialUSB.print(measured[i]); - SerialUSB.print(" "); - accumulate[i] = 0; - } - - if ((samplesSent % 100 == 0) && (samplesSent % 150 == 0)) { - LED = !LED; - digitalWrite(LED_PIN, LED); - digitalWrite(BOARD_LED_PIN, LED); - } - - SerialUSB.print(sampleCount); - SerialUSB.print(" "); - if (LED) - SerialUSB.print("1"); - else - SerialUSB.print("0"); - - SerialUSB.println(""); - sampleCount = 0; - } -} - - - From 3f957bbf5d8a0e9c0d2633ee4b11ae259d741a7d Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Thu, 5 Dec 2013 16:46:11 -0800 Subject: [PATCH 5/6] Rave out! --- interface/src/Application.cpp | 11 - interface/src/Menu.cpp | 4 +- interface/src/Menu.h | 1 - interface/src/avatar/Avatar.cpp | 4 - interface/src/avatar/Hand.cpp | 549 ------------------------- interface/src/avatar/Hand.h | 21 +- interface/src/avatar/MyAvatar.cpp | 19 - interface/src/avatar/MyAvatar.h | 1 - libraries/avatars/src/HandData.cpp | 28 +- libraries/avatars/src/HandData.h | 24 -- libraries/shared/src/PacketHeaders.cpp | 2 +- 11 files changed, 5 insertions(+), 659 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index b48a622772..9718e21e1c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -609,12 +609,6 @@ void Application::keyPressEvent(QKeyEvent* event) { return; } - //this is for switching between modes for the leap rave glove test - if (Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand) - || Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove)) { - _myAvatar.getHand().setRaveGloveEffectsMode((QKeyEvent*)event); - } - bool isShifted = event->modifiers().testFlag(Qt::ShiftModifier); bool isMeta = event->modifiers().testFlag(Qt::ControlModifier); switch (event->key()) { @@ -2252,7 +2246,6 @@ void Application::updateLeap(float deltaTime) { PerformanceWarning warn(showWarnings, "Application::updateLeap()"); LeapManager::enableFakeFingers(Menu::getInstance()->isOptionChecked(MenuOption::SimulateLeapHand)); - _myAvatar.getHand().setRaveGloveActive(Menu::getInstance()->isOptionChecked(MenuOption::TestRaveGlove)); LeapManager::nextFrame(); } @@ -3086,12 +3079,8 @@ void Application::displaySide(Camera& whichCamera, bool selfAvatarOnly) { } } - _myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS); - renderAvatars(whichCamera.getMode() == CAMERA_MODE_MIRROR, selfAvatarOnly); - _myAvatar.renderScreenTint(SCREEN_TINT_AFTER_AVATARS); - if (!selfAvatarOnly) { // Render the world box if (whichCamera.getMode() != CAMERA_MODE_MIRROR && Menu::getInstance()->isOptionChecked(MenuOption::Stats)) { diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 8a3debfa5f..a32159d186 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -363,12 +363,12 @@ Menu::Menu() : appInstance->getWebcam()->getGrabber(), SLOT(setDepthOnly(bool))); - QMenu* raveGloveOptionsMenu = developerMenu->addMenu("Rave Glove Options"); + QMenu* raveGloveOptionsMenu = developerMenu->addMenu("Hand Options"); addCheckableActionToQMenuAndActionHash(raveGloveOptionsMenu, MenuOption::SimulateLeapHand); addCheckableActionToQMenuAndActionHash(raveGloveOptionsMenu, MenuOption::DisplayLeapHands, 0, true); addCheckableActionToQMenuAndActionHash(raveGloveOptionsMenu, MenuOption::LeapDrive, 0, false); - addCheckableActionToQMenuAndActionHash(raveGloveOptionsMenu, MenuOption::TestRaveGlove); + QMenu* trackingOptionsMenu = developerMenu->addMenu("Tracking Options"); addCheckableActionToQMenuAndActionHash(trackingOptionsMenu, diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 65bcdc11f5..c4238eea4f 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -239,7 +239,6 @@ namespace MenuOption { const QString Stars = "Stars"; const QString Stats = "Stats"; const QString TestPing = "Test Ping"; - const QString TestRaveGlove = "Test Rave Glove"; const QString TreeStats = "Calculate Tree Stats"; const QString TransmitterDrive = "Transmitter Drive"; const QString Quit = "Quit"; diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 85fed15911..7a80bb51c9 100755 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -442,10 +442,6 @@ static TextRenderer* textRenderer() { void Avatar::render(bool forceRenderHead) { - if (Application::getInstance()->getAvatar()->getHand().isRaveGloveActive()) { - _hand.setRaveLights(RAVE_LIGHTS_AVATAR); - } - // render a simple round on the ground projected down from the avatar's position renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), _scale * 0.1f, 0.2f); diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 35b8f167cc..be9455b93d 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -21,8 +21,6 @@ using namespace std; Hand::Hand(Avatar* owningAvatar) : HandData((AvatarData*)owningAvatar), - _raveGloveClock(0.0f), - _raveGloveInitialized(false), _owningAvatar(owningAvatar), _renderAlpha(1.0), _ballColor(0.0, 0.0, 0.4), @@ -30,10 +28,6 @@ Hand::Hand(Avatar* owningAvatar) : _collisionAge(0), _collisionDuration(0) { - // initialize all finger particle emitters with an invalid id as default - for (int f = 0; f< NUM_FINGERS; f ++ ) { - _raveGloveEmitter[f] = NULL_EMITTER; - } } void Hand::init() { @@ -44,9 +38,6 @@ void Hand::init() { else { _ballColor = glm::vec3(0.0, 0.0, 0.4); } - - _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_FIRE; - _raveGloveEffectsModeChanged = false; } void Hand::reset() { @@ -60,15 +51,6 @@ void Hand::simulate(float deltaTime, bool isMine) { } calculateGeometry(); - - if (_isRaveGloveActive) { - if (_raveGloveEffectsModeChanged && _raveGloveInitialized) { - activateNewRaveGloveMode(); - _raveGloveEffectsModeChanged = false; - } - - updateRaveGloveParticles(deltaTime); - } if (isMine) { // Create a voxel at fingertip if controller button is pressed @@ -200,50 +182,14 @@ void Hand::calculateGeometry() { } } -void Hand::setRaveGloveEffectsMode(QKeyEvent* event) { - - _raveGloveEffectsModeChanged = true; - - switch (event->key()) { - - case Qt::Key_0: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR; break; - case Qt::Key_1: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_TRAILS; break; - case Qt::Key_2: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_FIRE; break; - case Qt::Key_3: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_WATER; break; - case Qt::Key_4: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_FLASHY; break; - case Qt::Key_5: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_BOZO_SPARKLER; break; - case Qt::Key_6: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_LONG_SPARKLER; break; - case Qt::Key_7: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_SNAKE; break; - case Qt::Key_8: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_PULSE; break; - case Qt::Key_9: _raveGloveEffectsMode = RAVE_GLOVE_EFFECTS_MODE_THROB; break; - }; -} - void Hand::render( bool isMine) { _renderAlpha = 1.0; if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayLeapHands)) { - if (!isRaveGloveActive()) { - renderLeapFingerTrails(); - } - if (isRaveGloveActive()) { - // Use mood lighting for the hand itself - setRaveLights(RAVE_LIGHTS_AVATAR); - } - renderLeapFingerTrails(); renderLeapHands(); } - if (_isRaveGloveActive) { - if (_raveGloveInitialized) { - updateRaveGloveEmitters(); // do this after calculateGeometry - - // Use normal lighting for the particles - setRaveLights(RAVE_LIGHTS_PARTICLES); - _raveGloveParticleSystem.render(); - } - } if (isMine) { // If hand/voxel collision has happened, render a little expanding sphere @@ -304,65 +250,6 @@ void Hand::render( bool isMine) { } -void Hand::setRaveLights(RaveLightsSetting setting) { - if (setting == RAVE_LIGHTS_AVATAR) { - // Set some mood lighting - GLfloat ambient_color[] = { 0.0, 0.0, 0.0 }; - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); - GLfloat diffuse_color[] = { 0.4, 0.0, 0.0 }; - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); - GLfloat specular_color[] = { 0.0, 0.0, 0.0, 0.0}; - glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color); - glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color); - glMateriali(GL_FRONT, GL_SHININESS, 0); - } - else if (setting == RAVE_LIGHTS_PARTICLES) { - // particles use a brighter light setting - GLfloat ambient_color[] = { 0.7, 0.7, 0.8 }; - glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_color); - GLfloat diffuse_color[] = { 0.8, 0.7, 0.7 }; - glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_color); - GLfloat specular_color[] = { 1.0, 1.0, 1.0, 1.0}; - glLightfv(GL_LIGHT0, GL_SPECULAR, specular_color); - glMaterialfv(GL_FRONT, GL_SPECULAR, specular_color); - glMateriali(GL_FRONT, GL_SHININESS, 96); - } -} - -void Hand::renderRaveGloveStage() { - - // Draw a simple fullscreen triangle fan, darkest in the center. - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glDisable(GL_DEPTH_TEST); - glDepthMask(GL_FALSE); - glEnable(GL_BLEND); - glBegin(GL_TRIANGLE_FAN); - // Dark center vertex - glColor4f(0.0f, 0.0f, 0.0f, 1.0f); - glVertex3f(0.0f, 0.0f, 0.0f); - // Lighter outer vertices - glColor4f(0.0f, 0.0f, 0.0f, 0.5f); - glVertex3f(-1.0f,-1.0f, 0.0f); - glVertex3f( 1.0f,-1.0f, 0.0f); - glVertex3f( 1.0f, 1.0f, 0.0f); - glVertex3f(-1.0f, 1.0f, 0.0f); - glVertex3f(-1.0f,-1.0f, 0.0f); - glEnd(); - glDepthMask(GL_TRUE); - glEnable(GL_DEPTH_TEST); - - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); -} - void Hand::renderLeapHands() { const float alpha = 1.0f; @@ -420,38 +307,6 @@ void Hand::renderLeapHands() { 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()) { - for (size_t f = 0; f < palm.getNumFingers(); ++f) { - FingerData& finger = palm.getFingers()[f]; - int numPositions = finger.getTrailNumPositions() - 1; - if (numPositions > 0) { - glBegin(GL_TRIANGLE_STRIP); - for (int t = 0; t < numPositions; ++t) - { - const glm::vec3& center = finger.getTrailPosition(t); - 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)); - alpha *= 0.25f; - glColor4f(1.0f, 1.0f, 1.0f, alpha); - glVertex3fv((float*)&edge0); - glVertex3fv((float*)&edge1); - } - glEnd(); - } - } - } - } - glEnable(GL_LIGHTING); -} - void Hand::setLeapHands(const std::vector& handPositions, const std::vector& handNormals) { @@ -469,410 +324,6 @@ 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 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++; - } - } - } -} - - -// call this from within the simulate method -void Hand::updateRaveGloveParticles(float deltaTime) { - - if (!_raveGloveInitialized) { - - // start up the rave glove finger particles... - for ( int f = 0; f< NUM_FINGERS; f ++ ) { - _raveGloveEmitter[f] = _raveGloveParticleSystem.addEmitter(); - assert( _raveGloveEmitter[f] >= 0 ); - assert( _raveGloveEmitter[f] != NULL_EMITTER ); - } - - setRaveGloveMode(RAVE_GLOVE_EFFECTS_MODE_FIRE); - activateNewRaveGloveMode(); - _raveGloveParticleSystem.setUpDirection(glm::vec3(0.0f, 1.0f, 0.0f)); - _raveGloveInitialized = true; - } else { - _raveGloveParticleSystem.simulate(deltaTime); - } -} - -// The rave glove mode has changed, so activate the effects. -void Hand::activateNewRaveGloveMode() { - - if (!_raveGloveInitialized) { - return; - } - - int mode = _raveGloveEffectsMode; - _raveGloveParticleSystem.killAllParticles(); - - for ( int f = 0; f< NUM_FINGERS; f ++ ) { - - ParticleSystem::ParticleAttributes attributes; - - //----------------------------------------- - // throbbing color cycle - //----------------------------------------- - if (mode == RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR) { - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.03f ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 30.0f ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 20 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.modulationAmplitude = 1.0; - attributes.modulationRate = 0.33; - attributes.modulationStyle = COLOR_MODULATION_STYLE_RAINBOW_CYCLE; - attributes.color = glm::vec4( 0.5f, 0.5f, 0.5f, 1.0f); - attributes.radius = 0.02f; - attributes.gravity = 0.0f; - attributes.airFriction = 0.0f; - attributes.jitter = 0.0f; - attributes.bounce = 0.0f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // trails - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_TRAILS) { - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_RIBBON ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], false ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 1.0f ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 50.0f ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 5 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.001f; - attributes.color = glm::vec4( 1.0f, 0.5f, 0.2f, 1.0f); - attributes.gravity = 0.005f; - attributes.airFriction = 0.0f; - attributes.jitter = 0.0f; - attributes.bounce = 0.0f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - - attributes.radius = 0.002f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - - attributes.color = glm::vec4( 1.0f, 0.2f, 0.2f, 0.5f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - - attributes.color = glm::vec4( 1.0f, 0.2f, 0.2f, 0.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - } - - //----------------------------------------- - // Fire! - //----------------------------------------- - if (mode == RAVE_GLOVE_EFFECTS_MODE_FIRE) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], false ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 1.0f ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.002f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 120.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 6 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.005f; - attributes.color = glm::vec4( 1.0f, 1.0f, 0.5f, 0.5f); - attributes.airFriction = 0.0f; - attributes.jitter = 0.003f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - - attributes.radius = 0.01f; - attributes.jitter = 0.0f; - attributes.gravity = -0.005f; - attributes.color = glm::vec4( 1.0f, 0.2f, 0.0f, 0.4f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - - attributes.radius = 0.01f; - attributes.gravity = 0.0f; - attributes.color = glm::vec4( 0.4f, 0.4f, 0.4f, 0.2f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - - attributes.radius = 0.02f; - attributes.color = glm::vec4( 0.4f, 0.6f, 0.9f, 0.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // water - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_WATER) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.6f ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.001f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 100.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 5 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.001f; - attributes.color = glm::vec4( 0.8f, 0.9f, 1.0f, 0.5f); - attributes.airFriction = 0.0f; - attributes.jitter = 0.004f; - attributes.bounce = 1.0f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - - attributes.gravity = 0.01f; - attributes.jitter = 0.0f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - - attributes.color = glm::vec4( 0.8f, 0.9f, 1.0f, 0.2f); - attributes.radius = 0.002f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - - attributes.color = glm::vec4( 0.8f, 0.9f, 1.0f, 0.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // flashy - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_FLASHY) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.1 ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.002f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 100.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 12 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.0f; - attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); - attributes.airFriction = 0.0f; - attributes.jitter = 0.05f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 1.0f, 1.0f, 0.0f, 1.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 1.0f, 0.0f, 1.0f, 1.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 0.0f, 0.0f, 0.0f, 1.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // Bozo sparkler - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_BOZO_SPARKLER) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_RIBBON ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], false ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.2 ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.002f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 100.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 12 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.0f; - attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); - attributes.airFriction = 0.0f; - attributes.jitter = 0.01f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 1.0f, 1.0f, 0.0f, 1.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 1.0f, 0.0f, .0f, 1.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - - attributes.radius = 0.0f; - attributes.color = glm::vec4( 0.0f, 0.0f, 1.0f, 0.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // long sparkler - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_LONG_SPARKLER) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_RIBBON ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], false ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 1.0 ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.002f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 100.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 7 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.color = glm::vec4( 0.3f, 0.3f, 0.3f, 0.4f); - attributes.radius = 0.0f; - attributes.airFriction = 0.0f; - attributes.jitter = 0.0001f; - attributes.bounce = 1.0f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - - attributes.radius = 0.005f; - attributes.color = glm::vec4( 0.0f, 0.5f, 0.5f, 0.8f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - - attributes.radius = 0.007f; - attributes.color = glm::vec4( 0.5f, 0.0f, 0.5f, 0.5f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - - attributes.radius = 0.02f; - attributes.color = glm::vec4( 0.0f, 0.0f, 1.0f, 0.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // bubble snake - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_SNAKE) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 1.0 ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.002f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 100.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 7 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.001f; - attributes.color = glm::vec4( 0.5f, 1.0f, 0.5f, 1.0f); - attributes.airFriction = 0.01f; - attributes.jitter = 0.0f; - attributes.emitterAttraction = 0.0f; - attributes.tornadoForce = 1.1f; - attributes.neighborAttraction = 1.1f; - attributes.neighborRepulsion = 1.1f; - attributes.bounce = 0.0f; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - - attributes.radius = 0.002f; - attributes.color = glm::vec4( 1.0f, 1.0f, 1.0f, 1.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - - attributes.radius = 0.003f; - attributes.color = glm::vec4( 0.3f, 0.3f, 0.3f, 0.5f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - - attributes.radius = 0.004f; - attributes.color = glm::vec4( 0.3f, 0.3f, 0.3f, 0.0f); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // pulse - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_PULSE) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.0 ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 30.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 20 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 0.1f, 0.2f, 0.4f, 0.5f); - attributes.modulationAmplitude = 0.9; - attributes.modulationRate = 7.0; - attributes.modulationStyle = COLOR_MODULATION_STYLE_LIGHNTESS_PULSE; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // long sparkler - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_LONG_SPARKLER) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.0 ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 30.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 20 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 0.5f, 0.4f, 0.3f, 0.5f); - attributes.modulationAmplitude = 0.3; - attributes.modulationRate = 1.0; - attributes.modulationStyle = COLOR_MODULATION_STYLE_LIGHTNESS_WAVE; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - - //----------------------------------------- - // throb - //----------------------------------------- - } else if (mode == RAVE_GLOVE_EFFECTS_MODE_THROB) { - - _raveGloveParticleSystem.setParticleRenderStyle (_raveGloveEmitter[f], PARTICLE_RENDER_STYLE_SPHERE ); - _raveGloveParticleSystem.setShowingEmitterBaseParticle(_raveGloveEmitter[f], true ); - _raveGloveParticleSystem.setEmitterParticleLifespan (_raveGloveEmitter[f], 0.03 ); - _raveGloveParticleSystem.setEmitterThrust (_raveGloveEmitter[f], 0.0f ); - _raveGloveParticleSystem.setEmitterRate (_raveGloveEmitter[f], 30.0 ); - _raveGloveParticleSystem.setEmitterParticleResolution (_raveGloveEmitter[f], 20 ); - - _raveGloveParticleSystem.setParticleAttributesToDefault(&attributes); - - attributes.radius = 0.01f; - attributes.color = glm::vec4( 0.1f, 0.2f, 0.4f, 0.5f); - attributes.modulationAmplitude = 0.5; - attributes.modulationRate = 3.0; - attributes.modulationStyle = COLOR_MODULATION_STYLE_LIGHTNESS_WAVE; - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_0, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_1, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_2, attributes); - _raveGloveParticleSystem.setParticleAttributes(_raveGloveEmitter[f], PARTICLE_LIFESTAGE_3, attributes); - } - } -} diff --git a/interface/src/avatar/Hand.h b/interface/src/avatar/Hand.h index 83d4a7f8a6..d6ec65004d 100755 --- a/interface/src/avatar/Hand.h +++ b/interface/src/avatar/Hand.h @@ -25,12 +25,6 @@ #include "world.h" #include "devices/SerialInterface.h" -enum RaveLightsSetting { - RAVE_LIGHTS_AVATAR = 0, - RAVE_LIGHTS_PARTICLES -}; - - class Avatar; class ProgramObject; @@ -53,13 +47,7 @@ public: void reset(); void simulate(float deltaTime, bool isMine); void render(bool isMine); - void renderRaveGloveStage(); - void setRaveLights(RaveLightsSetting setting); - void setBallColor (glm::vec3 ballColor ) { _ballColor = ballColor; } - void updateRaveGloveParticles(float deltaTime); - void updateRaveGloveEmitters(); - void setRaveGloveEffectsMode(QKeyEvent* event); // getters const glm::vec3& getLeapFingerTipBallPosition (int ball) const { return _leapFingerTipBalls [ball].position;} @@ -69,12 +57,7 @@ private: // disallow copies of the Hand, copy of owning Avatar is disallowed too Hand(const Hand&); Hand& operator= (const Hand&); - - ParticleSystem _raveGloveParticleSystem; - float _raveGloveClock; - bool _raveGloveInitialized; - int _raveGloveEmitter[NUM_FINGERS]; - + int _controllerButtons; /// Button states read from hand-held controllers Avatar* _owningAvatar; @@ -95,8 +78,6 @@ private: void setLeapHands(const std::vector& handPositions, const std::vector& handNormals); - void activateNewRaveGloveMode(); - void renderLeapHands(); void renderLeapFingerTrails(); void calculateGeometry(); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 833e6a4d4b..51b8b37007 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -499,10 +499,6 @@ static TextRenderer* textRenderer() { void MyAvatar::render(bool forceRenderHead) { - if (Application::getInstance()->getAvatar()->getHand().isRaveGloveActive()) { - _hand.setRaveLights(RAVE_LIGHTS_AVATAR); - } - // render a simple round on the ground projected down from the avatar's position renderDiskShadow(_position, glm::vec3(0.0f, 1.0f, 0.0f), _scale * 0.1f, 0.2f); @@ -562,21 +558,6 @@ void MyAvatar::render(bool forceRenderHead) { } } -void MyAvatar::renderScreenTint(ScreenTintLayer layer) { - - if (layer == SCREEN_TINT_BEFORE_AVATARS) { - if (_hand.isRaveGloveActive()) { - _hand.renderRaveGloveStage(); - } - } - else if (layer == SCREEN_TINT_BEFORE_AVATARS) { - if (_hand.isRaveGloveActive()) { - // Restore the world lighting - Application::getInstance()->setupWorldLight(); - } - } -} - void MyAvatar::saveData(QSettings* settings) { settings->beginGroup("Avatar"); diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 790f76b233..9f440a50bf 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -21,7 +21,6 @@ public: void simulate(float deltaTime, Transmitter* transmitter); void updateFromGyrosAndOrWebcam(bool turnWithHead); void render(bool forceRenderHead); - void renderScreenTint(ScreenTintLayer layer); // setters void setMousePressed(bool mousePressed) { _mousePressed = mousePressed; } diff --git a/libraries/avatars/src/HandData.cpp b/libraries/avatars/src/HandData.cpp index a38e2dee6d..3abaf3c431 100644 --- a/libraries/avatars/src/HandData.cpp +++ b/libraries/avatars/src/HandData.cpp @@ -10,8 +10,6 @@ #include "AvatarData.h" #include -// Glove flags -#define GLOVE_FLAG_RAVE 0x01 // When converting between fixed and float, use this as the radix. const int fingerVectorRadix = 4; @@ -19,10 +17,7 @@ const int fingerVectorRadix = 4; HandData::HandData(AvatarData* owningAvatar) : _basePosition(0.0f, 0.0f, 0.0f), _baseOrientation(0.0f, 0.0f, 0.0f, 1.0f), - _owningAvatarData(owningAvatar), - _isRaveGloveActive(false), - _raveGloveEffectsMode(RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR), - _raveGloveEffectsModeChanged(false) + _owningAvatarData(owningAvatar) { // Start with two palms addNewPalm(); @@ -67,13 +62,6 @@ _owningHandData(owningHandData) int HandData::encodeRemoteData(unsigned char* destinationBuffer) { const unsigned char* startPosition = destinationBuffer; - unsigned char gloveFlags = 0; - if (isRaveGloveActive()) - gloveFlags |= GLOVE_FLAG_RAVE; - - *destinationBuffer++ = gloveFlags; - *destinationBuffer++ = getRaveGloveMode(); - unsigned int numHands = 0; for (unsigned int handIndex = 0; handIndex < getNumPalms(); ++handIndex) { PalmData& palm = getPalms()[handIndex]; @@ -120,8 +108,6 @@ int HandData::encodeRemoteData(unsigned char* destinationBuffer) { int HandData::decodeRemoteData(unsigned char* sourceBuffer) { const unsigned char* startPosition = sourceBuffer; - unsigned char gloveFlags = *sourceBuffer++; - char effectsMode = *sourceBuffer++; unsigned int numHands = *sourceBuffer++; for (unsigned int handIndex = 0; handIndex < numHands; ++handIndex) { @@ -165,11 +151,6 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { palm.setActive(false); } - setRaveGloveActive((gloveFlags & GLOVE_FLAG_RAVE) != 0); - if (numHands > 0) { - setRaveGloveMode(effectsMode); - } - // One byte for error checking safety. unsigned char requiredLength = (unsigned char)(sourceBuffer - startPosition); unsigned char checkLength = *sourceBuffer++; @@ -178,13 +159,6 @@ int HandData::decodeRemoteData(unsigned char* sourceBuffer) { return sourceBuffer - startPosition; } -void HandData::setRaveGloveMode(int effectsMode) { - if (effectsMode != _raveGloveEffectsMode) { - _raveGloveEffectsModeChanged = true; - } - _raveGloveEffectsMode = effectsMode; -} - void HandData::setFingerTrailLength(unsigned int length) { for (size_t i = 0; i < getNumPalms(); ++i) { PalmData& palm = getPalms()[i]; diff --git a/libraries/avatars/src/HandData.h b/libraries/avatars/src/HandData.h index 8b43b64ef0..94ad263fbd 100755 --- a/libraries/avatars/src/HandData.h +++ b/libraries/avatars/src/HandData.h @@ -26,22 +26,6 @@ const int NUM_FINGERS = NUM_HANDS * NUM_FINGERS_PER_HAND; const int LEAPID_INVALID = -1; const int SIXENSEID_INVALID = -1; -enum RaveGloveEffectsMode -{ - RAVE_GLOVE_EFFECTS_MODE_NULL = -1, - RAVE_GLOVE_EFFECTS_MODE_THROBBING_COLOR, - RAVE_GLOVE_EFFECTS_MODE_TRAILS, - RAVE_GLOVE_EFFECTS_MODE_FIRE, - RAVE_GLOVE_EFFECTS_MODE_WATER, - RAVE_GLOVE_EFFECTS_MODE_FLASHY, - RAVE_GLOVE_EFFECTS_MODE_BOZO_SPARKLER, - RAVE_GLOVE_EFFECTS_MODE_LONG_SPARKLER, - RAVE_GLOVE_EFFECTS_MODE_SNAKE, - RAVE_GLOVE_EFFECTS_MODE_PULSE, - RAVE_GLOVE_EFFECTS_MODE_THROB, - NUM_RAVE_GLOVE_EFFECTS_MODES -}; - const int BUTTON_1 = 32; const int BUTTON_2 = 64; const int BUTTON_3 = 8; @@ -76,20 +60,12 @@ public: int encodeRemoteData(unsigned char* destinationBuffer); int decodeRemoteData(unsigned char* sourceBuffer); - void setRaveGloveActive(bool active) { _isRaveGloveActive = active; } - void setRaveGloveMode(int effectsMode); - bool isRaveGloveActive() const { return _isRaveGloveActive; } - int getRaveGloveMode() { return _raveGloveEffectsMode; } - friend class AvatarData; protected: glm::vec3 _basePosition; // Hands are placed relative to this glm::quat _baseOrientation; // Hands are placed relative to this AvatarData* _owningAvatarData; std::vector _palms; - bool _isRaveGloveActive; - int _raveGloveEffectsMode; - bool _raveGloveEffectsModeChanged; private: // privatize copy ctor and assignment operator so copies of this object cannot be made HandData(const HandData&); diff --git a/libraries/shared/src/PacketHeaders.cpp b/libraries/shared/src/PacketHeaders.cpp index d48ffdbaf1..aa7705592a 100644 --- a/libraries/shared/src/PacketHeaders.cpp +++ b/libraries/shared/src/PacketHeaders.cpp @@ -20,7 +20,7 @@ PACKET_VERSION versionForPacketType(PACKET_TYPE type) { return 2; case PACKET_TYPE_HEAD_DATA: - return 11; + return 12; case PACKET_TYPE_AVATAR_URLS: return 2; From 146d5294a00a25e227c4e0696a0ad9734c13b9f7 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Thu, 5 Dec 2013 16:51:04 -0800 Subject: [PATCH 6/6] more PortAudio cleanup in cmake --- cmake/modules/FindJack.cmake | 82 ----------------------------------- cmake/modules/FindLibrt.cmake | 61 -------------------------- interface/CMakeLists.txt | 19 +++----- 3 files changed, 5 insertions(+), 157 deletions(-) delete mode 100644 cmake/modules/FindJack.cmake delete mode 100644 cmake/modules/FindLibrt.cmake diff --git a/cmake/modules/FindJack.cmake b/cmake/modules/FindJack.cmake deleted file mode 100644 index a39fd63470..0000000000 --- a/cmake/modules/FindJack.cmake +++ /dev/null @@ -1,82 +0,0 @@ -# - Try to find jack-2.6 -# Once done this will define -# -# JACK_FOUND - system has jack -# JACK_INCLUDE_DIRS - the jack include directory -# JACK_LIBRARIES - Link these to use jack -# JACK_DEFINITIONS - Compiler switches required for using jack -# -# Copyright (c) 2008 Andreas Schneider -# Modified for other libraries by Lasse Kärkkäinen -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - -if (JACK_LIBRARIES AND JACK_INCLUDE_DIRS) - # in cache already - set(JACK_FOUND TRUE) -else (JACK_LIBRARIES AND JACK_INCLUDE_DIRS) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - include(UsePkgConfig) - pkgconfig(jack _JACK_INCLUDEDIR _JACK_LIBDIR _JACK_LDFLAGS _JACK_CFLAGS) - else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(_JACK jack) - endif (PKG_CONFIG_FOUND) - endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_path(JACK_INCLUDE_DIR - NAMES - jack/jack.h - PATHS - ${_JACK_INCLUDEDIR} - /usr/include - /usr/local/include - /opt/local/include - /sw/include - ) - - find_library(JACK_LIBRARY - NAMES - jack - PATHS - ${_JACK_LIBDIR} - /usr/lib - /usr/local/lib - /opt/local/lib - /sw/lib - ) - - if (JACK_LIBRARY AND JACK_INCLUDE_DIR) - set(JACK_FOUND TRUE) - - set(JACK_INCLUDE_DIRS - ${JACK_INCLUDE_DIR} - ) - - set(JACK_LIBRARIES - ${JACK_LIBRARIES} - ${JACK_LIBRARY} - ) - - endif (JACK_LIBRARY AND JACK_INCLUDE_DIR) - - if (JACK_FOUND) - if (NOT JACK_FIND_QUIETLY) - message(STATUS "Found jack: ${JACK_LIBRARY}") - endif (NOT JACK_FIND_QUIETLY) - else (JACK_FOUND) - if (JACK_FIND_REQUIRED) - message(FATAL_ERROR "Could not find JACK") - endif (JACK_FIND_REQUIRED) - endif (JACK_FOUND) - - # show the JACK_INCLUDE_DIRS and JACK_LIBRARIES variables only in the advanced view - mark_as_advanced(JACK_INCLUDE_DIRS JACK_LIBRARIES) - -endif (JACK_LIBRARIES AND JACK_INCLUDE_DIRS) - diff --git a/cmake/modules/FindLibrt.cmake b/cmake/modules/FindLibrt.cmake deleted file mode 100644 index 34450d3924..0000000000 --- a/cmake/modules/FindLibrt.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# You may redistribute this program and/or modify it under the terms of -# the GNU General Public License as published by the Free Software Foundation, -# either version 3 of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -if(NOT LIBRT_FOUND) - - find_path(LIBRT_INCLUDE_DIR - NAMES - time.h - PATHS - ${LIBRTDIR}/include/ - ) - - find_file( - LIBRT_LIBRARIES librt.a - PATHS - ${LIBRTDIR}/lib/ - /usr/local/lib64/ - /usr/local/lib/ - /usr/lib/i386-linux-gnu/ - /usr/lib/x86_64-linux-gnu/ - /usr/lib64/ - /usr/lib/ - ) - set (LIBRT_DYNAMIC "Using static library.") - - if (NOT LIBRT_LIBRARIES) - find_library( - LIBRT_LIBRARIES rt - PATHS - ${LIBRTDIR}/lib/ - /usr/local/lib64/ - /usr/local/lib/ - /usr/lib/i386-linux-gnu/ - /usr/lib/x86_64-linux-gnu/ - /usr/lib64/ - /usr/lib/ - ) - set (LIBRT_DYNAMIC "Using dynamic library.") - endif (NOT LIBRT_LIBRARIES) - - if (LIBRT_INCLUDE_DIR AND LIBRT_LIBRARIES) - set (LIBRT_FOUND TRUE) - endif (LIBRT_INCLUDE_DIR AND LIBRT_LIBRARIES) - - if (LIBRT_FOUND) - message(STATUS "Found librt: ${LIBRT_INCLUDE_DIR}, ${LIBRT_LIBRARIES} ${LIBRT_DYNAMIC}") - else (LIBRT_FOUND) - if (Librt_FIND_REQUIRED) - message (FATAL_ERROR "Could not find librt, try to setup LIBRT_PREFIX accordingly") - endif (Librt_FIND_REQUIRED) - endif (LIBRT_FOUND) - -endif (NOT LIBRT_FOUND) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index a416f8aac1..51c33bfa38 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -157,8 +157,6 @@ target_link_libraries( if (APPLE) # link in required OS X frameworks and include the right GL headers find_library(AppKit AppKit) - find_library(AudioToolbox AudioToolbox) - find_library(AudioUnit AudioUnit) find_library(CoreAudio CoreAudio) find_library(CoreServices CoreServices) find_library(Carbon Carbon) @@ -174,9 +172,7 @@ if (APPLE) target_link_libraries( ${TARGET_NAME} ${AppKit} - ${AudioToolbox} - ${AudioUnit} - ${CoreAudio} + ${CoreAudio} ${CoreServices} ${Carbon} ${Foundation} @@ -212,16 +208,11 @@ else (WIN32) # link required libraries on UNIX if (UNIX AND NOT APPLE) find_package(Threads REQUIRED) - find_package(Librt REQUIRED) - find_package(ALSA) - find_package(Jack) - target_link_libraries(${TARGET_NAME} - ${CMAKE_THREAD_LIBS_INIT} - ${LIBRT_LIBRARIES} - ${JACK_LIBRARIES} - ${ALSA_LIBRARIES} - ${GLUT_LIBRARY} + target_link_libraries( + ${TARGET_NAME} + ${CMAKE_THREAD_LIBS_INIT} + ${GLUT_LIBRARY} ) endif (UNIX AND NOT APPLE) endif (WIN32)