Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've a set of voxel data and I want to create a mesh out of it at run-time.

I've looked into MeshBuilder and 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?

share|improve this question
up vote 4 down vote accepted

I think this should answer your question:

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);


IndexBuffer  lineListIndexBuffer = new IndexBuffer(
    sizeof(short) * lineListIndices.Length,


GraphicsDevice.Indices = lineListIndexBuffer;
GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.LineList, 0, 0, 8, 0, 7);
share|improve this answer
thanks! (at least 15 characters) – Valdiralita Jul 24 '12 at 6:57

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.