MjViewer

Struct MjViewer 

Source
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>

Source

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.

Source

pub fn running(&self) -> bool

Checks whether the window is still open.

Source

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.

Source

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.

Source

pub fn user_scn(&self) -> &MjvScene<'m>

👎Deprecated since 1.3.0: use user_scene
Source

pub fn user_scn_mut(&mut self) -> &mut MjvScene<'m>

👎Deprecated since 1.3.0: use user_scene_mut
Source

pub fn sync(&mut self, data: &mut MjData<'_>)

Syncs the state of data with the viewer as well as perform rendering on the viewer.

Trait Implementations§

Source§

impl<'m> Debug for MjViewer<'m>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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>

§

impl<'m> UnwindSafe for MjViewer<'m>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.