예제 #1
0
        //-------------------------------------------------------------------------
        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);
        }