[X3D-Ecosystem] Research into MuJoCo XML for soft body physics
John Carlson
yottzumm at gmail.com
Wed Dec 10 03:11:31 PST 2025
Here's the Claude intro to the MuJoCo <flexcomp> element: If someone
knows what an MJCF element is, cool.
John
Based on my research, I can provide you with a comprehensive summary of the
MuJoCo flexcomp element and its children.
MuJoCo flexcomp Element Summary
flexcomp is a meta-element in MuJoCo's MJCF format that procedurally
generates deformable objects Readthedocs
<https://mujoco.readthedocs.io/en/stable/XMLreference.html>. It was
introduced in MuJoCo 3.0 as a convenience macro for creating deformable
objects, similar to how composite works for rigid structures Readthedocs
<https://mujoco.readthedocs.io/en/3.1.0/changelog.html>. Like other
meta-elements, flexcomp disappears from the model upon saving the XML and
is replaced with the generated low-level MJCF elements Readthedocs
<https://mujoco.readthedocs.io/en/latest/modeling.html>.
Purpose
flexcomp is designed to simulate soft objects like cloth, soft bodies, and
deformable materials, replacing older composite types that were used for
these purposes Readthedocs
<https://mujoco.readthedocs.io/en/latest/modeling.html>.
Main Attributes
>From the examples in the search results, flexcomp supports the following
key attributes:
- *type*: Defines the type of deformable object. Common values include:
- "grid" - creates a grid-based structure
- "gmsh" - imports tetrahedral meshes from GMSH format files
- "mesh" - uses mesh-based deformation
- *name*: Identifier for the flexcomp object
- *count*: For grid types, specifies the number of elements in each
dimension (e.g., "10 5 1" for a 2D cloth)
- *spacing*: Defines the distance between elements (e.g., ".025 .025
.025")
- *pos*: Position in 3D space
- *radius*: Visual radius of the deformable elements
- *rgba*: Color and transparency
- *dim*: Dimensionality (1, 2, or 3) - 2 for cloth/shells, 3 for solid
deformables
- *mass*: Total mass of the deformable object
- *file*: For gmsh or mesh types, specifies the mesh file to load
- *material*: References a material asset for appearance
Child Elements
flexcomp supports several child elements:
1. *<contact>* - Defines collision properties
- condim: Contact dimensionality (3 or 6)
- solref: Solver reference parameters
- solimp: Solver impedance parameters
- selfcollide: Controls self-collision behavior
- friction: Friction coefficients
2. *<edge>* - Controls edge behavior
- equality: Whether edges act as equality constraints (typically
"true")
- damping: Damping coefficient for edges
3. *<plugin>* - Specifies elasticity model and material properties
- Most commonly uses plugin="mujoco.elasticity.solid" (for 3D
volumes) or plugin="mujoco.elasticity.shell" (for 2D surfaces)
- Child <config> elements set material properties:
- key="poisson" - Poisson's ratio
- key="young" - Young's modulus (in Pascals)
- key="thickness" - For shell elements, material thickness
- key="damping" - Material damping
Example Usage
A typical cloth simulation might look like:
xml
<flexcomp type="grid" count="10 5 1" spacing=".025 .025 .025"
mass="0.1" name="cloth" radius="0.001" dim="2">
<contact condim="6" solref="0.001"/>
<edge equality="true" damping="0.1"/>
<plugin plugin="mujoco.elasticity.shell">
<config key="poisson" value="0"/>
<config key="thickness" value="10e-3"/>
<config key="young" value="3e4"/>
</plugin></flexcomp>
A 3D soft body example:
xml
<flexcomp type="grid" count="5 5 5" spacing=".02 .02 .02"
pos="0 0 0" radius="0" rgba="0 .7 .7 1" name="softbody"
dim="3" mass="1">
<contact condim="3" solref="0.01 1" solimp=".95 .99 .0001"
selfcollide="none"/>
<edge damping="1"/>
<plugin plugin="mujoco.elasticity.solid">
<config key="poisson" value="0.2"/>
<config key="young" value="5e5"/>
</plugin></flexcomp>
On Wed, Dec 10, 2025 at 5:00 AM John Carlson <yottzumm at gmail.com> wrote:
> Poncho "IndexedTriangleSet" for MuJoCo:
>
> <flexcomp name="f1" type="direct" rgba=".8 .2 .2 1" radius="0.01" dim="2"
> pos="0 0 2"
> mass="1"
> point="...MFVec3F..." (Coordinate.point)
> element="...MFInt32..." (IndexedTriangleSet coordIndex?)
>
> <edge equality="true" damping="0.1"/>
> <elasticity young="3e5" poisson="0" thickness="8e-3"
> elastic2d="bend"/>
> <contact solref="0.003"/>
> </flexcomp>
>
> Help converting this to something that works for X3D IndexedTriangleSet
> welcome.
>
> Hammock grid:
>
> <flexcomp name="hammock" type="grid" count="11 9 1" spacing="0.2 0.2 0.2"
> material="hammock"
> radius="0.04" dim="2">
> <pin id="0 8 90 98"/>
> <edge equality="true" solref="0.002 5"/>
> <contact selfcollide="none" internal="false" solimp=".99 .999
> .00001"/>
> </flexcomp>
>
> <!-- Copyright 2021 DeepMind Technologies Limited
>
> Licensed under the Apache License, Version 2.0 (the "License");
> you may not use this file except in compliance with the License.
> You may obtain a copy of the License at
>
> http://www.apache.org/licenses/LICENSE-2.0
>
> Unless required by applicable law or agreed to in writing, software
> distributed under the License is distributed on an "AS IS" BASIS,
> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> See the License for the specific language governing permissions and
> limitations under the License.
> -->
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-ecosystem_web3d.org/attachments/20251210/2f6b2db4/attachment-0001.html>
More information about the X3D-Ecosystem
mailing list