public void LoadCloudData(CloudData cloud_data, string file_path = null, bool isJSON = false, bool isSMAP = false) { int N = cloud_data.columnData[0].Length; // Init lists int[] _indices = new int[N]; Vector3[] _positions = new Vector3[N]; float[] _intensity = new float[N]; float[] _time = new float[N]; float[] _trajectory = new float[N]; float[] _hidden = new float[N]; Color[] _colors = new Color[N]; float[] _phi = new float[N]; float[] _theta = new float[N]; List <Vector2> uv1List = new List <Vector2>(); List <Vector2> uv2List = new List <Vector2>(); List <Vector2> uv3List = new List <Vector2>(); Vector3[] _normed_positions = new Vector3[N]; //// Set default min max value float xMax = Mathf.NegativeInfinity; float xMin = Mathf.Infinity; float yMax = Mathf.NegativeInfinity; float yMin = Mathf.Infinity; float zMax = Mathf.NegativeInfinity; float zMin = Mathf.Infinity; float iMax = Mathf.NegativeInfinity; float iMin = Mathf.Infinity; float tMax = Mathf.NegativeInfinity; float tMin = Mathf.Infinity; HashSet <float> TimeSet = new HashSet <float>(); List <float> TimeList = new List <float>(); for (int i = 0; i < N; i++) { _positions[i] = new Vector3(cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[0]][i], cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[1]][i], cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[2]][i]); //Debug.Log("Position "+i+" : "+_positions[i]); _trajectory[i] = cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[5]][i]; _time[i] = cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[4]][i]; _phi[i] = cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[6]][i]; _theta[i] = cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[7]][i]; if (isSMAP == true) { _hidden[i] = cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[8]][i]; } //Debug.Log("Frame " + i + " : " + _frame[i]); _intensity[i] = cloud_data.columnData[cloud_data.globalMetaData.displayCollumnsConfiguration[3]][i]; //Debug.Log("Intensity " + i + " : " + _intensity[i]); _indices[i] = i; //Debug.Log(_indices[i]); // Update min max if (xMax < _positions[i].x) { xMax = _positions[i].x; } if (xMin > _positions[i].x) { xMin = _positions[i].x; } if (yMax < _positions[i].y) { yMax = _positions[i].y; } if (yMin > _positions[i].y) { yMin = _positions[i].y; } if (zMax < _positions[i].z) { zMax = _positions[i].z; } if (zMin > _positions[i].z) { zMin = _positions[i].z; } if (iMax < _intensity[i]) { iMax = _intensity[i]; } if (iMin > _intensity[i]) { iMin = _intensity[i]; } if (tMax < _time[i]) { tMax = _time[i]; } if (tMin > _time[i]) { tMin = _time[i]; } bool check = false; TimeSet.Add(_time[i]); } foreach (float f in TimeSet) { TimeList.Add(f); } TimeList.Sort(); Dictionary <float, int> FrameDict = new Dictionary <float, int>(); for (int u = 0; u < TimeList.Count; u++) { FrameDict.Add(TimeList[u], u); } float xRange = xMax - xMin; float yRange = yMax - yMin; float zRange = zMax - zMin; float iRange = iMax - iMin; float tRange = tMax - tMin; float[] rangeList = new float[] { xRange, yRange, zRange }; float MaxRange = Mathf.Max(rangeList); Vector3 offsetVector = new Vector3((xMin + xMax) / 2, (yMin + yMax) / 2, (zMin + zMax) / 2); float normedxMax = Mathf.NegativeInfinity; float normedxMin = Mathf.Infinity; float normedyMax = Mathf.NegativeInfinity; float normedyMin = Mathf.Infinity; float normedzMax = Mathf.NegativeInfinity; float normedzMin = Mathf.Infinity; foreach (int point in _indices) { _normed_positions[point] = ((_positions[point] - offsetVector) / MaxRange); _colors[point] = new Color(((_intensity[point] - iMin) / (iMax - iMin)), ((_intensity[point] - iMin) / iMax - iMin), ((_intensity[point] - iMin) / iMax - iMin), 1); cloud_data.pointDataTable[point].position = _positions[point]; cloud_data.pointDataTable[point].normed_position = _normed_positions[point]; cloud_data.pointDataTable[point].intensity = _intensity[point]; cloud_data.pointDataTable[point].time = _time[point]; cloud_data.pointDataTable[point].frame = FrameDict[_time[point]]; cloud_data.pointDataTable[point].trajectory = _trajectory[point]; cloud_data.pointDataTable[point].phi_angle = _phi[point]; cloud_data.pointDataTable[point].theta_angle = _theta[point]; //Vincent Casamayou 15/05/2020 - SMAP COMMUNICATION //Hide point at creation if (_hidden[point] != 0f) { cloud_data.pointMetaDataTable[point].isHidden = true; } //cloud_data.pointDataTable[point].color = _colors[point]; cloud_data.pointDataTable[point]._color_index = _colors[point].r; uv1List.Add(new Vector2(cloud_data.pointDataTable[point]._color_index, point)); //uv3List.Add(new Vector2(cloud_data.pointDataTable[point].trajectory, cloud_data.pointDataTable[point].time)); cloud_data.pointDataTable[point].depth = _positions[point].z; float selected = 0f; float hidden = 0f; if (cloud_data.pointMetaDataTable[point].isSelected) { selected = 1f; } if (cloud_data.pointMetaDataTable[point].isHidden) { hidden = 1f; } uv2List.Add(new Vector2(selected, hidden)); uv3List.Add(new Vector2(cloud_data.pointDataTable[point].trajectory, cloud_data.pointDataTable[point].frame)); if (normedxMax < _normed_positions[point].x) { normedxMax = _normed_positions[point].x; } if (normedxMin > _normed_positions[point].x) { normedxMin = _normed_positions[point].x; } if (normedyMax < _normed_positions[point].y) { normedyMax = _normed_positions[point].y; } if (normedyMin > _normed_positions[point].y) { normedyMin = _normed_positions[point].y; } if (normedzMax < _normed_positions[point].z) { normedzMax = _normed_positions[point].z; } if (normedzMin > _normed_positions[point].z) { normedzMin = _normed_positions[point].z; } } cloud_data.globalMetaData.maxRange = MaxRange; cloud_data.globalMetaData.offsetVector = offsetVector; cloud_data.globalMetaData.normed_xMax = normedxMax; cloud_data.globalMetaData.normed_xMin = normedxMin; cloud_data.globalMetaData.normed_yMax = normedyMax; cloud_data.globalMetaData.normed_yMin = normedyMin; cloud_data.globalMetaData.normed_zMax = normedzMax; cloud_data.globalMetaData.normed_zMin = normedzMin; cloud_data.globalMetaData.timeList = TimeList; cloud_data.globalMetaData.lowerframeLimit = -1f; cloud_data.globalMetaData.upperframeLimit = TimeList.Count; if (file_path == null) { cloud_data.globalMetaData.fileName = "Cloud - " + N + " points"; } else { cloud_data.globalMetaData.fileName = "" + Path.GetFileName(file_path) + " - " + N + " points"; } cloud_data.globalMetaData.box_scale = new Vector3(xRange, yRange, zRange) / MaxRange; //Create the global metadata for the cloud if (!isJSON) { cloud_data.globalMetaData.colormapName = "autumn"; cloud_data.globalMetaData.colormapReversed = false; cloud_data.globalMetaData.point_size = 0.1f; cloud_data.globalMetaData.scale = Vector3.one; } cloud_data.InitGlobalCloudConstant(xMax, xMin, yMax, yMin, zMax, zMin, iMax, iMin, tMax, tMin); LoadCloudMesh(cloud_data, _normed_positions, _indices, uv1List.ToArray(), uv2List.ToArray(), uv3List.ToArray()); }