public override void Draw(GL_ControlModern control)
        {
            GL.LineWidth(2.0f);

            control.CurrentShader = defaultShaderProgram;
            GL.Uniform1(defaultShaderProgram["tex"], Framework.TextureSheet - 1);
            Matrix4 mtx = Matrix4.CreateScale(0.5f);

            mtx *= Matrix4.CreateTranslation(Position);
            control.UpdateModelMatrix(mtx);

            bool hovered  = EditorScene.IsHovered();
            bool selected = EditorScene.IsSelected();

            if (hovered && selected)
            {
                GL.Uniform4(defaultShaderProgram["color"], CubeColor * 0.5f + hoverColor * 0.5f);
            }
            else if (hovered || selected)
            {
                GL.Uniform4(defaultShaderProgram["color"], CubeColor * 0.5f + selectColor * 0.5f);
            }
            else
            {
                GL.Uniform4(defaultShaderProgram["color"], CubeColor);
            }
            GL.BindVertexArray(blockVao);
            GL.DrawArrays(PrimitiveType.Quads, 0, 24);

            control.CurrentShader = solidColorShaderProgram;
            if (hovered && selected)
            {
                GL.Uniform4(defaultShaderProgram["color"], hoverColor);
            }
            else if (hovered || selected)
            {
                GL.Uniform4(defaultShaderProgram["color"], selectColor);
            }
            else
            {
                GL.Uniform4(defaultShaderProgram["color"], CubeColor);
            }
            GL.BindVertexArray(linesVao);
            GL.DrawArrays(PrimitiveType.Lines, 0, 24);
        }
Esempio n. 2
0
        public override void Draw(GL_ControlModern control)
        {
            GL.LineWidth(2f);
            control.CurrentShader = defaultShaderProgram;

            Matrix4 mtx = Matrix4.CreateTranslation(Position);

            control.UpdateModelMatrix(mtx);

            GL.Uniform1(defaultShaderProgram["scale"], 0.5f);

            bool picked = EditorScene.IsHovered();

            GL.Begin(PrimitiveType.Points);
            {
                int i = 1;
                foreach (PathPoint point in pathPoints)
                {
                    GL.VertexAttrib4(1, (picked || EditorScene.IsHovered(i)) ? CubeColor * 0.5f + hoverColor * 0.5f : CubeColor);
                    GL.VertexAttrib3(2, point.controlPoint1);
                    GL.VertexAttrib3(3, point.controlPoint2);
                    GL.Vertex3(point.position);
                    i++;
                }
            }
            GL.End();

            control.CurrentShader = defaultLinesShaderProgram;
            GL.Uniform1(defaultLinesShaderProgram["scale"], 0.5f);

            GL.Begin(PrimitiveType.Points);
            {
                int i = 1;
                foreach (PathPoint point in pathPoints)
                {
                    GL.VertexAttrib4(1, (picked || EditorScene.IsHovered(i)) ? hoverColor : lineColor);
                    GL.VertexAttrib3(2, point.controlPoint1);
                    GL.VertexAttrib3(3, point.controlPoint2);
                    GL.Vertex3(point.position);
                    i++;
                }
            }
            GL.End();

            control.CurrentShader = connectLinesShaderProgram;

            GL.Uniform4(connectLinesShaderProgram["color"], picked ? hoverColor : CubeColor);

            GL.Begin(PrimitiveType.Lines);
            for (int i = 1; i < pathPoints.Count; i++)
            {
                PathPoint p1 = pathPoints[i - 1];
                PathPoint p2 = pathPoints[i];

                GL.VertexAttrib3(1, p1.controlPoint2);
                GL.Vertex3(p1.position);

                GL.VertexAttrib3(1, p2.controlPoint1);
                GL.Vertex3(p2.position);
            }
            GL.End();
        }