Example #1
0
 public virtual void Initialize(TerrainZone tz, int tileSize, int pageSize, bool asyncLoading,
                                TerrainZonePageSourceOptionList optionList)
 {
     this.mTerrainZone  = tz;
     this.mTileSize     = tileSize;
     this.mPageSize     = pageSize;
     this.mAsyncLoading = asyncLoading;
 }
Example #2
0
        public override PCZone CreatePCZone(PCZSceneManager pczsm, string zoneName)
        {
            //return new TerrainZone(pczsm, zoneName);
            var tz = new TerrainZone(pczsm, zoneName);
            // Create & register default sources (one per zone)
            var ps = new HeightmapTerrainZonePageSource();

            this.mTerrainZonePageSources.Add(ps);
            tz.registerPageSource("Heightmap", ps);
            return(tz);
        }
Example #3
0
        //-------------------------------------------------------------------------
        public override void Initialize(TerrainZone tsm, int tileSize, int pageSize, bool asyncLoading,
                                        TerrainZonePageSourceOptionList optionList)
        {
            // Shutdown to clear any previous data
            Shutdown();

            base.Initialize(tsm, tileSize, pageSize, asyncLoading, optionList);

            // Get source image

            bool imageFound = false;

            this.mIsRaw = false;
            bool rawSizeFound = false;
            bool rawBppFound  = false;

            foreach (var opt in optionList)
            {
                string key = opt.Key;
                key = key.Trim();
                if (key.StartsWith("HeightmapImage".ToLower(), StringComparison.InvariantCultureIgnoreCase))
                {
                    this.mSource = opt.Value;
                    imageFound   = true;
                    // is it a raw?
                    if (this.mSource.ToLowerInvariant().Trim().EndsWith("raw"))
                    {
                        this.mIsRaw = true;
                    }
                }
                else if (key.StartsWith("Heightmap.raw.size", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.mRawSize = Convert.ToInt32(opt.Value);
                    rawSizeFound  = true;
                }
                else if (key.StartsWith("Heightmap.raw.bpp", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.mRawBpp = Convert.ToByte(opt.Value);
                    if (this.mRawBpp < 1 || this.mRawBpp > 2)
                    {
                        throw new AxiomException(
                                  "Invalid value for 'Heightmap.raw.bpp', must be 1 or 2. HeightmapTerrainZonePageSource.Initialise");
                    }
                    rawBppFound = true;
                }
                else if (key.StartsWith("Heightmap.flip", StringComparison.InvariantCultureIgnoreCase))
                {
                    this.mFlipTerrainZone = Convert.ToBoolean(opt.Value);
                }
                else
                {
                    LogManager.Instance.Write("Warning: ignoring unknown Heightmap option '" + key + "'");
                }
            }
            if (!imageFound)
            {
                throw new AxiomException("Missing option 'HeightmapImage'. HeightmapTerrainZonePageSource.Initialise");
            }
            if (this.mIsRaw && (!rawSizeFound || !rawBppFound))
            {
                throw new AxiomException(
                          "Options 'Heightmap.raw.size' and 'Heightmap.raw.bpp' must be specified for RAW heightmap sources. HeightmapTerrainZonePageSource.Initialise");
            }
            // Load it!
            LoadHeightmap();
        }