I am facing a problem that many developers as have probably found a solution. I have a small project with a floor designed with small cubes (100X100). If I exceed this limit, my game suffered major slowdowns and Lagues!
Here's how I draw my floor:
//Function to draw my ground ( 100 X 100 X 1)
public void DrawGround(GameTime gameTime)
{
// Copy any parent transforms.
Matrix[] transforms = new Matrix[this.model.Bones.Count];
this.model.CopyAbsoluteBoneTransformsTo(transforms);
//loop 1 cube high
for (int a = 0; a < 1; a++)
{
//loop 100 along cube
for (int b = 0; b < 100; b++)
{
//loop 100 cubic wide
for (int c = 0; c < 100; c++)
{
// Draw the model. A model can have multiple meshes, so loop.
foreach (ModelMesh mesh in this.model.Meshes)
{
// This is where the mesh orientation is set, as well
// as our camera and projection.
foreach (BasicEffect effect in mesh.Effects)
{
effect.EnableDefaultLighting();
effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateTranslation(this.position);
effect.View = this.view;
effect.Projection = this.projection;
}
// Draw the mesh, using the effects set above.
mesh.Draw();
}
}
}
}
}
I think it is better to use the [VertexBuffer] "memory of the graphics card," but I have not found a tutorial for that I want to do ...
Can you just give me an example to use the [VertexBuffer] in my function "DrawGround"?
Thank you very much!