- remove dependence on /sim/number-views: the view manager just uses all
/sim/view[*] that it finds. It's not only unnecessary that view definitions have subsequent indices, but aircraft are now *requested* to use indices 100++. /sim/view[0] .. /sim/view[99] are reserved for the system. (Not that we'd ever need that many, This is just a convention, it's nowhere hard-coded.) - replace the string operations for property paths by method calls & other improvements
This commit is contained in:
parent
dad550e0eb
commit
5d8f383ded
2 changed files with 99 additions and 254 deletions
|
@ -34,18 +34,17 @@
|
||||||
#include <Model/acmodel.hxx>
|
#include <Model/acmodel.hxx>
|
||||||
|
|
||||||
#include "viewmgr.hxx"
|
#include "viewmgr.hxx"
|
||||||
#include "fg_props.hxx"
|
|
||||||
|
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
FGViewMgr::FGViewMgr( void ) :
|
FGViewMgr::FGViewMgr( void ) :
|
||||||
axis_long(0),
|
axis_long(0),
|
||||||
axis_lat(0),
|
axis_lat(0),
|
||||||
|
config_list(fgGetNode("/sim", true)->getChildren("view")),
|
||||||
current(0)
|
current(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Destructor
|
// Destructor
|
||||||
FGViewMgr::~FGViewMgr( void ) {
|
FGViewMgr::~FGViewMgr( void ) {
|
||||||
}
|
}
|
||||||
|
@ -53,120 +52,52 @@ FGViewMgr::~FGViewMgr( void ) {
|
||||||
void
|
void
|
||||||
FGViewMgr::init ()
|
FGViewMgr::init ()
|
||||||
{
|
{
|
||||||
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 damp_alt;
|
|
||||||
double damp_roll = 0.0, damp_pitch = 0.0, damp_heading = 0.0;
|
|
||||||
double x_offset_m, y_offset_m, z_offset_m, fov_deg;
|
|
||||||
double heading_offset_deg, pitch_offset_deg, roll_offset_deg;
|
|
||||||
double target_x_offset_m, target_y_offset_m, target_z_offset_m;
|
|
||||||
double near_m;
|
|
||||||
bool internal;
|
|
||||||
|
|
||||||
double aspect_ratio_multiplier
|
double aspect_ratio_multiplier
|
||||||
= fgGetDouble("/sim/current-view/aspect-ratio-multiplier");
|
= fgGetDouble("/sim/current-view/aspect-ratio-multiplier");
|
||||||
|
|
||||||
for (int i = 0; i < fgGetInt("/sim/number-views"); i++) {
|
for (unsigned int i = 0; i < config_list.size(); i++) {
|
||||||
viewpath = "/sim/view";
|
SGPropertyNode *n = config_list[i];
|
||||||
sprintf(stridx, "[%d]", i);
|
|
||||||
viewpath += stridx;
|
|
||||||
|
|
||||||
// find out what type of view this is...
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/type";
|
|
||||||
strdata = fgGetString(nodepath.c_str());
|
|
||||||
|
|
||||||
// find out if this is an internal view (e.g. in cockpit, low near plane)
|
// find out if this is an internal view (e.g. in cockpit, low near plane)
|
||||||
internal = false; // default
|
bool internal = n->getBoolValue("internal", false);
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/internal";
|
|
||||||
internal = fgGetBool(nodepath.c_str());
|
|
||||||
|
|
||||||
// FIXME:
|
// FIXME:
|
||||||
// this is assumed to be an aircraft model...we will need to read
|
// this is assumed to be an aircraft model...we will need to read
|
||||||
// model-from-type as well.
|
// model-from-type as well.
|
||||||
|
|
||||||
// find out if this is a model we are looking from...
|
// find out if this is a model we are looking from...
|
||||||
nodepath = viewpath;
|
bool from_model = n->getBoolValue("config/from-model");
|
||||||
nodepath += "/config/from-model";
|
int from_model_index = n->getIntValue("config/from-model-idx");
|
||||||
from_model = fgGetBool(nodepath.c_str());
|
|
||||||
|
|
||||||
// get model index (which model)
|
double x_offset_m = n->getDoubleValue("config/x-offset-m");
|
||||||
if (from_model) {
|
double y_offset_m = n->getDoubleValue("config/y-offset-m");
|
||||||
nodepath = viewpath;
|
double z_offset_m = n->getDoubleValue("config/z-offset-m");
|
||||||
nodepath += "/config/from-model-idx";
|
|
||||||
from_model_index = fgGetInt(nodepath.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( strcmp("lookat",strdata.c_str()) == 0 ) {
|
double heading_offset_deg = n->getDoubleValue("config/heading-offset-deg");
|
||||||
// find out if this is a model we are looking at...
|
n->setDoubleValue(heading_offset_deg);
|
||||||
nodepath = viewpath;
|
double pitch_offset_deg = n->getDoubleValue("config/pitch-offset-deg");
|
||||||
nodepath += "/config/at-model";
|
n->setDoubleValue(pitch_offset_deg);
|
||||||
at_model = fgGetBool(nodepath.c_str());
|
double roll_offset_deg = n->getDoubleValue("config/roll-offset-deg");
|
||||||
|
n->setDoubleValue(roll_offset_deg);
|
||||||
|
|
||||||
// get model index (which model)
|
double fov_deg = n->getDoubleValue("config/default-field-of-view-deg");
|
||||||
if (at_model) {
|
double near_m = n->getDoubleValue("config/ground-level-nearplane-m");
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/at-model-idx";
|
|
||||||
at_model_index = fgGetInt(nodepath.c_str());
|
|
||||||
|
|
||||||
nodepath = viewpath;
|
// supporting two types "lookat" = 1 and "lookfrom" = 0
|
||||||
nodepath += "/config/at-model-roll-damping";
|
const char *type = n->getStringValue("type");
|
||||||
damp_roll = fgGetDouble(nodepath.c_str(), 0.0);
|
if (!strcmp(type, "lookat")) {
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/at-model-pitch-damping";
|
|
||||||
damp_pitch = fgGetDouble(nodepath.c_str(), 0.0);
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/at-model-heading-damping";
|
|
||||||
damp_heading = fgGetDouble(nodepath.c_str(), 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nodepath = viewpath;
|
bool at_model = n->getBoolValue("config/at-model");
|
||||||
nodepath += "/config/x-offset-m";
|
int at_model_index = n->getIntValue("config/at-model-idx");
|
||||||
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/pitch-offset-deg";
|
|
||||||
pitch_offset_deg = fgGetDouble(nodepath.c_str());
|
|
||||||
fgSetDouble(nodepath.c_str(),pitch_offset_deg);
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/heading-offset-deg";
|
|
||||||
heading_offset_deg = fgGetDouble(nodepath.c_str());
|
|
||||||
fgSetDouble(nodepath.c_str(),heading_offset_deg);
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/roll-offset-deg";
|
|
||||||
roll_offset_deg = fgGetDouble(nodepath.c_str());
|
|
||||||
fgSetDouble(nodepath.c_str(),roll_offset_deg);
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/default-field-of-view-deg";
|
|
||||||
fov_deg = fgGetDouble(nodepath.c_str());
|
|
||||||
|
|
||||||
// target offsets for lookat mode only...
|
double damp_roll = n->getDoubleValue("config/at-model-roll-damping");
|
||||||
nodepath = viewpath;
|
double damp_pitch = n->getDoubleValue("config/at-model-pitch-damping");
|
||||||
nodepath += "/config/target-x-offset-m";
|
double damp_heading = n->getDoubleValue("config/at-model-heading-damping");
|
||||||
target_x_offset_m = fgGetDouble(nodepath.c_str());
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-y-offset-m";
|
|
||||||
target_y_offset_m = fgGetDouble(nodepath.c_str());
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-z-offset-m";
|
|
||||||
target_z_offset_m = fgGetDouble(nodepath.c_str());
|
|
||||||
|
|
||||||
nodepath = viewpath;
|
double target_x_offset_m = n->getDoubleValue("config/target-x-offset-m");
|
||||||
nodepath += "/config/ground-level-nearplane-m";
|
double target_y_offset_m = n->getDoubleValue("config/target-y-offset-m");
|
||||||
near_m = fgGetDouble(nodepath.c_str());
|
double target_z_offset_m = n->getDoubleValue("config/target-z-offset-m");
|
||||||
|
|
||||||
// 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,
|
add_view(new FGViewer ( FG_LOOKAT, from_model, from_model_index,
|
||||||
at_model, at_model_index,
|
at_model, at_model_index,
|
||||||
damp_roll, damp_pitch, damp_heading,
|
damp_roll, damp_pitch, damp_heading,
|
||||||
|
@ -175,90 +106,54 @@ FGViewMgr::init ()
|
||||||
roll_offset_deg, fov_deg, aspect_ratio_multiplier,
|
roll_offset_deg, fov_deg, aspect_ratio_multiplier,
|
||||||
target_x_offset_m, target_y_offset_m,
|
target_x_offset_m, target_y_offset_m,
|
||||||
target_z_offset_m, near_m, internal ));
|
target_z_offset_m, near_m, internal ));
|
||||||
else
|
} else {
|
||||||
add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index,
|
add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index,
|
||||||
false, 0, 0.0, 0.0, 0.0,
|
false, 0, 0.0, 0.0, 0.0,
|
||||||
x_offset_m, y_offset_m, z_offset_m,
|
x_offset_m, y_offset_m, z_offset_m,
|
||||||
heading_offset_deg, pitch_offset_deg,
|
heading_offset_deg, pitch_offset_deg,
|
||||||
roll_offset_deg, fov_deg, aspect_ratio_multiplier,
|
roll_offset_deg, fov_deg, aspect_ratio_multiplier,
|
||||||
0, 0, 0, near_m, internal ));
|
0, 0, 0, near_m, internal ));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
copyToCurrent();
|
copyToCurrent();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGViewMgr::reinit ()
|
FGViewMgr::reinit ()
|
||||||
{
|
{
|
||||||
char stridx [ 20 ];
|
|
||||||
string viewpath, nodepath, strdata;
|
|
||||||
double fov_deg;
|
|
||||||
|
|
||||||
// reset offsets and fov to configuration defaults
|
// reset offsets and fov to configuration defaults
|
||||||
|
for (unsigned int i = 0; i < config_list.size(); i++) {
|
||||||
for (int i = 0; i < fgGetInt("/sim/number-views"); i++) {
|
SGPropertyNode *n = config_list[i];
|
||||||
viewpath = "/sim/view";
|
|
||||||
sprintf(stridx, "[%d]", i);
|
|
||||||
viewpath += stridx;
|
|
||||||
|
|
||||||
setView(i);
|
setView(i);
|
||||||
|
|
||||||
nodepath = viewpath;
|
fgSetDouble("/sim/current-view/x-offset-m",
|
||||||
nodepath += "/config/x-offset-m";
|
n->getDoubleValue("config/x-offset-m"));
|
||||||
fgSetDouble("/sim/current-view/x-offset-m",fgGetDouble(nodepath.c_str()));
|
fgSetDouble("/sim/current-view/y-offset-m",
|
||||||
|
n->getDoubleValue("config/y-offset-m"));
|
||||||
nodepath = viewpath;
|
fgSetDouble("/sim/current-view/z-offset-m",
|
||||||
nodepath += "/config/y-offset-m";
|
n->getDoubleValue("config/z-offset-m"));
|
||||||
fgSetDouble("/sim/current-view/y-offset-m",fgGetDouble(nodepath.c_str()));
|
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/z-offset-m";
|
|
||||||
fgSetDouble("/sim/current-view/z-offset-m",fgGetDouble(nodepath.c_str()));
|
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/pitch-offset-deg";
|
|
||||||
fgSetDouble("/sim/current-view/pitch-offset-deg",
|
fgSetDouble("/sim/current-view/pitch-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/pitch-offset-deg"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/heading-offset-deg";
|
|
||||||
fgSetDouble("/sim/current-view/heading-offset-deg",
|
fgSetDouble("/sim/current-view/heading-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/heading-offset-deg"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/roll-offset-deg";
|
|
||||||
fgSetDouble("/sim/current-view/roll-offset-deg",
|
fgSetDouble("/sim/current-view/roll-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/roll-offset-deg"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
double fov_deg = n->getDoubleValue("config/default-field-of-view-deg");
|
||||||
nodepath += "/config/default-field-of-view-deg";
|
if (fov_deg < 10.0)
|
||||||
fov_deg = fgGetDouble(nodepath.c_str());
|
|
||||||
if (fov_deg < 10.0) {
|
|
||||||
fov_deg = 55.0;
|
fov_deg = 55.0;
|
||||||
}
|
fgSetDouble("/sim/current-view/field-of-view", fov_deg);
|
||||||
fgSetDouble("/sim/current-view/field-of-view",fov_deg);
|
|
||||||
|
|
||||||
// target offsets for lookat mode only...
|
// target offsets for lookat mode only...
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-x-offset-m";
|
|
||||||
fgSetDouble("/sim/current-view/target-x-offset-deg",
|
fgSetDouble("/sim/current-view/target-x-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/target-x-offset-m"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-y-offset-m";
|
|
||||||
fgSetDouble("/sim/current-view/target-y-offset-deg",
|
fgSetDouble("/sim/current-view/target-y-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/target-y-offset-m"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-z-offset-m";
|
|
||||||
fgSetDouble("/sim/current-view/target-z-offset-deg",
|
fgSetDouble("/sim/current-view/target-z-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/target-z-offset-m"));
|
||||||
|
}
|
||||||
}
|
setView(0);
|
||||||
|
|
||||||
setView(0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef double (FGViewMgr::*double_getter)() const;
|
typedef double (FGViewMgr::*double_getter)() const;
|
||||||
|
@ -292,7 +187,7 @@ FGViewMgr::bind ()
|
||||||
&FGViewMgr::setGoalViewRollOffset_deg);
|
&FGViewMgr::setGoalViewRollOffset_deg);
|
||||||
fgSetArchivable("/sim/current-view/goal-roll-offset-deg");
|
fgSetArchivable("/sim/current-view/goal-roll-offset-deg");
|
||||||
|
|
||||||
fgTie("/sim/current-view/view-number", this,
|
fgTie("/sim/current-view/view-number", this,
|
||||||
&FGViewMgr::getView, &FGViewMgr::setView);
|
&FGViewMgr::getView, &FGViewMgr::setView);
|
||||||
fgSetArchivable("/sim/current-view/view-number", FALSE);
|
fgSetArchivable("/sim/current-view/view-number", FALSE);
|
||||||
|
|
||||||
|
@ -338,45 +233,24 @@ FGViewMgr::unbind ()
|
||||||
void
|
void
|
||||||
FGViewMgr::update (double dt)
|
FGViewMgr::update (double dt)
|
||||||
{
|
{
|
||||||
char stridx [20];
|
|
||||||
string viewpath, nodepath;
|
|
||||||
double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
|
|
||||||
|
|
||||||
FGViewer * view = get_current_view();
|
FGViewer * view = get_current_view();
|
||||||
if (view == 0)
|
if (view == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//
|
FGViewer *loop_view = (FGViewer *)get_view(current);
|
||||||
int i = current;
|
SGPropertyNode *n = config_list[current];
|
||||||
viewpath = "/sim/view";
|
double lon_deg, lat_deg, alt_ft, roll_deg, pitch_deg, heading_deg;
|
||||||
sprintf(stridx, "[%d]", i);
|
|
||||||
viewpath += stridx;
|
|
||||||
|
|
||||||
FGViewer *loop_view = (FGViewer *)get_view( i );
|
// Set up view location and orientation
|
||||||
|
|
||||||
// Set up view location and orientation
|
if (!n->getBoolValue("config/from-model")) {
|
||||||
|
lon_deg = fgGetDouble(n->getStringValue("config/eye-lon-deg-path"));
|
||||||
|
lat_deg = fgGetDouble(n->getStringValue("config/eye-lat-deg-path"));
|
||||||
|
alt_ft = fgGetDouble(n->getStringValue("config/eye-alt-ft-path"));
|
||||||
|
roll_deg = fgGetDouble(n->getStringValue("config/eye-roll-deg-path"));
|
||||||
|
pitch_deg = fgGetDouble(n->getStringValue("config/eye-pitch-deg-path"));
|
||||||
|
heading_deg = fgGetDouble(n->getStringValue("config/eye-heading-deg-path"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/from-model";
|
|
||||||
if (!fgGetBool(nodepath.c_str())) {
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/eye-lon-deg-path";
|
|
||||||
lon_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/eye-lat-deg-path";
|
|
||||||
lat_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/eye-alt-ft-path";
|
|
||||||
alt_ft = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/eye-roll-deg-path";
|
|
||||||
roll_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/eye-pitch-deg-path";
|
|
||||||
pitch_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/eye-heading-deg-path";
|
|
||||||
heading_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
loop_view->setPosition(lon_deg, lat_deg, alt_ft);
|
loop_view->setPosition(lon_deg, lat_deg, alt_ft);
|
||||||
loop_view->setOrientation(roll_deg, pitch_deg, heading_deg);
|
loop_view->setOrientation(roll_deg, pitch_deg, heading_deg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -386,27 +260,13 @@ FGViewMgr::update (double dt)
|
||||||
|
|
||||||
// if lookat (type 1) then get target data...
|
// if lookat (type 1) then get target data...
|
||||||
if (loop_view->getType() == FG_LOOKAT) {
|
if (loop_view->getType() == FG_LOOKAT) {
|
||||||
nodepath = viewpath;
|
if (!n->getBoolValue("config/from-model")) {
|
||||||
nodepath += "/config/from-model";
|
lon_deg = fgGetDouble(n->getStringValue("config/target-lon-deg-path"));
|
||||||
if (!fgGetBool(nodepath.c_str())) {
|
lat_deg = fgGetDouble(n->getStringValue("config/target-lat-deg-path"));
|
||||||
nodepath = viewpath;
|
alt_ft = fgGetDouble(n->getStringValue("config/target-alt-ft-path"));
|
||||||
nodepath += "/config/target-lon-deg-path";
|
roll_deg = fgGetDouble(n->getStringValue("config/target-roll-deg-path"));
|
||||||
lon_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
pitch_deg = fgGetDouble(n->getStringValue("config/target-pitch-deg-path"));
|
||||||
nodepath = viewpath;
|
heading_deg = fgGetDouble(n->getStringValue("config/target-heading-deg-path"));
|
||||||
nodepath += "/config/target-lat-deg-path";
|
|
||||||
lat_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-alt-ft-path";
|
|
||||||
alt_ft = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-roll-deg-path";
|
|
||||||
roll_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-pitch-deg-path";
|
|
||||||
pitch_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/target-heading-deg-path";
|
|
||||||
heading_deg = fgGetDouble(fgGetString(nodepath.c_str()));
|
|
||||||
|
|
||||||
loop_view->setTargetPosition(lon_deg, lat_deg, alt_ft);
|
loop_view->setTargetPosition(lon_deg, lat_deg, alt_ft);
|
||||||
loop_view->setTargetOrientation(roll_deg, pitch_deg, heading_deg);
|
loop_view->setTargetOrientation(roll_deg, pitch_deg, heading_deg);
|
||||||
|
@ -423,7 +283,7 @@ FGViewMgr::update (double dt)
|
||||||
setViewTargetYOffset_m(fgGetDouble("/sim/current-view/target-y-offset-m"));
|
setViewTargetYOffset_m(fgGetDouble("/sim/current-view/target-y-offset-m"));
|
||||||
setViewTargetZOffset_m(fgGetDouble("/sim/current-view/target-z-offset-m"));
|
setViewTargetZOffset_m(fgGetDouble("/sim/current-view/target-z-offset-m"));
|
||||||
|
|
||||||
// Update the current view
|
// Update the current view
|
||||||
do_axes();
|
do_axes();
|
||||||
view->update(dt);
|
view->update(dt);
|
||||||
}
|
}
|
||||||
|
@ -431,45 +291,25 @@ FGViewMgr::update (double dt)
|
||||||
void
|
void
|
||||||
FGViewMgr::copyToCurrent()
|
FGViewMgr::copyToCurrent()
|
||||||
{
|
{
|
||||||
char stridx [20];
|
SGPropertyNode *n = config_list[current];
|
||||||
string viewpath, nodepath;
|
|
||||||
|
|
||||||
int i = current;
|
|
||||||
viewpath = "/sim/view";
|
|
||||||
sprintf(stridx, "[%d]", i);
|
|
||||||
viewpath += stridx;
|
|
||||||
|
|
||||||
// copy certain view config data for default values
|
// copy certain view config data for default values
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/default-heading-offset-deg";
|
|
||||||
fgSetDouble("/sim/current-view/config/heading-offset-deg",
|
fgSetDouble("/sim/current-view/config/heading-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/default-heading-offset-deg"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/pitch-offset-deg";
|
|
||||||
fgSetDouble("/sim/current-view/config/pitch-offset-deg",
|
fgSetDouble("/sim/current-view/config/pitch-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/pitch-offset-deg"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/roll-offset-deg";
|
|
||||||
fgSetDouble("/sim/current-view/config/roll-offset-deg",
|
fgSetDouble("/sim/current-view/config/roll-offset-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/roll-offset-deg"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/default-field-of-view-deg";
|
|
||||||
fgSetDouble("/sim/current-view/config/default-field-of-view-deg",
|
fgSetDouble("/sim/current-view/config/default-field-of-view-deg",
|
||||||
fgGetDouble(nodepath.c_str()));
|
n->getDoubleValue("config/default-field-of-view-deg"));
|
||||||
|
|
||||||
nodepath = viewpath;
|
|
||||||
nodepath += "/config/from-model";
|
|
||||||
fgSetBool("/sim/current-view/config/from-model",
|
fgSetBool("/sim/current-view/config/from-model",
|
||||||
fgGetBool(nodepath.c_str()));
|
n->getBoolValue("config/from-model"));
|
||||||
|
|
||||||
|
|
||||||
// copy view data
|
// copy view data
|
||||||
fgSetDouble("/sim/current-view/x-offset-m", getViewXOffset_m());
|
fgSetDouble("/sim/current-view/x-offset-m", getViewXOffset_m());
|
||||||
fgSetDouble("/sim/current-view/y-offset-m", getViewYOffset_m());
|
fgSetDouble("/sim/current-view/y-offset-m", getViewYOffset_m());
|
||||||
fgSetDouble("/sim/current-view/z-offset-m", getViewZOffset_m());
|
fgSetDouble("/sim/current-view/z-offset-m", getViewZOffset_m());
|
||||||
|
|
||||||
fgSetDouble("/sim/current-view/goal-heading-offset-deg",
|
fgSetDouble("/sim/current-view/goal-heading-offset-deg",
|
||||||
get_current_view()->getGoalHeadingOffset_deg());
|
get_current_view()->getGoalHeadingOffset_deg());
|
||||||
fgSetDouble("/sim/current-view/goal-pitch-offset-deg",
|
fgSetDouble("/sim/current-view/goal-pitch-offset-deg",
|
||||||
|
@ -488,10 +328,8 @@ FGViewMgr::copyToCurrent()
|
||||||
get_current_view()->getTargetYOffset_m());
|
get_current_view()->getTargetYOffset_m());
|
||||||
fgSetDouble("/sim/current-view/target-z-offset-m",
|
fgSetDouble("/sim/current-view/target-z-offset-m",
|
||||||
get_current_view()->getTargetZOffset_m());
|
get_current_view()->getTargetZOffset_m());
|
||||||
|
|
||||||
fgSetBool("/sim/current-view/internal",
|
fgSetBool("/sim/current-view/internal",
|
||||||
get_current_view()->getInternal());
|
get_current_view()->getInternal());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -718,20 +556,31 @@ FGViewMgr::getView () const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
FGViewMgr::setView (int newview )
|
FGViewMgr::setView (int newview)
|
||||||
{
|
{
|
||||||
|
// negative numbers -> set view with node index -newview
|
||||||
|
if (newview < 0) {
|
||||||
|
for (int i = 0; i < (int)config_list.size(); i++) {
|
||||||
|
int index = -config_list[i]->getIndex();
|
||||||
|
if (index == newview)
|
||||||
|
newview = i;
|
||||||
|
}
|
||||||
|
if (newview < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// if newview number too low wrap to last view...
|
// if newview number too low wrap to last view...
|
||||||
if ( newview < 0 ) {
|
if (newview < 0)
|
||||||
newview = (int)views.size() -1;
|
newview = (int)views.size() -1;
|
||||||
}
|
|
||||||
// if newview number to high wrap to zero...
|
// if newview number to high wrap to zero...
|
||||||
if ( newview > ((int)views.size() -1) ) {
|
if (newview > ((int)views.size() -1))
|
||||||
newview = 0;
|
newview = 0;
|
||||||
}
|
|
||||||
// set new view
|
// set new view
|
||||||
set_view( newview );
|
set_view(newview);
|
||||||
// copy in view data
|
// copy in view data
|
||||||
copyToCurrent ();
|
copyToCurrent();
|
||||||
|
|
||||||
// Copy the fdm's position into the SGLocation which is shared with
|
// Copy the fdm's position into the SGLocation which is shared with
|
||||||
// some views ...
|
// some views ...
|
||||||
|
|
|
@ -24,11 +24,7 @@
|
||||||
#ifndef _VIEWMGR_HXX
|
#ifndef _VIEWMGR_HXX
|
||||||
#define _VIEWMGR_HXX
|
#define _VIEWMGR_HXX
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#ifndef __cplusplus
|
|
||||||
# error This library requires C++
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#include <simgear/compiler.h>
|
#include <simgear/compiler.h>
|
||||||
#include <simgear/structure/subsystem_mgr.hxx>
|
#include <simgear/structure/subsystem_mgr.hxx>
|
||||||
|
@ -37,8 +33,7 @@
|
||||||
# include <config.h>
|
# include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <vector>
|
#include "fg_props.hxx"
|
||||||
|
|
||||||
#include "viewer.hxx"
|
#include "viewer.hxx"
|
||||||
|
|
||||||
SG_USING_STD(vector);
|
SG_USING_STD(vector);
|
||||||
|
@ -151,7 +146,8 @@ private:
|
||||||
int getView () const;
|
int getView () const;
|
||||||
void setView (int newview);
|
void setView (int newview);
|
||||||
|
|
||||||
typedef vector < FGViewer * > viewer_list;
|
vector<SGPropertyNode_ptr> config_list;
|
||||||
|
typedef vector<FGViewer *> viewer_list;
|
||||||
viewer_list views;
|
viewer_list views;
|
||||||
|
|
||||||
int current;
|
int current;
|
||||||
|
|
Loading…
Reference in a new issue