public DecalElement(List <string> imageNames, float timePerFrame,
                     float posX, float posZ, float sizeX, float sizeZ, float rot,
                     float lifetime, float deleteRadius, int priority, TerrainDecalManager manager)
     : this(timePerFrame, posX, posZ, sizeX, sizeZ, rot, lifetime, deleteRadius, priority, manager)
 {
     this.imageNames = imageNames;
 }
 public DecalElement(string imageName, float posX, float posZ, float sizeX, float sizeZ, float rot,
                     float lifetime, float deleteRadius, int priority, TerrainDecalManager manager)
     : this(0, posX, posZ, sizeX, sizeZ, rot, lifetime, deleteRadius, priority, manager)
 {
     imageNames = new List <string>();
     imageNames.Add(imageName);
 }
        private DecalElement(float timePerFrame,
                             float posX, float posZ, float sizeX, float sizeZ, float rot,
                             float lifetime, float deleteRadius, int priority, TerrainDecalManager manager)
        {
            this.timePerFrame = timePerFrame;
            this.posX         = posX;
            this.posZ         = posZ;
            this.sizeX        = sizeX;
            this.sizeZ        = sizeZ;
            this.rot          = rot;
            this.lifetime     = lifetime;
            this.deleteRadius = deleteRadius;
            this.priority     = priority;
            this.manager      = manager;

            lastUpdateTime = TerrainManager.Instance.Time;
        }
        public void Cleanup()
        {
            if ( initialized )
            {

                initialized = false;
                heightFieldsCreated = false;
                terrainDecalManager = null;
                cameraSet = false;

                if (pages != null)
                {
                    foreach (Page p in pages)
                    {
                        FreeTerrainPage(p);
                    }

                    pages = null;
                }

                foreach (Boundary b in boundaries)
                {
                    b.Dispose();
                }
                boundaries = null;

                roads.Dispose();
                roads = null;

                worldRootSceneNode.Creator.DestroySceneNode("TerrainRoot");
                worldRootSceneNode.Creator.DestroySceneNode("OceanNode");

                detailVeg.Dispose();
                detailVeg = null;

            }
        }
        /// <summary>
        /// Initialize the world manager
        /// </summary>
        public void Initialize(SceneManager sceneManager, ITerrainGenerator gen, ILODSpec clientLodSpec, SceneNode root)
        {
            Debug.Assert(!initialized, "Attempt to initialize already initialized TerrainManager");
            scene = sceneManager;
            terrainGenerator = gen;
            terrainGenerator.TerrainChanged += TerrainGenerator_OnTerrainChanged;
            lodSpec = clientLodSpec ?? defaultLODSpec;

            pageSize = lodSpec.PageSize;
            visPageRadius = lodSpec.VisiblePageRadius;
            pageArraySize = (visPageRadius * 2) + 1;

            // Compute the size of a "subPage", which is the same as the smalles tile size.
            // We assume that the page containing the camera will have the smallest sized tiles.
            subPageSize = pageSize / TilesPerPage(0);

            minMetersPerSample = lodSpec.MetersPerSample(Vector3.Zero, 0, 0);
            maxMetersPerSample = lodSpec.MetersPerSample(Vector3.Zero, visPageRadius, visPageRadius * pageSize / subPageSize);

            rootSceneNode = root;
            worldRootSceneNode = rootSceneNode.CreateChildSceneNode("TerrainRoot");
            oceanSceneNode = rootSceneNode.CreateChildSceneNode("OceanNode");

            terrainMaterialConfig = new AutoSplatConfig();

            terrainDecalManager = new TerrainDecalManager(pageArraySize);

            shadowConfig = new ShadowConfig(scene);

            oceanConfig = new OceanConfig();
            oceanConfig.ConfigChange += OceanConfigChanged;
            ocean = new OceanPage(oceanConfig);

            oceanSceneNode.AttachObject(ocean);
            //ocean.ShowBoundingBox = true;
            showOcean = true;

            detailVeg = new DetailVeg(65, rootSceneNode);

            // allocate the page array
            pages = new Page[pageArraySize, pageArraySize];

            InitPages();

            heightFieldsCreated = false;

            boundaries = new List<Boundary>();
            roads = new Roads();

            SpeedTreeWrapper.SetDropToBillboard(true);

            // make sure variables based on camera location are up to date
            CameraLocation = cameraLocation;

            // set up material used by water boundaries
            waterMaterial = MaterialManager.Instance.GetByName("MVSMWater");
            if (waterMaterial != null)
                waterMaterial.Load();

            initialized = true;
        }