Better wheel events

This commit is contained in:
Thomas FORGIONE
2016-12-01 13:50:04 +01:00
parent 2077cfb311
commit 02cfdbf1b9
3 changed files with 47 additions and 11 deletions

View File

@@ -58,10 +58,11 @@ class OrbitControls(Controls):
super().__init__()
self.phi = 0
self.theta = 0
self.scale = 1
self.scale_log = 0
def apply(self):
gl.glScalef(self.scale, self.scale, self.scale)
scale = math.exp(self.scale_log)
gl.glScalef(scale, scale, scale)
gl.glRotatef(self.theta * 180 / math.pi, 1.0, 0.0, 0.0)
gl.glRotatef(self.phi * 180 / math.pi, 0.0, 1.0, 0.0)
@@ -69,9 +70,10 @@ class OrbitControls(Controls):
if event.type == pygame.MOUSEBUTTONDOWN:
# Wheel up
if event.button == 4:
self.scale += 0.2
self.scale_log += 0.1
# Wheel down
elif event.button == 5:
self.scale -= 2
self.scale_log -= 0.1
def update(self, time = 10):