3d Collision Handling

I have trouble while detecting collisions on my 3D-Game.

I have set-up Rays, to detect collisions (Screenshot) and my main-rountine already analyzes them. But now there's the question what to do with that.

One possibility would be, to move the player back to the last position, but that's dirty, and does not work if the player can walk in multiple directions (e.g. if the player runs along a wall).

My question is, what to do with the collision data / or in which direction, by which amount move the player? I'm sure there is an algorithm for that (as for almost all is).

-

migrated from stackoverflow.comNov 27 '12 at 14:39

This question came from our site for professional and enthusiast programmers.

I guess you're going the right way, but there's more to that than you imagine. Collision detection is a vast research topic (GAMMA).

From Wikipedia:

"(...) physical simulators usually function one of two ways, where the collision is detected a posteriori (after the collision occurs) or a priori (before the collision occurs). In addition to the a posteriori and a priori distinction, almost all modern collision detection algorithms are broken into a hierarchy of algorithms. Often the terms "discrete" and "continuous" are used rather than a posteriori and a priori."

And it follows as this:

"In the a posteriori case, we advance the physical simulation by a small time step, then check if any objects are intersecting, (...) and the positions and trajectories of these objects are somehow "fixed" to account for the collision."

"In the a priori methods, we write a collision detection algorithm which will be able to predict very precisely the trajectories of the physical bodies (...) and the physical bodies never actually interpenetrate (...)"

Where to begin:

From my experience, I read a long time ago David Eberly's "3d Game Engine Design" book, which has a chapter on the subject that ends with a simple collision detection system implementation. I think it is a very adequate starting source, due to the fact you're trying to build a game engine.

Another way to go would be reading this very well recomended book (Real-time collision detection).

In addition, a quick google search on "collision detection state of art" led me to this paper.