Rendering and System Interaction

The system module contains various function to interact with rendering engine and host cpu.

mechanica.system.cpuinfo()

Returns a dictionary that contains a variety of information about the current procssor, such as processor vendor and supported instruction set features.

mechanica.system.gl_info()

Returns a dictionary that contains OpenGL capabilities and supported extensions.

mechanica.system.egl_info()

Gets a string of EGL info, only valid on Linux, we use EGL for Linux headless rendering.

mechanica.system.image_data()

Gets the contents of the rendering frame buffer back as a JPEG image stream, a byte array of the packed JPEG image.

mechanica.system.context_has_current()

Checks of the currently executing thread has a rendering context.

mechanica.system.context_make_current()

Makes the single Mechanica rendering context current on the current thread. Note, for multi-threaded rendering, the initialization thread needs to release the context via context_release(), then aquire it on the rendering thread via this function.

mechanica.system.context_release()

Release the rendering context on the currently executing thread.

mechanica.system.camera_move_to([eye][, center][, up])

Moves the camera to the specified ‘eye’ location, where it looks at the ‘center’ with an up vector of ‘up’. All of the parameters are optional, if they are not give, we use the initial default values.

Parameters:
  • eye – ([x, y, z]) New camera location, where we re-position the eye of the viewer.
  • center – ([x, y, z]) Location that the camera will look at, the what we want as the center of the view.
  • up – ([x, y, z]) Unit up vector, defines the up direction of the camera.
mechanica.system.camera_reset()

Resets the camera to the initial position.

mechanica.system.camera_rotate_mouse(mouse_pos)

Rotates the camera according to the current mouse position. Need to call camera_init_mouse() to initialize a mouse movement.

Parameters:mouse_pos – ([x, y]) current mouse position on the view window or image.
mechanica.system.camera_translate_mouse(mouse_pos)

Translates the camera according to the current mouse position. You need to call camera_init_mouse() to initialize a mouse movment, i.e. set the starting mouse position.

Parameters:mouse_pos – ([x, y]) current mouse position on the view window or image.
mechanica.system.camera_init_mouse(mouse_pos)

Initialize a mouse movment operation, this tells the simulator that a mouse click was performed at the given coordinates, and subsequent mouse motion will refer to this starting position.

Parameters:mouse_pos – ([x, y]) current mouse position on the view window or image.
mechanica.system.camera_translate_by(delta)

Translates the camera in the plane perpendicular to the view orientation, moves the camera a given delta x, delta y distance in that plane.

Parameters:delta – ([delta_x, delta_y]) a vector that indicates how much to translate the camera.
mechanica.system.camera_zoom_by(delta)

Zooms the camera in and out by a specified amount.

Parameters:delta – number that indicates how much to increment zoom distance.
mechanica.system.camera_zoom_to(distance)

Zooms the camera to the given distance.

Parameters:distance – distance to the universe center for the camera.
mechanica.system.camera_rotate_to_axis(axis, distance)

Rotates the camera to one of the principal axis, at a given zoom distance.

Parameters:
  • axis – ([x, y, z]) unit vector that defines the axis to move to.
  • distance – how far away the camera will be.
mechanica.system.camera_rotate_to_euler_angle(angles)

Rotate the camera to the given orientiation defined by three Euler angles.

Parameters:angles – ([alpha, beta, gamma]) Euler angles of rotation about the X, Y, and Z axis.
mechanica.system.camera_rotate_by_euler_angle(angles)

Incremetns the camera rotation by given orientiation defined by three Euler angles.

Parameters:angles – ([alpha, beta, gamma]) Euler angles of rotation about the X, Y, and Z axis.
mechanica.system.view_reshape(window_size)

Notify the simulator that the window or image size was changed.

Parameters:window_size – ([x, y]) new window size.