rigid body collisions?
I''m working on a 2d rigid body dynamics system for a game and I''m up to the point where I need to add collision response. I read a tutorial and implemented a simple integration/constraint system to create some rigid bodies (boxes, ropes, etc...) but it didn''t quite mention how to properly handle collisions.
I''m using Verlet integration (since it''s easy to handle constraints) and create the rigid bodies by attaching a bunch of point masses together with stick constraints. Collision is fairly simple for the outer edges of the screen (bouncing off the walls) but how should I handle collision between two objects? I was going to use the stick constraints as a means of collision detection (since each stick represents a side of the object) but I can''t figure out where to go from here...
Thanks for any replies.
-JtM
**WARNING, MAY CONTAIN NUTS**
-JtM
Well, you want to apply an impulse to both objects, in the direction of the normal of the collision. This can be done by modifying xold(moving it in the -normal direction).
Your impulse is going to look something like -(1+coefficient of restitution) * (relative normal velocity) / (1/mass1 + 1/mass2) for linear collisions. You have to add some more terms in for angular collisions. Check out "Physics for Game Developers" by Eberly, for instance, for some equations.
Your impulse is going to look something like -(1+coefficient of restitution) * (relative normal velocity) / (1/mass1 + 1/mass2) for linear collisions. You have to add some more terms in for angular collisions. Check out "Physics for Game Developers" by Eberly, for instance, for some equations.
Thanks. I went to amazon and searched the book. I found one with the same title with a kitten & mouse on the cover. Is that the same book?
Also, with linear collisions do I apply the impulse to all the points on the object or just the ones ones involved in the collision?
-JtM
**WARNING, MAY CONTAIN NUTS**
Also, with linear collisions do I apply the impulse to all the points on the object or just the ones ones involved in the collision?
-JtM
**WARNING, MAY CONTAIN NUTS**
-JtM
Yes--the mouse & cat book is the same one. It''s a good read.
(aside: I always have a hard time distinguishing between vectors & scalars in the book. I wish books would put the little arrow over a bolded letter to signify a vector...)
-Pete
(aside: I always have a hard time distinguishing between vectors & scalars in the book. I wish books would put the little arrow over a bolded letter to signify a vector...)
-Pete
quote:
Original post by JtM
Also, with linear collisions do I apply the impulse to all the points on the object or just the ones ones involved in the collision?
For rigid body collisions you would apply the impulse to all points on the object.
another note about the book: the formulas are good, the explanations are good, but the code is not so good. Just keep that in mind.
June 02, 2003 07:24 AM
Your system sounds very much like the one outlined in "Advanced character physics", which can be found at
http://www.ioi.dk/Homepages/thomasj/publications/gdc2001.htm
When you detect a collision, it''ll be in terms of two intersecting line segments, so you need to:
a) decide which endpoint passed through the other line
b) move the offending endpoint, along with the endpoints of the line that was penetrated, just enough that the intersection does not occur any more
And that''s it. It sounds too simple to work, but work it does. The effects of the collision are propogated to the rest of the body the next time you satisfy the constraints.
http://www.ioi.dk/Homepages/thomasj/publications/gdc2001.htm
When you detect a collision, it''ll be in terms of two intersecting line segments, so you need to:
a) decide which endpoint passed through the other line
b) move the offending endpoint, along with the endpoints of the line that was penetrated, just enough that the intersection does not occur any more
And that''s it. It sounds too simple to work, but work it does. The effects of the collision are propogated to the rest of the body the next time you satisfy the constraints.
Awsome! Thanks, AP, sjelkjd, pschmitt.
AP: That article looks like what I''m looking for. I had no idea hitman used the same system (the ragdoll effects were very nice in that game).
The reason I''m trying to develop a 2D physics engine is to create a varient of asteroids/minestorm with semi-realistic physics and collision response.
Thanks for the help everyone.
AP: That article looks like what I''m looking for. I had no idea hitman used the same system (the ragdoll effects were very nice in that game).
The reason I''m trying to develop a 2D physics engine is to create a varient of asteroids/minestorm with semi-realistic physics and collision response.
Thanks for the help everyone.
-JtM
you could even apply proper constraints to the objects, like link them and stuff. Make breakable scenery, deformable shapes, create chains, robotic animations, ect... This verlet/constraint stuff is the best thing since bread and butter. The possibilities are endless. Muhahahahaha!
I am working on that very thing right now. Trying my hands on ragdolls. 1/2 way there. I still need to constrain angles between joints, but the stiff constraint is there.
I am working on that very thing right now. Trying my hands on ragdolls. 1/2 way there. I still need to constrain angles between joints, but the stiff constraint is there.
Everything is better with Metal.
That was my intention :D. Although I haven''t quite figured out how to arbitrarily constrain two objects with each other, I definately want to implement it. For now I''m going to concentrate on the basics and get a stable and fast 2d physics engine off the ground.
It would be cool to have some kind free form, deformation, breakable asteroids though it might become too processor intensive for a large number of objects and my code isn''t heavily optomised either
)
It would be cool to have some kind free form, deformation, breakable asteroids though it might become too processor intensive for a large number of objects and my code isn''t heavily optomised either

-JtM
June 03, 2003 02:37 AM
hmmm, it seems that you have had the same idea that i had, only i had it last year! mwuhahaha!
I''ve been implementing it in Java, and you can find the editor and instructions for the physics engine at
http://www.homepages.inf.ed.ac.uk/s9902505/
the game is not yet released, but may be soon...
You''ve an interesting journey ahead of you.
I''ve been implementing it in Java, and you can find the editor and instructions for the physics engine at
http://www.homepages.inf.ed.ac.uk/s9902505/
the game is not yet released, but may be soon...
You''ve an interesting journey ahead of you.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement