public static void RenderRoundedRectangle(DoubleRect rect, Color color, float thickness, bool gamecoords = true)
 {
     using (new GLEnableCap(EnableCap.Blend))
     {
         using (new GLEnableCap(EnableCap.Texture2D))
         {
             if (gamecoords)
             {
                 GameDrawingMatrix.Enter();
             }
             var vao = GetLineVAO();
             vao.Scale = GameDrawingMatrix.Scale;
             var vec1 = rect.Vector;
             var vec2 = vec1 + new Vector2d(rect.Width, 0);
             var vec3 = vec1 + rect.Size;
             var vec4 = vec1 + new Vector2d(0, rect.Height);
             vao.AddLine(vec1, vec2, color, thickness);
             vao.AddLine(vec2, vec3, color, thickness);
             vao.AddLine(vec3, vec4, color, thickness);
             vao.AddLine(vec4, vec1, color, thickness);
             vao.knobstate = 0;
             vao.Draw(PrimitiveType.Triangles);
             if (gamecoords)
             {
                 GameDrawingMatrix.Exit();
             }
         }
     }
 }
示例#2
0
        public void Render(DrawOptions options, bool recording = false)
        {
            using (new GLEnableCap(EnableCap.Texture2D))
            {
                UpdateBuffers();
                GL.BlendFunc(
                    BlendingFactorSrc.SrcAlpha,
                    BlendingFactorDest.OneMinusSrcAlpha);
                GameDrawingMatrix.Enter();
                _physvbo.Scale     = options.Zoom;
                _physvbo.KnobState = options.KnobState;

                _sceneryvbo.Scale = options.Zoom;
                //green lines dont get lifelock
                if (options.KnobState != KnobState.Hidden)
                {
                    _sceneryvbo.KnobState = KnobState.Shown;
                }
                else
                {
                    _sceneryvbo.KnobState = KnobState.Hidden;
                }

                if ((Settings.PreviewMode || recording) && !(recording && !Settings.Recording.EnableColorTriggers))
                {
                    _sceneryvbo.OverrideColor = game.Track.Timeline.GetFrameLineColor(game.Track.Offset);
                    _physvbo.OverrideColor    = game.Track.Timeline.GetFrameLineColor(game.Track.Offset);
                }
                else
                {
                    _sceneryvbo.OverrideColor = (Settings.NightMode ? Constants.DefaultNightLineColor : Constants.DefaultLineColor);
                    _physvbo.OverrideColor    = (Settings.NightMode ? Constants.DefaultNightLineColor : Constants.DefaultLineColor);
                }

                if (options.LineColors)
                {
                    _sceneryvbo.OverrideColor    = Constants.SceneryLineColor;
                    _sceneryvbo.OverridePriority = 1;
                    _physvbo.OverridePriority    = 1;
                }
                else
                {
                    _sceneryvbo.OverridePriority = 255;//force override
                    _physvbo.OverridePriority    = 255;
                }
                _physvbo.Overlay    = options.Overlay;
                _sceneryvbo.Overlay = options.Overlay;
                _sceneryvbo.Draw();
                _decorator.DrawUnder(options);
                _physvbo.Draw();
                GameDrawingMatrix.Exit();
            }
        }
示例#3
0
        public void Render(DrawOptions options)
        {
            using (new GLEnableCap(EnableCap.Texture2D))
            {
                UpdateBuffers();
                GL.BlendFunc(
                    BlendingFactorSrc.SrcAlpha,
                    BlendingFactorDest.OneMinusSrcAlpha);
                GameDrawingMatrix.Enter();
                _physvbo.Scale     = options.Zoom;
                _physvbo.KnobState = options.KnobState;

                _sceneryvbo.Scale = options.Zoom;
                //green lines dont get lifelock
                if (options.KnobState != KnobState.Hidden)
                {
                    _sceneryvbo.KnobState = KnobState.Shown;
                }
                else
                {
                    _sceneryvbo.KnobState = KnobState.Hidden;
                }

                if (options.NightMode)
                {
                    _sceneryvbo.OverrideColor = Constants.DefaultNightLineColor;
                    _physvbo.OverrideColor    = Constants.DefaultNightLineColor;
                }
                else
                {
                    _sceneryvbo.OverrideColor = Constants.DefaultLineColor;
                    _physvbo.OverrideColor    = Constants.DefaultLineColor;
                }
                if (options.LineColors)
                {
                    _sceneryvbo.OverrideColor    = Constants.SceneryLineColor;
                    _sceneryvbo.OverridePriority = 1;
                    _physvbo.OverridePriority    = 1;
                }
                else
                {
                    _sceneryvbo.OverridePriority = 255;//force override
                    _physvbo.OverridePriority    = 255;
                }
                _physvbo.Overlay    = options.Overlay;
                _sceneryvbo.Overlay = options.Overlay;
                _sceneryvbo.Draw();
                _decorator.DrawUnder(options);
                _physvbo.Draw();
                GameDrawingMatrix.Exit();
            }
        }
 private static void RenderPointOutline(List <Vector2d> points, Color color)
 {
     GameDrawingMatrix.Enter();
     GL.Begin(PrimitiveType.LineStrip);
     for (int i = 0; i < points.Count; i++)
     {
         Color col = (i < 1 || i == points.Count - 1) ? color : Color.FromArgb(255, 200, 0);
         GL.Color3(col);
         GL.Vertex2(points[i]);
     }
     GL.End();
     GameDrawingMatrix.Exit();
 }
        private static void DrawCircle(Vector2d point, float size, Color color)
        {
            GameDrawingMatrix.Enter();
            var center = (Vector2)point;
            var circ   = StaticRenderer.GenerateCircle(center.X, center.Y, size, 360);

            GL.Begin(PrimitiveType.LineStrip);
            GL.Color3(color);
            for (int i = 0; i < circ.Length; i++)
            {
                GL.Vertex2((Vector2)circ[i]);
            }
            GL.End();
            GameDrawingMatrix.Exit();
        }
 public static void RenderRoundedLine(Vector2d position, Vector2d position2, Color color, float thickness, bool knobs = false, bool redknobs = false)
 {
     using (new GLEnableCap(EnableCap.Blend))
     {
         using (new GLEnableCap(EnableCap.Texture2D))
         {
             GameDrawingMatrix.Enter();
             var vao = GetLineVAO();
             vao.Scale = GameDrawingMatrix.Scale;
             vao.AddLine(position, position2, color, thickness);
             vao.knobstate = knobs ? (redknobs ? 2 : 1) : 0;
             vao.Draw(PrimitiveType.Triangles);
             GameDrawingMatrix.Exit();
         }
     }
 }
 public static void DrawBezierCurve(Vector2[] points, Color color, int resolution)
 {
     Vector2[] curvePoints = GenerateBezierCurve(points, resolution);
     if (points.Length > 0)
     {
         GameDrawingMatrix.Enter();
         GL.Begin(PrimitiveType.LineStrip);
         GL.Color3(color);
         for (int i = 0; i < curvePoints.Length; i++)
         {
             GL.Vertex2(curvePoints[i]);
         }
         GL.End();
         GameDrawingMatrix.Exit();
     }
 }
        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();
        }
        private static void renderPointTrace(List <Vector2d> points, BezierCurve curve, Color color)
        {
            double        lineLength      = 0;
            List <double> lengthsPerPoint = new List <double> {
                0
            };

            for (int i = 1; i < points.Count; i++)
            {
                lineLength += Distance(points[i - 1], points[i]);
                lengthsPerPoint.Add(lineLength);
            }
            for (int i = 1; i < points.Count - 1; i++)
            {
                Vector2 curvePoint = curve.CalculatePoint((float)lengthsPerPoint[i] / (float)lineLength);
                GameDrawingMatrix.Enter();
                GL.Begin(PrimitiveType.LineStrip);
                GL.Color3(color);
                GL.Vertex2(points[i]);
                GL.Vertex2(curvePoint);
                GL.End();
                GameDrawingMatrix.Exit();
            }
        }