MCPcopy Create free account
hub / github.com/BerkeleyAutomation/meshrender / SceneViewer

Class SceneViewer

meshrender/viewer.py:49–806  ·  view source on GitHub ↗

An interactive viewer for a 3D scene. This doesn't use the scene's camera - instead, it uses one based on a trackball. The basic commands for moving about the scene are given as follows: * To rotate the camera about the center of the scene, hold the left mouse button and drag the curs

Source from the content-addressed store, hash-verified

47 C_VOID_PS.append(ctypes.c_void_p(4*4*i))
48
49class SceneViewer(pyglet.window.Window):
50 """An interactive viewer for a 3D scene.
51
52 This doesn't use the scene's camera - instead, it uses one based on a trackball.
53
54 The basic commands for moving about the scene are given as follows:
55
56 * To rotate the camera about the center of the scene, hold the left mouse button and drag the cursor.
57 * To rotate the camera about its viewing axis, hold CTRL and then hold the left mouse button and drag the cursor.
58 * To pan the camera, do one of the following:
59
60 * Hold SHIFT, then hold the left mouse button and drag the cursor.
61 * Hold the middle mouse button and drag the cursor.
62
63 * To zoom the camera in or our, do one of the following:
64
65 * Scroll the mouse wheel.
66 * Hold the right mouse button and drag the cursor.
67
68 Other keyboard commands are as follows:
69
70 * z -- resets the view to the original view.
71 * w -- toggles wireframe mode for each mesh in the scene.
72 * a -- toggles rotational animation.
73 * l -- toggles two-sided lighting
74 * q -- quits the viewer
75 * s -- saves the current image
76 * r -- starts a recording session, pressing again stops (saves animation as .gif)
77 """
78 _raymond_lights = None
79
80
81 def __init__(self, scene, size=(640,480), raymond_lighting=True,
82 animate=False, animate_az=0.05, animate_rate=30.0, animate_axis=None,
83 two_sided_lighting=False, line_width = 1.0,
84 registered_keys={}, starting_camera_pose=None, max_frames=0,
85 save_directory=None, save_filename=None,
86 title='Scene Viewer', target_object=None, **kwargs):
87 """Initialize a scene viewer and open the viewer window.
88
89 Parameters
90 ----------
91 scene : Scene
92 A scene to view. The scene's camera is not used.
93 size : (int, int)
94 The width and height of the target window in pixels.
95 raymond_lighting : bool
96 If True, the scene's point and directional lights are discarded in favor
97 of a set of three directional lights that move with the camera.
98 animate : bool
99 If True, the camera will rotate by default about the scene.
100 animate_az : float
101 The number of radians to rotate per timestep.
102 animate_rate : float
103 The framerate for animation in fps.
104 animate_axis : (3,) float or None
105 If present, the animation will rotate about the given axis in world coordinates.
106 Otherwise, the animation will rotate in azimuth.

Callers 1

test_viewer.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected