Added OrbitControls
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user