Exemplo n.º 1
0
 public void Initialize(NavAgent agent)
 {
     this.mAgent = agent;
     mCrowdDebug = null;
     mCorners    = null;
     mCorridor   = null;
 }
Exemplo n.º 2
0
    void OnRenderObject()
    {
        if (!mDebugEnabled || mAgent == null)
        {
            return;
        }

        if (mAgent.crowdAgent != null)
        {
            if (mCrowdDebug == null)
            {
                mCorners    = null;
                mCorridor   = null;
                mCrowdDebug = new CrowdAgentDebug(mAgent.navGroup.crowd.Navmesh);
            }
            mCrowdDebug.DrawAll(mAgent.crowdAgent);
        }
        else if ((mAgent.data.flags & NavFlag.CorridorInUse) != 0)
        {
            if (mCorridor == null)
            {
                mCorners    = new CornerData();
                mCorridor   = new PathCorridorData(mAgent.corridor.MaxPathSize);
                mCrowdDebug = null;
            }
            int n = mAgent.corridor.FindCorners(mCorners);
            mCorners.cornerCount = n; // v0.3.0 bug workaround.
            mAgent.corridor.GetData(mCorridor);
            NavDebug.Draw(mAgent.navGroup.mesh, mCorridor);
            NavDebug.Draw(mCorners);
        }

        if (mAgent.crowdAgent == null)
        {
            Vector3 pos    = mAgent.data.position.point;
            float   height = mAgent.crowdConfig.height; // Might be zero.

            Vector3 velocity = mAgent.data.desiredVelocity;
            DebugDraw.Arrow(pos + Vector3.up * height
                            , pos + velocity + Vector3.up * height
                            , 0, 0.05f, CrowdAgentDebug.desiredVelocityColor);
        }

        DebugDraw.DiamondMarker(mAgent.data.position.point
                                , 0.1f
                                , NavDebug.positionColor);

        DebugDraw.DiamondMarker(mAgent.data.goal.point
                                , 0.1f
                                , NavDebug.goalColor);
    }
Exemplo n.º 3
0
    private void HandlePathBufferResize()
    {
        mCorridor = new PathCorridor(
            mPath.MaxElementCount, mCornerPolys.MaxElementCount, mGroup.query, mGroup.filter);

        mCorridorData = new PathCorridorData(mPath.MaxElementCount);

        if (mPathEnd.polyRef != 0)
        {
            FindPath();
        }
        else if (mPathStart.polyRef != 0)
        {
            mCorridor.Reset(mPathStart);
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// Draws a debug visualization of a corridor.
        /// </summary>
        /// <param name="mesh">The navigation mesh associated with the corridor.</param>
        /// <param name="corridor">The corridor to draw.</param>
        public static void Draw(Navmesh mesh, PathCorridorData corridor)
        {
            if (corridor.pathCount == 0)
            {
                return;
            }

            DebugDraw.SimpleMaterial.SetPass(0);

            Vector3[] tileVerts = null;

            for (int iPoly = 0; iPoly < corridor.pathCount; iPoly++)
            {
                NavmeshTile tile;
                NavmeshPoly poly;
                mesh.GetTileAndPoly(corridor.path[iPoly], out tile, out poly);

                if (poly.Type == NavmeshPolyType.OffMeshConnection)
                {
                    continue;
                }

                NavmeshTileHeader header = tile.GetHeader();
                if (tileVerts == null ||
                    tileVerts.Length < 3 * header.vertCount)
                {
                    // Resize.
                    tileVerts = new Vector3[header.vertCount];
                }

                tile.GetVerts(tileVerts);

                GL.Begin(GL.TRIANGLES);
                GL.Color(polygonOverlayColor);

                int pA = poly.indices[0];
                for (int i = 2; i < poly.vertCount; i++)
                {
                    int pB = poly.indices[i - 1];
                    int pC = poly.indices[i];

                    GL.Vertex(tileVerts[pA]);
                    GL.Vertex(tileVerts[pB]);
                    GL.Vertex(tileVerts[pC]);
                }

                GL.End();

                // Not drawing boundaries since it would obscure other agent
                // debug data.
            }

            Vector3 v = corridor.position;

            DebugDraw.XMarker(v, positionScale, positionColor);
            DebugDraw.Circle(v, positionScale, positionColor);
            DebugDraw.Circle(v, positionScale * 0.5f, positionColor);
            DebugDraw.Circle(v, positionScale * 0.25f, positionColor);

            v = corridor.target;
            DebugDraw.XMarker(v, goalScale, goalColor);
            DebugDraw.Circle(v, goalScale, goalColor);
            DebugDraw.Circle(v, goalScale * 0.5f, goalColor);
            DebugDraw.Circle(v, goalScale * 0.25f, goalColor);
        }
Exemplo n.º 5
0
 public static extern void dtcaGetPathCorridorData(IntPtr agent
                                                   , [In, Out] PathCorridorData corridor);
Exemplo n.º 6
0
        /// <summary>
        /// Draws a debug visualization of a corridor.
        /// </summary>
        /// <param name="mesh">The navigation mesh associated with the corridor.</param>
        /// <param name="corridor">The corridor to draw.</param>
        public static void Draw(Navmesh mesh, PathCorridorData corridor)
        {
            if (corridor.pathCount == 0)
                return;

            DebugDraw.SimpleMaterial.SetPass(0);

            Vector3[] tileVerts = null;

            for (int iPoly = 0; iPoly < corridor.pathCount; iPoly++)
            {
                NavmeshTile tile;
                NavmeshPoly poly;
                mesh.GetTileAndPoly(corridor.path[iPoly], out tile, out poly);

                if (poly.Type == NavmeshPolyType.OffMeshConnection)
                    continue;

                NavmeshTileHeader header = tile.GetHeader();
                if (tileVerts == null
                    || tileVerts.Length < 3 * header.vertCount)
                {
                    // Resize.
                    tileVerts = new Vector3[header.vertCount];
                }

                tile.GetVerts(tileVerts);

                GL.Begin(GL.TRIANGLES);
                GL.Color(polygonOverlayColor);

                int pA = poly.indices[0];
                for (int i = 2; i < poly.vertCount; i++)
                {
                    int pB = poly.indices[i - 1];
                    int pC = poly.indices[i];

                    GL.Vertex(tileVerts[pA]);
                    GL.Vertex(tileVerts[pB]);
                    GL.Vertex(tileVerts[pC]);
                }

                GL.End();

                // Not drawing boundaries since it would obscure other agent
                // debug data.
            }

            Vector3 v = corridor.position;
            DebugDraw.XMarker(v, positionScale, positionColor);
            DebugDraw.Circle(v, positionScale, positionColor);
            DebugDraw.Circle(v, positionScale * 0.5f, positionColor);
            DebugDraw.Circle(v, positionScale * 0.25f, positionColor);

            v = corridor.target;
            DebugDraw.XMarker(v, goalScale, goalColor);
            DebugDraw.Circle(v, goalScale, goalColor);
            DebugDraw.Circle(v, goalScale * 0.5f, goalColor);
            DebugDraw.Circle(v, goalScale * 0.25f, goalColor);
        }
Exemplo n.º 7
0
 public static extern bool dtpcGetData(IntPtr corridor
                                       , [In, Out] PathCorridorData data);