tailieunhanh - Microsoft XNA Game Studio Creator’s Guide- P7

Microsoft XNA Game Studio Creator’s Guide- P7:The release of the XNA platform and specifically the ability for anyone to write Xbox 360 console games was truly a major progression in the game-programming world. Before XNA, it was simply too complicated and costly for a student, software hobbyist, or independent game developer to gain access to a decent development kit for a major console platform. | 158 MICROSOFT XNA GAME STUDIO CREATOR S GUIDE Once the indices have been defined the SetData method stores the index references in the index buffer. There are several overrides for this method but for our needs all you have to do is pass in the array of indices SetData T T data Managing Vertex Data with Index Buffers and Vertex Buffers By themselves the VertexPositionColor VertexPositionColorTexture VertexPositionTexture and VertexPositionNormalTexture objects that you have used will not permit live updates to the position color texture and normal data. DynamicVertexBuffer objects in combination with index buffers on the other hand will permit updates to large amounts of vertex data. You are going to want a structure like this when creating an effect such as water. When initialized the constructor for the vertex buffer takes parameters for the current graphics device vertex type element count and buffer usage for memory allocation VertexBuffer GraphicsDevice Type int BufferUsage graphicsDevice vertexType elementCount usage As explained above BufferUsage options are None as the default WriteOnly for efficient writes to memory and for efficient drawing and Points for point sprites. After the vertex data is loaded into an array the vertex data is moved into the vertex buffer with the VertexBuffer object s SetData method. There are several variations of this method. The method used here only passes the array of vertices SetData VertexBuffer vertexBuffer Rendering Vertex Buffers with an Index Buffer Reference The draw method you use for dynamic vertex buffers using index buffers differs in three ways from the draw methods you have used until now 1. The SetSource method is used to set the vertex buffer that stores the grid the starting element and the size of the vertex type in bytes 0 .SetSource VertexBuffer int int vertexBuffer startingElement sizeOfVertex CHAPTER 1 1 1 59 2. The GraphicsDevice s Indices object is set with the .