What you need
The information provided in here is what I have picked up while writing my own Game Engine, the REngine. It's worth noting what the REngine is and is not as this will give you the best idea of what I do and (more importantly) do not understand. The REngine is the foundation of a space based fighter game. Therefore it handles rigid body physics in an idealized environment. There is no wind resistance, and friction is ignored. Conceivably you could add these things once you understand the basics. There are also no deformable bodies, and to be honest, I have no idea how those things work, I'm convinced they're some kind of dark magic. If you want to learn how to write race car games or cloth simulators this is probably not the guide for you. If you want to know how to make relatively complex shapes (ie things that look like space ships) collide, then you may want to read on.
If I still have your interest then at this point you will want to get yourself a copy of the REngine. The overview sections will not directly reference the source, but the details sections will pretty much only reference the source. I'm not going to embed source within this guide, I will leave it up to you to flip back and forth.
Other docs:
While it is pretty much essential that you have the REngine open, there are some other papers you will want to have handy as well. These are the papers that delve very deeply into the topics I will try to explain at a high level. These docs are amazing in the depth of their knowledge and I owe all my understanding to their authors. For the most part this guide is just a simplified explanation of what I got out of these papers, as well as some glue to try and put the important parts together into a working collision system. In order to truly understand what's going on you will want to read these. The authors listed here are MUCH smarter then I am, and their solutions are much more complete:
Online resources:
- Intersection of Convex Objects: The Method of Separating Axes by David Eberly (available at www.geometrictools.com). An introduction to Separating Axes. This is the collision detection system the REngine uses, and this is the most useful paper I've found on it.
- Dynamic Collision Detection using Oriented Bounding Boxes by David Eberly (available at www.geometrictools.com). Provides an incredibly useful discussion of how to write code using the Seperating Axis method to find collision points. He also spells out in easy to understand tables the exact projection of common shapes onto vectors.
- Chris Hecker's four articles on physics (available at www.d6.com/users/checker/index.htm). Absolutely crammed full with enough physics to give you a headache for weeks. Knowing that you have collided is only the first step, this paper tells you what to do with that knowledge.
- Olivier Renault's projects, specifically his Cube3D (available at uk.geocities.com/olivier_rebellion/). The only easy to follow example I could find. An invaluable body of code for making sense of collision detection and response.
From your favourite book shop:
- Game Physics by david Eberly
- 3D Game engine Architecture by David Eberly
- Mathematics for 3D Game Programming & Computer Graphics by Eric Lengyel
That list should keep you busy for years. I hope this paper will help give you a rough idea of how all the pieces fit together. So without any more intro, let's start by looking at
some physics...