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; }
public virtual void Initialize( TerrainZone tz, int tileSize, int pageSize, bool asyncLoading, TerrainZonePageSourceOptionList optionList ) { mTerrainZone = tz; mTileSize = tileSize; mPageSize = pageSize; mAsyncLoading = asyncLoading; }
//------------------------------------------------------------------------- public void SelectPageSource(string typeName, TerrainZonePageSourceOptionList optionList) { if (!this.mPageSources.ContainsKey(typeName)) { throw new AxiomException("Cannot locate a TerrainZonePageSource for type " + typeName + ". SelectPageSource"); } if (null != this.mActivePageSource) { this.mActivePageSource.Shutdown(); } this.mActivePageSource = this.mPageSources[typeName]; this.mActivePageSource.Initialize(this, Options.tileSize, Options.pageSize, this.mPagingEnabled, optionList); LogManager.Instance.Write("TerrainZone: Activated PageSource " + typeName); }
//------------------------------------------------------------------------- private void LoadConfig(Stream stream) { /* Set up the options */ var config = new ConfigFile("TerrainConfig"); string val; config.Load(stream); val = config.getSetting("DetailTile"); if (!string.IsNullOrEmpty(val)) { setDetailTextureRepeat(Convert.ToInt32(val)); } val = config.getSetting("MaxMipMapLevel"); if (!string.IsNullOrEmpty(val)) { setMaxGeoMipMapLevel(Convert.ToInt32(val)); } val = config.getSetting("PageSize"); if (!string.IsNullOrEmpty(val)) { setPageSize(Convert.ToInt32(val)); } else { throw new AxiomException("Missing option 'PageSize'. LoadConfig"); } val = config.getSetting("TileSize"); if (!string.IsNullOrEmpty(val)) { setTileSize(Convert.ToInt32(val)); } else { throw new AxiomException("Missing option 'TileSize'. LoadConfig"); } Vector3 v = Vector3.UnitScale; val = config.getSetting("PageWorldX"); if (!string.IsNullOrEmpty(val)) { v.x = (float)Convert.ToDouble(val); } val = config.getSetting("MaxHeight"); if (!string.IsNullOrEmpty(val)) { v.y = (float)Convert.ToDouble(val); } val = config.getSetting("PageWorldZ"); if (!string.IsNullOrEmpty(val)) { v.z = (float)Convert.ToDouble(val); } // Scale x/z relative to pagesize v.x /= Options.pageSize - 1; v.z /= Options.pageSize - 1; setScale(v); val = config.getSetting("MaxPixelError"); if (!string.IsNullOrEmpty(val)) { setMaxPixelError(Convert.ToInt32(val)); } this.mDetailTextureName = config.getSetting("DetailTexture"); this.mWorldTextureName = config.getSetting("WorldTexture"); if (config.getSetting("VertexColours") == "yes") { Options.coloured = true; } if (config.getSetting("VertexNormals") == "yes") { Options.lit = true; } if (config.getSetting("UseTriStrips") == "yes") { SetUseTriStrips(true); } if (config.getSetting("VertexProgramMorph") == "yes") { SetUseLODMorph(true); } val = config.getSetting("LODMorphStart"); if (!string.IsNullOrEmpty(val)) { setLODMorphStart((float)Convert.ToDouble(val)); } val = config.getSetting("MaterialName"); if (!string.IsNullOrEmpty(val)) { setCustomMaterial(val); } val = config.getSetting("MorphLODFactorParamName"); if (!string.IsNullOrEmpty(val)) { setCustomMaterialMorphFactorParam(val); } val = config.getSetting("MorphLODFactorParamIndex"); if (!string.IsNullOrEmpty(val)) { setCustomMaterialMorphFactorParam(Convert.ToInt32(val)); } // Now scan through the remaining settings, looking for any PageSource // prefixed items string pageSourceName = config.getSetting("PageSource"); if (pageSourceName == "") { throw new AxiomException("Missing option 'PageSource'. LoadConfig"); } var optlist = new TerrainZonePageSourceOptionList(); foreach (string[] s in config.GetEnumerator()) { string name = s[0]; string value = s[1]; if (name != pageSourceName) { optlist.Add(name, value); } } // set the page source SelectPageSource(pageSourceName, optlist); }
//------------------------------------------------------------------------- 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(); }
//------------------------------------------------------------------------- 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(); }