Implementation:Google deepmind Mujoco User Mesh
| Knowledge Sources | |
|---|---|
| Domains | Physics Simulation, Mesh Processing, Computational Geometry |
| Last Updated | 2026-02-15 04:00 GMT |
Overview
Implements mesh loading, processing, convex hull computation, and signed distance field generation for MuJoCo geometric assets.
Description
user_mesh.cc is a large (4671 lines) module responsible for all mesh-related operations in MuJoCo. It loads meshes via tinyobjloader, computes convex hulls using qhull, generates signed distance fields via TriangleMeshDistance, and creates marching cubes isosurfaces using the MC library. The file handles OBJ file parsing, vertex/face processing, normal computation, texture coordinate management, and the conversion of mesh data into MuJoCo-compatible internal formats. It also supports asset caching for performance optimization.
Usage
Used during model compilation whenever mesh assets (OBJ files, STL files, or procedural meshes) are referenced in the model specification, handling the full pipeline from file loading to compiled mesh data.
Code Reference
Source Location
- Repository: Google_deepmind_Mujoco
- File: src/user/user_mesh.cc
- Lines: 1-4671
Key Functions
// Key classes and external library usage
// Uses tinyobjloader for OBJ loading
// Uses qhull (qhull_ra.h) for convex hull computation
// Uses TriangleMeshDistance for SDF computation
// Uses MC.h for marching cubes isosurface extraction
Import
#include <mujoco/mjspec.h>
#include "user/user_api.h"
#include "user/user_cache.h"
#include "user/user_model.h"
#include "user/user_objects.h"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| resource | mjResource* | Yes | Resource handle for loading mesh file data |
| model | mjCModel* | Yes | Model context for compilation settings and asset cache |
| vfs | const mjVFS* | No | Virtual file system for resource lookups |
Outputs
| Name | Type | Description |
|---|---|---|
| vertices | float[] | Processed vertex positions |
| faces | int[] | Triangle face indices |
| normals | float[] | Computed vertex or face normals |
| texcoords | float[] | Texture coordinates |