private void BuildBuffers(IGenerator generator) { List<MyOwnVertexFormat> vertices = new List<MyOwnVertexFormat>(); for (int x = 0; x < sideSize; x++) { for (int z = 0; z < sideSize; z++) { for (int y = 0; y < sideSize; y++) { double sample = generator.Sample(new Vector3(x, y, z) + location); if ( sample > 0.6f) { CreateVertices(vertices, x, y, z, new Color((float)sample, (float)sample, (float)sample)); } } } } if(vertices.Count > 0) { vertexBuffer = new VertexBuffer(device, MyOwnVertexFormat.VertexDeclaration, vertices.Count, BufferUsage.WriteOnly); vertexBuffer.SetData(vertices.ToArray()); } numVertices = vertices.Count; }