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