-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.py
282 lines (210 loc) · 8.32 KB
/
camera.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
"""
This module was generated by Vizconnect.
Version: 1.02
Generated on: 2016-01-20 11:39:44.013000
"""
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 = 'custom_window'
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
VFOV = 60
aspect = viz.AUTO_COMPUTE
stereo = viz.OFF
#VC: create the raw object
_window.fov(VFOV,aspect)
_window.stereo(stereo)
rawDisplay[_name] = _window
#VC: init the wrapper (DO NOT EDIT)
if initFlag&vizconnect.INIT_WRAPPERS:
vizconnect.addDisplay(rawDisplay[_name], _name, make='Generic', model='Custom Window')
#VC: set the parent of the node
if initFlag&vizconnect.INIT_PARENTS:
vizconnect.getDisplay(_name).setParent(vizconnect.getTransport('orientation'))
#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: 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: initialize a new input
_name = 'joystick'
if vizconnect.isPendingInit('input', _name, initFlag, initList):
#VC: init the raw object
if initFlag&vizconnect.INIT_RAW:
#VC: create the raw object
import vizjoy
rawInput[_name] = vizjoy.add()
#VC: init the wrapper (DO NOT EDIT)
if initFlag&vizconnect.INIT_WRAPPERS:
vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Joystick')
#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: initialize a new transport
_name = 'orientation'
if vizconnect.isPendingInit('transport', _name, initFlag, initList):
#VC: init the raw object
if initFlag&vizconnect.INIT_RAW:
#VC: set some parameters
transportationGroup = None
debug = False
#VC: create the raw object
from transportation import orientation
rawTransport[_name] = orientation.Orientation(node=transportationGroup, debug=debug)
#VC: init the mappings for the raw object
if initFlag&vizconnect.INIT_MAPPINGS:
#VC: per frame mappings
if initFlag&vizconnect.INIT_MAPPINGS_PER_FRAME:
#VC: get the raw input dict so we have access to signals
import vizact
rawInput = vizconnect.getConfiguration().getRawDict('input')
#VC: set the update function which checks for input signals
def update(transport):
if rawInput['keyboard'].isButtonDown(30):# make=Generic, model=Keyboard, name=keyboard, signal=Key A
transport.left(mag=1)
if rawInput['joystick'].getPosition()[2] < -0.05:# make=Generic, model=Joystick, name=joystick, signal=Analog Z Down
transport.left(mag=abs(rawInput['joystick'].getPosition()[2]))
if rawInput['keyboard'].isButtonDown(32):# make=Generic, model=Keyboard, name=keyboard, signal=Key D
transport.right(mag=1)
if rawInput['joystick'].getPosition()[2] > 0.05:# make=Generic, model=Joystick, name=joystick, signal=Analog Z Up
transport.right(mag=abs(rawInput['joystick'].getPosition()[2]))
if rawInput['keyboard'].isButtonDown(17):# make=Generic, model=Keyboard, name=keyboard, signal=Key W
transport.up(mag=1)
if rawInput['joystick'].getRotation()[2] < -0.05:# make=Generic, model=Joystick, name=joystick, signal=Rotate Z Left
transport.up(mag=abs(rawInput['joystick'].getRotation()[2]))
if rawInput['keyboard'].isButtonDown(31):# make=Generic, model=Keyboard, name=keyboard, signal=Key S
transport.down(mag=1)
if rawInput['joystick'].getRotation()[2] > 0.05:# make=Generic, model=Joystick, name=joystick, signal=Rotate Z Right
transport.down(mag=abs(rawInput['joystick'].getRotation()[2]))
rawTransport[_name].setUpdateFunction(update)
#VC: init the wrapper (DO NOT EDIT)
if initFlag&vizconnect.INIT_WRAPPERS:
vizconnect.addTransport(rawTransport[_name], _name, make='Virtual', model='Orientation')
#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')