Exemplo n.º 1
0
        public void BufferData(OpenGL gl,
            uint[] indices, float[] vertices, float[] normals, Material[] materials)
        {
            IndicesCount = indices.Length;

            var color3Size = 3 * materials.Length;
            float[] ambs = new float[color3Size],
                diffs = new float[color3Size],
                specs = new float[color3Size],
                shinis = new float[materials.Length];

            // Convert materials to float arrays.
            var newPos = 0;
            for (int i = 0; i < materials.Length; i++)
            {
                var mat = materials[i];
                for (int j = 0; j < 3; j++)
                {
                    ambs[newPos] = mat.Ambient[j+1];
                    diffs[newPos] = mat.Diffuse[j+1];
                    specs[newPos] = mat.Specular[j+1];
                    newPos++;
                }
                shinis[i] = mat.Shininess;
            }

            // Because an Index Buffer Object ID is unique, we'll use this to generate a hit test color.
            var htColor = new ColorF(Ibo);
            var htColorID = htColor.ToRGB();

            // Set buffer data.
            BufferData(gl, indices, vertices, normals,
                ambs, diffs, specs, shinis, htColorID);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sets the background color, using a gradient existing from 2 colors
        /// </summary>
        /// <param name="gl"></param>
        private static void SetVerticalGradientBackground(OpenGL gl, ColorF colorTop, ColorF colorBot)
        {
            float topRed = colorTop.R;// / 255.0f;
            float topGreen = colorTop.G;// / 255.0f;
            float topBlue = colorTop.B;// / 255.0f;
            float botRed = colorBot.R;// / 255.0f;
            float botGreen = colorBot.G;// / 255.0f;
            float botBlue = colorBot.B;// / 255.0f;

            gl.Begin(OpenGL.GL_QUADS);

            //bottom color
            gl.Color(botRed, botGreen, botBlue);
            gl.Vertex(-1.0, -1.0);
            gl.Vertex(1.0, -1.0);

            //top color
            gl.Color(topRed, topGreen, topBlue);
            gl.Vertex(1.0, 1.0);
            gl.Vertex(-1.0, 1.0);

            gl.End();
        }
Exemplo n.º 3
0
        public void BufferData(OpenGL gl,
            uint[] indices, float[] vertices, ColorF colorValue)
        {
            if (indices != null)
                IndicesCount = indices.Length;
            else
                IndicesCount = 0;
            VerticesCount = vertices.Length;

            float[] colorsArr = new float[3];

            // Convert materials to float arrays.
            var newPos = 0;
            var argb = colorValue;
            for (int j = 0; j < 3; j++)
            {
                colorsArr[newPos] = argb[j+1];
                newPos++;
            }

            // Set buffer data.
            BufferData(gl, indices, vertices, colorsArr);
        }