Skip to main content

A CLI for processing Wavefront OBJ files into a MuJoCo-conducive format

Project description

obj2mjcf

PyPI Python Version PyPI version

obj2mjcf is a CLI for processing Wavefront OBJ files into a MuJoCo-conducive format. It automatically:

  • Splits an OBJ file into sub-meshes that are grouped by the materials referenced in the OBJ's MTL file
  • Creates a collision mesh by performing a convex decomposition of the OBJ with V-HACD
  • Generates an MJCF XML file that is pre-filled with materials, meshes and geom elements referencing these OBJ files

The generated meshes can then be used as a drop-in replacement for the original OBJ file. The result is vastly enhanced visuals for your model:

Before After

Motivation

As of June 2022, MuJoCo does not support OBJ files consisting of groups or objects (o or g tags) and only 1 material can be assigned per mesh. This means that you have to manually split your OBJ file into sub-meshes, a process that is tedious and error-prone. This tool is meant to automate this process.

Installation

The recommended way to install this package is via PyPI:

pip install --upgrade obj2mjcf

We also recommend installing V-HACD v4.0. If available, obj2mjcf will leverage it to create better collision geometry for your OBJ file.

Usage

usage: obj2mjcf [-h] --obj-dir STR [--obj-filter STR] [--save-mtl] [--save-mjcf] [--verbose] [--vhacd-args.enable]
                [--vhacd-args.max-output-convex-hulls INT] [--vhacd-args.voxel-resolution INT] [--vhacd-args.volume-error-percent FLOAT]
                [--vhacd-args.max-recursion-depth INT] [--vhacd-args.disable-shrink-wrap] [--vhacd-args.fill-mode {FLOOD,SURFACE,RAYCAST}]
                [--vhacd-args.max-hull-vert-count INT] [--vhacd-args.disable-async] [--vhacd-args.min-edge-length INT]
                [--vhacd-args.split-hull]

required arguments:
  --obj-dir STR         path to a directory containing obj files. All obj files in the directory will be
                        converted

optional arguments:
  -h, --help            show this help message and exit
  --obj-filter STR      only convert obj files matching this regex (default: None)
  --save-mtl            save the mtl files
  --save-mjcf           save an example MJCF file
  --verbose             print verbose output

optional vhacd args arguments:
  arguments to pass to V-HACD

  --vhacd-args.enable   enable convex decomposition using V-HACD
  --vhacd-args.max-output-convex-hulls INT
                        maximum number of output convex hulls (default: 64)
  --vhacd-args.voxel-resolution INT
                        total number of voxels to use (default: 400000)
  --vhacd-args.volume-error-percent FLOAT
                        volume error allowed as a percentage (default: 1.0)
  --vhacd-args.max-recursion-depth INT
                        maximum recursion depth (default: 14)
  --vhacd-args.disable-shrink-wrap
                        do not shrink wrap output to source mesh
  --vhacd-args.fill-mode {FLOOD,SURFACE,RAYCAST}
                        fill mode (default: FLOOD)
  --vhacd-args.max-hull-vert-count INT
                        maximum number of vertices in the output convex hull (default: 64)
  --vhacd-args.disable-async
                        do not run asynchronously
  --vhacd-args.min-edge-length INT
                        minimum size of a voxel edge (default: 2)
  --vhacd-args.split-hull
                        try to find optimal split plane location

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obj2mjcf-0.0.8.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

obj2mjcf-0.0.8-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file obj2mjcf-0.0.8.tar.gz.

File metadata

  • Download URL: obj2mjcf-0.0.8.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for obj2mjcf-0.0.8.tar.gz
Algorithm Hash digest
SHA256 bcc1ff27b4667dc4373449d994991fcafc5c1cfe20f8405f2d7efeea1eea5d45
MD5 1468764d9149fb1deab77b93f0f46fb0
BLAKE2b-256 e32f60992d484c5926efadea1c79e302ffb185f7c31506ef5e16274616de1415

See more details on using hashes here.

File details

Details for the file obj2mjcf-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: obj2mjcf-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for obj2mjcf-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 4224cca9ac109d617f2a2630a5abddee99765304151cf0d775cb0caaf9d41895
MD5 ac6cb1d3fb138f5058d598276dafee08
BLAKE2b-256 9bf95164e858de342371c9cb3a2e93eebc55f7accd714d9f74d509bc7ec00c37

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page