-
Notifications
You must be signed in to change notification settings - Fork 0
/
MarkerPositions.py
110 lines (88 loc) · 2.98 KB
/
MarkerPositions.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
"""
This script will query a single marker, the Marker 'E', for it's position.
Keys and their corresponding marker positions:
1 - Top left
2 - Top right
3 - Bottom left
4 - Bottom right
5 - Print in WEnvironment.py1 format
6 - Refresh (Delete) recorded positions
"""
import viz
import vizshape
from mocapInterface import mocapInterface
viz.setMultiSample(8)
viz.fov(60)
viz.go()
import vizact
from mocapInterface import mocapInterface
phaseSpaceIP = '192.168.1.230'
owlParamMarkerCount = 25
# Dir where textures and rb files are located
phaseSpaceFilePath = 'MocapResources/'
# Rb files in phaseSpaceFilePath
rigidFileNames_ridx = []
# Shapes defined in rigidbody._createVizNode()
# Look there to see what shapes are accepted, or add more shapes
rigidBodyShapes_ridx = ['sphere']
# Sizes must correspond to parameters for the vizshape in rigidBodyShapes_ridx
rigidBodySizes_ridx = [[.1]]
# Is the rigid body visible on startup?
rigidBodyToggleVisibility_ridx = [1]
#Phasespace mode. This is the profile number the server uses to load resources for our project
phaseSpaceMode = 1
# Start up the motion capture server
mocap = mocapInterface(phaseSpaceIP,phaseSpaceFilePath,owlParamMarkerCount,
rigidFileNames_ridx,rigidBodyShapes_ridx,rigidBodySizes_ridx,
rigidBodyToggleVisibility_ridx, 1)
strsEnv = []
strs3D = []
strsEnv.append([])
strsEnv.append([])
strsEnv.append([])
strsEnv.append([])
strs3D.append([])
strs3D.append([])
strs3D.append([])
strs3D.append([])
def refreshList():
global strs3D
global strsEnv
strsEnv = []
strs3D = []
print "cleared : ", len(strsEnv), len(strs3D)
def markerPos(key):
marker = mocap.getMarkerPosition(0,4)
if key == 1:
print "Top Left"
strsEnv[0] = "self.defaultTopLeft = [" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "]"
strs3D.append("upperLeft=(" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "),")
elif key == 2:
print "Top Right"
strsEnv[1] = "self.defaultTopRight = [" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "]"
strs3D.append("upperRight=(" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "),")
elif key == 3:
print "Bottom Left"
strsEnv[2] = "self.defaultBottomLeft = [" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "]"
strs3D.append("lowerLeft=(" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "),")
elif key == 4:
print "Bottom Right"
strsEnv[3] = "self.defaultBottomRight = [" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "]"
strs3D.append("lowerRight=(" + str(-marker[2]/1000) + ", 0.0, " + str(-marker[0]/1000) + "),")
elif key == 5:
print "For WEnv"
print strsEnv[0]
print strsEnv[1]
print strsEnv[2]
print strsEnv[3]
print "\nFor 3D"
print strs3D[0]
print strs3D[1]
print strs3D[2]
print strs3D[3]
vizact.onkeydown('1', markerPos, 1)
vizact.onkeydown('2', markerPos, 2)
vizact.onkeydown('3', markerPos, 3)
vizact.onkeydown('4', markerPos, 4)
vizact.onkeydown('5', markerPos, 5)
vizact.onkeydown('6', refreshList)