예제 #1
0
        public void OnChunkRemove(Terrain.TerrainChunkNode chunk, EventArgs e)
        {
            if (chunk.HasController(typeof(GrassPopulator)))
            {
                GrassPopulator grass = (GrassPopulator)chunk.GetController(typeof(GrassPopulator));
                grass.Destroy();
                grass = null;
            }
            if (chunk.HasController(typeof(RockPopulator)))
            {
                RockPopulator rock = (RockPopulator)chunk.GetController(typeof(RockPopulator));
                rock.Destroy();
                rock = null;
            }

            if (chunk.HasController(typeof(TreePopulator)))
            {
                TreePopulator tree = (TreePopulator)chunk.GetController(typeof(TreePopulator));
                tree.Destroy();
                tree = null;
            }
        }
예제 #2
0
        public void OnChunkAdd(Terrain.TerrainChunkNode chunk, EventArgs e)
        {
            if (!chunk.HasController(typeof(GrassPopulator)))
            {
                GrassPopulator grass;
                chunk.AddController(grass = new GrassPopulator(PhysicsWorld, cam));
                grass.GenPatches(chunk, 5, 12);
            }
            if (!chunk.HasController(typeof(RockPopulator)))
            {
                RockPopulator rock;
                chunk.AddController(rock = new RockPopulator(PhysicsWorld, cam));
                rock.GenPatches(chunk, 3, 3);
            }
            if (!chunk.HasController(typeof(TreePopulator)))
            {
                TreePopulator tree;
                chunk.AddController(tree = new TreePopulator(PhysicsWorld, cam));
                tree.GenPatches(chunk, 2, 2);
            }

            /*
            for (int i = 0; i < chunk.hm.heights.Length; i++)
            {
                chunk.hm.heights[i] = 0f;
            }
            chunk.hm.RebuildTerrainMesh();*/
        }