How would you do *real* collisions?

Member
Posts: 90
Joined: 2006.11
Post: #1
Currently, I just have an object, which checks constantly if there are any other objects within a certain radius; if so, it is colliding. This is what i did for a game where there is no 'bouncing'... but what if you want bouncing? what then?
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
Well, you're going to need to know their masses, centers of gravity, relative velocity, and the point of impact, and a good knowledge of high-school physics...

Personally, I tend to think that's a bit too hard, and go for Chipmunk or Newton or something like that to do the hard work for me
Sage
Posts: 1,482
Joined: 2002.09
Post: #3
Ah the sweet smell of vindication. Gives a person that warm fuzzy feeling.

Depends on how complicated you want to make it. Writing the physics for a pool game wouldn't be that hard. You could write that in a hundred lines probably. Jakobsen style physics are also pretty easy, and relatively powerful. (google is your friend)

Writing a robust and stable rigid body physics engine is not simple though. If you are really interested, I could find some of the resources and papers I read when creating Chipmunk.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Apprentice
Posts: 19
Joined: 2007.03
Post: #4
I'm in the process of writing a full 3D physics engine right now and i've found this book invaluable: Dynamic Simulations of Multibody Systems. Try to see if its at any local university libraries or similar high level institutions. It basically will tell you almost everything you need to know.

I also recommend reading the articles written by Chris Hecker here.

That should give you a good starting point for at least understanding how things work, though implementing a good engine is difficult at best.

But for your original question, as OSC said, you'll need to know the relative velocity at the collision point, the collision point, the collision normal, the masses of each body, and the inertia constant for each body. Then you'll have to use that to calculate the impulse on each body in the direction of the collision normal and apply the impulse to get final angular and linear velocities. (you can omit the angular components if you're just using spheres)