예제 #1
0
파일: NavDebug.cs 프로젝트: zwong91/Titan
        /// <summary>
        /// Draws a debug visualization of the navigation mesh with the closed nodes highlighted.
        /// </summary>
        /// <param name="mesh">The mesh to draw.</param>
        /// <param name="query">The query which provides the list of closed nodes.</param>
        public static void Draw(Navmesh mesh, NavmeshQuery query)
        {
            int count = mesh.GetMaxTiles();

            for (int i = 0; i < count; i++)
            {
                Draw(mesh.GetTile(i), query, null, 0, i);
            }
        }
예제 #2
0
파일: NavDebug.cs 프로젝트: zwong91/Titan
        /// <summary>
        /// Draws a debug visualization of the navigation mesh.
        /// </summary>
        /// <param name="mesh">The mesh to draw.</param>
        /// <param name="colorByArea">
        /// If true, will be colored by polygon area. If false, will be colored by tile index.
        /// </param>
        public static void Draw(Navmesh mesh, bool colorByArea)
        {
            int count = mesh.GetMaxTiles();

            for (int i = 0; i < count; i++)
            {
                Draw(mesh.GetTile(i), null, null, 0, colorByArea ? -1 : i);
            }
        }
예제 #3
0
파일: NavDebug.cs 프로젝트: zwong91/Titan
        /// <summary>
        /// Draws a debug visualization of the navigation mesh with the specified polygons
        /// highlighted.
        /// </summary>
        /// <param name="mesh">The mesh to draw.</param>
        /// <param name="markPolys">
        /// The references of the polygons that should be highlighted.
        /// </param>
        /// <param name="polyCount">
        /// The number of polygons in the <paramref name="markPolys"/> array.
        /// </param>
        public static void Draw(Navmesh mesh, uint[] markPolys, int polyCount)
        {
            int count = mesh.GetMaxTiles();

            for (int i = 0; i < count; i++)
            {
                Draw(mesh.GetTile(i)
                     , null
                     , markPolys
                     , polyCount
                     , i);
            }
        }
예제 #4
0
    private void SetConfigFromTargetIntern(Navmesh navmesh)
    {
        NavmeshBuildInfo targetConfig = BuildTarget.BuildInfo;
        NMGenParams      currConfig   = mConfig.GetConfig();

        // Note: Must ensure exact match with original configuration.
        // So this process is using the fields and trusting the
        // original configuration to have valid values.

        currConfig.tileSize       = targetConfig.tileSize;
        currConfig.walkableHeight = targetConfig.walkableHeight;
        currConfig.walkableRadius = targetConfig.walkableRadius;
        currConfig.walkableStep   = targetConfig.walkableStep;
        currConfig.xzCellSize     = targetConfig.xzCellSize;
        currConfig.yCellSize      = targetConfig.yCellSize;
        currConfig.borderSize     = targetConfig.borderSize;

        mBoundsMin = navmesh.GetConfig().origin;

        int maxTiles = navmesh.GetMaxTiles();

        // Make sure the maximum bounds fits the target mesh.
        // Note: Will not shrink the existing max bounds.
        for (int i = 0; i < maxTiles; i++)
        {
            NavmeshTile tile = navmesh.GetTile(i);

            if (tile == null)
            {
                continue;
            }

            NavmeshTileHeader tileHeader = tile.GetHeader();

            if (tileHeader.polyCount == 0)
            {
                continue;
            }

            mBoundsMax = Vector3.Max(mBoundsMax, tileHeader.boundsMax);
        }

        mConfig.SetConfig(currConfig);

        mIsDirty = true;
    }
예제 #5
0
파일: NavDebug.cs 프로젝트: zwong91/Titan
        /// <summary>
        /// Returns the 3D centroids of the provided navigation mesh polygons.
        /// </summary>
        /// <remarks>
        /// <para>
        /// If a polygon does not exist within the mesh, its associated centroid will not
        /// be altered.  So some centroid data will be invalid if  <paramref name="polyCount"/>
        /// is not equal to the result count.
        /// </para>
        /// </remarks>
        /// <param name="mesh">The navigation mesh containing the polygons.</param>
        /// <param name="polyRefs">The references of the polygons.</param>
        /// <param name="polyCount">The number of polygons.</param>
        /// <param name="centroids">
        /// The centroids for the polygons. [Length: >= polyCount] (Out)
        /// </param>
        /// <returns>The actual number of polygons found within the mesh. </returns>
        public static int GetCentroids(Navmesh mesh
                                       , uint[] polyRefs
                                       , int polyCount
                                       , Vector3[] centroids)
        {
            int resultCount = 0;
            int count       = mesh.GetMaxTiles();

            for (int i = 0; i < count; i++)
            {
                resultCount += GetCentroids(mesh.GetTile(i)
                                            , polyRefs
                                            , polyCount
                                            , centroids);
                if (resultCount == polyRefs.Length)
                {
                    break;
                }
            }
            return(resultCount);
        }
예제 #6
0
 /// <summary>
 /// Draws a debug visualization of the navigation mesh.
 /// </summary>
 /// <param name="mesh">The mesh to draw.</param>
 /// <param name="colorByArea">
 /// If true, will be colored by polygon area. If false, will be colored by tile index.
 /// </param>
 public static void Draw(Navmesh mesh, bool colorByArea)
 {
     int count = mesh.GetMaxTiles();
     for (int i = 0; i < count; i++)
     {
         Draw(mesh.GetTile(i), null, null, 0, colorByArea ? -1 : i);
     }
 }
예제 #7
0
 /// <summary>
 /// Returns the 3D centroids of the provided navigation mesh polygons.
 /// </summary>
 /// <remarks>
 /// <para>
 /// If a polygon does not exist within the mesh, its associated centroid will not 
 /// be altered.  So some centroid data will be invalid if  <paramref name="polyCount"/> 
 /// is not equal to the result count.
 /// </para>
 /// </remarks>
 /// <param name="mesh">The navigation mesh containing the polygons.</param>
 /// <param name="polyRefs">The references of the polygons.</param>
 /// <param name="polyCount">The number of polygons.</param>
 /// <param name="centroids">
 /// The centroids for the polygons. [Length: >= polyCount] (Out)
 /// </param>
 /// <returns>The actual number of polygons found within the mesh. </returns>
 public static int GetCentroids(Navmesh mesh
     , uint[] polyRefs
     , int polyCount
     , Vector3[] centroids)
 {
     int resultCount = 0;
     int count = mesh.GetMaxTiles();
     for (int i = 0; i < count; i++)
     {
         resultCount += GetCentroids(mesh.GetTile(i)
             , polyRefs
             , polyCount
             , centroids);
         if (resultCount == polyRefs.Length)
             break;
     }
     return resultCount;
 }
예제 #8
0
 /// <summary>
 /// Draws a debug visualization of the navigation mesh with the specified polygons 
 /// highlighted.
 /// </summary>
 /// <param name="mesh">The mesh to draw.</param>
 /// <param name="markPolys">
 /// The references of the polygons that should be highlighted.
 /// </param>
 /// <param name="polyCount">
 /// The number of polygons in the <paramref name="markPolys"/> array.
 /// </param>
 public static void Draw(Navmesh mesh, uint[] markPolys, int polyCount)
 {
     int count = mesh.GetMaxTiles();
     for (int i = 0; i < count; i++)
     {
         Draw(mesh.GetTile(i)
             , null
             , markPolys
             , polyCount
             , i);
     }
 }
예제 #9
0
 /// <summary>
 /// Draws a debug visualization of the navigation mesh with the closed nodes highlighted.
 /// </summary>
 /// <param name="mesh">The mesh to draw.</param>
 /// <param name="query">The query which provides the list of closed nodes.</param>
 public static void Draw(Navmesh mesh, NavmeshQuery query)
 {
     int count = mesh.GetMaxTiles();
     for (int i = 0; i < count; i++)
     {
         Draw(mesh.GetTile(i), query, null, 0, i);
     }
 }