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 Platform Interaction

From Leeroopedia
Knowledge Sources
Domains User Interaction, Camera Control
Last Updated 2026-02-15 04:00 GMT

Overview

Implements mouse-driven camera movement, object perturbation, and scene picking for interactive MuJoCo simulation control.

Description

interaction.cc provides the core input-handling logic for MuJoCo's platform layer. It computes camera movement scales based on frustum geometry (with special handling for orthographic vs perspective projections), implements AlignToCamera to transform mouse deltas into 3D camera-relative vectors for various mouse actions (rotate vertical/horizontal, move vertical/horizontal, zoom), and provides InitPerturb and MovePerturb functions for interactive object manipulation. The CalculateMovementScale function uses mjv_cameraFrustum to determine appropriate sensitivity for camera motions.

Usage

Called by Studio's input handling system in response to mouse events. Camera motions (orbit, zoom, truck, pedestal, dolly, pan, tilt, planar) and object perturbations (translate, rotate) are dispatched through these functions to update mjvCamera and mjvPerturb state.

Code Reference

Source Location

Key Functions

static mjtNum CalculateMovementScale(const mjModel* m, const mjvCamera* cam);
static void AlignToCamera(mjtNum res[3], mjtMouse action, mjtNum dx, mjtNum dy, const mjtNum forward[3]);
void InitPerturb(const mjModel* m, const mjData* d, const mjvCamera* cam, mjvPerturb* pert, mjtPertBit active);
void MovePerturb(const mjModel* m, const mjData* d, const mjvCamera* cam, mjvPerturb* pert, mjtMouse action, mjtNum reldx, mjtNum reldy);
void MoveCamera(const mjModel* m, const mjData* d, mjvCamera* cam, CameraMotion motion, mjtNum dx, mjtNum dy);

Import

#include "experimental/platform/interaction.h"

I/O Contract

Inputs

Name Type Required Description
m const mjModel* Yes MuJoCo model for frustum and body data
d const mjData* Yes MuJoCo data for current simulation state
cam mjvCamera* Yes Camera to move or query
dx, dy mjtNum Yes Mouse delta inputs (normalized)
motion CameraMotion Yes Requested camera motion type (ZOOM, ORBIT, etc.)

Outputs

Name Type Description
cam mjvCamera* Updated camera state (position, orientation, distance)
pert mjvPerturb* Updated perturbation state (translation, rotation)

Related Pages

Page Connections

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