From 35e7cfddbab7fe225b7aa7d0b8a91c6e7584a656 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 17 Dec 2013 11:20:26 -0800 Subject: [PATCH] =?UTF-8?q?Made=20drumming=20and=20slaps=20into=20menu=20c?= =?UTF-8?q?hoices=20from=20=E2=80=98Hand=20Options=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- interface/src/Menu.cpp | 5 +- interface/src/Menu.h | 2 + interface/src/avatar/Hand.cpp | 100 ++++++++++++++++++---------------- 3 files changed, 59 insertions(+), 48 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index d79c2938f1..374efd51e2 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -373,7 +373,10 @@ Menu::Menu() : addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayLeapHands, 0, true); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LeapDrive, 0, false); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false); - addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::BallFromHand, 0, false); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::BallFromHand, 0, false); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::VoxelDrumming, 0, false); + addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::PlaySlaps, 0, false); + QMenu* trackingOptionsMenu = developerMenu->addMenu("Tracking Options"); diff --git a/interface/src/Menu.h b/interface/src/Menu.h index 117a24831e..b62f49abe4 100644 --- a/interface/src/Menu.h +++ b/interface/src/Menu.h @@ -244,6 +244,8 @@ namespace MenuOption { const QString ShowAllLocalVoxels = "Show All Local Voxels"; const QString ShowTrueColors = "Show TRUE Colors"; const QString SimulateLeapHand = "Simulate Leap Hand"; + const QString VoxelDrumming = "Voxel Drumming"; + const QString PlaySlaps = "Play Slaps"; const QString SkeletonTracking = "Skeleton Tracking"; const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; const QString LEDTracking = "LED Tracking"; diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index d446c32469..cd979a681f 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -285,32 +285,35 @@ void Hand::simulate(float deltaTime, bool isMine) { _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); + + // Voxel Drumming with fingertips if enabled + if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDrumming)) { + 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); + } } } } @@ -338,28 +341,31 @@ void Hand::updateCollisions() { for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) { if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) { Avatar* otherAvatar = (Avatar*)node->getLinkedData(); - // Check for palm collisions - glm::vec3 myPalmPosition = palm.getPosition(); - float palmCollisionDistance = 0.1f; - palm.setIsCollidingWithPalm(false); - for (int j = 0; j < otherAvatar->getHand().getNumPalms(); j++) { - PalmData& otherPalm = otherAvatar->getHand().getPalms()[j]; - if (!otherPalm.isActive()) { - continue; - } - glm::vec3 otherPalmPosition = otherPalm.getPosition(); - if (glm::length(otherPalmPosition - myPalmPosition) < palmCollisionDistance) { - palm.setIsCollidingWithPalm(true); - const float PALM_COLLIDE_VOLUME = 1.f; - const float PALM_COLLIDE_FREQUENCY = 150.f; - const float PALM_COLLIDE_DURATION_MAX = 2.f; - const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.005f; - Application::getInstance()->getAudio()->startDrumSound(PALM_COLLIDE_VOLUME, - PALM_COLLIDE_FREQUENCY, - PALM_COLLIDE_DURATION_MAX, - PALM_COLLIDE_DECAY_PER_SAMPLE); + if (Menu::getInstance()->isOptionChecked(MenuOption::PlaySlaps)) { + // Check for palm collisions + glm::vec3 myPalmPosition = palm.getPosition(); + float palmCollisionDistance = 0.1f; + palm.setIsCollidingWithPalm(false); + // If 'Play Slaps' is enabled, look for palm-to-palm collisions and make sound + for (int j = 0; j < otherAvatar->getHand().getNumPalms(); j++) { + PalmData& otherPalm = otherAvatar->getHand().getPalms()[j]; + if (!otherPalm.isActive()) { + continue; + } + glm::vec3 otherPalmPosition = otherPalm.getPosition(); + if (glm::length(otherPalmPosition - myPalmPosition) < palmCollisionDistance) { + palm.setIsCollidingWithPalm(true); + const float PALM_COLLIDE_VOLUME = 1.f; + const float PALM_COLLIDE_FREQUENCY = 150.f; + const float PALM_COLLIDE_DURATION_MAX = 2.f; + const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.005f; + Application::getInstance()->getAudio()->startDrumSound(PALM_COLLIDE_VOLUME, + PALM_COLLIDE_FREQUENCY, + PALM_COLLIDE_DURATION_MAX, + PALM_COLLIDE_DECAY_PER_SAMPLE); - + + } } } glm::vec3 avatarPenetration;