I've a set of voxel data and I want to create a mesh out of it at run-time.
I've looked into
MeshHelper but I haven't found anything useful or a good tutorial how to use them. Can anyone tell me how to create a mesh at run-time?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.Sign up to join this community
I think this should answer your question: http://forums.create.msdn.com/forums/p/4751/24616.aspx
Basically you should just create a vertex and index buffer yourself (you can wrap them up in a nice class that implements IDrawable ofc).
Once you have a vertex and index buffer you can draw your model like in this MSDN article:
VertexBuffer vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), 8, BufferUsage.None); vertexBuffer.SetData<VertexPositionColor>(primitiveList); IndexBuffer lineListIndexBuffer = new IndexBuffer( GraphicsDevice, IndexElementSize.SixteenBits, sizeof(short) * lineListIndices.Length, BufferUsage.None); lineListIndexBuffer.SetData<short>(lineListIndices); GraphicsDevice.Indices = lineListIndexBuffer; GraphicsDevice.SetVertexBuffer(vertexBuffer); GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, 8, 0, 7);
I have been working on 2D game 2y ago and had to draw shapes like thet. You could look what I have done Project - Squared
Take a look at GraphicsDrawer class under SquaredEngine.Graphics, it will allow you to draw some basic meshes, triangles, lines, quads, ellipses, etc.
You could easily make this to work in 3D env.