mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 23:36:44 +02:00
added catch, throw, new ball sounds. Tuned ball speed for handball.
This commit is contained in:
parent
b3bb33e48c
commit
13be1ea825
1 changed files with 23 additions and 3 deletions
|
@ -98,7 +98,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
|
||||||
|
|
||||||
// update the particle with it's new state...
|
// update the particle with it's new state...
|
||||||
#ifdef DEBUG_HAND
|
#ifdef DEBUG_HAND
|
||||||
qDebug("Update caught particle!\n");
|
qDebug("Caught!\n");
|
||||||
#endif
|
#endif
|
||||||
caughtParticle->updateParticle(newPosition,
|
caughtParticle->updateParticle(newPosition,
|
||||||
closestParticle->getRadius(),
|
closestParticle->getRadius(),
|
||||||
|
@ -108,6 +108,7 @@ void Hand::simulateToyBall(PalmData& palm, const glm::vec3& fingerTipPosition, f
|
||||||
NO_DAMPING,
|
NO_DAMPING,
|
||||||
IN_HAND, // we just grabbed it!
|
IN_HAND, // we just grabbed it!
|
||||||
closestParticle->getUpdateScript());
|
closestParticle->getUpdateScript());
|
||||||
|
|
||||||
|
|
||||||
// now tell our hand about us having caught it...
|
// now tell our hand about us having caught it...
|
||||||
_toyBallInHand[handID] = true;
|
_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());
|
//printf(">>>>>>> caught... handID:%d particle ID:%d _toyBallInHand[handID] = true\n", handID, closestParticle->getID());
|
||||||
_ballParticleEditHandles[handID] = caughtParticle;
|
_ballParticleEditHandles[handID] = caughtParticle;
|
||||||
caughtParticle = NULL;
|
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,
|
TOY_BALL_DAMPING,
|
||||||
IN_HAND,
|
IN_HAND,
|
||||||
TOY_BALL_UPDATE_SCRIPT);
|
TOY_BALL_UPDATE_SCRIPT);
|
||||||
|
// Play a new ball sound
|
||||||
|
Application::getInstance()->getAudio()->startDrumSound(1.0,
|
||||||
|
2000,
|
||||||
|
0.5,
|
||||||
|
0.02);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Ball is in hand
|
// Ball is in hand
|
||||||
#ifdef DEBUG_HAND
|
#ifdef DEBUG_HAND
|
||||||
qDebug("Ball in hand\n");
|
//qDebug("Ball in hand\n");
|
||||||
#endif
|
#endif
|
||||||
glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition;
|
glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition;
|
||||||
_ballParticleEditHandles[handID]->updateParticle(ballPosition / (float)TREE_SCALE,
|
_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 toy ball just released, add velocity to it!
|
||||||
if (_toyBallInHand[handID]) {
|
if (_toyBallInHand[handID]) {
|
||||||
|
|
||||||
|
const float THROWN_VELOCITY_SCALING = 1.5f;
|
||||||
_toyBallInHand[handID] = false;
|
_toyBallInHand[handID] = false;
|
||||||
glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition;
|
glm::vec3 ballPosition = ballFromHand ? palm.getPosition() : fingerTipPosition;
|
||||||
glm::vec3 ballVelocity = ballFromHand ? palm.getRawVelocity() : palm.getTipVelocity();
|
glm::vec3 ballVelocity = ballFromHand ? palm.getRawVelocity() : palm.getTipVelocity();
|
||||||
glm::quat avatarRotation = _owningAvatar->getOrientation();
|
glm::quat avatarRotation = _owningAvatar->getOrientation();
|
||||||
ballVelocity = avatarRotation * ballVelocity;
|
ballVelocity = avatarRotation * ballVelocity;
|
||||||
|
ballVelocity *= THROWN_VELOCITY_SCALING;
|
||||||
|
|
||||||
// ball is no longer in hand...
|
|
||||||
#ifdef DEBUG_HAND
|
#ifdef DEBUG_HAND
|
||||||
qDebug("Threw ball, v = %.3f\n", glm::length(ballVelocity));
|
qDebug("Threw ball, v = %.3f\n", glm::length(ballVelocity));
|
||||||
#endif
|
#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
|
// note: deleting the edit handle doesn't effect the actual particle
|
||||||
delete _ballParticleEditHandles[handID];
|
delete _ballParticleEditHandles[handID];
|
||||||
_ballParticleEditHandles[handID] = NULL;
|
_ballParticleEditHandles[handID] = NULL;
|
||||||
|
|
||||||
|
// Play a throw sound
|
||||||
|
Application::getInstance()->getAudio()->startDrumSound(1.0,
|
||||||
|
3000,
|
||||||
|
0.5,
|
||||||
|
0.02);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue