From 6de9eafa137299652b68c8302491414857e2aa0b Mon Sep 17 00:00:00 2001 From: Tom Erez Date: Wed, 2 Feb 2022 20:17:13 +0000 Subject: [PATCH] Initial release of the Unity plugin. PiperOrigin-RevId: 425947505 --- doc/index.rst | 1 + doc/unity.rst | 333 ++ model/humanoid100/humanoid100.xml | 5 +- unity/CHANGELOG.md | 5 + unity/CHANGELOG.md.meta | 7 + unity/Editor.meta | 8 + unity/Editor/Components.meta | 8 + .../Components/AbsoluteValuePropertyEditor.cs | 26 + .../AbsoluteValuePropertyEditor.cs.meta | 13 + unity/Editor/Components/MjActuatorEditor.cs | 199 + .../Components/MjActuatorEditor.cs.meta | 13 + unity/Editor/Components/MjGeomEditor.cs | 77 + unity/Editor/Components/MjGeomEditor.cs.meta | 13 + unity/Editor/Components/MjHandles.cs | 58 + unity/Editor/Components/MjHandles.cs.meta | 13 + unity/Editor/Components/MjHingeJointEditor.cs | 41 + .../Components/MjHingeJointEditor.cs.meta | 13 + unity/Editor/Components/MjMouseSpring.cs | 176 + unity/Editor/Components/MjMouseSpring.cs.meta | 11 + .../Components/MjShapeComponentEditor.cs | 38 + .../Components/MjShapeComponentEditor.cs.meta | 11 + unity/Editor/Components/MjSlideJointEditor.cs | 48 + .../Components/MjSlideJointEditor.cs.meta | 13 + unity/Editor/Importer.meta | 8 + .../Editor/Importer/MjImporterEditorWindow.cs | 32 + .../Importer/MjImporterEditorWindow.cs.meta | 13 + unity/Editor/Importer/MjImporterWithAssets.cs | 287 ++ .../Importer/MjImporterWithAssets.cs.meta | 13 + unity/Editor/Importer/StlMeshImporter.cs | 36 + unity/Editor/Importer/StlMeshImporter.cs.meta | 13 + unity/Editor/Importer/StlMeshParser.cs | 127 + unity/Editor/Importer/StlMeshParser.cs.meta | 13 + unity/Editor/Mujoco.Editor.asmdef | 16 + unity/Editor/Mujoco.Editor.asmdef.meta | 7 + unity/README.md | 8 + unity/README.md.meta | 7 + unity/Runtime.meta | 8 + unity/Runtime/Bindings.meta | 8 + .../Runtime/Bindings/FixedSizeIListHelper.cs | 84 + .../Bindings/FixedSizeIListHelper.cs.meta | 13 + .../Runtime/Bindings/MujocoBinaryRetriever.cs | 47 + .../Bindings/MujocoBinaryRetriever.cs.meta | 11 + unity/Runtime/Bindings/MujocoBindings.cs | 3374 +++++++++++++++++ unity/Runtime/Bindings/MujocoBindings.cs.meta | 11 + unity/Runtime/Components.meta | 8 + unity/Runtime/Components/IMjShape.cs | 46 + unity/Runtime/Components/IMjShape.cs.meta | 13 + unity/Runtime/Components/MeshGenerators.cs | 360 ++ .../Runtime/Components/MeshGenerators.cs.meta | 13 + unity/Runtime/Components/MjActuator.cs | 394 ++ unity/Runtime/Components/MjActuator.cs.meta | 13 + .../Components/MjActuatorScalarSensor.cs | 54 + .../Components/MjActuatorScalarSensor.cs.meta | 13 + unity/Runtime/Components/MjBallJoint.cs | 52 + unity/Runtime/Components/MjBallJoint.cs.meta | 13 + unity/Runtime/Components/MjBaseBody.cs | 24 + unity/Runtime/Components/MjBaseBody.cs.meta | 13 + unity/Runtime/Components/MjBaseConstraint.cs | 47 + .../Components/MjBaseConstraint.cs.meta | 13 + unity/Runtime/Components/MjBaseJoint.cs | 63 + unity/Runtime/Components/MjBaseJoint.cs.meta | 13 + unity/Runtime/Components/MjBaseSensor.cs | 80 + unity/Runtime/Components/MjBaseSensor.cs.meta | 13 + unity/Runtime/Components/MjBaseTendon.cs | 65 + unity/Runtime/Components/MjBaseTendon.cs.meta | 13 + unity/Runtime/Components/MjBody.cs | 42 + unity/Runtime/Components/MjBody.cs.meta | 13 + .../Components/MjBodyQuaternionSensor.cs | 52 + .../Components/MjBodyQuaternionSensor.cs.meta | 13 + .../Runtime/Components/MjBodyVectorSensor.cs | 77 + .../Components/MjBodyVectorSensor.cs.meta | 13 + unity/Runtime/Components/MjBoxShape.cs | 55 + unity/Runtime/Components/MjBoxShape.cs.meta | 13 + unity/Runtime/Components/MjCapsuleShape.cs | 63 + .../Runtime/Components/MjCapsuleShape.cs.meta | 13 + unity/Runtime/Components/MjComponent.cs | 108 + unity/Runtime/Components/MjComponent.cs.meta | 13 + unity/Runtime/Components/MjConnect.cs | 51 + unity/Runtime/Components/MjConnect.cs.meta | 13 + unity/Runtime/Components/MjCylinderShape.cs | 63 + .../Components/MjCylinderShape.cs.meta | 13 + unity/Runtime/Components/MjDistance.cs | 48 + unity/Runtime/Components/MjDistance.cs.meta | 13 + unity/Runtime/Components/MjEllipsoidShape.cs | 58 + .../Components/MjEllipsoidShape.cs.meta | 13 + unity/Runtime/Components/MjExclude.cs | 54 + unity/Runtime/Components/MjExclude.cs.meta | 13 + unity/Runtime/Components/MjFixedTendon.cs | 81 + .../Runtime/Components/MjFixedTendon.cs.meta | 13 + unity/Runtime/Components/MjFreeJoint.cs | 29 + unity/Runtime/Components/MjFreeJoint.cs.meta | 13 + unity/Runtime/Components/MjGeom.cs | 96 + unity/Runtime/Components/MjGeom.cs.meta | 13 + .../Components/MjGeomQuaternionSensor.cs | 47 + .../Components/MjGeomQuaternionSensor.cs.meta | 13 + unity/Runtime/Components/MjGeomSettings.cs | 148 + .../Runtime/Components/MjGeomSettings.cs.meta | 13 + .../Runtime/Components/MjGeomVectorSensor.cs | 63 + .../Components/MjGeomVectorSensor.cs.meta | 13 + unity/Runtime/Components/MjGizmos.cs | 116 + unity/Runtime/Components/MjGizmos.cs.meta | 13 + unity/Runtime/Components/MjGlobalSettings.cs | 378 ++ .../Components/MjGlobalSettings.cs.meta | 13 + unity/Runtime/Components/MjHingeJoint.cs | 88 + unity/Runtime/Components/MjHingeJoint.cs.meta | 13 + unity/Runtime/Components/MjInertial.cs | 64 + unity/Runtime/Components/MjInertial.cs.meta | 13 + unity/Runtime/Components/MjJointConstraint.cs | 59 + .../Components/MjJointConstraint.cs.meta | 13 + .../Runtime/Components/MjJointScalarSensor.cs | 56 + .../Components/MjJointScalarSensor.cs.meta | 13 + unity/Runtime/Components/MjJointSettings.cs | 171 + .../Components/MjJointSettings.cs.meta | 13 + unity/Runtime/Components/MjMeshFilter.cs | 78 + unity/Runtime/Components/MjMeshFilter.cs.meta | 13 + unity/Runtime/Components/MjMeshShape.cs | 56 + unity/Runtime/Components/MjMeshShape.cs.meta | 13 + unity/Runtime/Components/MjMocapBody.cs | 42 + unity/Runtime/Components/MjMocapBody.cs.meta | 13 + unity/Runtime/Components/MjPlaneShape.cs | 50 + unity/Runtime/Components/MjPlaneShape.cs.meta | 13 + unity/Runtime/Components/MjScene.cs | 451 +++ unity/Runtime/Components/MjScene.cs.meta | 13 + unity/Runtime/Components/MjShapeComponent.cs | 92 + .../Components/MjShapeComponent.cs.meta | 13 + unity/Runtime/Components/MjSite.cs | 52 + unity/Runtime/Components/MjSite.cs.meta | 13 + .../Components/MjSiteQuaternionSensor.cs | 49 + .../Components/MjSiteQuaternionSensor.cs.meta | 13 + .../Runtime/Components/MjSiteScalarSensor.cs | 54 + .../Components/MjSiteScalarSensor.cs.meta | 13 + .../Runtime/Components/MjSiteVectorSensor.cs | 75 + .../Components/MjSiteVectorSensor.cs.meta | 13 + unity/Runtime/Components/MjSlideJoint.cs | 85 + unity/Runtime/Components/MjSlideJoint.cs.meta | 13 + unity/Runtime/Components/MjSpatialTendon.cs | 131 + .../Components/MjSpatialTendon.cs.meta | 13 + unity/Runtime/Components/MjSphereShape.cs | 55 + .../Runtime/Components/MjSphereShape.cs.meta | 13 + .../Runtime/Components/MjTendonConstraint.cs | 57 + .../Components/MjTendonConstraint.cs.meta | 13 + unity/Runtime/Components/MjWeld.cs | 61 + unity/Runtime/Components/MjWeld.cs.meta | 13 + unity/Runtime/Importer.meta | 8 + unity/Runtime/Importer/MjXmlModifiers.cs | 115 + unity/Runtime/Importer/MjXmlModifiers.cs.meta | 11 + unity/Runtime/Importer/MjcfImporter.cs | 435 +++ unity/Runtime/Importer/MjcfImporter.cs.meta | 11 + unity/Runtime/Mujoco.asmdef | 14 + unity/Runtime/Mujoco.asmdef.meta | 7 + unity/Runtime/Resources.meta | 8 + .../mujoco_semitransparent_template.mat | 77 + .../mujoco_semitransparent_template.mat.meta | 8 + unity/Runtime/Tools.meta | 8 + unity/Runtime/Tools/AbsoluteValueAttribute.cs | 24 + .../Tools/AbsoluteValueAttribute.cs.meta | 13 + unity/Runtime/Tools/MjEngineTool.cs | 361 ++ unity/Runtime/Tools/MjEngineTool.cs.meta | 13 + unity/Runtime/Tools/MjHierarchyTool.cs | 87 + unity/Runtime/Tools/MjHierarchyTool.cs.meta | 13 + unity/Runtime/Tools/MjTransformation.cs | 84 + unity/Runtime/Tools/MjTransformation.cs.meta | 13 + unity/Runtime/Tools/MjVfs.cs | 119 + unity/Runtime/Tools/MjVfs.cs.meta | 13 + unity/Runtime/Tools/MjcfGenerationContext.cs | 104 + .../Tools/MjcfGenerationContext.cs.meta | 13 + unity/Runtime/Tools/XmlElementExtensions.cs | 167 + .../Tools/XmlElementExtensions.cs.meta | 13 + unity/Tests.meta | 8 + unity/Tests/Editor.meta | 8 + unity/Tests/Editor/Mujoco.Editor.Tests.asmdef | 25 + .../Editor/Mujoco.Editor.Tests.asmdef.meta | 7 + unity/Tests/Editor/bindings.meta | 8 + .../bindings/FixedSizeIListHelperTests.cs | 171 + .../FixedSizeIListHelperTests.cs.meta | 13 + unity/Tests/Editor/components.meta | 8 + unity/Tests/Editor/components/Bodies.meta | 8 + .../Editor/components/Bodies/MjBodyTests.cs | 88 + .../components/Bodies/MjBodyTests.cs.meta | 13 + unity/Tests/Editor/components/Equality.meta | 8 + .../components/Equality/MjConnectTests.cs | 80 + .../Equality/MjConnectTests.cs.meta | 13 + .../components/Equality/MjDistanceTests.cs | 74 + .../Equality/MjDistanceTests.cs.meta | 13 + .../Equality/MjJointConstraintTests.cs | 69 + .../Equality/MjJointConstraintTests.cs.meta | 13 + .../Equality/MjTendonConstraintTests.cs | 69 + .../Equality/MjTendonConstraintTests.cs.meta | 13 + .../Editor/components/Equality/MjWeldTests.cs | 80 + .../components/Equality/MjWeldTests.cs.meta | 13 + unity/Tests/Editor/components/Joints.meta | 8 + .../components/Joints/MjBallJointTests.cs | 74 + .../Joints/MjBallJointTests.cs.meta | 13 + .../components/Joints/MjBaseJointTests.cs | 77 + .../Joints/MjBaseJointTests.cs.meta | 13 + .../components/Joints/MjHingeJointTests.cs | 102 + .../Joints/MjHingeJointTests.cs.meta | 13 + .../components/Joints/MjJointSettingsTests.cs | 223 ++ .../Joints/MjJointSettingsTests.cs.meta | 13 + .../components/Joints/MjSlideJointTests.cs | 102 + .../Joints/MjSlideJointTests.cs.meta | 13 + .../Editor/components/MjActuatorTests.cs | 559 +++ .../Editor/components/MjActuatorTests.cs.meta | 13 + .../Tests/Editor/components/MjExcludeTests.cs | 54 + .../Editor/components/MjExcludeTests.cs.meta | 13 + .../Editor/components/MjGeomSettingsTests.cs | 203 + .../components/MjGeomSettingsTests.cs.meta | 13 + unity/Tests/Editor/components/MjGeomTests.cs | 207 + .../Editor/components/MjGeomTests.cs.meta | 13 + .../components/MjGlobalSettingsTests.cs | 197 + .../components/MjGlobalSettingsTests.cs.meta | 13 + .../Editor/components/MjInertialTests.cs | 57 + .../Editor/components/MjInertialTests.cs.meta | 13 + unity/Tests/Editor/components/MjSceneTests.cs | 215 ++ .../Editor/components/MjSceneTests.cs.meta | 13 + unity/Tests/Editor/components/MjSiteTests.cs | 65 + .../Editor/components/MjSiteTests.cs.meta | 13 + .../components/MjcfGenerationContextTests.cs | 144 + .../MjcfGenerationContextTests.cs.meta | 13 + unity/Tests/Editor/components/Sensors.meta | 8 + .../Sensors/MjActuatorScalarSensorTests.cs | 108 + .../MjActuatorScalarSensorTests.cs.meta | 13 + .../components/Sensors/MjBaseSensorTests.cs | 72 + .../Sensors/MjBaseSensorTests.cs.meta | 13 + .../Sensors/MjBodyQuaternionSensorTests.cs | 91 + .../MjBodyQuaternionSensorTests.cs.meta | 13 + .../Sensors/MjBodyVectorSensorTests.cs | 176 + .../Sensors/MjBodyVectorSensorTests.cs.meta | 13 + .../Sensors/MjGeomQuaternionSensorTests.cs | 88 + .../MjGeomQuaternionSensorTests.cs.meta | 13 + .../Sensors/MjGeomVectorSensorTests.cs | 134 + .../Sensors/MjGeomVectorSensorTests.cs.meta | 13 + .../Sensors/MjJointScalarSensorTests.cs | 113 + .../Sensors/MjJointScalarSensorTests.cs.meta | 13 + .../Sensors/MjSiteQuaternionSensorTests.cs | 84 + .../MjSiteQuaternionSensorTests.cs.meta | 13 + .../Sensors/MjSiteScalarSensorTests.cs | 101 + .../Sensors/MjSiteScalarSensorTests.cs.meta | 13 + .../Sensors/MjSiteVectorSensorTests.cs | 173 + .../Sensors/MjSiteVectorSensorTests.cs.meta | 13 + unity/Tests/Editor/components/Shapes.meta | 8 + .../components/Shapes/MeshGeneratorsTests.cs | 174 + .../Shapes/MeshGeneratorsTests.cs.meta | 11 + .../components/Shapes/MjBoxShapeTests.cs | 104 + .../components/Shapes/MjBoxShapeTests.cs.meta | 13 + .../components/Shapes/MjCapsuleShapeTests.cs | 96 + .../Shapes/MjCapsuleShapeTests.cs.meta | 13 + .../components/Shapes/MjCylinderShapeTests.cs | 96 + .../Shapes/MjCylinderShapeTests.cs.meta | 13 + .../Shapes/MjEllipsoidShapeTests.cs | 104 + .../Shapes/MjEllipsoidShapeTests.cs.meta | 13 + .../Editor/components/Shapes/MjGizmosTests.cs | 270 ++ .../components/Shapes/MjGizmosTests.cs.meta | 13 + .../components/Shapes/MjPlaneShapeTests.cs | 78 + .../Shapes/MjPlaneShapeTests.cs.meta | 13 + .../components/Shapes/MjSphereShapeTests.cs | 72 + .../Shapes/MjSphereShapeTests.cs.meta | 13 + unity/Tests/Editor/components/Tendons.meta | 8 + .../components/Tendons/MjFixedTendonTests.cs | 60 + .../Tendons/MjFixedTendonTests.cs.meta | 13 + .../Tendons/MjSpatialTendonTests.cs | 56 + .../Tendons/MjSpatialTendonTests.cs.meta | 11 + unity/Tests/Editor/importer.meta | 8 + .../Tests/Editor/importer/MjImporterTests.cs | 185 + .../Editor/importer/MjImporterTests.cs.meta | 13 + .../Editor/importer/MjStlMeshParserTests.cs | 97 + .../importer/MjStlMeshParserTests.cs.meta | 13 + .../Editor/importer/MjXmlModifiersTests.cs | 256 ++ .../importer/MjXmlModifiersTests.cs.meta | 13 + .../Editor/importer/MjcfImporterTests.cs | 346 ++ .../Editor/importer/MjcfImporterTests.cs.meta | 11 + unity/Tests/Editor/tools.meta | 8 + .../Tests/Editor/tools/HierarchyToolTests.cs | 239 ++ .../Editor/tools/HierarchyToolTests.cs.meta | 13 + unity/Tests/Editor/tools/MjEngineTests.cs | 392 ++ .../Tests/Editor/tools/MjEngineTests.cs.meta | 13 + .../Editor/tools/MjTransformationTests.cs | 159 + .../tools/MjTransformationTests.cs.meta | 13 + unity/Tests/Editor/tools/MjVFSEditorTests.cs | 62 + .../Editor/tools/MjVFSEditorTests.cs.meta | 13 + unity/Tests/Editor/tools/Resources.meta | 8 + .../Editor/tools/Resources/ValidModel.xml | 30 + .../tools/Resources/ValidModel.xml.meta | 7 + .../Editor/tools/XmlElementExtensionsTests.cs | 193 + .../tools/XmlElementExtensionsTests.cs.meta | 13 + unity/Tests/Runtime.meta | 8 + unity/Tests/Runtime/MjJointTests.cs | 78 + unity/Tests/Runtime/MjJointTests.cs.meta | 11 + unity/Tests/Runtime/MjMeshFilterTests.cs | 65 + unity/Tests/Runtime/MjMeshFilterTests.cs.meta | 13 + unity/Tests/Runtime/MjScenePlayTests.cs | 106 + unity/Tests/Runtime/MjScenePlayTests.cs.meta | 11 + unity/Tests/Runtime/MjSitePlayTests.cs | 67 + unity/Tests/Runtime/MjSitePlayTests.cs.meta | 13 + unity/Tests/Runtime/Mujoco.Tests.asmdef | 21 + unity/Tests/Runtime/Mujoco.Tests.asmdef.meta | 7 + unity/package.json | 16 + unity/package.json.meta | 7 + 298 files changed, 20617 insertions(+), 2 deletions(-) create mode 100644 doc/unity.rst create mode 100644 unity/CHANGELOG.md create mode 100644 unity/CHANGELOG.md.meta create mode 100644 unity/Editor.meta create mode 100644 unity/Editor/Components.meta create mode 100644 unity/Editor/Components/AbsoluteValuePropertyEditor.cs create mode 100644 unity/Editor/Components/AbsoluteValuePropertyEditor.cs.meta create mode 100644 unity/Editor/Components/MjActuatorEditor.cs create mode 100644 unity/Editor/Components/MjActuatorEditor.cs.meta create mode 100644 unity/Editor/Components/MjGeomEditor.cs create mode 100644 unity/Editor/Components/MjGeomEditor.cs.meta create mode 100644 unity/Editor/Components/MjHandles.cs create mode 100644 unity/Editor/Components/MjHandles.cs.meta create mode 100644 unity/Editor/Components/MjHingeJointEditor.cs create mode 100644 unity/Editor/Components/MjHingeJointEditor.cs.meta create mode 100644 unity/Editor/Components/MjMouseSpring.cs create mode 100644 unity/Editor/Components/MjMouseSpring.cs.meta create mode 100644 unity/Editor/Components/MjShapeComponentEditor.cs create mode 100644 unity/Editor/Components/MjShapeComponentEditor.cs.meta create mode 100644 unity/Editor/Components/MjSlideJointEditor.cs create mode 100644 unity/Editor/Components/MjSlideJointEditor.cs.meta create mode 100644 unity/Editor/Importer.meta create mode 100644 unity/Editor/Importer/MjImporterEditorWindow.cs create mode 100644 unity/Editor/Importer/MjImporterEditorWindow.cs.meta create mode 100644 unity/Editor/Importer/MjImporterWithAssets.cs create mode 100644 unity/Editor/Importer/MjImporterWithAssets.cs.meta create mode 100644 unity/Editor/Importer/StlMeshImporter.cs create mode 100644 unity/Editor/Importer/StlMeshImporter.cs.meta create mode 100644 unity/Editor/Importer/StlMeshParser.cs create mode 100644 unity/Editor/Importer/StlMeshParser.cs.meta create mode 100644 unity/Editor/Mujoco.Editor.asmdef create mode 100644 unity/Editor/Mujoco.Editor.asmdef.meta create mode 100644 unity/README.md create mode 100644 unity/README.md.meta create mode 100644 unity/Runtime.meta create mode 100644 unity/Runtime/Bindings.meta create mode 100644 unity/Runtime/Bindings/FixedSizeIListHelper.cs create mode 100644 unity/Runtime/Bindings/FixedSizeIListHelper.cs.meta create mode 100644 unity/Runtime/Bindings/MujocoBinaryRetriever.cs create mode 100644 unity/Runtime/Bindings/MujocoBinaryRetriever.cs.meta create mode 100644 unity/Runtime/Bindings/MujocoBindings.cs create mode 100644 unity/Runtime/Bindings/MujocoBindings.cs.meta create mode 100644 unity/Runtime/Components.meta create mode 100644 unity/Runtime/Components/IMjShape.cs create mode 100644 unity/Runtime/Components/IMjShape.cs.meta create mode 100644 unity/Runtime/Components/MeshGenerators.cs create mode 100644 unity/Runtime/Components/MeshGenerators.cs.meta create mode 100644 unity/Runtime/Components/MjActuator.cs create mode 100644 unity/Runtime/Components/MjActuator.cs.meta create mode 100644 unity/Runtime/Components/MjActuatorScalarSensor.cs create mode 100644 unity/Runtime/Components/MjActuatorScalarSensor.cs.meta create mode 100644 unity/Runtime/Components/MjBallJoint.cs create mode 100644 unity/Runtime/Components/MjBallJoint.cs.meta create mode 100644 unity/Runtime/Components/MjBaseBody.cs create mode 100644 unity/Runtime/Components/MjBaseBody.cs.meta create mode 100644 unity/Runtime/Components/MjBaseConstraint.cs create mode 100644 unity/Runtime/Components/MjBaseConstraint.cs.meta create mode 100644 unity/Runtime/Components/MjBaseJoint.cs create mode 100644 unity/Runtime/Components/MjBaseJoint.cs.meta create mode 100644 unity/Runtime/Components/MjBaseSensor.cs create mode 100644 unity/Runtime/Components/MjBaseSensor.cs.meta create mode 100644 unity/Runtime/Components/MjBaseTendon.cs create mode 100644 unity/Runtime/Components/MjBaseTendon.cs.meta create mode 100644 unity/Runtime/Components/MjBody.cs create mode 100644 unity/Runtime/Components/MjBody.cs.meta create mode 100644 unity/Runtime/Components/MjBodyQuaternionSensor.cs create mode 100644 unity/Runtime/Components/MjBodyQuaternionSensor.cs.meta create mode 100644 unity/Runtime/Components/MjBodyVectorSensor.cs create mode 100644 unity/Runtime/Components/MjBodyVectorSensor.cs.meta create mode 100644 unity/Runtime/Components/MjBoxShape.cs create mode 100644 unity/Runtime/Components/MjBoxShape.cs.meta create mode 100644 unity/Runtime/Components/MjCapsuleShape.cs create mode 100644 unity/Runtime/Components/MjCapsuleShape.cs.meta create mode 100644 unity/Runtime/Components/MjComponent.cs create mode 100644 unity/Runtime/Components/MjComponent.cs.meta create mode 100644 unity/Runtime/Components/MjConnect.cs create mode 100644 unity/Runtime/Components/MjConnect.cs.meta create mode 100644 unity/Runtime/Components/MjCylinderShape.cs create mode 100644 unity/Runtime/Components/MjCylinderShape.cs.meta create mode 100644 unity/Runtime/Components/MjDistance.cs create mode 100644 unity/Runtime/Components/MjDistance.cs.meta create mode 100644 unity/Runtime/Components/MjEllipsoidShape.cs create mode 100644 unity/Runtime/Components/MjEllipsoidShape.cs.meta create mode 100644 unity/Runtime/Components/MjExclude.cs create mode 100644 unity/Runtime/Components/MjExclude.cs.meta create mode 100644 unity/Runtime/Components/MjFixedTendon.cs create mode 100644 unity/Runtime/Components/MjFixedTendon.cs.meta create mode 100644 unity/Runtime/Components/MjFreeJoint.cs create mode 100644 unity/Runtime/Components/MjFreeJoint.cs.meta create mode 100644 unity/Runtime/Components/MjGeom.cs create mode 100644 unity/Runtime/Components/MjGeom.cs.meta create mode 100644 unity/Runtime/Components/MjGeomQuaternionSensor.cs create mode 100644 unity/Runtime/Components/MjGeomQuaternionSensor.cs.meta create mode 100644 unity/Runtime/Components/MjGeomSettings.cs create mode 100644 unity/Runtime/Components/MjGeomSettings.cs.meta create mode 100644 unity/Runtime/Components/MjGeomVectorSensor.cs create mode 100644 unity/Runtime/Components/MjGeomVectorSensor.cs.meta create mode 100644 unity/Runtime/Components/MjGizmos.cs create mode 100644 unity/Runtime/Components/MjGizmos.cs.meta create mode 100644 unity/Runtime/Components/MjGlobalSettings.cs create mode 100644 unity/Runtime/Components/MjGlobalSettings.cs.meta create mode 100644 unity/Runtime/Components/MjHingeJoint.cs create mode 100644 unity/Runtime/Components/MjHingeJoint.cs.meta create mode 100644 unity/Runtime/Components/MjInertial.cs create mode 100644 unity/Runtime/Components/MjInertial.cs.meta create mode 100644 unity/Runtime/Components/MjJointConstraint.cs create mode 100644 unity/Runtime/Components/MjJointConstraint.cs.meta create mode 100644 unity/Runtime/Components/MjJointScalarSensor.cs create mode 100644 unity/Runtime/Components/MjJointScalarSensor.cs.meta create mode 100644 unity/Runtime/Components/MjJointSettings.cs create mode 100644 unity/Runtime/Components/MjJointSettings.cs.meta create mode 100644 unity/Runtime/Components/MjMeshFilter.cs create mode 100644 unity/Runtime/Components/MjMeshFilter.cs.meta create mode 100644 unity/Runtime/Components/MjMeshShape.cs create mode 100644 unity/Runtime/Components/MjMeshShape.cs.meta create mode 100644 unity/Runtime/Components/MjMocapBody.cs create mode 100644 unity/Runtime/Components/MjMocapBody.cs.meta create mode 100644 unity/Runtime/Components/MjPlaneShape.cs create mode 100644 unity/Runtime/Components/MjPlaneShape.cs.meta create mode 100644 unity/Runtime/Components/MjScene.cs create mode 100644 unity/Runtime/Components/MjScene.cs.meta create mode 100644 unity/Runtime/Components/MjShapeComponent.cs create mode 100644 unity/Runtime/Components/MjShapeComponent.cs.meta create mode 100644 unity/Runtime/Components/MjSite.cs create mode 100644 unity/Runtime/Components/MjSite.cs.meta create mode 100644 unity/Runtime/Components/MjSiteQuaternionSensor.cs create mode 100644 unity/Runtime/Components/MjSiteQuaternionSensor.cs.meta create mode 100644 unity/Runtime/Components/MjSiteScalarSensor.cs create mode 100644 unity/Runtime/Components/MjSiteScalarSensor.cs.meta create mode 100644 unity/Runtime/Components/MjSiteVectorSensor.cs create mode 100644 unity/Runtime/Components/MjSiteVectorSensor.cs.meta create mode 100644 unity/Runtime/Components/MjSlideJoint.cs create mode 100644 unity/Runtime/Components/MjSlideJoint.cs.meta create mode 100644 unity/Runtime/Components/MjSpatialTendon.cs create mode 100644 unity/Runtime/Components/MjSpatialTendon.cs.meta create mode 100644 unity/Runtime/Components/MjSphereShape.cs create mode 100644 unity/Runtime/Components/MjSphereShape.cs.meta create mode 100644 unity/Runtime/Components/MjTendonConstraint.cs create mode 100644 unity/Runtime/Components/MjTendonConstraint.cs.meta create mode 100644 unity/Runtime/Components/MjWeld.cs create mode 100644 unity/Runtime/Components/MjWeld.cs.meta create mode 100644 unity/Runtime/Importer.meta create mode 100644 unity/Runtime/Importer/MjXmlModifiers.cs create mode 100644 unity/Runtime/Importer/MjXmlModifiers.cs.meta create mode 100644 unity/Runtime/Importer/MjcfImporter.cs create mode 100644 unity/Runtime/Importer/MjcfImporter.cs.meta create mode 100644 unity/Runtime/Mujoco.asmdef create mode 100644 unity/Runtime/Mujoco.asmdef.meta create mode 100644 unity/Runtime/Resources.meta create mode 100644 unity/Runtime/Resources/mujoco_semitransparent_template.mat create mode 100644 unity/Runtime/Resources/mujoco_semitransparent_template.mat.meta create mode 100644 unity/Runtime/Tools.meta create mode 100644 unity/Runtime/Tools/AbsoluteValueAttribute.cs create mode 100644 unity/Runtime/Tools/AbsoluteValueAttribute.cs.meta create mode 100644 unity/Runtime/Tools/MjEngineTool.cs create mode 100644 unity/Runtime/Tools/MjEngineTool.cs.meta create mode 100644 unity/Runtime/Tools/MjHierarchyTool.cs create mode 100644 unity/Runtime/Tools/MjHierarchyTool.cs.meta create mode 100644 unity/Runtime/Tools/MjTransformation.cs create mode 100644 unity/Runtime/Tools/MjTransformation.cs.meta create mode 100644 unity/Runtime/Tools/MjVfs.cs create mode 100644 unity/Runtime/Tools/MjVfs.cs.meta create mode 100644 unity/Runtime/Tools/MjcfGenerationContext.cs create mode 100644 unity/Runtime/Tools/MjcfGenerationContext.cs.meta create mode 100644 unity/Runtime/Tools/XmlElementExtensions.cs create mode 100644 unity/Runtime/Tools/XmlElementExtensions.cs.meta create mode 100644 unity/Tests.meta create mode 100644 unity/Tests/Editor.meta create mode 100644 unity/Tests/Editor/Mujoco.Editor.Tests.asmdef create mode 100644 unity/Tests/Editor/Mujoco.Editor.Tests.asmdef.meta create mode 100644 unity/Tests/Editor/bindings.meta create mode 100644 unity/Tests/Editor/bindings/FixedSizeIListHelperTests.cs create mode 100644 unity/Tests/Editor/bindings/FixedSizeIListHelperTests.cs.meta create mode 100644 unity/Tests/Editor/components.meta create mode 100644 unity/Tests/Editor/components/Bodies.meta create mode 100644 unity/Tests/Editor/components/Bodies/MjBodyTests.cs create mode 100644 unity/Tests/Editor/components/Bodies/MjBodyTests.cs.meta create mode 100644 unity/Tests/Editor/components/Equality.meta create mode 100644 unity/Tests/Editor/components/Equality/MjConnectTests.cs create mode 100644 unity/Tests/Editor/components/Equality/MjConnectTests.cs.meta create mode 100644 unity/Tests/Editor/components/Equality/MjDistanceTests.cs create mode 100644 unity/Tests/Editor/components/Equality/MjDistanceTests.cs.meta create mode 100644 unity/Tests/Editor/components/Equality/MjJointConstraintTests.cs create mode 100644 unity/Tests/Editor/components/Equality/MjJointConstraintTests.cs.meta create mode 100644 unity/Tests/Editor/components/Equality/MjTendonConstraintTests.cs create mode 100644 unity/Tests/Editor/components/Equality/MjTendonConstraintTests.cs.meta create mode 100644 unity/Tests/Editor/components/Equality/MjWeldTests.cs create mode 100644 unity/Tests/Editor/components/Equality/MjWeldTests.cs.meta create mode 100644 unity/Tests/Editor/components/Joints.meta create mode 100644 unity/Tests/Editor/components/Joints/MjBallJointTests.cs create mode 100644 unity/Tests/Editor/components/Joints/MjBallJointTests.cs.meta create mode 100644 unity/Tests/Editor/components/Joints/MjBaseJointTests.cs create mode 100644 unity/Tests/Editor/components/Joints/MjBaseJointTests.cs.meta create mode 100644 unity/Tests/Editor/components/Joints/MjHingeJointTests.cs create mode 100644 unity/Tests/Editor/components/Joints/MjHingeJointTests.cs.meta create mode 100644 unity/Tests/Editor/components/Joints/MjJointSettingsTests.cs create mode 100644 unity/Tests/Editor/components/Joints/MjJointSettingsTests.cs.meta create mode 100644 unity/Tests/Editor/components/Joints/MjSlideJointTests.cs create mode 100644 unity/Tests/Editor/components/Joints/MjSlideJointTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjActuatorTests.cs create mode 100644 unity/Tests/Editor/components/MjActuatorTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjExcludeTests.cs create mode 100644 unity/Tests/Editor/components/MjExcludeTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjGeomSettingsTests.cs create mode 100644 unity/Tests/Editor/components/MjGeomSettingsTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjGeomTests.cs create mode 100644 unity/Tests/Editor/components/MjGeomTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjGlobalSettingsTests.cs create mode 100644 unity/Tests/Editor/components/MjGlobalSettingsTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjInertialTests.cs create mode 100644 unity/Tests/Editor/components/MjInertialTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjSceneTests.cs create mode 100644 unity/Tests/Editor/components/MjSceneTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjSiteTests.cs create mode 100644 unity/Tests/Editor/components/MjSiteTests.cs.meta create mode 100644 unity/Tests/Editor/components/MjcfGenerationContextTests.cs create mode 100644 unity/Tests/Editor/components/MjcfGenerationContextTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjActuatorScalarSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjActuatorScalarSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjBaseSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjBaseSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjBodyQuaternionSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjBodyQuaternionSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjBodyVectorSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjBodyVectorSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjGeomQuaternionSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjGeomQuaternionSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjGeomVectorSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjGeomVectorSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjJointScalarSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjJointScalarSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjSiteQuaternionSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjSiteQuaternionSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjSiteScalarSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjSiteScalarSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Sensors/MjSiteVectorSensorTests.cs create mode 100644 unity/Tests/Editor/components/Sensors/MjSiteVectorSensorTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes.meta create mode 100644 unity/Tests/Editor/components/Shapes/MeshGeneratorsTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MeshGeneratorsTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes/MjBoxShapeTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MjBoxShapeTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes/MjCapsuleShapeTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MjCapsuleShapeTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes/MjCylinderShapeTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MjCylinderShapeTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes/MjEllipsoidShapeTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MjEllipsoidShapeTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes/MjGizmosTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MjGizmosTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes/MjPlaneShapeTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MjPlaneShapeTests.cs.meta create mode 100644 unity/Tests/Editor/components/Shapes/MjSphereShapeTests.cs create mode 100644 unity/Tests/Editor/components/Shapes/MjSphereShapeTests.cs.meta create mode 100644 unity/Tests/Editor/components/Tendons.meta create mode 100644 unity/Tests/Editor/components/Tendons/MjFixedTendonTests.cs create mode 100644 unity/Tests/Editor/components/Tendons/MjFixedTendonTests.cs.meta create mode 100644 unity/Tests/Editor/components/Tendons/MjSpatialTendonTests.cs create mode 100644 unity/Tests/Editor/components/Tendons/MjSpatialTendonTests.cs.meta create mode 100644 unity/Tests/Editor/importer.meta create mode 100644 unity/Tests/Editor/importer/MjImporterTests.cs create mode 100644 unity/Tests/Editor/importer/MjImporterTests.cs.meta create mode 100644 unity/Tests/Editor/importer/MjStlMeshParserTests.cs create mode 100644 unity/Tests/Editor/importer/MjStlMeshParserTests.cs.meta create mode 100644 unity/Tests/Editor/importer/MjXmlModifiersTests.cs create mode 100644 unity/Tests/Editor/importer/MjXmlModifiersTests.cs.meta create mode 100644 unity/Tests/Editor/importer/MjcfImporterTests.cs create mode 100644 unity/Tests/Editor/importer/MjcfImporterTests.cs.meta create mode 100644 unity/Tests/Editor/tools.meta create mode 100644 unity/Tests/Editor/tools/HierarchyToolTests.cs create mode 100644 unity/Tests/Editor/tools/HierarchyToolTests.cs.meta create mode 100644 unity/Tests/Editor/tools/MjEngineTests.cs create mode 100644 unity/Tests/Editor/tools/MjEngineTests.cs.meta create mode 100644 unity/Tests/Editor/tools/MjTransformationTests.cs create mode 100644 unity/Tests/Editor/tools/MjTransformationTests.cs.meta create mode 100644 unity/Tests/Editor/tools/MjVFSEditorTests.cs create mode 100644 unity/Tests/Editor/tools/MjVFSEditorTests.cs.meta create mode 100644 unity/Tests/Editor/tools/Resources.meta create mode 100644 unity/Tests/Editor/tools/Resources/ValidModel.xml create mode 100644 unity/Tests/Editor/tools/Resources/ValidModel.xml.meta create mode 100644 unity/Tests/Editor/tools/XmlElementExtensionsTests.cs create mode 100644 unity/Tests/Editor/tools/XmlElementExtensionsTests.cs.meta create mode 100644 unity/Tests/Runtime.meta create mode 100644 unity/Tests/Runtime/MjJointTests.cs create mode 100644 unity/Tests/Runtime/MjJointTests.cs.meta create mode 100644 unity/Tests/Runtime/MjMeshFilterTests.cs create mode 100644 unity/Tests/Runtime/MjMeshFilterTests.cs.meta create mode 100644 unity/Tests/Runtime/MjScenePlayTests.cs create mode 100644 unity/Tests/Runtime/MjScenePlayTests.cs.meta create mode 100644 unity/Tests/Runtime/MjSitePlayTests.cs create mode 100644 unity/Tests/Runtime/MjSitePlayTests.cs.meta create mode 100644 unity/Tests/Runtime/Mujoco.Tests.asmdef create mode 100644 unity/Tests/Runtime/Mujoco.Tests.asmdef.meta create mode 100644 unity/package.json create mode 100644 unity/package.json.meta diff --git a/doc/index.rst b/doc/index.rst index d803f114..84852306 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -13,4 +13,5 @@ XMLreference programming APIreference + unity changelog diff --git a/doc/unity.rst b/doc/unity.rst new file mode 100644 index 00000000..09c45bdb --- /dev/null +++ b/doc/unity.rst @@ -0,0 +1,333 @@ +============= +Unity Plug-in +============= + +Introduction +------------ + +The MuJoCo `Unity plug-in `_ allows the Unity Editor and runtime to use the MuJoCo physics engine. Users can import MJCF +files and edit the models in the Editor. The plug-in relies on Unity for most aspects -- assets, game logic, simulation +time -- but uses MuJoCo to determine how objects move, giving the designer access to MuJoCo's full API. + +.. _UInstallation: + +Installation instructions +------------------------- + +The plug-in directory (available at https://github.com/deepmind/mujoco/tree/main/unity) includes a ``package.json`` +file. Unity's package manager recognizes this file and will import the plug-in's C# codebase to your project. In +addition, Unity also needs the native MuJoCo library, which can be found in the specific platfomr archive at +https://github.com/deepmind/mujoco/release. + +On Unity version 2020.2 and later, the Package Manager will look for the native library file and copy it to the package +directory when the package is imported. Alternatively, you can manually copy the native library to the package directory +and rename it, see platform-specific instructions below. The library can also be copied into any location under your +project's Assets directory. + +MacOS +_____ + +The MuJoCo app needs to be run at least once before the native library can be used, in order to register the library as +a trusted binary. Then, copy the dynamic library file from +``/Applications/MuJoCo.app/Contents/Frameworks/MuJoCo.framework/Versions/Current/libmujoco.2.1.1.dylib`` (it can be +found by browsing the contents of ``MuJoCo.app``) and rename it as ``mujoco.dylib``. + +Linux +_____ + +Expand the ``tar.gz`` archive to ``~/.mujoco``. Then copy the dynamic library from +``~/.mujoco/mujoco-2.1.1/lib/libmujoco_nogl.so.2.1.1`` (note the ``_nogl`` suffix) and rename it as ``libmujoco.so``. + +Windows +_______ + +Expand the ``zip`` archive to a directory called ``MuJoCo`` in your user directory, and copy the file +``MuJoCo\bin\mujoco.dll``. + +.. _UUsing: + +Using the plug-in +----------------- + +.. _UImporter: + +Importer +________ + +The importer is invoked from the Editor's *Asset* menu: click on "Import MuJoCo Scene" and select the XML file with your +model's MJCF specification. + +Context menus +_____________ + +- Right-clicking a geom component offers two options: + + - "Add mesh renderer" adds components to the same game object that render the geom: a standard ``MeshRenderer`` and a + ``MjMeshFilter`` that creates a procedural mesh that is recreated when the geom shape properties change. + - "Convert to free object" adds two new game objects: a parent with an ``MjBody`` component and a sibling with an + ``MjFreeJoint`` component. This allows the previously static geom to move about freely in the scene. This action + only applies to "world" geoms -- those that do not currently have an ``MjBody`` parent. + +- Right-clicking a Unity Collider offers the option to "Add a matching MuJoCo geom" to the same game object. Note that + this does not comprise a complete conversion of the physics -- Rigidbody, ArticulationBody and Joint configurations + still need to be recreated manually. + +Mouse spring +____________ + +When the selected game object has an ``MjBody`` component, spring forces can be applied to this body towards the mouse +cursor through a control-left-drag action in the Scene view. The 3D position of the spring force origin is found by +projecting the mouse position on a plane defined by the camera X direction and the world Y direction. Adding the shift +key changes the projection plane to be parallel to the world's X and Z axes. + +.. _UTips: + +Tips to Unity users +___________________ + +- If any compilation or runtime errors are encountered, the state of the system is undefined. Therefore, we recommend + turning on “Error Pause” in the console window. +- In PhysX, every `Rigidbody` is a “free body”. In contrast, MuJoCo requires explicit specification of joints for + mobility. For convenience, we provide a context menu for “freeing” a world geom (i.e., an ``MjGeom`` component without + any ``MjBody`` ancestor) by adding a parent ``MjBody`` and a sibling ``MjFreeJoint``. +- The plug-in doesn’t support collision detection without physical presence, so there is no built-in notion of trigger + colliders. The presence or absence of a contact force can be read by adding a touch sensor and reading its + ``SensorReading`` value (which will correspond to the normal force, see `touch sensor documentation `). + +.. _UDesign: + +Design principles +----------------- + +The plug-in design provides a one-to-one mapping between MJCF elements and Unity components. In order to simulate a +Unity scene (e.g., when the user hits the “play” button in the Editor) using MuJoCo, the plug-in: + +1. Scans the GameObject hierarchy in the scene for MuJoCo components. +2. Creates an MJCF description and passes it to MuJoCo’s compiler. +3. Binds every component to the MuJoCo runtime via the corresponding index in MuJoCo’s data structures. This index is + used for updating Unity’s transforms during simulation. + +This design principle has several implications: + +- Most fields of the Unity components correspond directly to MJCF attributes. Therefore, the user can refer to the + MuJoCo documentation for details on the semantics of different values. +- The layout of MuJoCo components in the GameObject hierarchy determines the layout of the resulting MuJoCo model. + Therefore, we adopt a design rule that **every game object must have at most one MuJoCo component**. +- We rely on Unity for spatial configuration, which requires vector components to be `swizzled + `_ since Unity uses left-handed frames with Y as the + vertical axis, while MuJoCo uses right-handed frames with Z as the vertical axis. +- Unity transform scaling affects positions, orientations, and scale of the entire game object subtree. However, MuJoCo + doesn’t support collision of skewed cylinders and capsules (skewed spheres are supported via the ellipsoid primitive). + The gizmo for geoms and sites ignores this skew (similarly to PhysX colliders), and will always show the primitive + shape as it will appear to the physics. +- During runtime, changing values of component fields will not trigger scene recreation, so it will have no immediate + effect on the physics. However, the new values will be loaded upon the next scene recreation. + +Wherever possible, we do things the Unity Way: gravity is read from Unity’s physics settings, and the simulation step is +read from Unity’s Time Manager’s `Fixed Timestep`. All aspects of appearance (e.g., meshes, materials, and textures) +are handled by Unity’s Asset Manager, and RGBA specifications are done using material assets. + +.. _UNotes: + +Implementation notes +-------------------- + +Importer workflow +_________________ + +When the user selects an MJCF file, the importer first loads +the file in MuJoCo, saves it to a temporary location, and then processes the generated saved file. This has several +effects: + +- It validates the MJCF - we are guaranteed that the saved MJCF matches the `schema `_. +- It validates the assets (materials, meshes, textures) and imports these assets into Unity, as well as creating new + material assets for geom RGBA specification. +- It allows the importer to handle :ref:`\ ` elements without replicating MuJoCo’s file-system + workflow. +- The current version of MuJoCo generates MJCF files with explicit :ref:`\ ` elements, even when + the original model uses geoms for implicit definition of the body inertia. If you plan to change geom properties of + an imported model, remove these auto-generated ``MjInertial`` components manually. We plan to address this in a + future release of MuJoCo. + +In Unity, there is no equivalent to MJCF’s “cascading” :ref:`\ ` clauses. Therefore, components in +Unity reflect the corresponding elements’ state after applying all the relevant default classes, and the class structure +in the original MJCF is discarded. + +The MuJoCo Scene +________________ + +When a MuJoCo scene is created, the ``MjScene`` component first scans the scene for all instances of ``MjComponent``. +Each component creates its own MJCF element using Unity scene’s spatial structure to describe the model’s initial +reference pose (called ``qpos0`` in MuJoCo). ``MjScene`` combines these XML elements according to the hierarchy of the +respective game objects and creates a single MJCF description of the physics model. It then creates the runtime structs +``mjModel`` and ``mjData``, and binds each component to the runtime by identifying its unique index. + +During runtime, ``MjScene.FixedUpdate()`` calls :ref:`mj_step`, and then synchronizes the state of each game object +according to the index ``MjComponent.MujocoId`` identified at binding time. An ``MjScene`` component is added +automatically when the application starts (e.g., when the user hits “play”) if and only if the scene includes any MuJoCo +components. If your application’s initialization phase involves ticking the physics while adding game objects and +components, you can call ``MjScene.CreateScene()`` when the initialization phase is over. + +Scene recreation maintains continuity of physics and state in the following way: + +1. The position and velocity of joints is cached. +2. MuJoCo’s state is reset (to ``qpos0``) and Unity transforms are synchronized. +3. A new XML is generated, creating a model that has the same ``qpos0`` as the previous one for the joints that + persisted. +4. The MuJoCo state (for the joints that persisted) is set from the cache, and Unity transforms are synchronized. + +Because the MuJoCo library doesn’t (yet) expose an API for scene editing, adding and removing MuJoCo components causes +complete scene recreation. This can be expensive for large models or if it happens frequently. We expect this +performance limitation to be lifted in future versions of MuJoCo. + +Global Settings +_______________ + +An exception to the one-element-per-one-component is the Global Settings component. This component is responsible for +all the configuration options that are included in the fixed-size, singleton, global elements of MJCF. Currently it +holds information that corresponds to the :ref:`\