public void Initialize(NavAgent agent) { this.mAgent = agent; mCrowdDebug = null; mCorners = null; mCorridor = null; }
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); }
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); } }
/// <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); }
public static extern void dtcaGetPathCorridorData(IntPtr agent , [In, Out] PathCorridorData corridor);
/// <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); }
public static extern bool dtpcGetData(IntPtr corridor , [In, Out] PathCorridorData data);