Пример #1
0
        protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
        {
            base.LoadContent(GraphicInfo, factory, contentManager);

            ///Create the Terrain Object
            ///Controls how the heigh map is loaded
            TerrainObject to = new TerrainObject(factory, "..\\Content\\Textures\\Untitled", Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 1, 1, 10);
            ///Create the Model using the Terrain Object. Here we pass the textures used, in our case we are using MultiTextured Terrain so we pass lots of textures
            TerrainModel stm = new TerrainModel(factory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass");

            stm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE);
            ///Create the shader
            ///In this sample we passed lots of textures, each one describe a level in the terrain, the ground is the sand and grass. the hills are rocks and the "mountains" are snow
            ///They are interpolated in the shader, you can control how using the shader parameters exposed in the DeferredTerrainShader
            ForwardXNABasicShader shader = new ForwardXNABasicShader();
            ///Deferred material
            ForwardMaterial fmaterial = new ForwardMaterial(shader);
            ///The object itself
            IObject obj = new IObject(fmaterial, stm, to);

            ///Add to the world
            this.World.AddObject(obj);

            shader.BasicEffect.EnableDefaultLighting();

            CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo.Viewport);

            this.World.CameraManager.AddCamera(cam);
        }
        void createterrain(int height = 5)
        {
            ///Create the Terrain Object
            ///Controls how the heigh map is loaded
            TerrainObject to = new TerrainObject(GraphicFactory, "..\\Content\\Textures\\hmap", new Vector3(0, -30, 0), Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 3, 3, height);

            ///Create the Model using the Terrain Object. Here we pass the textures used
            TerrainModel stm = new TerrainModel(GraphicFactory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass");

            stm.SetTexture("..\\Content\\Textures\\Terraingrass", TextureType.DIFFUSE);
            ForwardXNABasicShader shader    = new ForwardXNABasicShader();
            ForwardMaterial       fmaterial = new ForwardMaterial(shader);

            ///The object itself
            obj = new IObject(fmaterial, stm, to);
            ///Add to the world
            this.World.AddObject(obj);

            ///light =p
            shader.BasicEffect.EnableDefaultLighting();
            shader.BasicEffect.SpecularPower          = 250;
            shader.BasicEffect.PreferPerPixelLighting = true;


            //Fog =P
            shader.BasicEffect.FogEnabled = true;
            shader.BasicEffect.FogColor   = new Vector3(0.1f, 0.1f, 0.1f); // Dark grey
            shader.BasicEffect.FogStart   = 30;
            shader.BasicEffect.FogEnd     = 300;
        }