Bouncyness [Solved]

rewb0rn

15-01-2007 15:45:25

Hi, is there a method to change the bouncyness of a body, like the sphere feet in the walking character tutorial? At the moment my player bounces all over the level if he runs up stairs lol

bleubleu

15-01-2007 17:21:28

Hi there!

I am not an expert with ODE, but I know that if you use a collision callback, you can modify the bouncyness.

bool Application::collision(OgreOde::Contact* contact)
{
// The bouncyness is a parameter between 0 and 1.
contact->setBouncyness(0.0);
return true;
}

Here is what the ODE doc says about the bouncyness :
The bouncyness of the stops. This is a restitution parameter in the range 0..1. 0 means the stops are not bouncy at all, 1 means maximum bouncyness.
Your must register a collision listener when initializing your application :
world->setCollisionListener(this);

Have fun!

Mat

rewb0rn

15-01-2007 17:30:55

Thanx, it works! But how do I know what bodies are in contact so that not all object are not bouncy in the program?

bleubleu

15-01-2007 19:06:03

Hi!

The contact object that you receive in the callback can give you the pair of geometries colliding :

contact->getFirstGeometry()
contact->getSecondGeometry()


Then in the Geometry object, you can try to identify the geometry by its type or better yet, use the "getUserData()" method to retrieve some date you may have set earlier. You may want to keep a pointer to your actual application objects (like your character) or an ID that is meaningful to you.

Mat

rewb0rn

15-01-2007 19:44:19

You may want to keep a pointer to your actual application objects
Yea that sounds good, thx!