/* Loads the metadata from the json-file in the given cloudpath */ /// <summary> /// Loads the meta data from the json-file in the given cloudpath. Attributes "cloudPath", and "cloudName" are set as well. /// </summary> /// <param name="cloudPath">Folderpath of the cloud</param> /// <param name="moveToOrigin">True, if the center of the cloud should be moved to the origin</param> public static PointCloudMetaData LoadMetaData(string cloudPath, bool moveToOrigin = false) { string jsonfile; if (cloudPath.Contains("http")) { using (var webClient = new System.Net.WebClient()) { jsonfile = webClient.DownloadString(cloudPath); } } else { using (StreamReader reader = new StreamReader(cloudPath + "cloud.js", Encoding.Default)) { jsonfile = reader.ReadToEnd(); reader.Close(); } } string cleanCloudPath = cloudPath; if (cleanCloudPath.Contains("cloud.js")) { cleanCloudPath = cleanCloudPath.Replace("cloud.js", ""); } PointCloudMetaData metaData = PointCloudMetaData.ReadFromJson(jsonfile, moveToOrigin); metaData.cloudPath = cleanCloudPath; metaData.cloudName = cleanCloudPath.Substring(0, cleanCloudPath.Length - 1).Substring(cleanCloudPath.Substring(0, cleanCloudPath.Length - 1).LastIndexOf("/") + 1); return(metaData); }
// === FUNCTIONS === // Load PointCloud until level 5 and add to parentObject public IEnumerator LoadPointCloud(string cloudPath, GameObject parentObject, int level = 4, int pointRadius = 5) { meshConfiguration = new PointMeshConfiguration(parentObject, level, pointRadius); listNodes = new List <PotreeNode>(); // point cloud metadata pointCloudMetaData = new PointCloudMetaData(); string jsonfile; using (StreamReader reader = new StreamReader(new FileStream(cloudPath + "/cloud.js", FileMode.Open, FileAccess.Read, FileShare.Read))) { jsonfile = reader.ReadToEnd(); reader.Dispose(); } PointCloudMetaData metaData = PointCloudMetaData.ReadFromJson(jsonfile, meshConfiguration.moveToOrigin); metaData.cloudPath = cloudPath; metaData.cloudName = cloudPath.Substring(0, cloudPath.Length - 1).Substring(cloudPath.Substring(0, cloudPath.Length - 1).LastIndexOf("/") + 1); // root node string dataRPath = metaData.cloudPath + metaData.octreeDir + "/r/"; PotreeNode rootNode = new PotreeNode("", metaData, metaData.boundingBox, null); // load hierarchy LoadHierarchy(dataRPath, metaData, rootNode); // load pointcloud data //LoadAllPoints(dataRPath, metaData, rootNode); GetListNodes(dataRPath, metaData, rootNode); // now load data for nodes float startTime = DateTime.Now.Millisecond; foreach (PotreeNode node in listNodes) { LoadPoints(dataRPath, metaData, node); //Debug.Log(DateTime.Now.Millisecond); if (DateTime.Now.Millisecond - startTime > 100.0f) { //Debug.Log("resume display"); startTime = DateTime.Now.Millisecond; yield return(null); } } listNodes.Clear(); // create gameobjects rootNode.CreateAllGameObjects(meshConfiguration); yield return(null); }
/* Loads the metadata from the json-file in the given cloudpath */ /// <summary> /// Loads the meta data from the json-file in the given cloudpath. Attributes "cloudPath", and "cloudName" are set as well. /// </summary> /// <param name="cloudPath">Folderpath of the cloud</param> /// <param name="moveToOrigin">True, if the center of the cloud should be moved to the origin</param> public static PointCloudMetaData LoadMetaData(string cloudPath, bool moveToOrigin = false) { string jsonfile; using (StreamReader reader = new StreamReader(cloudPath + "cloud.js", Encoding.Default)) { jsonfile = reader.ReadToEnd(); reader.Close(); } PointCloudMetaData metaData = PointCloudMetaData.ReadFromJson(jsonfile, moveToOrigin); metaData.cloudPath = cloudPath; metaData.cloudName = cloudPath.Substring(0, cloudPath.Length - 1).Substring(cloudPath.Substring(0, cloudPath.Length - 1).LastIndexOf("\\") + 1); return(metaData); }