Пример #1
0
 public void Draw(Matrix view, Matrix projection)
 {
     effect.World      = worldMatrix;
     effect.View       = view;
     effect.Projection = projection;
     device.SetVertexBuffer(vertexBuffer);
     foreach (EffectPass CurrentPass in effect.CurrentTechnique.Passes)
     {
         CurrentPass.Apply();
         device.DrawPrimitives(PrimitiveType.TriangleStrip, 0, 2);
     }
 }
        //Draws the terrain
        public override void Draw(GameTime gameTime)
        {
            Game1 myGame = (Game1)Game;

            effect.World          = Matrix.Identity; //No transformation of the terrain
            effect.View           = myGame.camera.view;
            effect.Projection     = myGame.camera.projection;
            effect.Texture        = texture;
            effect.TextureEnabled = true;

            GraphicsDevice.SetVertexBuffer(vb); //Set vertices
            GraphicsDevice.Indices = ib;        //Set indices

            foreach (EffectPass CurrentPass in effect.CurrentTechnique.Passes)
            {
                CurrentPass.Apply();
                GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, numVertices, 0, numTriangles); //Draw all triangles that make up the mesh
            }

            base.Draw(gameTime);
        }