Sign in to follow this  
Scyth333

Collision Detection Tutorial

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Here's a really great tutorial:

www.paulnettle.com/pub/FluidStudios/CollisionDetection/Fluid_Studios_Generic_Collision_Detection_for_Games_Using_Ellipsoids.pdf

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this