Tuesday, May 6, 2008

An Overview of Collision Detection in OGRE 3D

OGRE3D provides some methods for collision detection. We, Japanese developers call collision detection "hit". Before I explain collision detection, I list factors of collision detection to share our recognization:

  • It's useful that many primitive form classes are defined for detect collisions. OGRE 3D provides ray, bounding sphere and Axis Aligned Bounding Box (AABB).
  • It's possible to handle triangle and planes at Collision Detection.
  • OGRE3D doesn't provide ellipse, cylinder and other high-order calculations.
  • It's possible to detect a collision between Ray and a triangle of a mesh.
  • We often use low level of detail meshes to detect collision quickly. Does OGRE 3D provide the method to do it?

I want to append a little explanation to the last item "low level of detail meshes to detect collision quickly". Japanese developers call such meshes "Hit Model". I don't know what to call it in English, so I describe it as Hit Model in this entry.

OGRE 3D provides all basic collision detections. Bounding Volume instances are generated automatically. For example, Mesh class generates Bounding Sphere and Bounding Box automatically and keep those. This thought is very happy and quick for programers, because they don't think about tools that generate collision data. But, it may be issue for video game development.

In the beginning, you may want to know how to detect collision between Ray and World Geometry. If the world geometry of your game is not height map but a static mesh (rigid model), it's easy to detect the collision. You need to check a collision between Ray and triangle of the world geometry. To do it, we use RaySceneQuery class instead of combination of primitive classes. This is very powerful thought.

A summary of RaySceneQuery is just Ray. But this class exists to handle collision detection. If you use Ray class, you have to write long code to detect collision between Ray and data of geometries in the scene that have possibility to collision with Ray. Plus, your program has to implement gradual detections from BoundingSphere to Triangle of the geometry with using Octree or Quadtree.

RaySceneQuery encapsulates such a standard collision detection process. RaySceneQuery returns the distance from the collision point, so it's easy to do Y-undulation. Some kinds of SceneQuery sub-classes are defined for other classes that work for Collision Detection.

Now, what do you think you need for the standard collision detection process? The scene has many meshes. And a mesh has many triangles. Features that we request to the engine are the following:

  • 1) Removes the geometries that don't have the possibility of collision with the ray from the candidates.
  • 2) Masks the geometries specified by us.
  • 3) Uses bounding volume for the first collision check.
  • 4) Keeps the gradation of 1) and re-uses at the next check.

Does RaySceneQuery provide these features? At the beginning, we want to understand all functions about collision detection of OGRE 3D.

2 comments:

Eric said...

Hi,

we have released MOC, its a simple and lightweight opensource collision detection toolkit for Ogre3D.
Collision Detection Toolkit

ilmi said...

thanks.... i 'll try it