Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 73f77c9

Browse filesBrowse files
authored
Create RuntimeLASConvert.cs
1 parent 625d509 commit 73f77c9
Copy full SHA for 73f77c9

File tree

1 file changed

+75
-0
lines changed
Filter options

1 file changed

+75
-0
lines changed

‎Extras/Scripts/RuntimeLASConvert.cs

Copy file name to clipboard
+75Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// example script to convert LAS/LAZ file at runtime and then read it in regular viewer (as .ucpc format)
2+
3+
using System.Diagnostics;
4+
using System.IO;
5+
using unitycodercom_PointCloudBinaryViewer;
6+
using UnityEngine;
7+
using Debug = UnityEngine.Debug;
8+
9+
namespace unitycoder_examples
10+
{
11+
public class RuntimeLASConvert : MonoBehaviour
12+
{
13+
public PointCloudViewerDX11 binaryViewerDX11;
14+
15+
public string lasFile = "runtime.las";
16+
17+
// inside streaming assets
18+
string commandlinePath = "PointCloudConverter173b/PointCloudConverter.exe";
19+
20+
bool isConverting = false;
21+
22+
void Start()
23+
{
24+
isConverting = true;
25+
26+
var sourceFile = lasFile;
27+
28+
// check if full path or relative to streaming assets
29+
if (Path.IsPathRooted(sourceFile) == false)
30+
{
31+
sourceFile = Path.Combine(Application.streamingAssetsPath, sourceFile);
32+
}
33+
34+
if (File.Exists(sourceFile))
35+
{
36+
Debug.Log("Converting file: " + sourceFile);
37+
}
38+
else
39+
{
40+
Debug.LogError("Input file missing: " + sourceFile);
41+
return;
42+
}
43+
44+
var outputPath = Path.GetDirectoryName(sourceFile);
45+
outputPath = Path.Combine(outputPath, "runtime.ucpc");
46+
47+
48+
// start commandline tool with params https://github.com/unitycoder/UnityPointCloudViewer/wiki/Commandline-Tools
49+
var exePath = Path.Combine(Application.streamingAssetsPath, commandlinePath);
50+
ProcessStartInfo startInfo = new ProcessStartInfo(exePath);
51+
startInfo.Arguments = "-input=" + sourceFile + " -flip=true -output=" + outputPath;
52+
startInfo.UseShellExecute = true;
53+
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
54+
//startInfo.WindowStyle = ProcessWindowStyle.Minimized;
55+
var process = Process.Start(startInfo);
56+
process.WaitForExit();
57+
58+
//Debug.Log(startInfo.Arguments);
59+
60+
isConverting = false;
61+
62+
// check if output exists
63+
if (File.Exists(outputPath))
64+
{
65+
Debug.Log("Reading output file: " + outputPath);
66+
binaryViewerDX11.CallReadPointCloudThreaded(outputPath);
67+
}
68+
else
69+
{
70+
Debug.LogError("File not found: " + outputPath);
71+
}
72+
73+
}
74+
}
75+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.