Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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"? enter image description here Thank you very much!

share|improve this question
As a suggestion, try loading/storing your map in chunks of 20-10 square. This will mean as the user moves around you load and unload areas and also only required to render (and store in memory) the structure of the chunk once. – AbstractChaos Jan 21 at 13:43
Yes thank you, but I would like the user can view a minimum 100X100 cubes around him. I think I have something here -> -> float4x4.net/index.php/2011/07/… – Mehdi Bugnard Jan 21 at 15:35
Do you need to use cubes? or are you doing a minecraft style game? – Luis Estrada Jan 21 at 16:05
Yes exactly! I wanted to keep the same idea as "Minecraft". Is it okay to make Like this ? – Mehdi Bugnard Jan 21 at 16:11

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.