Is there any way to make a primitive and use it over and over again? ex: if I make one cube, can I create 100 and make a 10x10 grid? I've tried using a for loop and updating the x and z coords with each loop thru, but it only moves the one cube thats created in the beginning

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace Cube_Chaser { class Cube { private GraphicsDevice device; private Texture2D texture; public Vector3 location; private Vector3 position; private VertexBuffer cubeVertexBuffer; private List<VertexPositionTexture> vertices = new List<VertexPositionTexture>(); public Cube(GraphicsDevice graphicsDevice, Vector3 playerLocation, float minDistance, Texture2D texture) { device = graphicsDevice; this.texture = texture; PositionCube(playerLocation, minDistance); BuildFace(new Vector3(0, 0, 0), new Vector3(0, 1, 1)); BuildFace(new Vector3(0, 0, 1), new Vector3(1, 1, 1)); BuildFace(new Vector3(1, 0, 1), new Vector3(1, 1, 0)); BuildFace(new Vector3(1, 0, 0), new Vector3(0, 1, 0)); BuildFaceHorizontal(new Vector3(0, 1, 0), new Vector3(1, 1, 1)); BuildFaceHorizontal(new Vector3(0, 0, 1), new Vector3(1, 0, 0)); cubeVertexBuffer = new VertexBuffer(device, VertexPositionTexture.VertexDeclaration, vertices.Count, BufferUsage.WriteOnly); cubeVertexBuffer.SetData<VertexPositionTexture>(vertices.ToArray()); this.position = position; } private void BuildFace(Vector3 p1, Vector3 p2) { vertices.Add(BuildVertex(p1.X, p1.Y, p1.Z, 1, 0)); vertices.Add(BuildVertex(p1.X, p2.Y, p1.Z, 1, 1)); vertices.Add(BuildVertex(p2.X, p2.Y, p2.Z, 0, 1)); vertices.Add(BuildVertex(p2.X, p2.Y, p2.Z, 0, 1)); vertices.Add(BuildVertex(p2.X, p1.Y, p2.Z, 0, 0)); vertices.Add(BuildVertex(p1.X, p1.Y, p1.Z, 1, 0)); } private void BuildFaceHorizontal(Vector3 p1, Vector3 p2) { vertices.Add(BuildVertex(p1.X, p1.Y, p1.Z, 0, 1)); vertices.Add(BuildVertex(p2.X, p1.Y, p1.Z, 1, 1)); vertices.Add(BuildVertex(p2.X, p2.Y, p2.Z, 1, 0)); vertices.Add(BuildVertex(p1.X, p1.Y, p1.Z, 0, 1)); vertices.Add(BuildVertex(p2.X, p2.Y, p2.Z, 1, 0)); vertices.Add(BuildVertex(p1.X, p1.Y, p2.Z, 0, 0)); } private VertexPositionTexture BuildVertex(float x, float y, float z, float u, float v) { return new VertexPositionTexture(new Vector3(x, y, z), new Vector2(u, v)); } public void PositionCube(Vector3 playerLocation, float minDistance) { location = new Vector3(.5f, .5f, .5f); } public void Draw(Camera camera, BasicEffect effect) { effect.VertexColorEnabled = false; effect.TextureEnabled = true; effect.Texture = texture; Matrix center = Matrix.CreateTranslation(new Vector3(-0.5f, -0.5f, -0.5f)); Matrix scale = Matrix.CreateScale(0.05f); Matrix translate = Matrix.CreateTranslation(location); effect.World = center * scale * translate; effect.View = camera.View; effect.Projection = camera.Projection; foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.SetVertexBuffer(cubeVertexBuffer); device.DrawPrimitives(PrimitiveType.TriangleList, 0, cubeVertexBuffer.VertexCount / 3); } } } }