Ephemeris::~Ephemeris()
{
- delete _impl;
+}
+
+SGEphemeris* Ephemeris::data()
+{
+ return _impl;
}
void Ephemeris::init()
SGPath ephem_data_path(globals->get_fg_root());
ephem_data_path.append("Astro");
_impl = new SGEphemeris(ephem_data_path.c_str());
- globals->set_ephem(_impl);
tieStar("/ephemeris/sun/xs", _impl->get_sun(), &Star::getxs);
tieStar("/ephemeris/sun/ys", _impl->get_sun(), &Star::getys);
tieStar("/ephemeris/sun/ze", _impl->get_sun(), &Star::getze);
tieStar("/ephemeris/sun/ye", _impl->get_sun(), &Star::getye);
tieStar("/ephemeris/sun/lat-deg", _impl->get_sun(), &Star::getLat);
-
- _latProp = fgGetNode("/position/latitude-deg", true);
- update(0.0);
+
+ _latProp = fgGetNode("/position/latitude-deg", true);
+
+ update(0.0);
+}
+
+void Ephemeris::shutdown()
+{
+ delete _impl;
+ _impl = NULL;
}
void Ephemeris::postinit()
{
-
}
void Ephemeris::bind()
void Ephemeris::unbind()
{
+ _latProp = 0;
}
void Ephemeris::update(double)
{
- SGTime* st = globals->get_time_params();
- _impl->update(st->getMjd(), st->getLst(), _latProp->getDoubleValue());
+ SGTime* st = globals->get_time_params();
+ _impl->update(st->getMjd(), st->getLst(), _latProp->getDoubleValue());
}
virtual void unbind();
virtual void update(double dt);
virtual void init();
- virtual void postinit();
-
+ virtual void shutdown();
+ virtual void postinit();
+
+ static const char* subsystemName() { return "ephemeris"; }
+
+ SGEphemeris* data();
private:
SGEphemeris* _impl;
SGPropertyNode* _latProp;
// Initialize the weather modeling subsystem
globals->add_subsystem("environment", new FGEnvironmentMgr);
- globals->add_subsystem("ephemeris", new Ephemeris);
+ globals->add_new_subsystem<Ephemeris>();
////////////////////////////////////////////////////////////////////
// Initialize the aircraft systems and instrumentation (before the
fg_root( "" ),
fg_home( "" ),
time_params( NULL ),
- ephem( NULL ),
commands( SGCommandMgr::instance() ),
channel_options_list( NULL ),
initial_waypoints( NULL ),
// pointers, we don't need to know anything about the class details
// anyway.
-class SGEphemeris;
class SGCommandMgr;
class SGMaterialLib;
class SGPropertyNode;
// Time structure
SGTime *time_params;
- // Sky structures
- SGEphemeris *ephem;
-
// Material properties library
SGSharedPtr<SGMaterialLib> matlib;
inline SGTime *get_time_params() const { return time_params; }
inline void set_time_params( SGTime *t ) { time_params = t; }
- inline SGEphemeris *get_ephem() const { return ephem; }
- inline void set_ephem( SGEphemeris *e ) { ephem = e; }
-
inline SGMaterialLib *get_matlib() const { return matlib; }
void set_matlib( SGMaterialLib *m );
#include <Instrumentation/HUD/HUD.hxx>
#include <Environment/precipitation_mgr.hxx>
#include <Environment/environment_mgr.hxx>
+#include <Environment/ephemeris.hxx>
//#include <Main/main.hxx>
#include "viewer.hxx"
setupRoot();
-// build the sky
+// build the sky
+ Ephemeris* ephemerisSub = globals->get_subsystem<Ephemeris>();
+
+
// The sun and moon diameters are scaled down numbers of the
// actual diameters. This was needed to fit both the sun and the
// moon within the distance to the far clip plane.
opt->setPropertyNode(globals->get_props());
_sky->build( 80000.0, 80000.0,
463.3, 361.8,
- *globals->get_ephem(),
+ *ephemerisSub->data(),
fgGetNode("/environment", true),
opt.get());
} else {
sun_horiz_eff = moon_horiz_eff = 1.0;
}
+
+
SGSkyState sstate;
sstate.pos = globals->get_current_view()->getViewPosition();
scolor.cloud_color = SGVec3f(l->cloud_color().data());
scolor.sun_angle = l->get_sun_angle();
scolor.moon_angle = l->get_moon_angle();
-
+
+ Ephemeris* ephemerisSub = globals->get_subsystem<Ephemeris>();
double delta_time_sec = _sim_delta_sec->getDoubleValue();
- _sky->reposition( sstate, *globals->get_ephem(), delta_time_sec );
- _sky->repaint( scolor, *globals->get_ephem() );
+ _sky->reposition( sstate, *ephemerisSub->data(), delta_time_sec );
+ _sky->repaint( scolor, *ephemerisSub->data() );
}
void