Ejemplo n.º 1
0
        /// <summary>
        /// A draw method for all other VBOs
        /// </summary>
        /// <param name="VertexBufferObject">the VBO to draw</param>
        /// <param name="type">the PrimitiveType to draw the VBO</param>
        /// <author>Markus Strobel</author>
        private void DrawVBO(VBO VertexBufferObject, PrimitiveType type)
        {
            GL.UseProgram(transformationShaderProgramId);
            MatrixLocation = GL.GetUniformLocation(transformationShaderProgramId, "modelMatrix");
            GL.UniformMatrix4(MatrixLocation, false, ref ModelMatrix);

            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Line);
            GL.EnableVertexAttribArray(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject.VertexBufferID);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 0, 0);

            GL.DrawArrays(type, 0, VertexBufferObject.NumElements);

            GL.UseProgram(0);
            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// creates the VBO for the YxyPolygonVBO
        /// </summary>
        /// <author>Justine Smyzek</author>
        private void createYxyPolygonVBO()
        {
            //Quelle: http://www.amazon.com/exec/obidos/ASIN/0471399183/efgscomputlab#reader_0471399183

            VBO vbo = new VBO();
            Vector3[] vertices = new Vector3[64];
            GL.Color3(0.5f, 0.5f, 0.5f);
            vertices[0] = new Vector3(0.1741f, 0.0050f, 0f);
            vertices[1] = new Vector3(0.1740f, 0.0050f, 0f);
            vertices[2] = new Vector3(0.1738f, 0.0049f, 0f);
            vertices[3] = new Vector3(0.1736f, 0.0049f, 0f);

            vertices[4] = new Vector3(0.1733f, 0.0048f, 0f);
            vertices[5] = new Vector3(0.1730f, 0.0048f, 0f);
            vertices[6] = new Vector3(0.1726f, 0.0048f, 0f);
            vertices[7] = new Vector3(0.1721f, 0.0048f, 0f);
            vertices[8] = new Vector3(0.1714f, 0.0051f, 0f);

            vertices[9] = new Vector3(0.1703f, 0.0058f, 0f);
            vertices[10] = new Vector3(0.1689f, 0.0069f, 0f);
            vertices[11] = new Vector3(0.1669f, 0.0086f, 0f);
            vertices[12] = new Vector3(0.1644f, 0.0109f, 0f);
            vertices[13] = new Vector3(0.1611f, 0.0138f, 0f);

            vertices[14] = new Vector3(0.1566f, 0.0177f, 0f);
            vertices[15] = new Vector3(0.1510f, 0.0227f, 0f);
            vertices[16] = new Vector3(0.1440f, 0.0297f, 0f);
            vertices[17] = new Vector3(0.1355f, 0.0399f, 0f);
            vertices[18] = new Vector3(0.1241f, 0.0578f, 0f);

            vertices[19] = new Vector3(0.1096f, 0.0868f, 0f);
            vertices[20] = new Vector3(0.0913f, 0.1327f, 0f);
            vertices[21] = new Vector3(0.0687f, 0.2007f, 0f);
            vertices[22] = new Vector3(0.0454f, 0.2950f, 0f);
            vertices[23] = new Vector3(0.0235f, 0.4127f, 0f);

            vertices[24] = new Vector3(0.0082f, 0.5384f, 0f);
            vertices[25] = new Vector3(0.0039f, 0.6548f, 0f);
            vertices[26] = new Vector3(0.0139f, 0.7502f, 0f);
            vertices[27] = new Vector3(0.0389f, 0.8120f, 0f);
            vertices[28] = new Vector3(0.0743f, 0.8338f, 0f);

            vertices[29] = new Vector3(0.1142f, 0.8262f, 0f);
            vertices[30] = new Vector3(0.1547f, 0.8059f, 0f);
            vertices[31] = new Vector3(0.1929f, 0.7816f, 0f);
            vertices[32] = new Vector3(0.2296f, 0.7543f, 0f);
            vertices[33] = new Vector3(0.2658f, 0.7243f, 0f);

            vertices[34] = new Vector3(0.3016f, 0.6923f, 0f);
            vertices[35] = new Vector3(0.3373f, 0.6589f, 0f);
            vertices[36] = new Vector3(0.3731f, 0.6245f, 0f);
            vertices[37] = new Vector3(0.4087f, 0.5896f, 0f);
            vertices[38] = new Vector3(0.4441f, 0.5547f, 0f);

            vertices[39] = new Vector3(0.4788f, 0.5202f, 0f);

            vertices[40] = new Vector3(0.5125f, 0.4866f, 0f);
            vertices[41] = new Vector3(0.5448f, 0.4544f, 0f);
            vertices[42] = new Vector3(0.5752f, 0.4242f, 0f);
            vertices[43] = new Vector3(0.6029f, 0.3965f, 0f);

            vertices[44] = new Vector3(0.6270f, 0.3725f, 0f);
            vertices[45] = new Vector3(0.6482f, 0.3514f, 0f);
            vertices[46] = new Vector3(0.6658f, 0.3340f, 0f);
            vertices[47] = new Vector3(0.6801f, 0.3197f, 0f);
            vertices[48] = new Vector3(0.6915f, 0.3083f, 0f);

            vertices[49] = new Vector3(0.7006f, 0.2993f, 0f);
            vertices[50] = new Vector3(0.7079f, 0.2920f, 0f);
            vertices[51] = new Vector3(0.7140f, 0.2859f, 0f);
            vertices[52] = new Vector3(0.7190f, 0.2809f, 0f);
            vertices[53] = new Vector3(0.7230f, 0.2770f, 0f);

            vertices[54] = new Vector3(0.7260f, 0.2740f, 0f);
            vertices[55] = new Vector3(0.7283f, 0.2717f, 0f);
            vertices[56] = new Vector3(0.7300f, 0.2700f, 0f);
            vertices[57] = new Vector3(0.7311f, 0.2689f, 0f);
            vertices[58] = new Vector3(0.7320f, 0.2680f, 0f);

            vertices[59] = new Vector3(0.7327f, 0.2673f, 0f);
            vertices[60] = new Vector3(0.7334f, 0.2666f, 0f);
            vertices[61] = new Vector3(0.7340f, 0.2660f, 0f);
            vertices[62] = new Vector3(0.7344f, 0.2656f, 0f);
            vertices[63] = new Vector3(0.7346f, 0.2654f, 0f);

            int[] indices = new int[vertices.Length];
            for (int i = 0; i < vertices.Length; i++)
            {
                indices[i] = i;
            }
            YxyPolygonVBO = LoadVBO(vertices, indices);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This method deletes a given VBO Object
 /// </summary>
 /// <param name="vbo">the vbo to delete</param>
 /// <author>Markus Strobel</author>
 private void DeleteVBO(VBO vbo)
 {
     if (vbo != null)
     {
         if (vbo.VertexBufferID != -1)
             GL.DeleteBuffer(vbo.VertexBufferID);
         if (vbo.IndicesBufferID != -1)
             GL.DeleteBuffer(vbo.IndicesBufferID);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// This method creates the circle for the selected S & L value in HSL Space
 /// </summary>
 /// <param name="x">the current x coordinate or x value from Yxy</param>
 /// <param name="y">the current y coordinate or y value from Yxy</param>
 /// <param name="radius">the radius of the circle</param>
 /// <param name="vertices">the amount of vertices, which the circle shell have</param>
 /// <author>Markus Strobel</author>
 private void createSelectedSLCircle(float x, float y, float radius, int vertices)
 {
     selectedSLCircleVBO = creatCircleVBO(x, y, radius, vertices);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// this method creates the VBO for the XYZ Space
        /// </summary>
        /// <author>Markus Strobel</author>
        private void createXYZViewVBO()
        {
            Vector3[] vertices = new Vector3[4];
            vertices[0] = new Vector3(0.0f, 0.0f, 0f);
            vertices[1] = new Vector3(1.0f, 0.0f, 0f);
            vertices[2] = new Vector3(0.0f, 1.0f, 0f);
            vertices[3] = new Vector3(1.0f, 1.0f, 0f);

            int[] indices = { 0, 1, 2, 3 };

            xyzColorSpaceVBO = LoadVBO(vertices, indices);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// this method creates the RGBPreviewLines for the XYZ Space
        /// </summary>
        /// <author>Markus Strobel</author>
        private void createRGBPreviewLines(RGB selectedColor)
        {
            RGB rgb = new RGB();
            Yxy yxy;

            GL.Color3(0.5f, 0.5f, 0.5f);
            rgb.R = 1;
            rgb.G = selectedColor.G;
            rgb.B = selectedColor.B;
            yxy = rgb.asXYZ().asYxy();
            Vector3 RGB_1GB = new Vector3(yxy.x, yxy.y, 0f);
            rgb.R = 0;
            rgb.G = selectedColor.G;
            rgb.B = selectedColor.B;
            yxy = rgb.asXYZ().asYxy();
            Vector3 RGB_0GB = new Vector3(yxy.x, yxy.y, 0f);
            rgb.R = selectedColor.R;
            rgb.G = 1;
            rgb.B = selectedColor.B;
            yxy = rgb.asXYZ().asYxy();
            Vector3 RGB_R1B = new Vector3(yxy.x, yxy.y, 0f);
            rgb.R = selectedColor.R;
            rgb.G = 0;
            rgb.B = selectedColor.B;
            yxy = rgb.asXYZ().asYxy();
            Vector3 RGB_R0B = new Vector3(yxy.x, yxy.y, 0f);
            rgb.R = selectedColor.R;
            rgb.G = selectedColor.G;
            rgb.B = 1;
            yxy = rgb.asXYZ().asYxy();
            Vector3 RGB_RG1 = new Vector3(yxy.x, yxy.y, 0f);
            rgb.R = selectedColor.R;
            rgb.G = selectedColor.G;
            rgb.B = 0;
            yxy = rgb.asXYZ().asYxy();
            Vector3 RGB_RG0 = new Vector3(yxy.x, yxy.y, 0f);

            Vector3[] vertices = { RGB_1GB, RGB_0GB, RGB_R1B, RGB_R0B, RGB_RG1, RGB_RG0 };

            int[] indices = new int[vertices.Length];
            for (int i = 0; i < vertices.Length; i++)
            {
                indices[i] = i;
            }
            rgbPreviewLines = LoadVBO(vertices, indices);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// this method creates the Circle and Rect VBO for the HSL Space
        /// </summary>
        /// <author>Markus Strobel</author>
        private void createHSLViewVBO()
        {
            // Hue Circle
            float x = 0.5f;
            float y = 0.5f;
            float outerRadius = 0.49f;
            float innerRadius = 0.36f;
            int vertices = 360;
            float degreeStep = 360f / vertices;

            Vector3[] innerCircle = new Vector3[vertices];
            Vector3[] outerCircle = new Vector3[vertices];

            for (int i = 0; i < vertices; i++)
            {
                float outerXOffSet = outerRadius * (float)Math.Cos((double)(i * degreeStep) * Math.PI / 180d);
                float outerYOffSet = outerRadius * (float)Math.Sin((double)(i * degreeStep) * Math.PI / 180d);
                float innerXOffSet = innerRadius * (float)Math.Cos((double)(i * degreeStep) * Math.PI / 180d);
                float innerYOffSet = innerRadius * (float)Math.Sin((double)(i * degreeStep) * Math.PI / 180d);

                outerCircle[i] = new Vector3(x + outerXOffSet, y + outerYOffSet, 0);
                innerCircle[i] = new Vector3(x + innerXOffSet, y + innerYOffSet, 0);
            }

            Vector3[] circleVertices = new Vector3[2 * vertices + 2];
            int[] circleIndices = new int[2 * vertices + 2];

            int j = 0; // helper index for
            for (int i = 0; i < vertices; i++)
            {
                circleVertices[j] = outerCircle[i];
                circleVertices[j + 1] = innerCircle[i];
                j += 2;
            }

            // connect last with first vertex
            circleVertices[2 * vertices] = outerCircle[0];
            circleVertices[2 * vertices + 1] = innerCircle[0];

            hslColorSpaceCircleVBO = LoadVBO(circleVertices, circleIndices);

            // S & L Rect
            Vector3[] rectVertices = new Vector3[4];
            rectVertices[0] = new Vector3(0.25f, 0.25f, 0.1f);
            rectVertices[1] = new Vector3(0.75f, 0.25f, 0.1f);
            rectVertices[2] = new Vector3(0.25f, 0.75f, 0.1f);
            rectVertices[3] = new Vector3(0.75f, 0.75f, 0.1f);
            int[] rectIndices = { 0, 1, 2, 3 };
            hslColorSpaceRectVBO = LoadVBO(rectVertices, rectIndices);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// creating the PreviewLines for HSL Saturation
        /// </summary>
        /// <param name="selectedColor">the selected Color</param>
        /// <author>Justine Smyzek</author>
        private void createHSLPreviewLines(HSL selectedColor)
        {
            HSL hsl = new HSL();
            Yxy yxy;

            GL.Color3(0.5f, 0.5f, 0.5f);
            hsl.H = selectedColor.H;
            hsl.S = 0;
            hsl.L = selectedColor.L;
            yxy = hsl.asRGB().asXYZ().asYxy();
            Vector3 HSL_H0L = new Vector3(yxy.x, yxy.y, 0f);
            hsl.H = selectedColor.H;
            hsl.S = 1;
            hsl.L = selectedColor.L;
            yxy = hsl.asRGB().asXYZ().asYxy();
            Vector3 HSL_H1L = new Vector3(yxy.x, yxy.y, 0f);

            Vector3[] vertices = { HSL_H0L, HSL_H1L };

            int[] indices = new int[vertices.Length];
            for (int i = 0; i < vertices.Length; i++)
            {
                indices[i] = i;
            }
            hslPreviewLines = LoadVBO(vertices, indices);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// create HDL Polygon for Hue circulation
        /// </summary>
        /// <param name="selectedColor">the selected Color</param>
        /// <author>Justine Smyzek</author>
        private void createHSLPreviewCircle(HSL selectedColor)
        {
            HSL hsl = new HSL();
            Yxy yxy;
            int j = 0;
            Vector3[] vertices = new Vector3[36];

            GL.Color3(0.5f, 0.5f, 0.5f);
            for (int i = 0; i < 360; i += 10)
            {
                hsl.H = i;
                hsl.S = selectedColor.S;
                hsl.L = selectedColor.L;
                yxy = hsl.asRGB().asXYZ().asYxy();
                Vector3 hsli = new Vector3(yxy.x, yxy.y, 0f);
                vertices[j] = hsli;
                j += 1;

            }

            int[] indices = new int[vertices.Length];
            for (int i = 0; i < vertices.Length; i++)
            {
                indices[i] = i;
            }
            hslPreviewCircle = LoadVBO(vertices, indices);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// This method takes vertices and indices and creates/binds buffer and stores the respective BufferIds in a VBO and returns it
        /// </summary>
        /// <param name="vertices">the vertices</param>
        /// <param name="indices">the indices</param>
        /// <returns>a VBO with the IDs to the respective Buffers</returns>
        /// <author>Markus Strobel</author>
        private VBO LoadVBO(Vector3[] vertices, int[] indices)
        {
            VBO VertexBufferObject = new VBO();

            if (vertices != null)
            {
                VertexBufferObject.VertexBufferID = GL.GenBuffer();
                GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject.VertexBufferID);
                GL.BufferData(BufferTarget.ArrayBuffer, (IntPtr)(vertices.Length * Vector3.SizeInBytes), vertices, BufferUsageHint.DynamicDraw);
                GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
            }

            if (indices != null)
            {
                VertexBufferObject.IndicesBufferID = GL.GenBuffer();
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, VertexBufferObject.IndicesBufferID);
                GL.BufferData(BufferTarget.ElementArrayBuffer, (IntPtr)(indices.Length * sizeof(int)), indices, BufferUsageHint.StaticDraw);
                GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0);

                VertexBufferObject.NumElements = indices.Length;
            }

            return VertexBufferObject;
        }