forked from Omnifinity/OpenVR-Tracking-Example
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmirror-coords.py
65 lines (51 loc) · 1.18 KB
/
mirror-coords.py
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
from vpython import *
import time
import threading
#scene.autoscale = False
print("\n")
hmd = vector(0,0,0)
left = vector(0,0,0)
right = vector(0,0,0)
devices = [hmd, left, right]
def process():
xyz = ['x','y','z']
global devices
while True:
try:
editIndex = -1;
nInput = input()
splits = nInput.split()
except Exception as e:
break
else:
pass
finally:
pass
for split in splits:
if "HMD" in split:
editIndex = 0;
if "LEFT:" in split:
editIndex = 1;
if "RIGHT:" in split:
editIndex = 2;
if editIndex < 0 or len(split) < 3 or split[1] != ':' or split[0] not in xyz:
continue
num = float(split[2:])
if split[0] == 'x':
devices[editIndex].z = -num;
elif split[0] == 'y':
devices[editIndex].y = num;
elif split[0] == 'z':
devices[editIndex].x = -num;
thread = threading.Thread(target=process)
thread.start()
b_hmd = box(color=color.magenta)
b_left = box(color=color.blue)
b_right = box(color=color.red)
b_white = box(color=color.white)
b_white.pos = vector(0,0,0)
while True:
b_hmd.pos = devices[0] * 2
b_left.pos = devices[1] * 2
b_right.pos = devices[2] * 2
b_left.rotate(angle=.001, axis=vector(0,1,0))