From f08354c853e2a186d6d8e10f4a9c8b0d4df88504 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 17 Dec 2013 15:36:26 -0800 Subject: [PATCH 1/3] higher speed collisions to trigger a bounce sound --- interface/src/avatar/Hand.cpp | 4 ++-- libraries/particles/src/ParticleCollisionSystem.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index bd3a0a1fac..7f8e3ffe52 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -24,11 +24,11 @@ using namespace std; const float FINGERTIP_VOXEL_SIZE = 0.05; const int TOY_BALL_HAND = 1; const float TOY_BALL_RADIUS = 0.05f; -const float TOY_BALL_DAMPING = 0.99f; +const float TOY_BALL_DAMPING = 0.999f; const glm::vec3 NO_VELOCITY = glm::vec3(0,0,0); const glm::vec3 NO_GRAVITY = glm::vec3(0,0,0); const float NO_DAMPING = 0.f; -const glm::vec3 TOY_BALL_GRAVITY = glm::vec3(0,-0.5,0); +const glm::vec3 TOY_BALL_GRAVITY = glm::vec3(0,-2.0,0); const QString TOY_BALL_UPDATE_SCRIPT(""); const float PALM_COLLISION_RADIUS = 0.03f; const float CATCH_RADIUS = 0.2f; diff --git a/libraries/particles/src/ParticleCollisionSystem.cpp b/libraries/particles/src/ParticleCollisionSystem.cpp index 1a21d1231e..313c4d7045 100644 --- a/libraries/particles/src/ParticleCollisionSystem.cpp +++ b/libraries/particles/src/ParticleCollisionSystem.cpp @@ -206,7 +206,7 @@ void ParticleCollisionSystem::applyHardCollision(Particle* particle, const glm:: void ParticleCollisionSystem::updateCollisionSound(Particle* particle, const glm::vec3 &penetration, float frequency) { // consider whether to have the collision make a sound - const float AUDIBLE_COLLISION_THRESHOLD = 0.02f; + const float AUDIBLE_COLLISION_THRESHOLD = 0.1f; const float COLLISION_LOUDNESS = 1.f; const float DURATION_SCALING = 0.004f; const float NOISE_SCALING = 0.1f; From e6847961f5553b95bb05ed3787c6a749389fbdca Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 17 Dec 2013 20:11:53 -0800 Subject: [PATCH 2/3] reduced damping for thrown balls, turned off screen flash --- interface/src/avatar/Hand.cpp | 2 +- libraries/particles/src/ParticleCollisionSystem.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index 7f8e3ffe52..c276b9baca 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -24,7 +24,7 @@ using namespace std; const float FINGERTIP_VOXEL_SIZE = 0.05; const int TOY_BALL_HAND = 1; const float TOY_BALL_RADIUS = 0.05f; -const float TOY_BALL_DAMPING = 0.999f; +const float TOY_BALL_DAMPING = 0.1f; const glm::vec3 NO_VELOCITY = glm::vec3(0,0,0); const glm::vec3 NO_GRAVITY = glm::vec3(0,0,0); const float NO_DAMPING = 0.f; diff --git a/libraries/particles/src/ParticleCollisionSystem.cpp b/libraries/particles/src/ParticleCollisionSystem.cpp index 313c4d7045..8281deb12d 100644 --- a/libraries/particles/src/ParticleCollisionSystem.cpp +++ b/libraries/particles/src/ParticleCollisionSystem.cpp @@ -235,6 +235,6 @@ void ParticleCollisionSystem::updateCollisionSound(Particle* particle, const glm fmin(COLLISION_LOUDNESS * velocityTowardCollision, 1.f), frequency * (1.f + velocityTangentToCollision / velocityTowardCollision), fmin(velocityTangentToCollision / velocityTowardCollision * NOISE_SCALING, 1.f), - 1.f - DURATION_SCALING * powf(frequency, 0.5f) / velocityTowardCollision, true); + 1.f - DURATION_SCALING * powf(frequency, 0.5f) / velocityTowardCollision, false); } } \ No newline at end of file From 13be1ea825b5c67e963812e5f9d144adc8bb74e9 Mon Sep 17 00:00:00 2001 From: Philip Rosedale Date: Tue, 17 Dec 2013 22:08:52 -0800 Subject: [PATCH 3/3] added catch, throw, new ball sounds. Tuned ball speed for handball. --- interface/src/avatar/Hand.cpp | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/interface/src/avatar/Hand.cpp b/interface/src/avatar/Hand.cpp index c276b9baca..2fa59ee43f 100755 --- a/interface/src/avatar/Hand.cpp +++ b/interface/src/avatar/Hand.cpp @@ -98,7 +98,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f // update the particle with it's new state... #ifdef DEBUG_HAND - qDebug("Update caught particle!\n"); + qDebug("Caught!\n"); #endif caughtParticle->updateParticle(newPosition, closestParticle->getRadius(), @@ -108,6 +108,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f NO_DAMPING, IN_HAND, // we just grabbed it! closestParticle->getUpdateScript()); + // now tell our hand about us having caught it... _toyBallInHand[handID] = true; @@ -115,6 +116,11 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f //printf(">>>>>>> caught... handID:%d particle ID:%d _toyBallInHand[handID] = true\n", handID, closestParticle->getID()); _ballParticleEditHandles[handID] = caughtParticle; caughtParticle = NULL; + // Play a catch sound! + Application::getInstance()->getAudio()->startDrumSound(1.0, + 300, + 0.5, + 0.05); } } @@ -158,11 +164,17 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f TOY_BALL_DAMPING, IN_HAND, TOY_BALL_UPDATE_SCRIPT); + // Play a new ball sound + Application::getInstance()->getAudio()->startDrumSound(1.0, + 2000, + 0.5, + 0.02); + } } else { // Ball is in hand #ifdef DEBUG_HAND - qDebug("Ball in hand\n"); + //qDebug("Ball in hand\n"); #endif glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition; _ballParticleEditHandles[handID]->updateParticle(ballPosition / (float)TREE_SCALE, @@ -178,13 +190,14 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f // If toy ball just released, add velocity to it! if (_toyBallInHand[handID]) { + const float THROWN_VELOCITY_SCALING = 1.5f; _toyBallInHand[handID] = false; glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition; glm::vec3 ballVelocity = ballFromHand ? palm.getRawVelocity() : palm.getTipVelocity(); glm::quat avatarRotation = _owningAvatar->getOrientation(); ballVelocity = avatarRotation * ballVelocity; + ballVelocity *= THROWN_VELOCITY_SCALING; - // ball is no longer in hand... #ifdef DEBUG_HAND qDebug("Threw ball, v = %.3f\n", glm::length(ballVelocity)); #endif @@ -201,6 +214,13 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f // note: deleting the edit handle doesn't effect the actual particle delete _ballParticleEditHandles[handID]; _ballParticleEditHandles[handID] = NULL; + + // Play a throw sound + Application::getInstance()->getAudio()->startDrumSound(1.0, + 3000, + 0.5, + 0.02); + } }