-
Notifications
You must be signed in to change notification settings - Fork 0
/
vizconnectDK2.py
267 lines (195 loc) · 7.07 KB
/
vizconnectDK2.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
"""
This module was generated by Vizconnect.
Version: 1.05
Generated on: 2016-02-23 14:02:47.932000
"""
import viz
import vizconnect
#################################
# Parent configuration, if any
#################################
def getParentConfiguration():
#VC: set the parent configuration
_parent = ''
#VC: return the parent configuration
return _parent
#################################
# Pre viz.go() Code
#################################
def preVizGo():
return True
#################################
# Pre-initialization Code
#################################
def preInit():
"""Add any code here which should be called after viz.go but before any initializations happen.
Returned values can be obtained by calling getPreInitResult for this file's vizconnect.Configuration instance."""
return None
#################################
# Group Code
#################################
def initGroups(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawGroup = vizconnect.getRawGroupDict()
#VC: return values can be modified here
return None
#################################
# Display Code
#################################
def initDisplays(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawDisplay = vizconnect.getRawDisplayDict()
#VC: initialize a new display
_name = 'dk2'
if vizconnect.isPendingInit('display', _name, initFlag, initList):
#VC: init the raw object
if initFlag&vizconnect.INIT_RAW:
#VC: set the window for the display
_window = viz.MainWindow
#VC: set some parameters
autoDetectMonitor = True
#VC: create the raw object
import oculus
try:
display = oculus.Rift(window=_window, autoDetectMonitor=autoDetectMonitor)
_window.displayNode = display
except AttributeError:
_window.displayNode = None
rawDisplay[_name] = _window
#VC: init the wrapper (DO NOT EDIT)
if initFlag&vizconnect.INIT_WRAPPERS:
vizconnect.addDisplay(rawDisplay[_name], _name, make='Oculus VR', model='DK2')
#VC: set the parent of the node
if initFlag&vizconnect.INIT_PARENTS:
vizconnect.getDisplay(_name).setParent(vizconnect.getTracker('dk2'))
#VC: return values can be modified here
return None
#################################
# Tracker Code
#################################
def initTrackers(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawTracker = vizconnect.getRawTrackerDict()
#VC: initialize a new tracker
_name = 'dk2'
if vizconnect.isPendingInit('tracker', _name, initFlag, initList):
#VC: init the raw object
if initFlag&vizconnect.INIT_RAW:
#VC: set some parameters
index = 0
#VC: create the raw object
import oculus
sensorList = oculus.getSensors()
if index < len(sensorList):
orientationTracker = sensorList[index]
else:
viz.logWarn("** WARNING: Oculus VR Rift Orientation Tracker not present.")
orientationTracker = viz.addGroup()
orientationTracker.invalidTracker = True
rawTracker[_name] = orientationTracker
#VC: init the wrapper (DO NOT EDIT)
if initFlag&vizconnect.INIT_WRAPPERS:
vizconnect.addTracker(rawTracker[_name], _name, make='Oculus VR', model='DK2')
#VC: init the offsets
if initFlag&vizconnect.INIT_OFFSETS:
_link = vizconnect.getTracker(_name).getLink()
#VC: clear link offsets
_link.reset(viz.RESET_OPERATORS)
#VC: apply offsets
_link.postTrans([0, 1.405, 0])
#VC: init the mappings for the wrapper
if initFlag&vizconnect.INIT_WRAPPER_MAPPINGS:
#VC: on-state mappings
if initFlag&vizconnect.INIT_MAPPINGS_ON_STATE:
vizconnect.getTracker(_name).setOnStateEventList([
vizconnect.onstate(lambda rawInput: rawInput['keyboard'].isButtonDown(19), vizconnect.getTracker(_name).resetHeading),# make=Generic, model=Keyboard, name=keyboard, signal=Key R
])
#VC: return values can be modified here
return None
#################################
# Input Code
#################################
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawInput = vizconnect.getRawInputDict()
#VC: initialize a new input
_name = 'keyboard'
if vizconnect.isPendingInit('input', _name, initFlag, initList):
#VC: init the raw object
if initFlag&vizconnect.INIT_RAW:
#VC: set some parameters
index = 0
#VC: create the raw object
d = viz.add('directinput.dle')
device = d.getKeyboardDevices()[index]
rawInput[_name] = d.addKeyboard(device)
#VC: init the wrapper (DO NOT EDIT)
if initFlag&vizconnect.INIT_WRAPPERS:
vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Keyboard')
#VC: return values can be modified here
return None
#################################
# Event Code
#################################
def initEvents(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawEvent = vizconnect.getRawEventDict()
#VC: return values can be modified here
return None
#################################
# Transport Code
#################################
def initTransports(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawTransport = vizconnect.getRawTransportDict()
#VC: return values can be modified here
return None
#################################
# Tool Code
#################################
def initTools(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawTool = vizconnect.getRawToolDict()
#VC: return values can be modified here
return None
#################################
# Avatar Code
#################################
def initAvatars(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
#VC: place any general initialization code here
rawAvatar = vizconnect.getRawAvatarDict()
#VC: return values can be modified here
return None
#################################
# Application Settings
#################################
def initSettings():
#VC: apply general application settings
viz.mouse.setTrap(False)
viz.mouse.setVisible(viz.MOUSE_AUTO_HIDE)
vizconnect.setMouseTrapToggleKey('')
#VC: return values can be modified here
return None
#################################
# Post-initialization Code
#################################
def postInit():
"""Add any code here which should be called after all of the initialization of this configuration is complete.
Returned values can be obtained by calling getPostInitResult for this file's vizconnect.Configuration instance."""
return None
#################################
# Stand alone configuration
#################################
def initInterface():
#VC: start the interface
vizconnect.interface.go(__file__,
live=True,
openBrowserWindow=True,
startingInterface=vizconnect.interface.INTERFACE_STARTUP)
#VC: return values can be modified here
return None
###############################################
if __name__ == "__main__":
initInterface()
viz.add('piazza.osgb')
viz.add('piazza_animations.osgb')