summaryrefslogtreecommitdiff
path: root/camera.py
diff options
context:
space:
mode:
Diffstat (limited to 'camera.py')
-rwxr-xr-xcamera.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/camera.py b/camera.py
index af48735..470a1b9 100755
--- a/camera.py
+++ b/camera.py
@@ -588,7 +588,7 @@ class Camera(multiprocessing.Process):
if spnav_event is None:
return
- if spnav_event.type == self.spnav_module.SPNAV_EVENT_MOTION:
+ if spnav_event.ev_type == self.spnav_module.SPNAV_EVENT_MOTION:
if pygame.key.get_mods() & (KMOD_LSHIFT | KMOD_RSHIFT):
accelerate_factor = 2.0
else:
@@ -598,14 +598,15 @@ class Camera(multiprocessing.Process):
v2 = self.axis2
v3 = np.cross(self.axis1,self.axis2)
- v = v2*spnav_event.motion.x + v1*spnav_event.motion.y + \
- v3*spnav_event.motion.z
+ x, y, z = spnav_event.translation
+ rx, ry, rz = spnav_event.rotation
+
+ v = v2*x + v1*y + v3*z
v *= self.scale / 5000.0 * accelerate_factor
self.translate(v, redraw=False)
- axis = -v2*spnav_event.motion.rx - v1*spnav_event.motion.ry - \
- v3*spnav_event.motion.rz
+ axis = -v2*rx - v1*ry - v3*rz
if (axis != 0).any():
axis = axis.astype(float)
@@ -621,8 +622,8 @@ class Camera(multiprocessing.Process):
self.update()
pygame.event.clear(pygame.SYSWMEVENT)
- elif spnav_event.type == self.spnav_module.SPNAV_EVENT_BUTTON:
- if spnav_event.button.bnum == 0 and spnav_event.button.press:
+ elif spnav_event.ev_type == self.spnav_module.SPNAV_EVENT_BUTTON:
+ if spnav_event.bnum == 0 and spnav_event.press:
if not hasattr(self, 'rng_states_gpu'):
self.initialize_render()