void Init() { RecastNavigationDllImports.CreateLog(4096, 500); if (RecastNavigationDllImports.NavGeneration_Init() == false) { Debug.Log("Error initializing Recast Navigation plugin!"); } UpdateLog(); m_navMeshRepresentation = new RecastNavigationNavMeshRepresentation(); m_navMeshRepresentation.LoadShadersAndMaterials(); BuildProjectNameAndSceneName(); if (sceneName != null && sceneName.Length != 0) { BuildDatabaseMesh(); } SceneView.onSceneGUIDelegate += this.OnSceneGUI; }
void UpdateMeshFromDatabaseTriangles() { RecastNavigationDllImports.BuildDatabaseGeometry(); // TODO: understand why sometimes m_navMeshRepresentation becomes null if (m_navMeshRepresentation == null) { Debug.LogWarning("NavMesh representation became null!"); m_navMeshRepresentation = new RecastNavigationNavMeshRepresentation(); m_navMeshRepresentation.LoadShadersAndMaterials(); } uint triangleCount = RecastNavigationDllImports.GetDatabaseTriangleCount(); m_navMeshRepresentation.Begin(triangleCount); RecastVisualTriangle triangle; for (uint i = 0; i < triangleCount; ++i) { RecastNavigationDllImports.GetDatabaseTriangle(i, out triangle); m_navMeshRepresentation.AddTriangle(triangle); } m_navMeshRepresentation.End(); int vertexCount = RecastNavigationDllImports.GetPolygonVertexCount(); m_navMeshRepresentation.ReSetLine(vertexCount); for (int i = 0; i < vertexCount; i++) { Vector3 vertex = new Vector3(); Color32 color = new Color32(); RecastNavigationDllImports.GetPolygonVertex((uint)i, out vertex, out color); m_navMeshRepresentation.AddLineVertex(i, vertex, color); } m_navMeshRepresentation.BuildLineMesh(); //hasNavMeshVisualRep = true; }