Added scroll wheel support (Linux only right now).

This commit is contained in:
2020-07-15 12:04:47 -05:00
parent a4aa0c628f
commit 94e2603ab5
+19 -3
View File
@@ -28,18 +28,34 @@ Matrix3x3(Vector3d(1.0,0.0,1.0),Vector3d(0.0,0.0,0.0),Vector3d(1.0,0.0,0.0))
#'''
#tris = Mesh()
def main():
#tris.load_obj_file('teddy.obj')
#tris.load_obj_file('shuttle.obj')
ui.scale = 3
ui.thetax = 1
ui.thetaz = 1
ui.window.bind('<Left>', left)
ui.window.bind('<Right>', right)
ui.window.bind('<Up>', up)
ui.window.bind('<Down>', down)
ui.window.bind('<ButtonPress-1>', mouse_start)
ui.window.bind('<Button-4>', wheel)
ui.window.bind('<Button-5>', wheel)
#ui.window.bind('<ButtonPress-1>', mouse_start)
ui.canvas.bind('<B1-Motion>', mouse_end)
ui.canvas.old_coords = None
ui.window.after(0, draw_scene)
ui.show()
def wheel(event):
# respond to Linux or Windows wheel event
#if event.num == 5 or event.delta == -120:
if event.num == 4:
ui.scale -= .5
else:
ui.scale += .5
if ui.scale < 1.5:
ui.scale = 1.5
draw_scene()
def left(event):
ui.thetaz += .1
@@ -84,7 +100,7 @@ def draw_scene():
rotation_matrix_x = Matrix4x4.get_x_rotation_matrix(ui.thetax)
translation = Matrix4x4.get_translation_matrix(Vector3d(0, 0, 3))
translation = Matrix4x4.get_translation_matrix(Vector3d(0, 0, ui.scale))
world_matrix = Matrix4x4.get_identity_matrix()
world_matrix = rotation_matrix_z.multiply_matrix(rotation_matrix_x)