Break some subsystem dependencies, by explicitly using properties to read the primary position, orientation and velocities. (Instead of directly accessing the primary model placement). This means a couple more globals can die.
// ordering here is important : Nasal (via events), then models, then views
globals->add_subsystem("events", globals->get_event_mgr(), SGSubsystemMgr::DISPLAY);
-
- FGAircraftModel* acm = new FGAircraftModel;
- globals->set_aircraft_model(acm);
- globals->add_subsystem("aircraft-model", acm, SGSubsystemMgr::DISPLAY);
- FGModelMgr* mm = new FGModelMgr;
- globals->set_model_mgr(mm);
- globals->add_subsystem("model-manager", mm, SGSubsystemMgr::DISPLAY);
+ globals->add_subsystem("aircraft-model", new FGAircraftModel, SGSubsystemMgr::DISPLAY);
+ globals->add_subsystem("model-manager", new FGModelMgr, SGSubsystemMgr::DISPLAY);
FGViewMgr *viewmgr = new FGViewMgr;
globals->set_viewmgr( viewmgr );
#include <simgear/misc/ResourceManager.hxx>
#include <simgear/props/propertyObject.hxx>
#include <simgear/props/props_io.hxx>
-#include <simgear/scene/model/placement.hxx>
#include <Aircraft/controls.hxx>
#include <Airports/runways.hxx>
#include <Autopilot/route_mgr.hxx>
#include <GUI/FGFontCache.hxx>
#include <GUI/gui.h>
-#include <Model/acmodel.hxx>
-#include <Model/modelmgr.hxx>
#include <MultiPlayer/multiplaymgr.hxx>
#include <Scenery/scenery.hxx>
#include <Scenery/tilemgr.hxx>
controls( NULL ),
viewmgr( NULL ),
commands( SGCommandMgr::instance() ),
- acmodel( NULL ),
- model_mgr( NULL ),
channel_options_list( NULL ),
initial_waypoints( NULL ),
scenery( NULL ),
tile_mgr( NULL ),
fontcache ( new FGFontCache ),
- navlist( NULL ),
- loclist( NULL ),
- gslist( NULL ),
- dmelist( NULL ),
- tacanlist( NULL ),
- carrierlist( NULL ),
channellist( NULL ),
haveUserSettings(false)
{
simgear::ResourceManager::instance()->addProvider(new AircraftResourceProvider());
simgear::PropertyObjectBase::setDefaultRoot(props);
+
+ positionLon = props->getNode("position/longitude-deg", true);
+ positionLat = props->getNode("position/latitude-deg", true);
+ positionAlt = props->getNode("position/altitude-ft", true);
+
+ orientPitch = props->getNode("orientation/pitch-deg", true);
+ orientHeading = props->getNode("orientation/heading-deg", true);
+ orientRoll = props->getNode("orientation/roll-deg", true);
}
// Destructor
delete scenery;
delete fontcache;
- delete navlist;
- delete loclist;
- delete gslist;
- delete dmelist;
- delete tacanlist;
- delete carrierlist;
delete channellist;
delete sound;
SGGeod
FGGlobals::get_aircraft_position() const
{
- if( acmodel != NULL ) {
- SGModelPlacement * mp = acmodel->get3DModel();
- if( mp != NULL )
- return mp->getPosition();
- }
-
- // fall back to reading the property tree. this can occur during
- // startup before the acmodel is initialised
-
- return SGGeod::fromDegFt(fgGetDouble("/position/longitude-deg"),
- fgGetDouble("/position/latitude-deg"),
- fgGetDouble("/position/altitude-ft"));
+ return SGGeod::fromDegFt(positionLon->getDoubleValue(),
+ positionLat->getDoubleValue(),
+ positionAlt->getDoubleValue());
}
SGVec3d
return SGVec3d::fromGeod(get_aircraft_position());
}
+void FGGlobals::get_aircraft_orientation(double& heading, double& pitch, double& roll)
+{
+ heading = orientHeading->getDoubleValue();
+ pitch = orientPitch->getDoubleValue();
+ roll = orientRoll->getDoubleValue();
+}
+
// Save the current state as the initial state.
void
class SGSoundMgr;
class FGATISMgr;
-class FGAircraftModel;
class FGControls;
-class FGFlightPlanDispatcher;
-class FGNavList;
class FGTACANList;
class FGLocale;
-class FGModelMgr;
class FGRouteMgr;
class FGScenery;
class FGTileMgr;
SGCommandMgr *commands;
- //FGFlightPlanDispatcher *fpDispatcher;
-
- FGAircraftModel *acmodel;
-
- FGModelMgr * model_mgr;
-
// list of serial port-like configurations
string_list *channel_options_list;
FGFontCache *fontcache;
// Navigational Aids
- FGNavList *navlist;
- FGNavList *loclist;
- FGNavList *gslist;
- FGNavList *dmelist;
- FGNavList *tacanlist;
- FGNavList *carrierlist;
FGTACANList *channellist;
/// roots of Aircraft trees
bool haveUserSettings;
+ SGPropertyNode_ptr positionLon, positionLat, positionAlt;
+ SGPropertyNode_ptr orientHeading, orientPitch, orientRoll;
public:
FGGlobals();
inline SGCommandMgr *get_commands () { return commands; }
- inline FGAircraftModel *get_aircraft_model () { return acmodel; }
-
- inline void set_aircraft_model (FGAircraftModel * model)
- {
- acmodel = model;
- }
-
SGGeod get_aircraft_position() const;
SGVec3d get_aircraft_positon_cart() const;
-
- inline FGModelMgr *get_model_mgr () { return model_mgr; }
-
- inline void set_model_mgr (FGModelMgr * mgr)
- {
- model_mgr = mgr;
- }
+ void get_aircraft_orientation(double& heading, double& pitch, double& roll);
+
inline string_list *get_channel_options_list () {
return channel_options_list;
}
inline void set_tile_mgr ( FGTileMgr *t ) { tile_mgr = t; }
inline FGFontCache *get_fontcache() const { return fontcache; }
-
-#if 0
- inline FGNavList *get_navlist() const { return navlist; }
- inline void set_navlist( FGNavList *n ) { navlist = n; }
- inline FGNavList *get_loclist() const { return loclist; }
- inline void set_loclist( FGNavList *n ) { loclist = n; }
- inline FGNavList *get_gslist() const { return gslist; }
- inline void set_gslist( FGNavList *n ) { gslist = n; }
- inline FGNavList *get_dmelist() const { return dmelist; }
- inline void set_dmelist( FGNavList *n ) { dmelist = n; }
- inline FGNavList *get_tacanlist() const { return tacanlist; }
- inline void set_tacanlist( FGNavList *n ) { tacanlist = n; }
- inline FGNavList *get_carrierlist() const { return carrierlist; }
- inline void set_carrierlist( FGNavList *n ) { carrierlist = n; }
-#endif
inline FGTACANList *get_channellist() const { return channellist; }
inline void set_channellist( FGTACANList *c ) { channellist = c; }
{
// Update location data ...
if ( _from_model ) {
- SGModelPlacement* placement = globals->get_aircraft_model()->get3DModel();
- _position = placement->getPosition();
-
- _heading_deg = placement->getHeadingDeg();
- _pitch_deg = placement->getPitchDeg();
- _roll_deg = placement->getRollDeg();
+ _position = globals->get_aircraft_position();
+ globals->get_aircraft_orientation(_heading_deg, _pitch_deg, _roll_deg);
}
double head = _heading_deg;
{
// The geodetic position of our target to look at
if ( _at_model ) {
- SGModelPlacement* placement = globals->get_aircraft_model()->get3DModel();
- _target = placement->getPosition();
- _target_heading_deg = placement->getHeadingDeg();
- _target_pitch_deg = placement->getPitchDeg();
- _target_roll_deg = placement->getRollDeg();
+ _target = globals->get_aircraft_position();
+ globals->get_aircraft_orientation(_target_heading_deg,
+ _target_pitch_deg,
+ _target_roll_deg);
} else {
// if not model then calculate our own target position...
setDampTarget(_target_roll_deg, _target_pitch_deg, _target_heading_deg);
if ( _from_model ) {
- SGModelPlacement* placement = globals->get_aircraft_model()->get3DModel();
- _position = placement->getPosition();
- _heading_deg = placement->getHeadingDeg();
- _pitch_deg = placement->getPitchDeg();
- _roll_deg = placement->getRollDeg();
+ _position = globals->get_aircraft_position();
+ globals->get_aircraft_orientation(_heading_deg, _pitch_deg, _roll_deg);
} else {
// update from our own data, just the rotation here...
setDampTarget(_roll_deg, _pitch_deg, _heading_deg);
#include <simgear/compiler.h>
#include <simgear/sound/soundmgr_openal.hxx>
-#include <Model/acmodel.hxx>
#include <Main/fg_props.hxx>
#include "viewer.hxx"
void
FGViewMgr::do_bind()
{
+ velocityNorthFPS = fgGetNode("velocities/speed-north-fps", true);
+ velocityEastFPS = fgGetNode("velocities/speed-east-fps", true);
+ velocityDownFPS = fgGetNode("velocities/speed-down-fps", true);
+
// these are bound to the current view properties
_tiedProperties.setRoot(fgGetNode("/sim/current-view", true));
_tiedProperties.Tie("heading-offset-deg", this,
// get the model velocity
SGVec3d velocity = SGVec3d::zeros();
if ( !stationary() ) {
- velocity = globals->get_aircraft_model()->getVelocity();
+ velocity = SGVec3d( velocityNorthFPS->getDoubleValue(),
+ velocityEastFPS->getDoubleValue(),
+ velocityDownFPS->getDoubleValue() );
}
smgr->set_velocity( velocity );
}
SGQuatd current_view_orientation, current_view_or_offset;
SGSoundMgr *smgr;
-
+
+ SGPropertyNode_ptr velocityNorthFPS, velocityEastFPS, velocityDownFPS;
};
// This takes the conventional aviation XYZ body system