Study: Navigation Mesh Generation Java

The NMGen Study is an adaptation in Java of Recast's static mesh functionality for purposes of study and experimentation. NMGen takes an arbitrary triangle mesh as input and generates data representing the traversable surface of the source mesh.

This documentation provides a thorough overview of the process NMGen uses to generate navigation meshes.

"A navigation mesh is an abstract data structure used in artificial intelligence applications to aid agents in path-finding through large spaces. ... Meshes are typically implemented as graphs, opening their use to a large number of algorithms defined on these structures." -Wikipedia

I became interested in navigation mesh generation after attending the Recast master class at AIGameDev.com. Two very productive ways of learning something are to translate it into something else, in this case Java, and to try to explain it to others, in this case through thorough documentation and visualizations.

This documentation will be useful to anyone who wants to get a high level overview of the process used by NMGen to generate navigation meshes. For those who want to go further, the NMGen source code is documented to the extreme.

Special Thanks

To Mikko Mononen for making Recast available for study and use by everyone.

To Alex J. Champandard of AIGameDev.com for presenting Mikko and his work. (See the reference section for links.)

Due to these priorities, documentation is more verbose than normal, variable names are descriptive rather than concise, and code structure skews toward simple rather than efficient.

What This Project Is Not (Limitations)

First and foremost, NMGen is an adaptation, not a port of Recast. Recast is about efficiency and concise code. Since NMGen's highest priority is the study of the algorithms, functionality found in Recast was dropped, reorganized, played around with, etc. Some specifics:

NMGen only covers the static mesh functionality found in Recast as of version 1.4. Recast has a lot more functionality than is found in NMGen. Mikko is also continually enhancing Recast.

While between 80 to 90% of the algorithms in NMGen closely match those found in Recast, there has been extensive refactoring of names and general structure to improve usefulness as a study tool.

The high level structure has been adapted to fit Java standards more closely. Code is skewed toward OOP rather than the procedural programming structure used in Recast.

While NMGen's performance and memory usage is decent, it is not as good as Recast. So the code is not suitable for generation of navigation meshes while the simulation is running.

NMGen is fully functional. But it is still only a prototype. So it is not suitable for use in professional projects without adjustments and more testing.

Prerequisite Knowledge

If you wish to benefit from studying NMGen you will need to be a beginner to intermediate level programmer who can read Java. The code is not particularly complex in structure, so people familiar with C#, C++, and similar languages shouldn't have a problem. People who are only familiar with VB and scripting languages may have difficulty with the syntax.

You will need a pre-calculus level of knowledge if you want to understand some of the more complex algorithms. I provide public sources for many of the algorithms. But without an adequate level of math you will have trouble understanding them.

If you are new to polygon meshes and their common data structures, I recommend detouring for a primer.

Getting Started

Documentation is broken down into three areas. The documentation on this site (overview documentation), API documentation, and detailed source code comments.

If you want to drill all the way down, then the process will likely be:

This overview documentation provides information on each step in the navigation mesh generation process with liberal visualizations, configuration information, and information on important data structures. Throughout this documentation there are links to associated API documentation.

The API documentation provides information related to structure and usage.

The source code is thoroughly commented with links to external references and extra visualizations. When I say "thoroughly" I mean that you can go through certain sections without reading any code. I do this to support the target audience which includes novices.

How you go through the documentation will depend on your level of knowledge and purpose.

Are you coming here from Recast? If so, you might want to review the differences between NMGen and Recast first, rather than last. Otherwise you may get confused with the differences in structure.

If you are a C++ developer who is familiar with computational geometry, then you can probably head right back to Recast after going through this overview documentation, skipping the API documentation and Java source. You can always pull up the associated Java source and review its documentation if there is a particular Recast algorithm that is giving you trouble.

If you are new to navigation mesh generation or the techniques used by Recast, then start with this overview documentation. You can then move on to the API documentation and the source code, stopping at whatever level of detail you desire.