示例#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 = true;
            //effect.FogStart = 120f;
            //effect.FogEnd = 150f;
            //effect.FogColor = Color.CornflowerBlue.ToVector3();
            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);
            }

            //base.Draw(gameTime);
        }