Added OrbitControls

This commit is contained in:
Thomas FORGIONE
2016-11-25 15:41:52 +01:00
parent e953492280
commit a2cf694b60
2 changed files with 16 additions and 2 deletions

View File

@@ -59,3 +59,17 @@ class OrbitControls(Controls):
self.phi = 0
self.theta = 0
def apply(self):
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)
def update(self, time = 10):
if not pygame.mouse.get_pressed()[0]:
return
move = pygame.mouse.get_rel()
self.theta += move[1] * 0.01
self.phi += move[0] * 0.01
self.theta = max(min(self.theta, math.pi / 2), -math.pi / 2)