Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Google deepmind Mujoco Engine Vis Visualize

From Leeroopedia
Revision as of 12:45, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Google_deepmind_Mujoco_Engine_Vis_Visualize.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Physics Simulation, Visualization, 3D Rendering
Last Updated 2026-02-15 04:00 GMT

Overview

Implements the core scene visualization pipeline for MuJoCo, converting model and simulation state into renderable geometry (geoms, labels, lights) for the 3D scene graph.

Description

This is the largest visualization source file in MuJoCo, responsible for populating the mjvScene structure with all renderable elements. It includes utility functions for float array copying, label generation, HSV-to-RGB color conversion, and geometry creation helpers. The main visualization functions iterate over all model elements (bodies, geoms, sites, tendons, actuators, contacts, constraints, lights, cameras, flex, skin) and create corresponding mjvGeom visual primitives with appropriate positions, orientations, sizes, colors, and labels. It handles visualization options such as wireframe mode, transparency, contact force arrows, constraint visualization, frame rendering, selection highlighting, and island coloring. The file also manages lights (headlight, model lights) and text overlays. Plugin-provided visualization callbacks are also supported.

Usage

The main entry point mjv_updateScene is called each rendering frame to rebuild the scene graph from the current model and simulation state, respecting the active visualization options and camera configuration.

Code Reference

Source Location

Key Functions

// Utility functions
static void makeLabel(const mjModel* m, mjtObj type, int id, char* label);
void hsv2rgb(float* RGB, float H, float S, float V);

// Scene update (main entry point)
void mjv_updateScene(const mjModel* m, mjData* d, const mjvOption* opt,
                     const mjvPerturb* pert, mjvCamera* cam, int catmask,
                     mjvScene* scn);

// Geometry addition
void mjv_addGeoms(const mjModel* m, mjData* d, const mjvOption* opt,
                  const mjvPerturb* pert, int catmask, mjvScene* scn);

// Light setup
void mjv_makeLights(const mjModel* m, mjData* d, mjvScene* scn);

// Camera setup
void mjv_updateCamera(const mjModel* m, mjData* d, mjvCamera* cam, mjvScene* scn);

// Scene initialization
void mjv_makeScene(const mjModel* m, mjvScene* scn, int maxgeom);
void mjv_freeScene(mjvScene* scn);

Import

#include "engine/engine_vis_visualize.h"

I/O Contract

Inputs

Name Type Required Description
m const mjModel* Yes Model with geometry, material, and visual definitions
d mjData* Yes Current simulation state (positions, forces, contacts)
opt const mjvOption* Yes Visualization options controlling which elements to render
pert const mjvPerturb* No Active perturbation to visualize
cam mjvCamera* Yes Camera configuration for view computation
catmask int Yes Bitmask selecting which geom categories to include
maxgeom int Yes Maximum number of geoms to allocate in scene

Outputs

Name Type Description
scn mjvScene* Populated scene graph with geoms, lights, and camera data ready for rendering

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment