Collision detection


I am writing a simple 3D first person maze game.

I have created a model of the maze in 3D Studio Max and have loaded it into OpenGL. You can also “walk” around the maze (changing the camara position).

My problem is that you can walk right through the walls. Is there any simple way of implementing collision detection? Where would be a good source of information about implementing this?


Is there any simple way of implementing collision detection?
No. Unless colliding objects have all sphere or box shapes this is more difficult than rendering these objects. And since you created a scene in 3D studio I assume it’s not a box :slight_smile:

I remember there were ray-plane and ray-triangle intersection demos at and that’s where you should start.
Edit: I just looked at nehe and couldn’t find these, but I’ve found this:
Look at last tutorial.

Keep in mind that collision detection usually requires more optimizations than rendering. You can’t just detect collisions between every possible pair of objects in the scene unless you have only few simple objects.
With brute-force approach detecting collision between 2 objects, each having 50 polygons will require a few thousands (!) tests for intersection.

Thanks for the info.