private List <int> DrawThickLine(Vector2 p, Vector2 p1, float width, Color c) { List <int> ret = new List <int>(6); var vecs = StaticRenderer.GenerateThickLine(p, p1, width); int v1 = AddVertex(new Vertex(vecs[0].X, vecs[0].Y, c)); int v2 = AddVertex(new Vertex(vecs[1].X, vecs[1].Y, c)); int v3 = AddVertex(new Vertex(vecs[2].X, vecs[2].Y, c)); int v4 = AddVertex(new Vertex(vecs[3].X, vecs[3].Y, c)); ret.Add(v1); ret.Add(v2); ret.Add(v3); ret.Add(v1); ret.Add(v4); ret.Add(v3); return(ret); }
public static List <Vertex> GenRoundedLine(Vector2d position, Vector2d position2, Color color, float thickness, bool knobs = false, bool redknobs = false) { List <Vertex> vertices = new List <Vertex>(6 * 5); var end1 = (position + Game.ScreenTranslation) * Game.Track.Zoom; var end2 = (position2 + Game.ScreenTranslation) * Game.Track.Zoom; var line = StaticRenderer.GenerateThickLine((Vector2)end1, (Vector2)end2, thickness * Game.Track.Zoom); vertices.Add(new Vertex(line[0], color)); vertices.Add(new Vertex(line[1], color)); vertices.Add(new Vertex(line[2], color)); vertices.Add(new Vertex(line[0], color)); vertices.Add(new Vertex(line[3], color)); vertices.Add(new Vertex(line[2], color)); vertices.AddRange(StaticRenderer.FastCircle((Vector2)(end1), Game.Track.Zoom * (thickness / 2), color)); vertices.AddRange(StaticRenderer.FastCircle((Vector2)(end2), Game.Track.Zoom * (thickness / 2), color)); if (knobs) { vertices.AddRange(StaticRenderer.FastCircle((Vector2)(end1), Game.Track.Zoom * (thickness / 3), redknobs ? Color.Red : Color.White)); vertices.AddRange(StaticRenderer.FastCircle((Vector2)(end2), Game.Track.Zoom * (thickness / 3), redknobs ? Color.Red : Color.White)); } return(vertices); }
public static void DrawTrackLine(StandardLine l, Color color, bool drawwell, bool drawcolor, bool drawknobs, bool redknobs = false) { color = Color.FromArgb(255, color); var thickness = 2; Color color2; var type = l.GetLineType(); switch (type) { case LineType.Blue: color2 = Color.FromArgb(0, 0x66, 0xFF); break; case LineType.Red: color2 = Color.FromArgb(0xCC, 0, 0); break; default: throw new Exception("Rendering Invalid Line"); } if (drawcolor) { var loc3 = l.Perpendicular.X > 0 ? (Math.Ceiling(l.Perpendicular.X)) : (Math.Floor(l.Perpendicular.X)); var loc4 = l.Perpendicular.Y > 0 ? (Math.Ceiling(l.Perpendicular.Y)) : (Math.Floor(l.Perpendicular.Y)); if (type == LineType.Red) { var redline = l as RedLine; GameDrawingMatrix.Enter(); GL.Color3(color2); GL.Begin(PrimitiveType.Triangles); var basepos = l.Position2; for (int ix = 0; ix < redline.Multiplier; ix++) { var angle = MathHelper.RadiansToDegrees(Math.Atan2(l.diff.Y, l.diff.X)); Turtle t = new Turtle(l.Position2); var basex = 8 + (ix * 2); t.Move(angle, -basex); GL.Vertex2(new Vector2((float)t.X, (float)t.Y)); t.Move(90, l.inv ? -8 : 8); GL.Vertex2(new Vector2((float)t.X, (float)t.Y)); t.Point = l.Position2; t.Move(angle, -(ix * 2)); GL.Vertex2(new Vector2((float)t.X, (float)t.Y)); } GL.End(); GameDrawingMatrix.Exit(); } RenderRoundedLine(new Vector2d(l.Position.X + loc3, l.Position.Y + loc4), new Vector2d(l.Position2.X + loc3, l.Position2.Y + loc4), color2, thickness); } RenderRoundedLine(l.Position, l.Position2, color, thickness, drawknobs, redknobs); if (drawwell) { using (new GLEnableCap(EnableCap.Blend)) { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GameDrawingMatrix.Enter(); GL.Begin(PrimitiveType.Quads); GL.Color4(new Color4(150, 150, 150, 150)); var rect = StaticRenderer.GenerateThickLine((Vector2)l.Position, (Vector2)l.Position2, (float)(StandardLine.Zone * 2)); GL.Vertex2(l.Position); GL.Vertex2(l.Position2); GL.Vertex2(rect[l.inv ? 2 : 1]); GL.Vertex2(rect[l.inv ? 3 : 0]); GL.End(); GL.PopMatrix(); } } }