Chapter 8

Pathfinding

WHAT’S IN THIS CHAPTER?

  • Introducing the Recast and Detour libraries
  • Building a navigation mesh from an arbitrary geometry using Recast
  • Creating a pathfinding query and sending it over to Detour
  • Implementing physics picking (from 2D to 3D)
  • Implementing a CPU-based character auto-drive system
  • Implementing basic artificial intelligence using pathfinding
  • Using a True Type Font file to print dynamic text on top of your scenes

From first-person shooter to point-and-click, pathfinding plays an important role in navigating levels and for artificial intelligence. Pathfinding allows your characters to move to a specific location by themselves, while avoiding obstacles. You can also use it to enable an NPC (non-player character) to find the player inside a scene, and a lot more.

RECAST AND DETOUR

In this chapter, you will be studying the Recast and Detour libraries. As a quick introduction, Recast is a state-of-the-art library that allows you to construct a navigation mesh from an arbitrary geometry, or a set of different geometries. And the Detour library supports dynamic navigation tiles, crow simulation, ray casting, and dynamic obstacles that can be generated at run time, as well as many other goodies, based on the navigation mesh created by Recast.

More information on Recast and Detour can be found at http://code.google.com/p/recastnavigation/, where you can download the latest source code, SDK, and demo app (as shown in Figure 8-1) from SVN.

FIGURE 8-1: Recast ...

Get Game and Graphics Programming for iOS and Android® with OpenGL® ES 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.