private void LASReaderThread(string path, int pointskip, Action <Thread, Vector3[]> cb) { byte[] bytes = File.ReadAllBytes(path); LASHeader_1_2 header = LASHeaders.MarshalHeader(bytes, true); LASReaderThread(pointskip, cb, bytes, header); }
/// <summary> /// starts the conversion /// </summary> public void Convert() { for (int i = 0; i < _files.Length; i++) { byte[] bytes = File.ReadAllBytes(_files[i]); LASHeader_1_2 header = LASHeaders.MarshalHeader(bytes, true); if (!_merge) { Thread t = _pointReader.ReadLASPointsAsync(bytes, header); _separateQues.Add(t, new ConcurrentQueue <string>()); StartSeparateWriter(Path.Combine(_outputpath, _files[i].Split('/').Last() + ".pcache"), header, _pskip, t); } else { Thread t = _pointReader.ReadLASPointsAsync(bytes, header); _totalrecords += Mathf.FloorToInt((header.NumberOfPointRecords / (float)(1 + _pskip))); } } if (_merge) { StartMergeWriter(_totalrecords); } }
public void OnGUI() { scrollpos = EditorGUILayout.BeginScrollView(scrollpos); EditorGUILayout.LabelField("EXPERIMENTAL Editor to easily instantiate VFX Graphs from .las into the scene"); EditorGUILayout.LabelField("\n"); EditorGUILayout.LabelField(".las files in StreamingAssets:"); EditorGUILayout.PropertyField(filenamesprop, true); if (GUILayout.Button("Add file")) { string path = EditorUtility.OpenFilePanel("select .las file", "Assets/StreamingAssets", "las"); string[] filepath = path.Split('/'); filenames.Add(filepath[filepath.Length - 1]); } EditorGUILayout.LabelField("\n"); EditorGUILayout.LabelField("VisualEffect to be used:"); EditorGUILayout.LabelField("Requires two exposed properties in the graph"); EditorGUILayout.LabelField("1. _PositionMapArray (Texture2DArray)"); EditorGUILayout.LabelField("2. _Depth (int)"); EditorGUILayout.PropertyField(vfxgraphprop, true); EditorGUILayout.LabelField("\n"); EditorGUILayout.LabelField("Whether to merge all to one LASBinder or create separate"); EditorGUILayout.LabelField("(try to disable if precision of the graph becomes a problem)"); EditorGUILayout.PropertyField(mergeFilesprop, true); EditorGUILayout.LabelField("\n"); EditorGUILayout.LabelField("Amount of points to skip in between readings:"); EditorGUILayout.PropertyField(pointskipprop, true); EditorGUILayout.LabelField("\n"); EditorGUILayout.LabelField("Whether to center the first point to zero and use it as origin:"); EditorGUILayout.PropertyField(anchortofirstpointprop, true); pointskipprop.intValue = Mathf.Clamp(pointskipprop.intValue, 0, 10000); if (GUILayout.Button("Add to selected gameobject")) { byte[] bytes = File.ReadAllBytes(Path.Combine(Application.streamingAssetsPath, filenames[0])); LASHeader_1_2 firstfileheader = LASHeaders.MarshalHeader(bytes, true); anchor = LASPointReader.GetFirstPoint(bytes, firstfileheader); if (Selection.transforms != null && Selection.transforms.Length > 0) { parent = Selection.transforms[0]; } if (!mergefiles) { generated = 0; EditorApplication.update += FrameByFrameNewGraph; } else { NewGraph(filenames, parent, anchor); } } EditorGUILayout.LabelField("\n"); EditorGUILayout.EndScrollView(); so.ApplyModifiedProperties(); so.Update(); }