Exemplo n.º 1
0
        public override void Draw(GL_ControlModern control)
        {
            GL.LineWidth(2.0f);

            control.CurrentShader = solidColorShaderProgram;
            Matrix4 mtx = Matrix4.CreateScale(1f, 0.25f, 1f);

            mtx *= Matrix4.CreateFromAxisAngle(Vector3.UnitY, -(float)Math.PI / 2f);
            mtx *= Matrix4.CreateTranslation(Position);
            control.UpdateModelMatrix(mtx);

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

            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);

            mtx *= Matrix4.CreateTranslation(Vector3.UnitX * 3f);
            control.UpdateModelMatrix(mtx);

            GL.DrawArrays(PrimitiveType.Lines, 0, 24);

            mtx *= Matrix4.CreateTranslation(-Vector3.UnitX * Math.Abs(control.RedrawerFrame * 0.0625f % 6f - 3f));
            control.UpdateModelMatrix(mtx);

            control.CurrentShader = defaultShaderProgram;
            GL.Uniform1(defaultShaderProgram["tex"], Framework.TextureSheet - 1);

            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);
        }