我面临一个问题,许多开发人员可能已经找到了解决方案。我有一个小项目,地板设计有小立方体(100X100)。如果我超过这个限制,我的游戏就会出现严重的减速和 Lagues!
这是我绘制地板的方式:
//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();
}
}
}
}
}
我认为最好使用[VertexBuffer]“显卡的内存”,但我还没有找到我想做的教程......
你能给我一个在我的函数“DrawGround”中使用[VertexBuffer]的例子吗? 非常感谢你!