- Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathRuntimeLASConvert.cs
More file actions
Latest commit
75 lines (59 loc) · 2.39 KB
/
Copy pathRuntimeLASConvert.cs
File metadata and controls
75 lines (59 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// example script to convert LAS/LAZ file at runtime and then read it in regular viewer (as .ucpc format)
usingSystem.Diagnostics;
usingSystem.IO;
usingunitycodercom_PointCloudBinaryViewer;
usingUnityEngine;
usingDebug=UnityEngine.Debug;
namespaceunitycoder_examples
{
publicclassRuntimeLASConvert:MonoBehaviour
{
publicPointCloudViewerDX11binaryViewerDX11;
publicstringlasFile="runtime.las";
// inside streaming assets
stringcommandlinePath="PointCloudConverter173b/PointCloudConverter.exe";
boolisConverting=false;
voidStart()
{
isConverting=true;
varsourceFile=lasFile;
// check if full path or relative to streaming assets
if(Path.IsPathRooted(sourceFile)==false)
{
sourceFile=Path.Combine(Application.streamingAssetsPath,sourceFile);
}
if(File.Exists(sourceFile))
{
Debug.Log("Converting file: "+sourceFile);
}
else
{
Debug.LogError("Input file missing: "+sourceFile);
return;
}
varoutputPath=Path.GetDirectoryName(sourceFile);
outputPath=Path.Combine(outputPath,"runtime.ucpc");
// start commandline tool with params https://github.com/unitycoder/UnityPointCloudViewer/wiki/Commandline-Tools
varexePath=Path.Combine(Application.streamingAssetsPath,commandlinePath);
ProcessStartInfostartInfo=newProcessStartInfo(exePath);
startInfo.Arguments="-input="+sourceFile+" -flip=true -output="+outputPath;
startInfo.UseShellExecute=true;
startInfo.WindowStyle=ProcessWindowStyle.Hidden;
//startInfo.WindowStyle = ProcessWindowStyle.Minimized;
varprocess=Process.Start(startInfo);
process.WaitForExit();
//Debug.Log(startInfo.Arguments);
isConverting=false;
// check if output exists
if(File.Exists(outputPath))
{
Debug.Log("Reading output file: "+outputPath);
binaryViewerDX11.CallReadPointCloudThreaded(outputPath);
}
else
{
Debug.LogError("File not found: "+outputPath);
}
}
}
}