History: Critter AI
Source of version: 2 (current)
Copy to clipboard
{maketoc}
!!Introducation
Critter AI is a .NET avaiable NavMesh generating and Path finding library, it support Unity3d or pure .Net environment, it supports MOGRE too.
!!Code Snippet
Here are some codes from [https://www.ogre3d.org/addonforums/8/t-29245.html|this link], which you can create a navmesh which is compliable with MOGRE
{CODE(theme="C#")}
private void TestNavmesh() {
NavStatus status;
NavmeshQuery query;
float[] vagueStartPoint = { -8, 0.6f, -3 };
float[] vagueEndPoint = { 16.3f, 0.8f, 4.5f };
uint startPoly;
uint endPoly;
float[] startPoint = new float[3];
float[] endPoint = new float[3];
float[] extents = { 2, 2, 2 };
status = NavmeshQuery.Build(navmesh, 100, out query);
Console.WriteLine("Status returned when NavmeshQuery was built: " + status);
NavmeshQueryFilter filter = new NavmeshQueryFilter();
filter.IncludeFlags = 1;
status = query.GetNearestPoly(vagueStartPoint, extents, filter, out startPoly, startPoint);
Console.WriteLine("\nStatus of startPoint getNearestPoly: " + status);
Console.WriteLine("Start polyref: " + startPoly + " startpoint: (" + startPoint[0] + ", " + startPoint[1] + ", " + startPoint[2] + ")");
query.GetNearestPoly(vagueEndPoint, extents, filter, out endPoly, endPoint);
Console.WriteLine("\nStatus of endPoint getNearestPoly: " + status);
Console.WriteLine("end polyref: " + endPoly + " endpoint: (" + endPoint[0] + ", " + endPoint[1] + ", " + endPoint[2] + ")");
uint[] path = new uint[100];
int pathCount;
status = query.FindPath(startPoly, endPoly, startPoint, endPoint, filter, path, out pathCount);
//status = query.FindPath(ref startPoly, ref endPoly, vagueStartPoint, vagueEndPoint, extents, filter, path, out pathCount);
Console.WriteLine("\nStatus of FindPath: " + status);
Console.WriteLine("Pathcount: " + pathCount);
//MessageBox.Show( Debug.ToString(navmesh.GetTile(0).GetHeader()));
}
{CODE}