private void LoadTerrain(string filename) { if (!File.Exists(filename)) { return; } XMLReader xmlReader = new XMLReader(); xmlReader.Open(filename); Editor.bDrawSkybox = Convert.ToBoolean(xmlReader.GetElementValue("drawskybox")); if (Editor.skybox == null) { Editor.skybox = new Skybox(); } Editor.skybox.LoadTextures(xmlReader.GetElementValue("skybox")); //Sun Settings Editor.bDrawSun = Convert.ToBoolean(xmlReader.GetElementValue("drawsun")); Editor.sun = new Sun(Convert.ToDouble(xmlReader.GetElementValue("angle")), Convert.ToDouble(xmlReader.GetElementValue("elevation"))); string[] sColor = xmlReader.GetElementValue("suncolor").Split(';'); Editor.sun.color = new Vector3((float)Convert.ToDouble(sColor[0]), (float)Convert.ToDouble(sColor[1]), (float)Convert.ToDouble(sColor[2])); Editor.sun.LongitudeSpeed = Convert.ToDouble(xmlReader.GetElementValue("longitudespeed")); Editor.sun.LatitudeSpeed = Convert.ToDouble(xmlReader.GetElementValue("latitudespeed")); Editor.sun.lightPower = (float)Convert.ToDouble(xmlReader.GetElementValue("intensity")); Editor.sun.bCheckTerrainCollision = Convert.ToBoolean(xmlReader.GetElementValue("sunraycollision")); //Fog Settings Editor.bUseFog = Convert.ToBoolean(xmlReader.GetElementValue("usefog")); string[] fColor = xmlReader.GetElementValue("fogcolor").Split(';'); Microsoft.Xna.Framework.Graphics.Color fogColor = new Microsoft.Xna.Framework.Graphics.Color(new Vector3((float)Convert.ToDouble(fColor[0]), (float)Convert.ToDouble(fColor[1]), (float)Convert.ToDouble(fColor[2]))); Console.WriteLine("FogColor: " + fogColor.ToString()); Editor.fogColor = fogColor; Editor.fogStart = (float)Convert.ToDouble(xmlReader.GetElementValue("fogstart")); Editor.fogEnd = (float)Convert.ToDouble(xmlReader.GetElementValue("fogend")); Editor.fogDensity = (float)Convert.ToDouble(xmlReader.GetElementValue("fogdensity")); Editor.InitFog(); //Heightmap if (xmlReader.GetElementValue("heightmap") != string.Empty) { string[] cSize = xmlReader.GetElementValue("cellsize").Split(';'); Editor.heightmap = new Heightmap(new Vector2((float)Convert.ToDouble(cSize[0]), (float)Convert.ToDouble(cSize[1]))); Editor.water = new Water(null, true); Editor.heightmap.LoadHeightMap(xmlReader.GetElementValue("heightmap")); Editor.heightmap.LoadColormap(xmlReader.GetElementValue("colormap")); Editor.heightmap.maxHeight = (float)Convert.ToDouble(xmlReader.GetElementValue("maxheight")); Editor.heightmap.bSmooth = Convert.ToBoolean(xmlReader.GetElementValue("smooth")); Editor.heightmap.bDrawDetail = Convert.ToBoolean(xmlReader.GetElementValue("drawdetail")); string[] aLight = xmlReader.GetElementValue("ambientlight").Split(';'); Editor.heightmap.ambientLight = new Vector3(); Editor.heightmap.ambientLight.X = (float)Convert.ToDouble(aLight[0]); Editor.heightmap.ambientLight.Y = (float)Convert.ToDouble(aLight[1]); Editor.heightmap.ambientLight.Z = (float)Convert.ToDouble(aLight[2]); //Texture Layers for (int i = 0; i < 4; i++) { Editor.heightmap.textureLayer[i].layerTex = xmlReader.GetElementValue("layer" + i + "tex"); Editor.heightmap.textureLayer[i].scale = (float)Convert.ToDouble(xmlReader.GetElementValue("layer" + i + "texScale")); } Editor.heightmap.Init(); } GetSkyboxes(); GetSunData(); GetHeightmapData(); }