/// <summary>
        ///     Creates a Index Buffer for a Mesh, trying to repeat as less Vertices as possible.
        /// </summary>
        /// <param name="mesh">The Mesh that should be optimized</param>
        /// <returns></returns>
        public static optimizedMesh optimizeMesh(RenderBase.OMesh mesh)
        {
            optimizedMesh output = new optimizedMesh();

            output.hasNormal  = mesh.hasNormal;
            output.hasTangent = mesh.hasTangent;
            output.hasColor   = mesh.hasColor;
            output.hasNode    = mesh.hasNode;
            output.hasWeight  = mesh.hasWeight;
            output.texUVCount = mesh.texUVCount;

            for (int i = 0; i < mesh.vertices.Count; i++)
            {
                bool found = false;
                for (int j = 1; j <= optimizerLookBack; j++)
                {
                    int p = output.vertices.Count - j;
                    if (p < 0 || p >= output.vertices.Count)
                    {
                        break;
                    }
                    if (output.vertices[p].Equals(mesh.vertices[i]))
                    {
                        output.indices.Add((uint)p);
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    output.vertices.Add(mesh.vertices[i]);
                    output.indices.Add((uint)(output.vertices.Count - 1));
                }
            }

            return(output);
        }
        /// <summary>
        ///     Creates a Index Buffer for a Mesh, trying to repeat as less Vertices as possible.
        /// </summary>
        /// <param name="mesh">The Mesh that should be optimized</param>
        /// <returns></returns>
        public static optimizedMesh optimizeMesh(RenderBase.OMesh mesh)
        {
            optimizedMesh output = new optimizedMesh();

            output.hasNormal = mesh.hasNormal;
            output.hasTangent = mesh.hasTangent;
            output.hasColor = mesh.hasColor;
            output.hasNode = mesh.hasNode;
            output.hasWeight = mesh.hasWeight;
            output.texUVCount = mesh.texUVCount;

            for (int i = 0; i < mesh.vertices.Count; i++)
            {
                bool found = false;
                for (int j = 1; j <= optimizerLookBack; j++)
                {
                    int p = output.vertices.Count - j;
                    if (p < 0 || p >= output.vertices.Count) break;
                    if (output.vertices[p].Equals(mesh.vertices[i]))
                    {
                        output.indices.Add((uint)p);
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    output.vertices.Add(mesh.vertices[i]);
                    output.indices.Add((uint)(output.vertices.Count - 1));
                }
            }

            return output;
        }