Made drumming and slaps into menu choices from ‘Hand Options’

This commit is contained in:
Philip Rosedale 2013-12-17 11:20:26 -08:00
parent d6efcce28e
commit 35e7cfddba
3 changed files with 59 additions and 48 deletions

View file

@ -373,7 +373,10 @@ Menu::Menu() :
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayLeapHands, 0, true); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayLeapHands, 0, true);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LeapDrive, 0, false); addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::LeapDrive, 0, false);
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 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"); QMenu* trackingOptionsMenu = developerMenu->addMenu("Tracking Options");

View file

@ -244,6 +244,8 @@ namespace MenuOption {
const QString ShowAllLocalVoxels = "Show All Local Voxels"; const QString ShowAllLocalVoxels = "Show All Local Voxels";
const QString ShowTrueColors = "Show TRUE Colors"; const QString ShowTrueColors = "Show TRUE Colors";
const QString SimulateLeapHand = "Simulate Leap Hand"; const QString SimulateLeapHand = "Simulate Leap Hand";
const QString VoxelDrumming = "Voxel Drumming";
const QString PlaySlaps = "Play Slaps";
const QString SkeletonTracking = "Skeleton Tracking"; const QString SkeletonTracking = "Skeleton Tracking";
const QString SuppressShortTimings = "Suppress Timings Less than 10ms"; const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
const QString LEDTracking = "LED Tracking"; const QString LEDTracking = "LED Tracking";

View file

@ -285,32 +285,35 @@ void Hand::simulate(float deltaTime, bool isMine) {
_lastFingerDeleteVoxel = fingerTipPosition; _lastFingerDeleteVoxel = fingerTipPosition;
} }
} }
// Check if the finger is intersecting with a voxel in the client voxel tree
VoxelTreeElement* fingerNode = Application::getInstance()->getVoxels()->getVoxelEnclosing( // Voxel Drumming with fingertips if enabled
glm::vec3(fingerTipPosition / (float)TREE_SCALE)); if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelDrumming)) {
if (fingerNode) { VoxelTreeElement* fingerNode = Application::getInstance()->getVoxels()->getVoxelEnclosing(
if (!palm.getIsCollidingWithVoxel()) { glm::vec3(fingerTipPosition / (float)TREE_SCALE));
// Collision has just started if (fingerNode) {
palm.setIsCollidingWithVoxel(true); if (!palm.getIsCollidingWithVoxel()) {
handleVoxelCollision(&palm, fingerTipPosition, fingerNode, deltaTime); // Collision has just started
// Set highlight voxel palm.setIsCollidingWithVoxel(true);
VoxelDetail voxel; handleVoxelCollision(&palm, fingerTipPosition, fingerNode, deltaTime);
glm::vec3 pos = fingerNode->getCorner(); // Set highlight voxel
voxel.x = pos.x; VoxelDetail voxel;
voxel.y = pos.y; glm::vec3 pos = fingerNode->getCorner();
voxel.z = pos.z; voxel.x = pos.x;
voxel.s = fingerNode->getScale(); voxel.y = pos.y;
voxel.red = fingerNode->getColor()[0]; voxel.z = pos.z;
voxel.green = fingerNode->getColor()[1]; voxel.s = fingerNode->getScale();
voxel.blue = fingerNode->getColor()[2]; voxel.red = fingerNode->getColor()[0];
Application::getInstance()->setHighlightVoxel(voxel); voxel.green = fingerNode->getColor()[1];
Application::getInstance()->setIsHighlightVoxel(true); voxel.blue = fingerNode->getColor()[2];
} Application::getInstance()->setHighlightVoxel(voxel);
} else { Application::getInstance()->setIsHighlightVoxel(true);
if (palm.getIsCollidingWithVoxel()) { }
// Collision has just ended } else {
palm.setIsCollidingWithVoxel(false); if (palm.getIsCollidingWithVoxel()) {
Application::getInstance()->setIsHighlightVoxel(false); // 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++) { for (NodeList::iterator node = nodeList->begin(); node != nodeList->end(); node++) {
if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) { if (node->getLinkedData() && node->getType() == NODE_TYPE_AGENT) {
Avatar* otherAvatar = (Avatar*)node->getLinkedData(); Avatar* otherAvatar = (Avatar*)node->getLinkedData();
// Check for palm collisions if (Menu::getInstance()->isOptionChecked(MenuOption::PlaySlaps)) {
glm::vec3 myPalmPosition = palm.getPosition(); // Check for palm collisions
float palmCollisionDistance = 0.1f; glm::vec3 myPalmPosition = palm.getPosition();
palm.setIsCollidingWithPalm(false); float palmCollisionDistance = 0.1f;
for (int j = 0; j < otherAvatar->getHand().getNumPalms(); j++) { palm.setIsCollidingWithPalm(false);
PalmData& otherPalm = otherAvatar->getHand().getPalms()[j]; // If 'Play Slaps' is enabled, look for palm-to-palm collisions and make sound
if (!otherPalm.isActive()) { for (int j = 0; j < otherAvatar->getHand().getNumPalms(); j++) {
continue; PalmData& otherPalm = otherAvatar->getHand().getPalms()[j];
} if (!otherPalm.isActive()) {
glm::vec3 otherPalmPosition = otherPalm.getPosition(); continue;
if (glm::length(otherPalmPosition - myPalmPosition) < palmCollisionDistance) { }
palm.setIsCollidingWithPalm(true); glm::vec3 otherPalmPosition = otherPalm.getPosition();
const float PALM_COLLIDE_VOLUME = 1.f; if (glm::length(otherPalmPosition - myPalmPosition) < palmCollisionDistance) {
const float PALM_COLLIDE_FREQUENCY = 150.f; palm.setIsCollidingWithPalm(true);
const float PALM_COLLIDE_DURATION_MAX = 2.f; const float PALM_COLLIDE_VOLUME = 1.f;
const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.005f; const float PALM_COLLIDE_FREQUENCY = 150.f;
Application::getInstance()->getAudio()->startDrumSound(PALM_COLLIDE_VOLUME, const float PALM_COLLIDE_DURATION_MAX = 2.f;
PALM_COLLIDE_FREQUENCY, const float PALM_COLLIDE_DECAY_PER_SAMPLE = 0.005f;
PALM_COLLIDE_DURATION_MAX, Application::getInstance()->getAudio()->startDrumSound(PALM_COLLIDE_VOLUME,
PALM_COLLIDE_DECAY_PER_SAMPLE); PALM_COLLIDE_FREQUENCY,
PALM_COLLIDE_DURATION_MAX,
PALM_COLLIDE_DECAY_PER_SAMPLE);
}
} }
} }
glm::vec3 avatarPenetration; glm::vec3 avatarPenetration;