Page 1 of 1

Collisions in 3D

Posted: Sun Nov 08, 2009 10:50 am
by Sylus101
Okay... so I've worked with 2D collisions quite a bit, and I'm wondering what are the most commonly used methods for collision in 3D? Can you apply the rectangular and circular collision concepts to a rectangular cube or sphere?

My guess... for reasonable dirty collisions I would do the best I could to define rectangular dimensions around an object and run greater than/less than boundary tests... does that sound about right?

I'm currently researching the model matrix and how to determine the new location of a vertex after it's been translated, rotated or scaled... I'm gathering I can use glGetFixed() and retrieve the GL_GET_MATRIX_POSITION to run some tests?

Re: Collisions in 3D

Posted: Sun Nov 08, 2009 11:13 pm
by Dark Dude
When I did OpenGL 3D for Win32, I drew all my models' vertices as offsets from a central point. From there, I gauged a sphere around the model itself using a presumed radius, and every time the physics engine updated, I looped through all the models comparing them to each other, in which I had some trig in way to calculate the distance between the two central points of the comparing models, and then I added together their radii and checked if it matched/was smaller (and thus collided) than the distance :P

A very quick and dirty method indeed. Can kill your framerate if the scene is big enough, but very easy to deploy, and not unlike that of the 2D one either ;)