This repository was archived by the owner on Aug 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
82 lines (65 loc) · 2.42 KB
/
main.py
File metadata and controls
82 lines (65 loc) · 2.42 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
76
77
78
79
80
81
82
import vault
from ctypes import c_int, c_float
import os
import platform
from os.path import dirname, basename, abspath
from sys import exit
from PIL import Image
from sys import argv
# Load the SDK and fetch symbols
SDKPath = abspath("./vaultSDK")
vault.LoadVaultSDK(SDKPath)
vaultSDK = vault.vaultSDK
modelFile = abspath("../../samplefiles/DirCube.uds")
outFile = abspath("./tmp.png")
appName = "PythonSample"
serverPath = "https://earth.vault.euclideon.com"
userName = "Username"
userPass = "Password"
width = 1280
height = 720
#array of 32 bit ARGB pixels:
colourBuffer = (c_int * width * height)()
#float depths, z' is normalized between 0 and 1
depthBuffer = (c_float * width * height)()
#the camera matrix using left handed GL convention (i.e. last row is translation)
cameraMatrix = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, -5, 0, 1]
if __name__ == "__main__":
if len(argv) >= 3:
userName = argv[1]
userPass = argv[2]
if len(argv) >= 4:
modelFile = abspath(argv[3])
# Do the thing
vaultContext = vault.vdkContext()
vaultRenderer = vault.vdkRenderContext()
vaultRenderView = vault.vdkRenderView()
vaultModel = vault.vdkPointCloud()
try:
#initialize
vaultContext.Connect(serverPath, appName, userName, userPass)
vaultContext.RequestLicense(vault.vdkLicenseType.Render)
vaultRenderer.Create(vaultContext)
vaultRenderView.Create(vaultContext, vaultRenderer, width, height)
vaultModel.Load(vaultContext, modelFile)
vaultRenderView.SetTargets(colourBuffer, 0, depthBuffer)
vaultRenderView.SetMatrix(vault.vdkRenderViewMatrix.Camera, cameraMatrix)
renderInstance = vault.vdkRenderInstance()
renderInstance.pPointCloud = vaultModel.pPointCloud
renderInstance.matrix = vaultModel.header.storedMatrix
renderInstances = (vault.vdkRenderInstance *1 )()
renderInstances[0] = renderInstance
for x in range(10):
vaultRenderer.Render(vaultRenderView, renderInstances)
Image.frombuffer("RGBA", (width, height), colourBuffer, "raw", "RGBA", 0, 1).save(outFile)
print("{0} written to the build directory.\nPress enter to exit.\n".format(basename(outFile)))
# Exit gracefully
vaultModel.Unload()
vaultRenderView.Destroy()
vaultRenderer.Destroy()
vaultContext.Disconnect()
except vault.VdkException as err:
err.printout()