I'm trying to develop a simple 3d environment (in openTK, so basically openGL) and implement simple collision detection. I will have the camera object which will have a bounding cube and a world full of triangles and quads.
If I'm given a bounding cube (or bounding sphere if that's easier) and a list of polygons, is there a quick and dirty way to do basic collision detection?
Thanks for any help
Ok, for simple bounding box collision, I wrote the following method that will accept a
BoundingBox
object and determine if it is inside the the current instance of aBoundingBox
.A bounding box consists of the a
Point3D
object (same as thePoint
class but with a Z coordinate) for the center of the bounding box, and the height, width, and depth of the box. With those 4 objects, it calculates the Left (min X), Right (max X), Bottom (min Y), Top (max Y), Front (min Z) and Back (max Z) of the box (The box is axis aligned. This is simple collision). Here is the method to detect if one box is within the other, and if so, modifiy the box to move it outside.You call it by doing something like:
meshData.Box.Intersection(ref camera.box);
wheremeshData
is some kind of geometry in the scene and thecamera
is the object for the current user's perspective.Hope this is useful for someone else!