Collision Detection Tutorial

Started by
2 comments, last by Captain P 17 years, 1 month ago
I've searched everywhere but I couldn't find a tutorial that learns you how to code some real basic collision detection. Does anyone know a good tutorial? I'm programming in C++ and OpenGL.
Advertisement
It's a pretty fleshed out topic, I think that you need to be more precise. For example when you say
Quote:
how to code some real basic collision detection


Then I could reply
bool checkSphereCollision(vector position1, vector position2, float radius){    if ( (position1 - position2).length() <= (2 * radius) )        return true;    else        return false;}


Which is a valid answer to your question, but that's probably not what you are looking for. General collision detection for arbitrary cases is not a basic issue, although you could do a brute force triangle-triangle check on your entire scene, but that won't extend well at all. You usually have specialized cases for different collision shapes.
For example a quick [google] revealed Basic Collision Detection. There is even a tutorial on NeHe for a few cases if you want it to be in the context of C++ and OpenGL.
Best regards, Omid
Here's a really great tutorial:

www.paulnettle.com/pub/FluidStudios/CollisionDetection/Fluid_Studios_Generic_Collision_Detection_for_Games_Using_Ellipsoids.pdf
It'll help you if you first formulate what exactly you're looking for. 2D collisions or 3D? Just squares/blocks or arbitrary shapes? And once you're able to detect collisions, what kind of response are you looking for?

Anyway, you may find this tutorial on the Separating Axis Theorem usefull, if you're into 2D.
Create-ivity - a game development blog Mouseover for more information.

This topic is closed to new replies.

Advertisement