Refactor camera orthographic attribute to projection enum.
PiperOrigin-RevId: 847069028 Change-Id: I7f686fe654e9b56519cab8bd2f37c9cc40091d3f
This commit is contained in:
committed by
Copybara-Service
parent
44c8ef890d
commit
b8a4ac5d48
@@ -27,6 +27,7 @@
|
||||
// keyword maps (defined in implementation files)
|
||||
extern const int joint_sz;
|
||||
extern const int bodysleep_sz;
|
||||
extern const int projection_sz;
|
||||
extern const int camlight_sz;
|
||||
extern const int lighttype_sz;
|
||||
extern const int integrator_sz;
|
||||
@@ -53,6 +54,7 @@ extern const mjMap TFAuto_map[];
|
||||
extern const mjMap joint_map[];
|
||||
extern const mjMap bodysleep_map[];
|
||||
extern const mjMap geom_map[];
|
||||
extern const mjMap projection_map[];
|
||||
extern const mjMap camlight_map[];
|
||||
extern const mjMap lighttype_map[];
|
||||
extern const mjMap integrator_map[];
|
||||
|
||||
@@ -171,7 +171,7 @@ std::vector<const char*> MJCF[nMJCF] = {
|
||||
"hfield", "mesh", "fitscale", "rgba", "fluidshape", "fluidcoef", "user"},
|
||||
{"site", "?", "type", "group", "pos", "quat", "material",
|
||||
"size", "fromto", "axisangle", "xyaxes", "zaxis", "euler", "rgba", "user"},
|
||||
{"camera", "?", "orthographic", "fovy", "ipd", "resolution", "pos", "quat",
|
||||
{"camera", "?", "projection", "fovy", "ipd", "resolution", "pos", "quat",
|
||||
"axisangle", "xyaxes", "zaxis", "euler", "mode", "focal", "focalpixel",
|
||||
"principal", "principalpixel", "sensorsize", "user"},
|
||||
{"light", "?", "pos", "dir", "bulbradius", "intensity", "range",
|
||||
@@ -285,7 +285,7 @@ std::vector<const char*> MJCF[nMJCF] = {
|
||||
{"attach", "*", "model", "body", "prefix"},
|
||||
{"site", "*", "name", "class", "type", "group", "pos", "quat",
|
||||
"material", "size", "fromto", "axisangle", "xyaxes", "zaxis", "euler", "rgba", "user"},
|
||||
{"camera", "*", "name", "class", "orthographic", "fovy", "ipd", "resolution", "pos",
|
||||
{"camera", "*", "name", "class", "projection", "fovy", "ipd", "resolution", "pos",
|
||||
"quat", "axisangle", "xyaxes", "zaxis", "euler", "mode", "target",
|
||||
"focal", "focalpixel", "principal", "principalpixel", "sensorsize", "user"},
|
||||
{"light", "*", "name", "class", "directional", "type", "castshadow", "active",
|
||||
@@ -590,6 +590,13 @@ const mjMap geom_map[mjNGEOMTYPES] = {
|
||||
};
|
||||
|
||||
|
||||
// projection type
|
||||
const int projection_sz = 2;
|
||||
const mjMap projection_map[projection_sz] = {
|
||||
{"perspective", mjPROJ_PERSPECTIVE},
|
||||
{"orthographic", mjPROJ_ORTHOGRAPHIC}
|
||||
};
|
||||
|
||||
// camlight type
|
||||
const int camlight_sz = 5;
|
||||
const mjMap camlight_map[camlight_sz] = {
|
||||
@@ -1926,8 +1933,8 @@ void mjXReader::OneCamera(XMLElement* elem, mjsCamera* camera) {
|
||||
ReadAlternative(elem, camera->alt);
|
||||
ReadAttr(elem, "ipd", 1, &camera->ipd, text);
|
||||
|
||||
if (MapValue(elem, "orthographic", &n, bool_map, 2)) {
|
||||
camera->orthographic = (n == 1);
|
||||
if (MapValue(elem, "projection", &n, projection_map, 2)) {
|
||||
camera->proj = (mjtProjection)n;
|
||||
}
|
||||
|
||||
bool has_principal = ReadAttr(elem, "principalpixel", 2, camera->principal_pixel, text) ||
|
||||
|
||||
@@ -573,7 +573,7 @@ void mjXWriter::OneCamera(XMLElement* elem, const mjCCamera* camera, mjCDef* def
|
||||
WriteAttr(elem, "ipd", 1, &camera->ipd, &def->Camera().ipd);
|
||||
WriteAttrKey(elem, "mode", camlight_map, camlight_sz, camera->mode, def->Camera().mode);
|
||||
WriteAttr(elem, "resolution", 2, camera->resolution, def->Camera().resolution);
|
||||
WriteAttrKey(elem, "orthographic", bool_map, 2, camera->orthographic, def->Camera().orthographic);
|
||||
WriteAttrKey(elem, "projection", projection_map, projection_sz, camera->proj, def->Camera().proj);
|
||||
|
||||
// camera intrinsics if specified
|
||||
if (camera->sensor_size[0] > 0 && camera->sensor_size[1] > 0) {
|
||||
|
||||
Reference in New Issue
Block a user