예제 #1
0
        /// <summary>
        /// Initializes the terrain materials and settings.
        /// </summary>
        public override bool init()
        {
            World world = World;
            TerrainEngine terr = world.Terrain;

            // Aor now, register a single ground material.
            MatGround = terr.RegisterMaterial("Ground");

            // Add the geometry for the terrain LoDs >= 9.
            int pipeline = MatGround.AddDefaultPipeline(9);
            MatGround.AddDefaultShadowAndZPre(pipeline);
            MatGround.AddMeshMaterial(pipeline, "Output", Resources.UseMaterial("::Terrain/GrassyMountains", HostScript.ModDomain), Renderer.Opaque.Mesh);

            // Add the geometry for the terrain LoDs 5-8. Add some tree impostors to make the ground look nicer.
            pipeline = MatGround.AddPipeline(Resources.UseGeometryPipeline("PineImpostorField", HostScript.ModDomain), "Input", 5, 8);
            MatGround.AddDefaultShadowAndZPre(pipeline, "Input");
            MatGround.AddMeshMaterial(pipeline, "Input", Resources.UseMaterial("::Terrain/GrassyMountains", HostScript.ModDomain), Renderer.Opaque.Mesh);
            MatGround.AddMeshMaterial(pipeline, "PineSpawns", Resources.UseMaterial("PineImpostor", HostScript.ModDomain), Renderer.Opaque.Mesh);

            // For terrain LoDs 0-4, spawn "real" tree models instead of the impostors.
            pipeline = MatGround.AddPipeline(Resources.UseGeometryPipeline("PineField", HostScript.ModDomain), "Input", 0, 4);
            MatGround.AddDefaultShadowAndZPre(pipeline, "Decimate");
            MatGround.AddMeshMaterial(pipeline, "Decimate", Resources.UseMaterial("::Terrain/GrassyMountains", HostScript.ModDomain), Renderer.Opaque.Mesh);
            MatGround.AddMeshMaterial(pipeline, "PineSpawns", Resources.UseMaterial("PineLeaves", HostScript.ModDomain), Renderer.Opaque.Mesh);
            MatGround.AddMeshMaterial(pipeline, "PineSpawns", Resources.UseMaterial("::Shadow", HostScript.ModDomain), Renderer.Shadow.Mesh);

            return base.init();
        }