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
@@ -474,9 +474,7 @@ void mjXWriter::OneCamera(XMLElement* elem, const mjCCamera* pcam, mjCDef* def)
|
||||
WriteAttr(elem, "ipd", 1, &pcam->ipd, &def->Camera().ipd);
|
||||
WriteAttrKey(elem, "mode", camlight_map, camlight_sz, pcam->mode, def->Camera().mode);
|
||||
WriteAttr(elem, "resolution", 2, pcam->resolution, def->Camera().resolution);
|
||||
|
||||
// resolution if positive
|
||||
WriteAttr(elem, "resolution", 2, pcam->resolution, def->Camera().resolution);
|
||||
WriteAttrKey(elem, "orthographic", bool_map, 2, pcam->orthographic, def->Camera().orthographic);
|
||||
|
||||
// camera intrinsics if specified
|
||||
if (pcam->sensor_size[0]>0 && pcam->sensor_size[1]>0) {
|
||||
@@ -1012,15 +1010,16 @@ void mjXWriter::Visual(XMLElement* root) {
|
||||
|
||||
// global
|
||||
elem = InsertEnd(section, "global");
|
||||
WriteAttr(elem, "fovy", 1, &vis->global.fovy, &visdef.global.fovy);
|
||||
WriteAttr(elem, "ipd", 1, &vis->global.ipd, &visdef.global.ipd);
|
||||
WriteAttr(elem, "azimuth", 1, &vis->global.azimuth, &visdef.global.azimuth);
|
||||
WriteAttr(elem, "elevation", 1, &vis->global.elevation, &visdef.global.elevation);
|
||||
WriteAttr(elem, "linewidth", 1, &vis->global.linewidth, &visdef.global.linewidth);
|
||||
WriteAttr(elem, "glow", 1, &vis->global.glow, &visdef.global.glow);
|
||||
WriteAttr(elem, "realtime", 1, &vis->global.realtime, &visdef.global.realtime);
|
||||
WriteAttrInt(elem, "offwidth", vis->global.offwidth, visdef.global.offwidth);
|
||||
WriteAttrInt(elem, "offheight", vis->global.offheight, visdef.global.offheight);
|
||||
WriteAttrKey(elem, "orthographic", bool_map, 2, vis->global.orthographic, visdef.global.orthographic);
|
||||
WriteAttr(elem, "fovy", 1, &vis->global.fovy, &visdef.global.fovy);
|
||||
WriteAttr(elem, "ipd", 1, &vis->global.ipd, &visdef.global.ipd);
|
||||
WriteAttr(elem, "azimuth", 1, &vis->global.azimuth, &visdef.global.azimuth);
|
||||
WriteAttr(elem, "elevation", 1, &vis->global.elevation, &visdef.global.elevation);
|
||||
WriteAttr(elem, "linewidth", 1, &vis->global.linewidth, &visdef.global.linewidth);
|
||||
WriteAttr(elem, "glow", 1, &vis->global.glow, &visdef.global.glow);
|
||||
WriteAttr(elem, "realtime", 1, &vis->global.realtime, &visdef.global.realtime);
|
||||
WriteAttrInt(elem, "offwidth", vis->global.offwidth, visdef.global.offwidth);
|
||||
WriteAttrInt(elem, "offheight", vis->global.offheight, visdef.global.offheight);
|
||||
WriteAttrKey(elem, "ellipsoidinertia", bool_map, 2, vis->global.ellipsoidinertia, visdef.global.ellipsoidinertia);
|
||||
WriteAttrKey(elem, "bvactive", bool_map, 2, vis->global.bvactive, visdef.global.bvactive);
|
||||
if (!elem->FirstAttribute()) {
|
||||
|
||||
Reference in New Issue
Block a user