// what is the debug color for the specified node public static Color CalculateNodeDebugColor(GraphNode node) { if (null != AstarPath.active && null != AstarPath.active.graphs && node.GraphIndex < AstarPath.active.graphs.Length) { NavGraph graph = AstarPath.active.graphs[node.GraphIndex]; return(graph.NodeColor(node, AstarPath.active.debugPathData)); } return(Color.white); }
private void DrawTriangles() { // draw all graph nodes GL.Begin(GL.TRIANGLES); Vector3 offsetUp = new Vector3(0f, 0.1f, 0f); for (int graphIndex = 0; graphIndex < AstarPath.active.graphs.Length; ++graphIndex) { NavGraph graph = AstarPath.active.graphs[graphIndex]; INavmesh ng = graph as INavmesh; if (null != ng) { ng.GetNodes(delegate(GraphNode _node) { // if we are only displaying one region, and this is not that region if (desplaySpecifiedRegion != DisplayAllRegions && desplaySpecifiedRegion != _node.Area) { return(true); } Color theColor = graph.NodeColor(_node, AstarPath.active.debugPathData); theColor.a = navMeshAlpha; TriangleMeshNode node = _node as TriangleMeshNode; if (!node.Walkable) { theColor = Color.black; } GL.Color(theColor); Vector3 vert0 = (Vector3)node.GetVertex(0); Vector3 vert1 = (Vector3)node.GetVertex(1); Vector3 vert2 = (Vector3)node.GetVertex(2); GL.Vertex(vert0 + offsetUp); GL.Vertex(vert1 + offsetUp); GL.Vertex(vert2 + offsetUp); return(true); }); } } GL.End(); }
private void DrawTriangleLines() { GL.Begin(GL.LINES); for (int graphIndex = 0; graphIndex < AstarPath.active.graphs.Length; ++graphIndex) { NavGraph graph = AstarPath.active.graphs[graphIndex]; INavmesh ng = graph as INavmesh; if (null != ng) { ng.GetNodes(delegate(GraphNode _node) { // if we are only displaying one region, and this is not that region if (desplaySpecifiedRegion != DisplayAllRegions && desplaySpecifiedRegion != _node.Area) { return(true); } Color theColor = graph.NodeColor(_node, AstarPath.active.debugPathData); GL.Color(theColor); TriangleMeshNode node = _node as TriangleMeshNode; Vector3 vertZero = (Vector3)node.GetVertex(0); Vector3 vertOne = (Vector3)node.GetVertex(1); Vector3 vertTwo = (Vector3)node.GetVertex(2); GL.Vertex(vertZero); GL.Vertex(vertOne); GL.Vertex(vertOne); GL.Vertex(vertTwo); GL.Vertex(vertTwo); GL.Vertex(vertZero); GL.Color(Color.blue); // draw a line to all of the connected nodes (only if a two way connection exists) for (int nodeConnect = 0; nodeConnect < node.connections.Length; nodeConnect++) { TriangleMeshNode connectedNode = node.connections[nodeConnect] as TriangleMeshNode; if (null != connectedNode) { // go over all the nodes that this connected node is connected to in order to check that one of them is the original node, thus a two way connection exists for (int connectedNodeConnect = 0; connectedNodeConnect < connectedNode.connections.Length; connectedNodeConnect++) { TriangleMeshNode originalNode = connectedNode.connections[connectedNodeConnect] as TriangleMeshNode; if (originalNode == node) // is this the original node, meaning a two way connection exists { GL.Vertex((Vector3)node.position); GL.Vertex((Vector3)connectedNode.position); break; } } } } return(true); }); } } GL.End(); }