Sunday, November 22, 2009

OpenGL: Collision Detection

Still experimenting with OpenGL, Today's example is about Collision Detection. As you can see from the screenshot... There's two crates and a wire sphere (I've no texture for that).. from the post title, you can imagine that the sphere moves in the direction of a crate and when it collided with the crate it changes its direction.
All the magic is under the hood, in the hit.c engine file. I've implemented a couple of methods that test collision between Box and Box, Box and Sphere, Box and Point, Sphere and Sphere, Sphere and Box, Sphere and Point. In this way you can easily handle the most common meshes, just checking glDataHitCollision(obj1, obj2).

The Source code is available here: GLData Collision Detection Example Source Code. Just type python to build and run (Linux, Mac).

No comments:

Post a Comment