Refactor camera orthographic attribute to projection enum.

PiperOrigin-RevId: 847069028
Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
This commit is contained in:
Yuval Tassa
2025-12-20 03:27:42 -08:00
committed by Copybara-Service
parent 44c8ef890d
commit b8a4ac5d48
20 changed files with 102 additions and 44 deletions
+10
View File
@@ -166,6 +166,16 @@ elements. These values are used in ``m->geom_type`` and ``m->site_type``.
.. mujoco-include:: mjtGeom
.. _mjtProjection:
mjtProjection
~~~~~~~~~~~~~
Type of camera projection. Used in ``m->cam_projection``.
.. mujoco-include:: mjtProjection
.. _mjtCamLight:
mjtCamLight
+5 -5
View File
@@ -2961,11 +2961,11 @@ and the +Y axis points up. Thus the frame position and orientation are the key a
When the camera mode is "targetbody" or "targetbodycom", this attribute becomes required. It specifies which body
should be targeted by the camera. In all other modes this attribute is ignored.
.. _body-camera-orthographic:
.. _body-camera-projection:
:at:`orthographic`: :at-val:`[false, true], "false"`
Whether the camera uses a perspective projection (the default) or an orthographic projection. Setting this attribute
changes the semantic of the :ref:`fovy<body-camera-fovy>` attribute, see below.
:at:`projection`: :at-val:`[perspective, orthographic], "perspective"`
Whether the camera uses a perspective (the default) or orthographic projection. Setting this
attribute to "orthographic" changes the semantic of the :ref:`fovy<body-camera-fovy>` attribute, see below.
.. _body-camera-fovy:
@@ -8666,7 +8666,7 @@ if omitted.
| This element sets the attributes of the dummy :ref:`site <body-site>` element of the defaults class.
| All site attributes are available here except: name, class.
.. _default-camera-orthographic:
.. _default-camera-projection:
.. _default-camera-fovy:
+2 -2
View File
@@ -302,7 +302,7 @@
| :ref:`camera | \* | :class: mjcf-attributes |
| <body-camera>` | | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`name<body-camera-name>` | :ref:`class<body-camera-class>` | :ref:`orthographic<body-camera-orthographic>` | :ref:`fovy<body-camera-fovy>` | |
| | | | :ref:`name<body-camera-name>` | :ref:`class<body-camera-class>` | :ref:`projection<body-camera-projection>` | :ref:`fovy<body-camera-fovy>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`ipd<body-camera-ipd>` | :ref:`resolution<body-camera-resolution>` | :ref:`pos<body-camera-pos>` | :ref:`quat<body-camera-quat>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
@@ -1490,7 +1490,7 @@
| :ref:`camera | ? | :class: mjcf-attributes |
| <default-camera>` | | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`orthographic<default-camera-orthographic>` | :ref:`fovy<default-camera-fovy>` | :ref:`ipd<default-camera-ipd>` | :ref:`resolution<default-camera-resolution>` | |
| | | | :ref:`projection<default-camera-projection>` | :ref:`fovy<default-camera-fovy>` | :ref:`ipd<default-camera-ipd>` | :ref:`resolution<default-camera-resolution>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
| | | | :ref:`pos<default-camera-pos>` | :ref:`quat<default-camera-quat>` | :ref:`axisangle<default-camera-axisangle>` | :ref:`xyaxes<default-camera-xyaxes>` | |
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
+12 -1
View File
@@ -5,6 +5,17 @@ Changelog
Upcoming version (not yet released)
-----------------------------------
.. admonition:: Breaking API changes
:class: attention
- The ``mjModel.cam_orthographic`` field has been renamed to ``cam_projection``, with the semantic of a new enum type
:ref:`mjtProjection`. This will allow for more projection types in the future like fisheye cameras.
Relatedly, the ``camera/orthographic`` MJCF attribute for cameras has been renamed to
:ref:`camera/projection<body-camera-projection>` and now accepts the values ``orthographic`` and ``perspective``.
**Migration:** Replace ``orthographic = "false/true"`` with ``projection="perspective/orthographic"``,
respectively.
General
^^^^^^^
- Non-breaking ABI changes:
@@ -793,7 +804,7 @@ General
:width: 240px
8. Added support for orthographic cameras. This is available for both fixed cameras and the free camera, using the
:ref:`camera/orthographic<body-camera-orthographic>` and :ref:`global/orthographic<visual-global-orthographic>`
``camera/orthographic`` and :ref:`global/orthographic<visual-global-orthographic>`
attributes, respectively.
9. Added :ref:`maxhullvert<asset-mesh-maxhullvert>`, the maximum number of vertices in a mesh's convex hull.
10. Added :ref:`mj_setKeyframe` for saving the current state into a model keyframe.
+6 -2
View File
@@ -538,6 +538,10 @@ typedef enum mjtGeom_ { // type of geometric shape
mjGEOM_NONE = 1001 // missing geom type
} mjtGeom;
typedef enum mjtProjection_ { // type of camera projection
mjPROJ_PERSPECTIVE = 0, // perspective
mjPROJ_ORTHOGRAPHIC // orthographic
} mjtProjection;
typedef enum mjtCamLight_ { // tracking mode for camera and light
mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body
mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global
@@ -1223,7 +1227,7 @@ struct mjModel_ {
mjtNum* cam_poscom0; // global position rel. to sub-com in qpos0 (ncam x 3)
mjtNum* cam_pos0; // global position rel. to body in qpos0 (ncam x 3)
mjtNum* cam_mat0; // global orientation in qpos0 (ncam x 9)
int* cam_orthographic; // orthographic camera; 0: no, 1: yes (ncam x 1)
int* cam_projection; // projection type (mjtProjection) (ncam x 1)
mjtNum* cam_fovy; // y field-of-view (ortho ? len : deg) (ncam x 1)
mjtNum* cam_ipd; // inter-pupilary distance (ncam x 1)
int* cam_resolution; // resolution: pixels [width, height] (ncam x 2)
@@ -2102,7 +2106,7 @@ typedef struct mjsCamera_ { // camera specification
mjString* targetbody; // target body for tracking/targeting
// intrinsics
int orthographic; // is camera orthographic
mjtProjection proj; // camera projection type
double fovy; // y-field of view
double ipd; // inter-pupilary distance
float intrinsic[4]; // camera intrinsics (length)