Beispiel #1
0
 public void DrawTerrainAsset(TerrainBlock asset)
 {
     SamplerState s = new SamplerState();
     effect.View = viewMatrix;
     effect.Projection = projectionMatrix;
     s.AddressU = TextureAddressMode.Wrap; s.AddressV = TextureAddressMode.Wrap;
     Game.GraphicsDevice.SamplerStates[0] = s;
     Game.GraphicsDevice.RasterizerState = new RasterizerState() { CullMode = CullMode.None };
     effect.FogEnabled = Fog.On ;
     effect.FogStart = Fog.Start;
     effect.FogEnd = Fog.End;
     effect.FogColor = Fog.Colour;
     effect.TextureEnabled = true;
     effect.Texture = asset.GetTexture();
     effect.EnableDefaultLighting();
     effect.AmbientLightColor = new Vector3(0.5f, 0.5f, 0.5f);
     foreach (EffectPass pass in effect.CurrentTechnique.Passes)
     {
         pass.Apply();
         game.GraphicsDevice.SetVertexBuffer(asset.GetVertexBuffer());
         game.GraphicsDevice.Indices = asset.GetIndexBuffer();
         game.GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, asset.GetVerticesLength(), 0, asset.GetIndicesLength() / 3);
     }
 }