C# Port of Recast/Detour Navigation Mesh

Filed Under (Uncategorized) by sickadmin on 21-12-2012

I’m releasing Sick Kreations C# port of ‘Recast/Detour by Mikko Mononen’ and hope it helps others solve complex AI path finding.
Recast/Detour tool with End of Days:Survivor level loaded and the navigation mesh generated

Here’s is a link to Recast and Detour 1.21 by Mikko Mononen on his ‘Digesting Duck’ blog, here.
Here’s is the modified project we use to export the navigation mesh in a format compatible with Xbox360 Big Endian, Download.
Here is the files  to add to your game for run time loading and getting routes, Download.

To compile the Recast/Detour navigation mesh generation tool:
I downloaded C++ 2010 Express to build the Recast/Detour project, you can get it free from Microsoft.
After unzipping ‘Recast Detour Project’ you should find the solution file at ‘..RecastDemo\Build\VC9\Recast.sln’.
You’ll probably have to set the include, source and library paths for your build.

In addition to that you’ll have to set ‘Additional Library Directories’ in the C++ Express environment to point to were you downloaded and unzipped the Recast/Detour files from  Mikko Mononen’s blog.


To load a navigation mesh in game:
dtStatNavMesh NavigationMesh = new dtStatNavMesh();
NavigationMesh.LoadNavigationMesh( AssetDirectory + NavigationMeshName + “NavMeshXbox360”);

To get a route in game:
int NavMeshStart = 0;
int NavMeshCount = NavigationMesh.GetPath(ref Vector3 Start, ref Vector3 End, ushort[] routePolys, Vector3[] NavMeshRoute, true);

To walk through the route:
while (NavMeshStart < NavMeshCount)
{ Vector3 RouteNode = NavMeshRoute[NavMeshStart++]; }

My implementation of Recast/Detour was quick and dirty and there is room to optimize the code, the first place to look for optimizing would be the file DetourNode.cs’.

If I left out any files from the End Game Engine that are referenced please leave a commit and I’ll get those included asap.
Mikko Mononen stuff works flawlessly for our engine and we are grateful to him for sharing his navigation mesh code. All the original code is by Mikko Mononen and I have clearly marked my changes, please do the same with the code when you get it.