+ char stridx [ 20 ];
+ string viewpath, nodepath, strdata;
+ bool from_model = false;
+ bool at_model = false;
+ int from_model_index = 0;
+ int at_model_index = 0;
+ double x_offset_m, y_offset_m, z_offset_m;
+ double near_m;
+
+ for (int i = 0; i < fgGetInt("/sim/number-views"); i++) {
+ viewpath = "/sim/view";
+ sprintf(stridx, "[%d]", i);
+ viewpath += stridx;
+
+ // find out what type of view this is...
+ nodepath = viewpath;
+ nodepath += "/type";
+ strdata = fgGetString(nodepath.c_str());
+
+ // 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...
+ nodepath = viewpath;
+ nodepath += "/config/from-model";
+ from_model = fgGetBool(nodepath.c_str());
+
+ // get model index (which model)
+ if (from_model) {
+ nodepath = viewpath;
+ nodepath += "/config/from-model-idx";
+ from_model_index = fgGetInt(nodepath.c_str());
+ }
+
+ if ( strcmp("lookat",strdata.c_str()) == 0 ) {
+ // find out if this is a model we are looking at...
+ nodepath = viewpath;
+ nodepath += "/config/at-model";
+ at_model = fgGetBool(nodepath.c_str());
+
+ // get model index (which model)
+ if (at_model) {
+ nodepath = viewpath;
+ nodepath += "/config/at-model-idx";
+ at_model_index = fgGetInt(nodepath.c_str());
+ }
+ }
+
+ nodepath = viewpath;
+ nodepath += "/config/x-offset-m";
+ x_offset_m = fgGetDouble(nodepath.c_str());
+ nodepath = viewpath;
+ nodepath += "/config/y-offset-m";
+ y_offset_m = fgGetDouble(nodepath.c_str());
+ nodepath = viewpath;
+ nodepath += "/config/z-offset-m";
+ z_offset_m = fgGetDouble(nodepath.c_str());
+
+ nodepath = viewpath;
+ nodepath += "/config/ground-level-nearplane-m";
+ near_m = fgGetDouble(nodepath.c_str());
+
+ // supporting two types now "lookat" = 1 and "lookfrom" = 0
+ if ( strcmp("lookat",strdata.c_str()) == 0 )
+ add_view(new FGViewer ( FG_LOOKAT, from_model, from_model_index,
+ at_model, at_model_index, x_offset_m, y_offset_m,
+ z_offset_m, near_m ));
+ else
+ add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index, false,
+ 0, x_offset_m, y_offset_m, z_offset_m, near_m ));
+
+ }
+
+ copyToCurrent();
+