public MathGeometry(Game game, GeometryParameters parameters) { graphics = game.GraphicsDevice; this.game = game; this.parameters = parameters; effect = game.Content.Load <Effect>("VoxelEffect"); materials = game.Content.Load <Texture2D>("materials"); if (!init) { Init(game.GraphicsDevice); } List <VoxelVertex> voxels = new List <VoxelVertex>(); for (int x = 0; x < parameters.Size.X; x++) { for (int y = 0; y < parameters.Size.Y; y++) { for (int z = 0; z < parameters.Size.Y; z++) { Point3D p = new Point3D(x, y, z); if (!parameters.Visible(p)) { continue; } int material = parameters.MaterialID(p); VoxelVertex v = new VoxelVertex() { Position = p.ToVector3(), MaterialID = material }; voxels.Add(v); } } } instanceBuffer = new VertexBuffer(graphics, typeof(VoxelVertex), voxels.Count, BufferUsage.WriteOnly); instanceBuffer.SetData(voxels.ToArray()); numInstances = voxels.Count; }
public MathGeometry(Game game, GeometryParameters parameters) { graphics = game.GraphicsDevice; this.game = game; this.parameters = parameters; effect = game.Content.Load<Effect>("VoxelEffect"); materials = game.Content.Load<Texture2D>("materials"); if (!init) Init(game.GraphicsDevice); List<VoxelVertex> voxels = new List<VoxelVertex>(); for (int x = 0; x < parameters.Size.X; x++) { for (int y = 0; y < parameters.Size.Y; y++) { for (int z = 0; z < parameters.Size.Y; z++) { Point3D p = new Point3D(x, y, z); if (!parameters.Visible(p)) continue; int material = parameters.MaterialID(p); VoxelVertex v = new VoxelVertex() { Position = p.ToVector3(), MaterialID = material }; voxels.Add(v); } } } instanceBuffer = new VertexBuffer(graphics, typeof(VoxelVertex), voxels.Count, BufferUsage.WriteOnly); instanceBuffer.SetData(voxels.ToArray()); numInstances = voxels.Count; }