private static LineVertex[] GenerateLine(GameLine line, bool hit)
        {
            int color = 0;

            if (line is StandardLine stl)
            {
                if (hit)
                {
                    color = Utility.ColorToRGBA_LE(line.Color);
                }
                else if (stl.Trigger != null)
                {
                    var trigger = Utility.ColorToRGBA_LE(
                        Constants.TriggerLineColor);
                    color = Utility.ChangeAlpha(trigger, 254);
                }
            }
            var lineverts = LineRenderer.CreateTrackLine(
                line.Position,
                line.Position2,
                2 * line.Width,
                color);

            return(lineverts);
        }
        public static LineVertex[] CreateDecorationLine(StandardLine line, Color color)
        {
            var slant = new Vector2d(
                line.DiffNormal.X > 0 ? Math.Ceiling(line.DiffNormal.X) : Math.Floor(line.DiffNormal.X),
                line.DiffNormal.Y > 0 ? Math.Ceiling(line.DiffNormal.Y) : Math.Floor(line.DiffNormal.Y));

            return(LineRenderer.CreateTrackLine(line.Position + slant, line.Position2 + slant, 2, Utility.ColorToRGBA_LE(color)));
        }
Esempio n. 3
0
        public static void DrawTrackLine(StandardLine line, Color color, bool drawwell, bool drawcolor)
        {
            var lv    = new AutoArray <LineVertex>(24);
            var verts = new AutoArray <GenericVertex>(30);

            if (drawcolor)
            {
                if (line is RedLine redline)
                {
                    verts.AddRange(LineAccelRenderer.GetAccelDecor(redline));
                }
                lv.AddRange(LineColorRenderer.CreateDecorationLine(line, line.Color));
            }
            lv.AddRange(
                LineRenderer.CreateTrackLine(
                    line.Start,
                    line.End,
                    line.Width * 2,
                    Utility.ColorToRGBA_LE(color)));
            if (drawwell)
            {
                verts.AddRange(WellRenderer.GetWell(line));
            }
            var vao = GetLineVAO();

            vao.Scale = Game.Track.Zoom;
            foreach (var v in lv.unsafe_array)
            {
                vao.AddVertex(v);
            }
            GameDrawingMatrix.Enter();
            using (new GLEnableCap(EnableCap.Blend))
            {
                if (verts.Count != 0)
                {
                    GenericVAO gvao = new GenericVAO();
                    foreach (var v in verts.unsafe_array)
                    {
                        gvao.AddVertex(v);
                    }
                    gvao.Draw(PrimitiveType.Triangles);
                }
                vao.Draw(PrimitiveType.Triangles);
            }
            GameDrawingMatrix.Exit();
        }