Public Group

# Basic 2D Physics and Collision Detection

This topic is 4546 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello. I've been working on a game engine and started a demo project to see how well it worked. I got a bit ambitious with this demo project and decided I wanted to simulate some rigid bodies in the game. I first turned to ODE, but I found it a tad complicated and far too powerful for my needs. The biggest problem was that ODE is designed for 3D simulation and I'm working in 2D! Adding joints and constraints to keep rotations on one axis and movement on two seemed like more annoying work. So I decide I should try implementing my own rigid bodies as well as collision detection and I would add this functionality to my engine. So far, I've added a few objects for simulation, including Geometry, RigidBody, DynamicsSystem, and CollisionInfo. Geometry stores a list of points that make up a convex polygon used for collision detection. The origin of such shapes is always (0,0) and I plan for the origin to always be the COM during simulation. A RigidBody requires a pointer to a valid Geometry object and a DynamicsSystem to be created. It contains information like mass, position, and orientation. The DynamicsSystem object contains a list of RigidBodies. It updates these RigidBodies and allows them to interact. CollisionInfo is a struct returned from RigidBody's CheckCollision(const RigidBody&) method. First of all, I'm wondering if this is a good breakdown or not. Am I putting any data in the wrong place? I'm not terribly familiar with simulation physics, so I'm really not sure. I'm using SAT to test for collisions. Here's a little diagram I just drew up in Photoshop: After looking over the N tutorials, I've been curious about the displacement vector in my diagram and how it can be used to not only keep objects from penetrating, but how it can be used to calculate the appropriate resultant force. If I somehow combine these vectors, can I get some useful information? How can I scale them by the masses of the two objects to predict the appropriate displacement? I need help from here. I can detect the collision, but how can I use information from the SAT test to create some reasonable physics. I'm not looking for anything realistic. I just want objects to bounce, spin, and move. It doesn't need to look too real. I would like to avoid using an integrator (if that's possible). Eventually, I want to be able to manipulate RigidBody objects with methods like AddForce() and AddTorque() and then update the position and orientation of game objects with respect to their associated RigidBody object. Any help, links, articles, or comments are greatly appreciated. Thanks! [Edited by - GenuineXP on May 7, 2006 12:23:41 PM]

##### Share on other sites
Two suggestions: a) look into Chris Hecker's articles if you haven't already, and b) maybe see if you can get this moved to 'math & physics'; you might get more help on this particular topic there.

##### Share on other sites

now that is awesome. thanks for sharing the link.

Quote:
 Original post by SoftBeatClicky

##### Share on other sites
No problem.

I just added rigid body physics to my game engine.

Clicky

[Edited by - SoftBeat on May 12, 2006 10:09:35 PM]

1. 1
2. 2
Rutin
25
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 20
• 14
• ### Forum Statistics

• Total Topics
632950
• Total Posts
3009378
• ### Who's Online (See full list)

There are no registered users currently online

×