SharpGL Collision Help

Mar 19, 2015 at 11:05 AM
Hey all im new to sharpGL and so far iv made a project with a flat plane for a ground and a cube which i can move around with my WASD keys but 1 think i cant figure out is how to check collisions with the plane atm iv got a temp collision on if you would even call it a collision where if the object is not at the Y Axis 0.0f it moves down if it is it stops but thats not really collision its just checking positions how can i get a function where it returns true or false when my cube is somewhere in contact with my plane?

Thanks.

Sorry for my bad english.
Mar 25, 2015 at 8:44 AM
Hi Mumbot!

Thanks a lot for your question and sorry for the late answer. We moved to GitHub, so please contact us there.

To your question: There is no real support for collision detection in SharpGL. If you look into the SceneGraph, you can find some raytracing stuff, e.g. find intersections of a ray with a polygon. Maybe that helps a bit. But I think, it is not what you need. Further, the SceneGraph will be obsolete in this form in the near future. So please don't relay on it.

But how to make collision detection? There are several tutorials in the web. Please find some links below.

Collision detection can be implemented with octrees or quadtrees. The idea is to separate the scene space into cubes. First there is one big cube containing the whole scene. This one is divided into 4 sub-cubes. Each of the 4 sub-cubes are divided into more sub-cubes and so on. To detect collisions of 2 objects, you can check if both objects are in the same cube. The more cubes you have the more precise your detection will be. But more cubes mean more calculations, so detection will be slower. Precision vs. performance. Keep this in mind. Find below some links for this topics.

Octree
Quadtree
NeHe
Octree Tutorial

Hope that helps!

Robin