Example #1
0
        /// <summary>
        ///     Reads vertices from a vertex buffer.
        /// </summary>
        /// <param name="reader">The stream to read from.</param>
        /// <param name="layout">The layout of each vertex to read.</param>
        /// <param name="count">The number of vertices to read.</param>
        /// <param name="boundingBox">The bounding box to transform vertices with. Can be null.</param>
        /// <param name="processor">The IVertexProcessor to send read vertices to. Can be null.</param>
        public static void ReadVertices(IReader reader, VertexLayout layout, int count, BoundingBox boundingBox,
                                        IVertexProcessor processor)
        {
            for (int i = 0; i < count; i++)
            {
                long vertexStartPos = reader.Position;
                if (processor != null)
                {
                    processor.BeginVertex();
                }

                foreach (VertexElementLayout element in layout.Elements)
                {
                    if (element.Stream == 0)                     // Not sure how multistream vertices work yet
                    {
                        reader.SeekTo(vertexStartPos + element.Offset);
                        ReadElement(reader, element, boundingBox, processor);
                    }
                }

                if (processor != null)
                {
                    processor.EndVertex();
                }
            }
        }
        /// <summary>
        /// Reads vertices from a vertex buffer.
        /// </summary>
        /// <param name="reader">The stream to read from.</param>
        /// <param name="layout">The layout of each vertex to read.</param>
        /// <param name="count">The number of vertices to read.</param>
        /// <param name="boundingBox">The bounding box to transform vertices with. Can be null.</param>
        /// <param name="processor">The IVertexProcessor to send read vertices to. Can be null.</param>
        public static void ReadVertices(IReader reader, VertexLayout layout, int count, IModelBoundingBox boundingBox, IVertexProcessor processor)
        {
            for (int i = 0; i < count; i++)
            {
                long vertexStartPos = reader.Position;
                if (processor != null)
                    processor.BeginVertex();

                foreach (VertexElementLayout element in layout.Elements)
                {
                    if (element.Stream == 0) // Not sure how multistream vertices work yet
                    {
                        reader.SeekTo(vertexStartPos + element.Offset);
                        ReadElement(reader, element, boundingBox, processor);
                    }
                }

                if (processor != null)
                    processor.EndVertex();
            }
        }