Add content_type attribute that takes a MIME type to specify the file contents for meshes, hfields, and textures.

PiperOrigin-RevId: 549302344
Change-Id: I30a8adfef5b5d87bb20479329f3396892f5137ff
This commit is contained in:
Kyle Bayes
2023-07-19 06:50:35 -07:00
committed by Copybara-Service
parent 5f327b0c31
commit 5fcdae771b
12 changed files with 556 additions and 44 deletions
+29 -5
View File
@@ -2081,7 +2081,10 @@ This adds an element to the tuple.
This is a grouping element for defining assets. It does not have attributes. Assets are created in the model so that
they can be referenced from other model elements; recall the discussion of :ref:`Assets <Assets>` in the Overview
chapter.
chapter. Assets opened from a file can be identified in two different ways: filename extensions or the ``content_type``
attribute. MuJoCo will attempt to open a file specified by the content type provided, and only defaults to the filename
extension if no ``content_type`` attribute is specified. The content type is ignored if the asset isn't loaded from a
file.
.. _asset-texture:
@@ -2097,8 +2100,8 @@ chapter.
textures. Alternatively the data can be generated by the compiler as a procedural texture. Because different texture
types require different parameters, only a subset of the attributes below are used for any given texture.
| MuJoCo 2.0 introduced a second file format for loading textures, in addition to PNG. If the file name extension is
different from .png or .PNG, MuJoCo assumes that the texture is in the new format. This is a custom binary file
format, containing the following data:
different from .png or .PNG, or if the ``content_type`` attribute is set to ``image/vnd.mujoco.texture``, then MuJoCo
assumes that the texture is in the new format. This is a custom binary file format, containing the following data:
.. code:: Text
@@ -2153,6 +2156,13 @@ chapter.
texrepeat attribute of :ref:`material <asset-material>`. The data can be loaded from a singlefile or created
procedurally.
.. _asset-texture-content_type:
:at:`content_type`: :at-val:`string, optional`
If the file attribute is specified, then this sets the `MIME <https://en.wikipedia.org/wiki/MIME>`_ type of the file
to be loaded. Any filename extensions will be ignored. Currently ``image/png`` and ``image/vnd.mujoco.texture`` are
supported.
.. _asset-texture-file:
:at:`file`: :at-val:`string, optional`
@@ -2335,6 +2345,13 @@ also known as terrain map, is a 2D matrix of elevation data. The data can be spe
Name of the height field, used for referencing. If the name is omitted and a file name is specified, the height field
name equals the file name without the path and extension.
.. _asset-hfield-content_type:
:at:`content_type`: :at-val: `string, optional`
If the file attribute is specified, then this sets the `MIME <https://en.wikipedia.org/wiki/MIME>`_ type of the file
to be loaded. Any filename extensions will be overloaded. Currently ``image/png`` and ``image/vnd.mujoco.hfield``
are supported.
.. _asset-hfield-file:
:at:`file`: :at-val:`string, optional`
@@ -2500,12 +2517,19 @@ The full list of processing steps applied by the compiler to each mesh is as fol
:at:`class`: :at-val:`string, optional`
Defaults class for setting unspecified attributes (only scale in this case).
.. _asset-mesh-content_type:
:at:`content_type`: :at-val:`string, optional`
If the file attribute is specified, then this sets the `MIME <https://en.wikipedia.org/wiki/MIME>`_ type of the file
to be loaded. Any filename extensions will be overloaded. Currently ``model/vnd.mujoco.msh``, ``model/obj``, and
``model/stl`` are supported.
.. _asset-mesh-file:
:at:`file`: :at-val:`string, optional`
The file from which the mesh will be loaded. The path is determined as described in the meshdir attribute of
:ref:`compiler <compiler>`. The file extension must be "stl" or "msh" (not case sensitive) specifying the file type.
If the file name is omitted, the vertex attribute becomes required.
:ref:`compiler <compiler>`. The file extension must be "stl", "msh", or "obj" (not case sensitive) specifying the
file type. If the file name is omitted, the vertex attribute becomes required.
.. _asset-mesh-scale: