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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
    public static void ShowTilePolyDetails(DbgRenderMesh renderMesh, Detour.dtNavMesh navMesh, int tileId)
    {
        renderMesh.Clear();

        UnityEngine.Random.seed = c_RandomSeed;

        if (navMesh == null)
        {
            renderMesh.Rebuild();
            return;
        }

        Detour.dtMeshTile tile = navMesh.getTile(tileId);

        if (tile == null)
        {
            Debug.LogError("RcdtcsUnityUtils.ShowTilePolyDetails : Tile " + tileId + " does not exist.");
            return;
        }

        int detailMeshCount = tile.detailMeshes.Length;

        for (int i = 0; i < detailMeshCount; ++i)
        {
            Detour.dtPolyDetail pd   = tile.detailMeshes[i];
            Detour.dtPoly       poly = tile.polys[i];

            Color col = Color.green;            //new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value);

            for (int j = 0; j < pd.triCount; ++j)
            {
                int       tStart  = (int)(pd.triBase + j) * 4;
                int[]     vStarts = new int[3];
                float[][] vSrc    = new float[3][];
                for (int k = 0; k < 3; ++k)
                {
                    byte tk     = tile.detailTris[tStart + k];
                    byte vCount = poly.vertCount;
                    if (tk < vCount)
                    {
                        vStarts[k] = poly.verts[tk] * 3;
                        vSrc[k]    = tile.verts;
                    }
                    else
                    {
                        vStarts[k] = (int)(pd.vertBase + (tk - vCount)) * 3;
                        vSrc[k]    = tile.detailVerts;
                    }
                }
                Vector3 a = new Vector3(vSrc[0][vStarts[0] + 0], vSrc[0][vStarts[0] + 1], vSrc[0][vStarts[0] + 2]);
                Vector3 b = new Vector3(vSrc[1][vStarts[1] + 0], vSrc[1][vStarts[1] + 1], vSrc[1][vStarts[1] + 2]);
                Vector3 c = new Vector3(vSrc[2][vStarts[2] + 0], vSrc[2][vStarts[2] + 1], vSrc[2][vStarts[2] + 2]);

                col = VaryColor(col);
                renderMesh.AddTriangle(new DbgRenderTriangle(a, b, c, col));
            }
        }
        renderMesh.Rebuild();
    }
        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);
        }