Monday, November 18, 2013

Navigation Mesh Revisited



Navigation Mesh Revisited 

I would like to revisit navigation meshes as I feel that my last blog was a little slim in information. Moving on, Navigation Meshes are used as a data structure that defines the traversable areas for AI path finding. Navigation Meshes differ from how waypoints represent the traversable areas because instead of a series of connected points, a navigation mesh represents it as a connected graph of convex polygons. Unlike waypoints, the navigation mesh does not have to sample a waypoint directly because it represents a more complete version of the level. This can additional information makes Navigations meshes a better choice, for instance, they can help entities turn corners more fluently. 

Figure 1 shows the difference between the path calculated by a Navigation mesh, and that of a more traditional method. We can notice that the path generated by the navigation mesh is much representative of the path that should be taken.
Figure 1

Now that we know about navigation meshes what is the process of actually making or generating one? First off, the easiest way is to generate them with third party applications like Recast, which is a great tool. There are plenty of algorithms for creating a navigation mesh but one algorithm does it in a very cool way. The level geometry is subjected to intense ray casting which produces a grid like mesh on the floor of the game world. The ray cast can also be done by a voxel grid with both of them having multiple parameters, such as subdivision count. This grid is then reduced or simplified into a small number of convex polygons. Figure 2 shows the ray casted grid on the floor of the game world. Note the subdivisions in the grid to increasing the accuracy of the final navigation mesh.

Figure 2

The algorithm for utilizing Navigation Meshes is virtually the same as that of traditional waypoints; They both use A* at their core. A* finds one of the shortest paths from the start to the end goal by evaluating the nodes connections and distance them. This process is easy for Navigation Meshes because the polygons in the data structure are convex, so we can guarantee that within a polygon (node) any point is a valid. This means that any connected polygons create a valid path, and A* becomes easy to apply to it. Furthermore, because Navigation Meshes are usually less complex then waypoints, path finding is more efficient because there are fewer nodes to process.

In conclusion, I would recommend Navigation Meshes over waypoints as they are easy to make, produce better results and are quicker to process.

No comments:

Post a Comment