pub struct MjViewer<'m> { /* private fields */ }
Expand description
A Rust-native implementation of the MuJoCo viewer. To confirm to rust safety rules,
the viewer doesn’t store a mutable reference to the MjData
struct, but it instead
accepts it as a parameter at its methods.
The MjViewer::sync
method must be called to sync the state of MjViewer
and MjData
.
§Shortcuts
Main keyboard and mouse shortcuts can be viewed by pressing F1
.
Additionally, some visualization toggles are included, but not displayed
in the F1
help menu:
- C: camera,
- U: actuator,
- J: joint,
- M: center of mass,
- H: convex hull,
- Z: light,
- T: transparent,
- I: inertia.
§Safety
Due to the nature of OpenGL, this should only be run in the main thread.
Implementations§
Source§impl<'m> MjViewer<'m>
impl<'m> MjViewer<'m>
Sourcepub fn launch_passive(
model: &'m MjModel,
scene_max_geom: usize,
) -> Result<Self, MjViewerError>
pub fn launch_passive( model: &'m MjModel, scene_max_geom: usize, ) -> Result<Self, MjViewerError>
Launches the MuJoCo viewer. A Result
struct is returned that either contains
MjViewer
or a MjViewerError
. The scene_max_geom
parameter
defines how much space will be allocated for additional, user-defined visual-only geoms.
It can thus be set to 0 if no additional geoms will be drawn by the user.
Sourcepub fn user_scene(&self) -> &MjvScene<'m>
pub fn user_scene(&self) -> &MjvScene<'m>
Returns an immutable reference to a user scene for drawing custom visual-only geoms.
Geoms in the user scene are preserved between calls to MjViewer::sync
.
Sourcepub fn user_scene_mut(&mut self) -> &mut MjvScene<'m>
pub fn user_scene_mut(&mut self) -> &mut MjvScene<'m>
Returns a mutable reference to a user scene for drawing custom visual-only geoms.
Geoms in the user scene are preserved between calls to MjViewer::sync
.