farZ=10000.0) # ms.ortho(left=-150.0, # right=150.0, # back=-150.0, # top=150.0, # near=1.0, # far=10000.0) glMatrixMode(GL_PROJECTION) # ascontiguousarray puts the array in column major order glLoadMatrixf( np.ascontiguousarray(ms.getCurrentMatrix(ms.MatrixStack.projection).T)) # note - opengl matricies use degrees ms.translate(ms.MatrixStack.view, 0.0, 0.0, -moving_camera_r) ms.rotate_x(ms.MatrixStack.view, moving_camera_rot_x) ms.rotate_y(ms.MatrixStack.view, -moving_camera_rot_y) glMatrixMode(GL_MODELVIEW) draw_ground() if animation_time < 5.0 or (animation_time > 40.0 and animation_time < 45.0): draw_axises() else: draw_axises(grayed_out=True) with ms.PushMatrix(ms.MatrixStack.model): if animation_time > 5.0: # draw paddle 1 ms.translate(
axes_list = glfw.get_joystick_axes(glfw.JOYSTICK_1) if len(axes_list) >= 1 and axes_list[0]: if math.fabs(float(axes_list[0][0])) > 0.19: camera.x += 10.0 * axes_list[0][0] * math.cos(camera.rot_y) camera.z -= 10.0 * axes_list[0][0] * math.sin(camera.rot_y) if math.fabs(float(axes_list[0][1])) > 0.19: camera.x += 10.0 * axes_list[0][1] * math.sin(camera.rot_y) camera.z += 10.0 * axes_list[0][1] * math.cos(camera.rot_y) if math.fabs(axes_list[0][3]) > 0.19: camera.rot_y -= 3.0 * axes_list[0][3] * 0.01 if math.fabs(axes_list[0][4]) > 0.19: camera.rot_x += axes_list[0][4] * 0.01 # note - opengl matricies use degrees ms.rotate_x(ms.MatrixStack.view, -camera.rot_x) ms.rotate_y(ms.MatrixStack.view, -camera.rot_y) ms.translate(ms.MatrixStack.view, -camera.x, -camera.y, -camera.z) with ms.push_matrix(ms.MatrixStack.model): # draw paddle 1 # Unlike in previous demos, because the transformations # are on a stack, the fns on the model stack can # be read forwards, where each operation translates/rotates/scales # the current space ms.translate( ms.MatrixStack.model, paddle1.position[0], paddle1.position[1], 0.0, )
farZ=10000.0) # ms.ortho(left=-150.0, # right=150.0, # back=-150.0, # top=150.0, # near=1.0, # far=10000.0) glMatrixMode(GL_PROJECTION) # ascontiguousarray puts the array in column major order glLoadMatrixf( np.ascontiguousarray(ms.getCurrentMatrix(ms.MatrixStack.projection).T)) # note - opengl matricies use degrees ms.translate(ms.MatrixStack.view, 0.0, 0.0, -camera.r) ms.rotate_x(ms.MatrixStack.view, camera.rot_x) ms.rotate_y(ms.MatrixStack.view, -camera.rot_y) glMatrixMode(GL_MODELVIEW) # draw NDC in global space, so that we can see the camera space # go to NDC with ms.PushMatrix(ms.MatrixStack.model): ms.scale(ms.MatrixStack.model, 5.0, 5.0, 5.0) draw_ndc() draw_ground() if animation_time > 80.0: ms.rotate_x( ms.MatrixStack.model,