+ double aspect_ratio_multiplier
+ = fgGetDouble("/sim/current-view/aspect-ratio-multiplier");
+
+ for (unsigned int i = 0; i < config_list.size(); i++) {
+ SGPropertyNode *n = config_list[i];
+
+ // find out if this is an internal view (e.g. in cockpit, low near plane)
+ bool internal = n->getBoolValue("internal", false);
+
+ // FIXME:
+ // this is assumed to be an aircraft model...we will need to read
+ // model-from-type as well.
+
+ // find out if this is a model we are looking from...
+ bool from_model = n->getBoolValue("config/from-model");
+ int from_model_index = n->getIntValue("config/from-model-idx");
+
+ double x_offset_m = n->getDoubleValue("config/x-offset-m");
+ double y_offset_m = n->getDoubleValue("config/y-offset-m");
+ double z_offset_m = n->getDoubleValue("config/z-offset-m");
+
+ double heading_offset_deg = n->getDoubleValue("config/heading-offset-deg");
+ n->setDoubleValue("config/heading-offset-deg", heading_offset_deg);
+ double pitch_offset_deg = n->getDoubleValue("config/pitch-offset-deg");
+ n->setDoubleValue("config/pitch-offset-deg", pitch_offset_deg);
+ double roll_offset_deg = n->getDoubleValue("config/roll-offset-deg");
+ n->setDoubleValue("config/roll-offset-deg", roll_offset_deg);
+
+ double fov_deg = n->getDoubleValue("config/default-field-of-view-deg");
+ double near_m = n->getDoubleValue("config/ground-level-nearplane-m");
+
+ // supporting two types "lookat" = 1 and "lookfrom" = 0
+ const char *type = n->getStringValue("type");
+ if (!strcmp(type, "lookat")) {
+
+ bool at_model = n->getBoolValue("config/at-model");
+ int at_model_index = n->getIntValue("config/at-model-idx");
+
+ double damp_roll = n->getDoubleValue("config/at-model-roll-damping");
+ double damp_pitch = n->getDoubleValue("config/at-model-pitch-damping");
+ double damp_heading = n->getDoubleValue("config/at-model-heading-damping");
+
+ double target_x_offset_m = n->getDoubleValue("config/target-x-offset-m");
+ double target_y_offset_m = n->getDoubleValue("config/target-y-offset-m");
+ double target_z_offset_m = n->getDoubleValue("config/target-z-offset-m");
+
+ add_view(new FGViewer ( FG_LOOKAT, from_model, from_model_index,
+ at_model, at_model_index,
+ damp_roll, damp_pitch, damp_heading,
+ x_offset_m, y_offset_m,z_offset_m,
+ heading_offset_deg, pitch_offset_deg,
+ roll_offset_deg, fov_deg, aspect_ratio_multiplier,
+ target_x_offset_m, target_y_offset_m,
+ target_z_offset_m, near_m, internal ));
+ } else {
+ add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index,
+ false, 0, 0.0, 0.0, 0.0,
+ x_offset_m, y_offset_m, z_offset_m,
+ heading_offset_deg, pitch_offset_deg,
+ roll_offset_deg, fov_deg, aspect_ratio_multiplier,
+ 0, 0, 0, near_m, internal ));
+ }
+ }
+
+ copyToCurrent();
+}
+
+void
+FGViewMgr::reinit ()
+{
+ // reset offsets and fov to configuration defaults
+ for (unsigned int i = 0; i < config_list.size(); i++) {
+ SGPropertyNode *n = config_list[i];
+ setView(i);
+
+ fgSetDouble("/sim/current-view/x-offset-m",
+ n->getDoubleValue("config/x-offset-m"));
+ fgSetDouble("/sim/current-view/y-offset-m",
+ n->getDoubleValue("config/y-offset-m"));
+ fgSetDouble("/sim/current-view/z-offset-m",
+ n->getDoubleValue("config/z-offset-m"));
+ fgSetDouble("/sim/current-view/pitch-offset-deg",
+ n->getDoubleValue("config/pitch-offset-deg"));
+ fgSetDouble("/sim/current-view/heading-offset-deg",
+ n->getDoubleValue("config/heading-offset-deg"));
+ fgSetDouble("/sim/current-view/roll-offset-deg",
+ n->getDoubleValue("config/roll-offset-deg"));
+
+ double fov_deg = n->getDoubleValue("config/default-field-of-view-deg");
+ if (fov_deg < 10.0)
+ fov_deg = 55.0;
+ fgSetDouble("/sim/current-view/field-of-view", fov_deg);
+
+ // target offsets for lookat mode only...
+ fgSetDouble("/sim/current-view/target-x-offset-m",
+ n->getDoubleValue("config/target-x-offset-m"));
+ fgSetDouble("/sim/current-view/target-y-offset-m",
+ n->getDoubleValue("config/target-y-offset-m"));
+ fgSetDouble("/sim/current-view/target-z-offset-m",
+ n->getDoubleValue("config/target-z-offset-m"));
+ }
+ setView(0);