private void PrepareRender() { // Add to scene after building a mesh vertices = new List <Vertex>(); indices = new List <int>(); for (int i = 0; i < navMesh.getMaxTiles(); ++i) { Detour.dtMeshTile tile = navMesh.getTile(i); if (tile.header != null) { AddMeshTile(tile); } } var geom = new Mesh(); geom.Load(vertices, indices, indices.Count / 3); var mat = new MaterialDiffuse() { ShaderProgram = "diffuse", Tex = "" }; node = new Scene.Node() { Name = "NaviMesh", Material = mat, Mesh = geom }; scene.Add(node); }
static bool LoadedTilesCommand(StringArguments args, CommandHandler handler) { Player player = handler.GetSession().GetPlayer(); uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMap(), player.GetPositionX(), player.GetPositionY()); Detour.dtNavMesh navmesh = Global.MMapMgr.GetNavMesh(terrainMapId); Detour.dtNavMeshQuery navmeshquery = Global.MMapMgr.GetNavMeshQuery(terrainMapId, handler.GetPlayer().GetInstanceId()); if (navmesh == null || navmeshquery == null) { handler.SendSysMessage("NavMesh not loaded for current map."); return(true); } handler.SendSysMessage("mmap loadedtiles:"); for (int i = 0; i < navmesh.getMaxTiles(); ++i) { Detour.dtMeshTile tile = navmesh.getTile(i); if (tile.header == null) { continue; } handler.SendSysMessage("[{0:D2}, {1:D2}]", tile.header.x, tile.header.y); } return(true); }
static bool LoadedTilesCommand(StringArguments args, CommandHandler handler) { uint mapid = handler.GetPlayer().GetMapId(); Detour.dtNavMesh navmesh = Global.MMapMgr.GetNavMesh(mapid); Detour.dtNavMeshQuery navmeshquery = Global.MMapMgr.GetNavMeshQuery(mapid, handler.GetPlayer().GetInstanceId()); if (navmesh == null || navmeshquery == null) { handler.SendSysMessage("NavMesh not loaded for current map."); return(true); } handler.SendSysMessage("mmap loadedtiles:"); for (int i = 0; i < navmesh.getMaxTiles(); ++i) { Detour.dtMeshTile tile = navmesh.getTile(i); if (tile == null) { continue; } handler.SendSysMessage("[{0:D2}, {1:D2}]", tile.header.x, tile.header.y); } return(true); }
static bool HandleMmapStatsCommand(StringArguments args, CommandHandler handler) { Player player = handler.GetSession().GetPlayer(); uint terrainMapId = PhasingHandler.GetTerrainMapId(player.GetPhaseShift(), player.GetMap(), player.GetPositionX(), player.GetPositionY()); handler.SendSysMessage("mmap stats:"); handler.SendSysMessage(" global mmap pathfinding is {0}abled", Global.DisableMgr.IsPathfindingEnabled(player.GetMapId()) ? "En" : "Dis"); handler.SendSysMessage(" {0} maps loaded with {1} tiles overall", Global.MMapMgr.getLoadedMapsCount(), Global.MMapMgr.getLoadedTilesCount()); Detour.dtNavMesh navmesh = Global.MMapMgr.GetNavMesh(terrainMapId); if (navmesh == null) { handler.SendSysMessage("NavMesh not loaded for current map."); return(true); } uint tileCount = 0; int nodeCount = 0; int polyCount = 0; int vertCount = 0; int triCount = 0; int triVertCount = 0; for (int i = 0; i < navmesh.getMaxTiles(); ++i) { Detour.dtMeshTile tile = navmesh.getTile(i); if (tile == null) { continue; } tileCount++; nodeCount += tile.header.bvNodeCount; polyCount += tile.header.polyCount; vertCount += tile.header.vertCount; triCount += tile.header.detailTriCount; triVertCount += tile.header.detailVertCount; } handler.SendSysMessage("Navmesh stats:"); handler.SendSysMessage(" {0} tiles loaded", tileCount); handler.SendSysMessage(" {0} BVTree nodes", nodeCount); handler.SendSysMessage(" {0} polygons ({1} vertices)", polyCount, vertCount); handler.SendSysMessage(" {0} triangles ({1} vertices)", triCount, triVertCount); return(true); }