Ejemplo n.º 1
0
        public void LineChanged(StandardLine line)
        {
            if (line == null)
            {
                return;
            }
            lock (SyncRoot)
            {
                linevertices lv;
                if (_lines.TryGetValue(line.ID, out lv))
                {
                    LineChangedFreeVertices(lv.coloredtrackline);

                    var newcoloredline = DrawTrackLine(line, true);                    //chance the colored line could change in type, like 3x multiplier

                    LineChangedFreeVertices(lv.blacktrackline);
                    DrawBasicTrackLine((Vector2)line.Position, (Vector2)line.Position2,
                                       Settings.Default.NightMode ? Color.White : Color.Black);

                    LineChangedFreeVertices(lv.knobs);
                    RenderCircle((Vector2)line.Position, Settings.Default.NightMode ? Color.Black : Color.White, 0.75f,
                                 100);
                    RenderCircle((Vector2)line.Position2, Settings.Default.NightMode ? Color.Black : Color.White,
                                 0.75f, 100);


                    LineChangedFreeVertices(lv.redknobs);
                    RenderCircle((Vector2)line.Position, Color.Red, 0.75f, 100);
                    RenderCircle((Vector2)line.Position2, Color.Red, 0.75f, 100);

                    Color linecolor = line.GetLineType() == LineType.Red
                                                ? Color.FromArgb(0xCC, 0, 0)
                                                : Color.FromArgb(0, 0x66, 0xFF);
                    LineChangedFreeVertices(lv.hittestline);
                    DrawBasicTrackLine((Vector2)line.Position, (Vector2)line.Position2, linecolor);

                    LineChangedFreeVertices(lv.gwell);
                    DrawGWell(line as StandardLine);

                    if (lv.coloredtrackline.Count != newcoloredline.Count)//line indices changed, remind the vao
                    {
                        RequiresUpdate      = true;
                        lv.coloredtrackline = newcoloredline;
                        _lines[line.ID]     = lv;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private linevertices CreateLine(StandardLine l)
        {
            linevertices lv = new linevertices();

            lv.coloredtrackline = DrawTrackLine(l, true);
            lv.blacktrackline   = DrawBasicTrackLine((Vector2)l.Position, (Vector2)l.Position2, Settings.Default.NightMode ? Color.White : Color.Black);
            lv.knobs            = new List <int>(6 * 2);

            lv.knobs.AddRange(RenderCircle((Vector2)l.Position, Settings.Default.NightMode ? Color.Black : Color.White, 0.75f, 100));
            lv.knobs.AddRange(RenderCircle((Vector2)l.Position2, Settings.Default.NightMode ? Color.Black : Color.White, 0.75f, 100));
            lv.redknobs = new List <int>(6 * 2);
            lv.redknobs.AddRange(RenderCircle((Vector2)l.Position, Color.Red, 0.75f, 100));
            lv.redknobs.AddRange(RenderCircle((Vector2)l.Position2, Color.Red, 0.75f, 100));
            Color linecolor = l.GetLineType() == LineType.Red ? Color.FromArgb(0xCC, 0, 0) : Color.FromArgb(0, 0x66, 0xFF);

            lv.hittestline = DrawBasicTrackLine((Vector2)l.Position, (Vector2)l.Position2, linecolor);

            lv.gwell = DrawGWell(l);
            return(lv);
        }
Ejemplo n.º 3
0
        private List <int> DrawTrackLine(StandardLine line, bool colors)
        {
            List <int> ret  = new List <int>((6 * 6) + 3);
            var        type = line.GetLineType();
            Color      c    = Settings.Default.NightMode ? Color.White : Color.Black;

            if (colors)
            {
                switch (type)
                {
                case LineType.Blue:
                {
                    c = Color.FromArgb(0, 0x66, 0xFF);
                    var     l    = line;
                    var     loc3 = (float)(l.Perpendicular.X > 0 ? (Math.Ceiling(l.Perpendicular.X)) : (Math.Floor(l.Perpendicular.X)));
                    var     loc4 = (float)(l.Perpendicular.Y > 0 ? (Math.Ceiling(l.Perpendicular.Y)) : (Math.Floor(l.Perpendicular.Y)));
                    Vector2 p1   = new Vector2((float)l.Position.X + loc3, (float)l.Position.Y + loc4),
                            p2   = new Vector2((float)l.Position2.X + loc3, (float)l.Position2.Y + loc4);
                    ret.AddRange(DrawBasicTrackLine(p1, p2, c));
                }
                break;

                case LineType.Red:
                {
                    c = Color.FromArgb(0xCC, 0, 0);
                    var l    = line as RedLine;
                    var loc3 = (float)(l.Perpendicular.X > 0 ? (Math.Ceiling(l.Perpendicular.X)) : (Math.Floor(l.Perpendicular.X)));
                    var loc4 = (float)(l.Perpendicular.Y > 0 ? (Math.Ceiling(l.Perpendicular.Y)) : (Math.Floor(l.Perpendicular.Y)));
                    for (int ix = 0; ix < l.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);
                        var v0 = AddVertex(new Vertex((float)t.X, (float)t.Y, c));
                        t.Move(90, l.inv ? -8 : 8);
                        var v1 = AddVertex(new Vertex((float)t.X, (float)t.Y, c));
                        t.Point = l.Position2;
                        t.Move(angle, -(ix * 2));
                        var v2 = AddVertex(new Vertex((float)t.X, (float)t.Y, c));
                        ret.Add(v0);
                        ret.Add(v1);
                        ret.Add(v2);
                    }
                    Vector2 p1 = new Vector2((float)l.Position.X + loc3, (float)l.Position.Y + loc4), p2 = new Vector2((float)l.Position2.X + loc3, (float)l.Position2.Y + loc4);
                    ret.AddRange(DrawBasicTrackLine(p1, p2, c));
                }
                break;
                }
            }
            Color linecolor = Settings.Default.NightMode ? Color.White : Color.Black;
            var   linep1    = line.Position;
            var   linep2    = line.Position2;

            if (line.Trigger != null && line.Trigger.Enabled && colors)
            {
                linecolor = Color.FromArgb(0xFF, 0x95, 0x4F);
            }
#if drawextension
            if (l.Extension != StandardLine.ExtensionDirection.None)
            {
                linerider.Tools.Angle angle = Tools.Angle.FromLine(l.Position, l.Position2);
                switch (l.Extension)
                {
                case StandardLine.ExtensionDirection.Left:
                {
                    Turtle turtle = new Turtle(l.CompliantPosition);
                    turtle.Move(angle.Degrees, l.inv ? 4 : -4);
                    if (l.inv)
                    {
                        linep2 = turtle.Point;
                    }
                    else
                    {
                        linep1 = turtle.Point;
                    }
                }
                break;

                case StandardLine.ExtensionDirection.Right:
                {
                    Turtle turtle = new Turtle(l.CompliantPosition2);
                    turtle.Move(angle.Degrees, !l.inv ? 4 : -4);
                    if (l.inv)
                    {
                        linep1 = turtle.Point;
                    }
                    else
                    {
                        linep2 = turtle.Point;
                    }
                }
                break;

                case StandardLine.ExtensionDirection.Both:
                {
                    Turtle turtle = new Turtle(l.CompliantPosition);
                    turtle.Move(angle.Degrees, -2);
                    if (l.inv)
                    {
                        linep2 = turtle.Point;
                    }
                    else
                    {
                        linep1 = turtle.Point;
                    }

                    turtle = new Turtle(l.CompliantPosition2);
                    turtle.Move(angle.Degrees, !l.inv ? 4 : -4);
                    if (l.inv)
                    {
                        linep1 = turtle.Point;
                    }
                    else
                    {
                        linep2 = turtle.Point;
                    }
                }
                break;
                }
            }
#endif
            ret.AddRange(DrawBasicTrackLine((Vector2)linep1, (Vector2)linep2, linecolor));
            return(ret);
        }
Ejemplo n.º 4
0
        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();
                }
            }
        }