• Advertisement
Sign in to follow this  

Collision Detection Tutorial

This topic is 4061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
Sign in to follow this  

  • Advertisement