MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / initialize

Method initialize

dm_control/viewer/viewer.py:134–224  ·  view source on GitHub ↗

Initialize the viewer. Args: physics: Physics instance. renderer_instance: A renderer.Base instance. touchpad: A boolean, use input dedicated to touchpad.

(self, physics, renderer_instance, touchpad)

Source from the content-addressed store, hash-verified

132 del self._camera_select
133
134 def initialize(self, physics, renderer_instance, touchpad):
135 """Initialize the viewer.
136
137 Args:
138 physics: Physics instance.
139 renderer_instance: A renderer.Base instance.
140 touchpad: A boolean, use input dedicated to touchpad.
141 """
142 self._camera = renderer.SceneCamera(
143 physics.model,
144 physics.data,
145 self._render_settings,
146 settings=self._camera_settings,
147 zoom_factor=self._zoom_factor,
148 scene_callback=self._scene_callback)
149
150 self._manipulator = ManipulationController(
151 self._viewport, self._camera, self._mouse)
152
153 self._free_camera = FreeCameraController(
154 self._viewport, self._camera, self._mouse, self._manipulator)
155
156 self._camera_select = CameraSelector(
157 physics.model, self._camera, self._free_camera)
158
159 self._renderer = renderer_instance
160
161 self._input_map.clear_bindings()
162
163 if touchpad:
164 self._input_map.bind(
165 self._manipulator.set_move_vertical_mode,
166 _MOVE_OBJECT_VERTICAL_TOUCHPAD)
167 self._input_map.bind(
168 self._manipulator.set_move_horizontal_mode,
169 _MOVE_OBJECT_HORIZONTAL_TOUCHPAD)
170 self._input_map.bind(
171 self._manipulator.set_rotate_mode, _ROTATE_OBJECT_TOUCHPAD)
172 self._input_map.bind(
173 self._free_camera.set_pan_vertical_mode,
174 _PAN_CAMERA_VERTICAL_TOUCHPAD)
175 self._input_map.bind(
176 self._free_camera.set_pan_horizontal_mode,
177 _PAN_CAMERA_HORIZONTAL_TOUCHPAD)
178 else:
179 self._input_map.bind(
180 self._manipulator.set_move_vertical_mode, _MOVE_OBJECT_VERTICAL_MOUSE)
181 self._input_map.bind(
182 self._manipulator.set_move_horizontal_mode,
183 _MOVE_OBJECT_HORIZONTAL_MOUSE)
184 self._input_map.bind(
185 self._manipulator.set_rotate_mode, _ROTATE_OBJECT_MOUSE)
186 self._input_map.bind(
187 self._free_camera.set_pan_vertical_mode, _PAN_CAMERA_VERTICAL_MOUSE)
188 self._input_map.bind(
189 self._free_camera.set_pan_horizontal_mode,
190 _PAN_CAMERA_HORIZONTAL_MOUSE)
191

Calls 7

CameraSelectorClass · 0.85
clear_bindingsMethod · 0.80
bind_z_axisMethod · 0.80
bind_planeMethod · 0.80
bindMethod · 0.45