pub struct MjViewer<M: Deref<Target = MjModel> + Clone> { /* 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,
- E: constraint.
§Safety
Due to the nature of OpenGL, this should only be run in the main thread.
Implementations§
Source§impl<M: Deref<Target = MjModel> + Clone> MjViewer<M>
impl<M: Deref<Target = MjModel> + Clone> MjViewer<M>
Sourcepub fn launch_passive(
model: M,
max_user_geom: usize,
) -> Result<Self, MjViewerError>
pub fn launch_passive( model: M, max_user_geom: usize, ) -> Result<Self, MjViewerError>
Launches the MuJoCo viewer. A Result struct is returned that either contains
MjViewer or a MjViewerError. The max_user_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.
pub fn user_scn(&self) -> &MjvScene<M>
pub fn user_scn_mut(&mut self) -> &mut MjvScene<M>
Trait Implementations§
Auto Trait Implementations§
impl<M> !Freeze for MjViewer<M>
impl<M> !RefUnwindSafe for MjViewer<M>
impl<M> !Send for MjViewer<M>
impl<M> !Sync for MjViewer<M>
impl<M> Unpin for MjViewer<M>where
M: Unpin,
impl<M> !UnwindSafe for MjViewer<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.