private IEnumerator loadScene(string osmFileName, HeightmapContinent continent, MapProvider provider) { scene = new Scene(); Alert alert = new Alert(); alert.openAlertDialog("Loading project might take a couple of minute. Please wait..."); yield return(new WaitForSeconds(0.2f)); scene.initializeScene(osmFileName, continent, provider); alert.closeAlertDialog(); this.gameObject.SetActive(false); yield return(true); }
//Constructor create heightmap object public HeightmapLoader(BBox bbox, HeightmapContinent _continent) { if (!Directory.Exists(Path.Combine(Application.persistentDataPath, "HeightmapFiles/"))) { Directory.CreateDirectory(Path.Combine(Application.persistentDataPath, "HeightmapFiles/")); } heightmap = new short[1201, 1201]; continent = _continent; if ((Math.Floor(bbox.left) != Math.Floor(bbox.right)) || (Math.Floor(bbox.bottom) != Math.Floor(bbox.top))) { Debug.Log("<color=red>HEIGHTMAP ERROR:</color> Specified area requires multiple heightmap files!"); return; } string filename = ""; if (Math.Floor(bbox.bottom) >= 0.0f) { filename = filename + "N" + Math.Floor(bbox.bottom).ToString("00"); } else { filename = filename + "S" + Math.Abs(Math.Floor(bbox.bottom)).ToString("00"); } if (Math.Floor(bbox.left) >= 0.0f) { filename = filename + "E" + Math.Floor(bbox.left).ToString("000"); } else { filename = filename + "W" + Math.Abs(Math.Floor(bbox.left)).ToString("000"); } string savedFilename = filename + ".hgt"; filename = filename + ".hgt.zip"; Debug.Log("<color=blue>HEIGHTMAP</color> Filename: " + filename); string fullURL = baseURL + continent.ToString("G") + "/" + filename; string savePath = Path.Combine(Application.persistentDataPath, "HeightmapFiles/" + filename); FileDownloader.downloadfromURL(fullURL, savePath); Debug.Log("<color=blue>HEIGHTMAP</color> Download Complete!!"); string extractPath = Path.Combine(Application.persistentDataPath, "HeightmapFiles"); if (!File.Exists(extractPath)) { UniZip.Unzip(savePath, extractPath); } Debug.Log("<color=blue>HEIGHTMAP</color> Filemap Uncompress Complete!!"); fillHeightmap(extractPath + "/" + savedFilename); Debug.Log("<color=blue>HEIGHTMAP</color> Filemap Loading Complete!!"); }
private IEnumerator loadScene(string osmFileName,HeightmapContinent continent, MapProvider provider) { scene = new Scene(); Alert alert = new Alert(); alert.openAlertDialog("Loading project might take a couple of minute. Please wait..."); yield return new WaitForSeconds(0.2f); scene.initializeScene(osmFileName, continent, provider); alert.closeAlertDialog(); this.gameObject.SetActive(false); yield return true; }
/// <summary> /// Constructs the scene from given parameters /// </summary> /// <param name="OSMfilename">Full path of OSM file</param> /// <param name="continent">Specify Continent to download correct Heightmap from Nasa Srtm Data</param> /// <param name="provider">Choose mapProvider to select Texture of Terrain</param> public void initializeScene(string OSMfilename, HeightmapContinent _continent, MapProvider _provider) { string[] subStr = OSMfilename.Split(new char[] { '/', '\\' }); sceneName = subStr[subStr.Length - 1]; OSMPath = OSMfilename; continent = _continent; provider = _provider; List <Way> WayListforHighway = new List <Way>(); List <Way> WayListforBuilding = new List <Way>(); InitialConfigLoader configloader = new InitialConfigLoader(); var stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); OSMparser parser = new OSMparser(); scenebbox = parser.readBBox(OSMfilename); scenebbox = editbbox(scenebbox); config = configloader.loadInitialConfig(); HeightmapLoader heightMap = new HeightmapLoader(scenebbox, continent); terrain = new myTerrain(heightMap, scenebbox, OSMfilename, provider); stopwatch.Stop(); Debug.Log("<color=blue>TERRAIN RENDER TIME:</color>" + stopwatch.ElapsedMilliseconds); stopwatch.Reset(); stopwatch.Start(); osmxml = parser.parseOSM(OSMfilename); assignNodePositions(); stopwatch.Stop(); Debug.Log("<color=blue>OSM PARSING TIME:</color>" + stopwatch.ElapsedMilliseconds); stopwatch.Reset(); stopwatch.Start(); defaultObject3DList = DefaultObject3DHandler.drawDefaultObjects(osmxml.defaultobject3DList); stopwatch.Stop(); Debug.Log("<color=blue>3D OBJECT RENDER TIME:</color>" + stopwatch.ElapsedMilliseconds); stopwatch.Reset(); stopwatch.Start(); for (int k = 0; k < osmxml.wayList.Count; k++) { Way w = osmxml.wayList[k]; switch (w.type) { case ItemEnumerator.wayType.building: WayListforBuilding.Add(w); break; case ItemEnumerator.wayType.highway: WayListforHighway.Add(w); break; case ItemEnumerator.wayType.area: break; case ItemEnumerator.wayType.barrier: barrierList.Add(new Barrier(w, config.barrierConfig)); break; case ItemEnumerator.wayType.river: highwayList.Add(new Highway(w, config.highwayConfig, terrain)); break; case ItemEnumerator.wayType.none: break; } } stopwatch.Stop(); Debug.Log("<color=blue>ITEM ENUMERATING TIME:</color>" + stopwatch.ElapsedMilliseconds); stopwatch.Reset(); stopwatch.Start(); highwayModeller = new HighwayModeller(WayListforHighway, terrain, config.highwayConfig); highwayModeller.renderHighwayList(); highwayModeller.renderPavementList(); highwayList = highwayModeller.highwayList; pavementList = highwayModeller.pavementList; stopwatch.Stop(); Debug.Log("<color=blue>HIGHWAY RENDERING TIME:</color>" + stopwatch.ElapsedMilliseconds); stopwatch.Reset(); stopwatch.Start(); BuildingListModeller buildingListModeller = new BuildingListModeller(WayListforBuilding, osmxml.buildingRelations, config.buildingConfig); buildingListModeller.renderBuildingList(); buildingList = buildingListModeller.buildingList; stopwatch.Stop(); Debug.Log("<color=blue>BUILDING RENDERING TIME:</color>" + stopwatch.ElapsedMilliseconds); Debug.Log("<color=red>Scene Info:</color> BuildingCount:" + buildingList.Count.ToString() + " HighwayCount:" + highwayList.Count); }