PDA

View Full Version : Collision response



Run-E
06-08-2001, 05:01 AM
Hi!
I wnat to be able to roll and / or bounce a ball around in an arbitrary shaped landscape... And I want it to be reasonably correct according to physical laws.
Any suggestions?
Thanks!

Ps. I have a working collision detecion. Ds

Zadkiel
06-08-2001, 08:32 AM
You say you have working collision detection so I assume you know therefore which face of your landscape the ball hits.

If that the case then physically correct bouncing is quite easy (well...).

You have to calculate the normal of that face. Then (and this is the hard part) you have to figure out the speed the ball was moving parallel to that normal. You invert that value and multiply it by a constant called the coefficient of restitution, e. This should only be a value between 0 and 1. The lower it is the smaller the subsequent bounce. (Note if you have it between -1 and 0 then that will invert the direction for you)

Make sure you only change the speed parallel to the normal. This is quite difficult in 3d maths but then again its a challange.

Ps. How did you get collision detection to work. On my engine if something moves too fast it can shoot throught the landscape in one frame and never collide. Did you manage to solve this problem.

Tim Stirling
06-08-2001, 09:11 AM
Zadkiel, sounds like a classic case of not taking into acount time in some way or another. You don't only have to check where the collider is and where it is going but also every point (infinite) inbetween. You need to find the distance to the colliding plane from the initial position this will show you where and how far to move.

Run-E
06-08-2001, 10:46 AM
Hi!
Thanks for your help guys!
ABout the ball going through the landscape... I honestly didn't test that yet... :-/
I guess was hoping the framerate would be high enough (and the ball always slow enough)not to miss any collisions, but when i think about it I can see how this might become a problem. At the time my landscape is nothing more than a rather simple kind of a miniature golf course.
Well... Thanks again and feel free to add anything you think I should take into account!