示例#1
0
        /// <summary>
        /// Creates a new <see cref="VertexUnit"/>.
        /// </summary>
        /// <param name="format">The <see cref="VertexFormat"/> of the new format.</param>
        public VertexUnit Clone(VertexFormat format)
        {
            VertexUnit unit = new VertexUnit(format, size);

            for (int i = 0; i < format.Size; i++)
            {
                IGraphicsStream stream = unit[i];
                if (this.format.Contains(stream.GetType(), format.GetUsageIndex(i)))
                {
                    IGraphicsStream from = this[stream.GetType(), format.GetUsageIndex(i)];
                    Array.Copy(from.Data, stream.Data, from.Size);
                }
            }
            return(unit);
        }
示例#2
0
        /// <summary>
        /// Changes the format of the <see cref="VertexUnit"/> to fit the given
        /// semantics.
        /// </summary>
        /// <param name="semantics">Semantics to fit.</param>
        public void ChangeFormat(Semantic[] semantics)
        {
            VertexFormat newFormat = format.Clone(semantics);

            IVertexStream[] newStreams = new IVertexStream[semantics.Length];
            for (int i = 0; i < newFormat.Size; i++)
            {
                int index = format.GetIndex(newFormat.GetType(i), newFormat.GetUsageIndex(i));
                newStreams[i] = this[index];
            }
            this.vertexStreams = newStreams;
            format             = newFormat;
        }