defpan_camera(camera, right_amount, up_amount): # Get the current position, focal point and view up vector of the camera position = camera.GetPosition() focal_point = camera.GetFocalPoint() view_up = camera.GetViewUp()
# Convert tuples to numpy arrays position = np.array(position) focal_point = np.array(focal_point) view_up = np.array(view_up)
# Compute the direction of projection or the view plane normal view_plane_normal = position - focal_point view_plane_normal = view_plane_normal / np.linalg.norm(view_plane_normal)
# Compute the right vector (cross product of view up vector and view plane normal) right_vector = np.cross(view_up, view_plane_normal) right_vector = right_vector / np.linalg.norm(right_vector)
# Compute the up vector (cross product of view plane normal and right vector, to ensure orthogonal) up_vector = np.cross(view_plane_normal, right_vector) up_vector = up_vector / np.linalg.norm(up_vector)
# Scale the pan movements to match the specified amounts right_movement = right_vector * right_amount up_movement = up_vector * up_amount
# Calculate the new camera position and focal point new_position = position + right_movement + up_movement new_focal_point = focal_point + right_movement + up_movement
# Update the camera's position and focal point camera.SetPosition(new_position.tolist()) camera.SetFocalPoint(new_focal_point.tolist()) camera.SetViewUp( view_up.tolist() ) # Ensure to reset the view up vector too, if it has been changed
# Main loop whilenot glfw.window_should_close(window): # Handle ImGui inputs and start a new ImGui frame impl.process_inputs() imgui.new_frame() imgui.begin("Dashboard", True)
# ... Create ImGui windows here
# End the ImGui frame and render the ImGui output imgui.end() imgui.render() render_window.Render()
# ... Some operations for scene updates here
# Render the ImGui output and swap the GLFW buffers impl.render(imgui.get_draw_data()) glfw.swap_buffers(window) glfw.poll_events() # Shutdown ImGui and terminate GLFW impl.shutdown() glfw.terminate()