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 mjv makeScene

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

Overview

Concrete tool for allocating the abstract 3D scene representation provided by the MuJoCo visualization API.

Description

The mjv_makeScene function allocates all buffers needed for the abstract scene: geometry arrays (up to maxgeom entries), flex data (edges, vertices, faces), and skin data (vertices, normals). It also initializes default rendering flags and model transformation. Companion functions mjv_defaultCamera and mjv_defaultOption initialize the camera and visualization options respectively.

Usage

Call after model loading to prepare for rendering. Typical maxgeom value is 10000 for complex scenes.

Code Reference

Source Location

  • Repository: mujoco
  • File: src/engine/engine_vis_init.c
  • Lines (mjv_makeScene): 126-276
  • Lines (mjv_defaultCamera): 341-350
  • Lines (mjv_defaultOption): 316-340

Signature

void mjv_makeScene(const mjModel* m, mjvScene* scn, int maxgeom);
void mjv_defaultCamera(mjvCamera* cam);
void mjv_defaultOption(mjvOption* opt);

Import

#include <mujoco/mujoco.h>

I/O Contract

Inputs

Name Type Required Description
m const mjModel* Yes Model (for flex/skin sizing)
scn mjvScene* Yes Scene struct to allocate
maxgeom int Yes Maximum geometry count (e.g. 10000)
cam mjvCamera* Yes Camera struct to initialize
opt mjvOption* Yes Options struct to initialize

Outputs

Name Type Description
scn (modified) mjvScene* Allocated scene with geom, flex, skin buffers
cam (modified) mjvCamera* Free camera at default distance/angle
opt (modified) mjvOption* Default visualization flags

Usage Examples

#include <mujoco/mujoco.h>

mjModel* m = mj_loadXML("scene.xml", NULL, error, 1000);
mjData* d = mj_makeData(m);

// Initialize visualization structures
mjvCamera cam;
mjvOption opt;
mjvScene scn;
mjv_defaultCamera(&cam);
mjv_defaultOption(&opt);
mjv_makeScene(m, &scn, 10000);

// ... render loop ...

// Cleanup
mjv_freeScene(&scn);

Related Pages

Implements Principle

Page Connections

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