Add orthographic cameras.
Orthographic cameras are specified by setting the `orthographic` attribute of the `<camera>` element. The `fovy` attribute is still used to specify the field-of-view, but its semantic is different for orthographic cameras. For orthographic cameras, the field-of-view is expressed in units of length, rather than degrees. Other related changes: * Fix bug in the ordering of `cam_xxx` elements in `mjModel`. * Make camera visualization translucent only when the frustum is visualized. * Added a button to `simulate` to toggle between perspective and orthographic free cameras. https://youtu.be/ZXBTEIDWHhs PiperOrigin-RevId: 642293435 Change-Id: Id090a421ad88ab404b5b27ddbbd6bfc81ad49bc5
This commit is contained in:
committed by
Copybara-Service
parent
171b0d6e06
commit
07fc95ca9a
+24
-6
@@ -2615,11 +2615,20 @@ 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:
|
||||
|
||||
: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.
|
||||
|
||||
.. _body-camera-fovy:
|
||||
|
||||
:at:`fovy`: :at-val:`real, "45"`
|
||||
Vertical field of view of the camera, expressed in degrees regardless of the global angle setting. The horizontal
|
||||
field of view is computed automatically given the window size and the vertical field of view.
|
||||
Vertical field-of-view of the camera. If the camera uses a perspective projection, the field-of-view is expressed in
|
||||
degrees, regardless of the global :ref:`compiler/angle <compiler-angle>` setting. If the camera uses an orthographic
|
||||
projection, the field-of-view is expressed in units of length; note that in this case the default of 45 is too large
|
||||
for most scenes and should likely be reduced. In either case, the horizontal field of view is computed automatically
|
||||
given the window size and the vertical field of view.
|
||||
|
||||
.. _body-camera-resolution:
|
||||
|
||||
@@ -7157,14 +7166,22 @@ coordinated visual settings corresponding to a "theme", and then include this fi
|
||||
While all settings in mjVisual are global, the settings here could not be fit into any of the other subsections. So this
|
||||
is effectively a miscellaneous subsection.
|
||||
|
||||
.. _visual-global-orthographic:
|
||||
|
||||
:at:`orthographic`: :at-val:`[false, true], "false"`
|
||||
Whether the free camera uses a perspective projection (the default) or an orthographic projection. Setting this
|
||||
attribute changes the semantic of the :ref:`global/fovy<visual-global-fovy>` attribute, see below.
|
||||
|
||||
.. _visual-global-fovy:
|
||||
|
||||
:at:`fovy`: :at-val:`real, "45"`
|
||||
This attribute specifies the vertical field of view of the free camera, i.e., the camera that is always available in
|
||||
the visualizer even if no cameras are explicitly defined in the model. It is always expressed in degrees, regardless
|
||||
of the setting of the angle attribute of :ref:`compiler <compiler>`, and is also represented in the low level model
|
||||
in degrees. This is because we pass it to OpenGL which uses degrees. The same convention applies to the fovy
|
||||
attribute of the :ref:`camera <body-camera>` element below.
|
||||
the visualizer even if no cameras are explicitly defined in the model. If the camera uses a perspective projection,
|
||||
the field-of-view is expressed in degrees, regardless of the global :ref:`compiler/angle <compiler-angle>` setting.
|
||||
If the camera uses an orthographic projection, the field-of-view is expressed in units of length; note that in this
|
||||
case the default of 45 is too large for most scenes and should likely be reduced. In either case, the horizontal
|
||||
field of view is computed automatically given the window size and the vertical field of view. The same convention
|
||||
applies to the :ref:`camera/fovy <body-camera-fovy>` attribute.
|
||||
|
||||
.. _visual-global-ipd:
|
||||
|
||||
@@ -7869,6 +7886,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-fovy:
|
||||
|
||||
|
||||
+14
-12
@@ -277,15 +277,15 @@
|
||||
| :ref:`camera | \* | :class: mjcf-attributes |
|
||||
| <body-camera>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`name<body-camera-name>` | :ref:`class<body-camera-class>` | :ref:`fovy<body-camera-fovy>` | :ref:`ipd<body-camera-ipd>` | |
|
||||
| | | | :ref:`name<body-camera-name>` | :ref:`class<body-camera-class>` | :ref:`orthographic<body-camera-orthographic>` | :ref:`fovy<body-camera-fovy>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`resolution<body-camera-resolution>` | :ref:`pos<body-camera-pos>` | :ref:`quat<body-camera-quat>` | :ref:`axisangle<body-camera-axisangle>` | |
|
||||
| | | | :ref:`ipd<body-camera-ipd>` | :ref:`resolution<body-camera-resolution>` | :ref:`pos<body-camera-pos>` | :ref:`quat<body-camera-quat>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`xyaxes<body-camera-xyaxes>` | :ref:`zaxis<body-camera-zaxis>` | :ref:`euler<body-camera-euler>` | :ref:`mode<body-camera-mode>` | |
|
||||
| | | | :ref:`axisangle<body-camera-axisangle>` | :ref:`xyaxes<body-camera-xyaxes>` | :ref:`zaxis<body-camera-zaxis>` | :ref:`euler<body-camera-euler>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`target<body-camera-target>` | :ref:`focal<body-camera-focal>` | :ref:`focalpixel<body-camera-focalpixel>` | :ref:`principal<body-camera-principal>` | |
|
||||
| | | | :ref:`mode<body-camera-mode>` | :ref:`target<body-camera-target>` | :ref:`focal<body-camera-focal>` | :ref:`focalpixel<body-camera-focalpixel>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`principalpixel<body-camera-principalpixel>` | :ref:`sensorsize<body-camera-sensorsize>` | :ref:`user<body-camera-user>` | | |
|
||||
| | | | :ref:`principal<body-camera-principal>` | :ref:`principalpixel<body-camera-principalpixel>` | :ref:`sensorsize<body-camera-sensorsize>` | :ref:`user<body-camera-user>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_| body |br| |_| |L| | | .. table:: |
|
||||
@@ -1246,11 +1246,11 @@
|
||||
| :ref:`global | ? | :class: mjcf-attributes |
|
||||
| <visual-global>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`fovy<visual-global-fovy>` | :ref:`ipd<visual-global-ipd>` | :ref:`azimuth<visual-global-azimuth>` | :ref:`elevation<visual-global-elevation>` | |
|
||||
| | | | :ref:`orthographic<visual-global-orthographic>` | :ref:`fovy<visual-global-fovy>` | :ref:`ipd<visual-global-ipd>` | :ref:`azimuth<visual-global-azimuth>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`linewidth<visual-global-linewidth>` | :ref:`glow<visual-global-glow>` | :ref:`offwidth<visual-global-offwidth>` | :ref:`offheight<visual-global-offheight>` | |
|
||||
| | | | :ref:`elevation<visual-global-elevation>` | :ref:`linewidth<visual-global-linewidth>` | :ref:`glow<visual-global-glow>` | :ref:`offwidth<visual-global-offwidth>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`realtime<visual-global-realtime>` | :ref:`ellipsoidinertia<visual-global-ellipsoidinertia>` | :ref:`bvactive<visual-global-bvactive>` | | |
|
||||
| | | | :ref:`offheight<visual-global-offheight>` | :ref:`realtime<visual-global-realtime>` | :ref:`ellipsoidinertia<visual-global-ellipsoidinertia>` | :ref:`bvactive<visual-global-bvactive>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_| visual |br| |_| |L| | | .. table:: |
|
||||
@@ -1396,13 +1396,15 @@
|
||||
| :ref:`camera | ? | :class: mjcf-attributes |
|
||||
| <default-camera>` | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`fovy<default-camera-fovy>` | :ref:`ipd<default-camera-ipd>` | :ref:`resolution<default-camera-resolution>` | :ref:`pos<default-camera-pos>` | |
|
||||
| | | | :ref:`orthographic<default-camera-orthographic>` | :ref:`fovy<default-camera-fovy>` | :ref:`ipd<default-camera-ipd>` | :ref:`resolution<default-camera-resolution>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`quat<default-camera-quat>` | :ref:`axisangle<default-camera-axisangle>` | :ref:`xyaxes<default-camera-xyaxes>` | :ref:`zaxis<default-camera-zaxis>` | |
|
||||
| | | | :ref:`pos<default-camera-pos>` | :ref:`quat<default-camera-quat>` | :ref:`axisangle<default-camera-axisangle>` | :ref:`xyaxes<default-camera-xyaxes>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`euler<default-camera-euler>` | :ref:`mode<default-camera-mode>` | :ref:`focal<default-camera-focal>` | :ref:`focalpixel<default-camera-focalpixel>` | |
|
||||
| | | | :ref:`zaxis<default-camera-zaxis>` | :ref:`euler<default-camera-euler>` | :ref:`mode<default-camera-mode>` | :ref:`focal<default-camera-focal>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`principal<default-camera-principal>` | :ref:`principalpixel<default-camera-principalpixel>` | :ref:`sensorsize<default-camera-sensorsize>` | :ref:`user<default-camera-user>` | |
|
||||
| | | | :ref:`focalpixel<default-camera-focalpixel>` | :ref:`principal<default-camera-principal>` | :ref:`principalpixel<default-camera-principalpixel>` | :ref:`sensorsize<default-camera-sensorsize>` | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
| | | | :ref:`user<default-camera-user>` | | | | |
|
||||
| | | +-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+-----------------------------------------------------------------+ |
|
||||
+------------------------------------+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| |_| default |br| |_| |L| | | .. table:: |
|
||||
|
||||
+11
-5
@@ -13,15 +13,21 @@ General
|
||||
- Detailed documentation.
|
||||
- Python bindings.
|
||||
|
||||
2. Added :ref:`maxhullvert<asset-mesh-maxhullvert>`, the maximum number of vertices in a mesh's convex hull.
|
||||
.. youtube:: ZXBTEIDWHhs
|
||||
:align: right
|
||||
:width: 240px
|
||||
|
||||
2. 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>`
|
||||
attributes, respectively.
|
||||
3. Added :ref:`maxhullvert<asset-mesh-maxhullvert>`, the maximum number of vertices in a mesh's convex hull.
|
||||
|
||||
|
||||
MJX
|
||||
~~~
|
||||
|
||||
3. Added support for :ref:`elliptic friction cones<option-cone>`.
|
||||
4. Fixed a bug that resulted in less-optimal linesearch solutions for some difficult constraint settings.
|
||||
5. Fixed a bug in the Newton solver that sometimes resulted in less-optimal gradients.
|
||||
4. Added support for :ref:`elliptic friction cones<option-cone>`.
|
||||
5. Fixed a bug that resulted in less-optimal linesearch solutions for some difficult constraint settings.
|
||||
6. Fixed a bug in the Newton solver that sometimes resulted in less-optimal gradients.
|
||||
|
||||
Version 3.1.6 (Jun 3, 2024)
|
||||
---------------------------
|
||||
|
||||
@@ -751,7 +751,8 @@ struct mjOption_ { // physics options
|
||||
typedef struct mjOption_ mjOption;
|
||||
struct mjVisual_ { // visualization options
|
||||
struct { // global parameters
|
||||
float fovy; // y-field of view for free camera (degrees)
|
||||
int orthographic; // is the free camera orthographic (0: no, 1: yes)
|
||||
float fovy; // y field-of-view of free camera (orthographic ? length : degree)
|
||||
float ipd; // inter-pupilary distance for free camera
|
||||
float azimuth; // initial azimuth of free camera (degrees)
|
||||
float elevation; // initial elevation of free camera (degrees)
|
||||
@@ -1072,11 +1073,12 @@ 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_resolution; // [width, height] in pixels (ncam x 2)
|
||||
mjtNum* cam_fovy; // y-field of view (deg) (ncam x 1)
|
||||
float* cam_intrinsic; // [focal length; principal point] (ncam x 4)
|
||||
float* cam_sensorsize; // sensor size (ncam x 2)
|
||||
int* cam_orthographic; // orthographic camera; 0: no, 1: yes (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)
|
||||
float* cam_sensorsize; // sensor size: length [width, height] (ncam x 2)
|
||||
float* cam_intrinsic; // [focal length; principal point] (ncam x 4)
|
||||
mjtNum* cam_user; // user data (ncam x nuser_cam)
|
||||
|
||||
// lights
|
||||
@@ -1858,6 +1860,7 @@ typedef struct mjsCamera_ { // camera specification
|
||||
mjString* targetbody; // target body for tracking/targeting
|
||||
|
||||
// intrinsics
|
||||
int orthographic; // is camera orthographic
|
||||
double fovy; // y-field of view
|
||||
double ipd; // inter-pupilary distance
|
||||
float intrinsic[4]; // camera intrinsics (length)
|
||||
@@ -2602,6 +2605,9 @@ struct mjvCamera_ { // abstract camera
|
||||
mjtNum distance; // distance to lookat point or tracked body
|
||||
mjtNum azimuth; // camera azimuth (deg)
|
||||
mjtNum elevation; // camera elevation (deg)
|
||||
|
||||
// orthographic / perspective
|
||||
int orthographic; // 0: perspective; 1: orthographic
|
||||
};
|
||||
typedef struct mjvCamera_ mjvCamera;
|
||||
struct mjvGLCamera_ { // OpenGL camera
|
||||
@@ -2617,6 +2623,9 @@ struct mjvGLCamera_ { // OpenGL camera
|
||||
float frustum_top; // top
|
||||
float frustum_near; // near
|
||||
float frustum_far; // far
|
||||
|
||||
// orthographic / perspective
|
||||
int orthographic; // 0: perspective; 1: orthographic
|
||||
};
|
||||
typedef struct mjvGLCamera_ mjvGLCamera;
|
||||
struct mjvGeom_ { // abstract geom
|
||||
@@ -2869,10 +2878,12 @@ struct mjvSceneState_ {
|
||||
mjtNum* site_size;
|
||||
float* site_rgba;
|
||||
|
||||
int* cam_orthographic;
|
||||
mjtNum* cam_fovy;
|
||||
mjtNum* cam_ipd;
|
||||
float* cam_intrinsic;
|
||||
int* cam_resolution;
|
||||
float* cam_sensorsize;
|
||||
float* cam_intrinsic;
|
||||
|
||||
mjtByte* light_directional;
|
||||
mjtByte* light_castshadow;
|
||||
|
||||
Reference in New Issue
Block a user