Using DynamicVertexBuffer in XNA 4.0

Posted by Bevin on Stack Overflow See other posts from Stack Overflow or by Bevin
Published on 2011-01-15T22:50:32Z Indexed on 2011/01/15 22:53 UTC
Read the original article Hit count: 188

Filed under:
|
|
|

I read about DynamicVertexBuffer, and how it's supposed to be better for data that changes often. I have a world built up by cubes, and I need to store the cubes' vertices in this buffer to draw them to the screen.

However, not all cubes have vertices (some are air, which is transparent) and not all faces of the cubes need to be drawn either (they are facing each other), so how do I keep track of what vertices are stored where in the buffer? Also, certain faces need to be drawn last, namely the ones with transparency in them (like glass or leaves), and these faces also need to be drawn in a back-to-front order to not mess up the alpha blending.

If all of these vertices are stored arbitrarily in this buffer, how do I know what vertices are where?

Also, the number of vertices can change, but the DynamicVertexBuffer doesn't seem very dynamic to me, since I can't change it's size at all. Do I have to recreate the buffer every time I need to add or remove faces?

© Stack Overflow or respective owner

Related posts about c#

Related posts about XNA