private void Render(ConvexPolyForm poly) { if (poly == _selectedPoly) { GLUtil.SetColor(new Color(0, 0, 0, 1)); } else { GLUtil.SetColor(new Color(0.1f, 0.1f, 0.1f, 0.5f)); } PolyDrawer.RenderPoly(poly); RenderNormals(poly); RenderCentroid(poly); if (poly == _selectedPoly) { RenderNearestEdge(poly); RenderVerts(poly); } if (_editState == EditState.ConnectPressed) { GLUtil.SetColor(new Color(0, 0, 0, 1)); PrimitiveDrawer.DrawLine2d(_connectStart, _input.Mouse.Position); RenderCrossedEdges(); } }
public void Render() { Gl.glClearColor(1, 1, 1, 0); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); _pathFinder.Polygons.ForEach(x => PolyDrawer.RenderPoly(x)); if (_drawingPath) { PrimitiveDrawer.DrawFilledCircle(_pathStart, 15, new Color(0, 0, 0, 1)); } GLUtil.SetColor(new Color(1, 0, 0, 1)); Gl.glBegin(Gl.GL_LINE_STRIP); { foreach (Point p in _path) { GLUtil.DrawPointVertex(p); } } Gl.glEnd(); _renderer.DrawText(0, 0, "Path Drawing State", _font); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA); _renderer.Render(); Gl.glDisable(Gl.GL_TEXTURE_2D); }
private void DrawPath(List <NavNode> list) { GLUtil.SetColor(new Color(0, 0, 0, 1)); Gl.glBegin(Gl.GL_LINE_STRIP); { foreach (NavNode node in list) { GLUtil.DrawPointVertex(node.Position); } } Gl.glEnd(); }
private void RenderCrossedEdges() { foreach (var tuple in _connectIntersectedEdges) { ConvexPolyForm poly = tuple.Item1; EdgeIndex edge = tuple.Item2; Point start = poly.Vertices[edge.Start]; Point end = poly.Vertices[edge.End]; GLUtil.SetColor(new Color(0, 0, 1, 1)); PrimitiveDrawer.DrawLine2d(start, end); } }
private void RenderNormals(ConvexPolyForm poly) { GLUtil.SetColor(new Color(0, 1, 0, 1)); foreach (EdgeIndex edge in poly.Edges) { Point start = poly.Vertices[edge.Start]; Point end = poly.Vertices[edge.End]; Point middle = LineSegment.GetMiddle(start, end); Point normal = EdgeIndex.GetLineNormal(start, end); Gl.glBegin(Gl.GL_LINES); { GLUtil.DrawPointVertex(middle); GLUtil.DrawPointVertex(new Point(middle.X + (normal.X * 50), middle.Y + (normal.Y * 50))); } Gl.glEnd(); } }
private void RenderNearestEdge(ConvexPolyForm poly) { EdgeIndex edge = poly.GetClosestEdge(_input.Mouse.Position); GLUtil.SetColor(new Color(1, 0, 0, 1)); Gl.glBegin(Gl.GL_LINE_STRIP); { GLUtil.DrawPointVertex(poly.Vertices[edge.Start]); GLUtil.DrawPointVertex(poly.Vertices[edge.End]); } Gl.glEnd(); // Render closest point Point p = EdgeIndex.GetClosestPoint(poly.Vertices[edge.Start], poly.Vertices[edge.End], _input.Mouse.Position); Gl.glBegin(Gl.GL_POINTS); { GLUtil.DrawPointVertex(p); } Gl.glEnd(); }