From 6bd02587aae5216d90921162c968fee9dbec139a Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 8 Jul 2000 05:09:24 +0000 Subject: [PATCH] Tidying up the SGEphemeris class. --- src/Main/globals.hxx | 7 +++++++ src/Main/main.cxx | 45 +++++++++++++++++++++++++------------------- src/Time/moonpos.cxx | 9 +++------ src/Time/sunpos.cxx | 9 +++------ 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/src/Main/globals.hxx b/src/Main/globals.hxx index d21fce514..bc225f998 100644 --- a/src/Main/globals.hxx +++ b/src/Main/globals.hxx @@ -25,6 +25,7 @@ #define _GLOBALS_HXX +#include #include @@ -46,6 +47,9 @@ private: // Time structure SGTime *time_params; + // Sky structures + SGEphemeris *ephem; + public: FGGlobals(); @@ -64,6 +68,9 @@ public: 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; } }; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 1a93b585d..179b7beb8 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -66,7 +66,6 @@ #include // for VERSION #include -#include #include #include #include @@ -161,7 +160,6 @@ ssgTransform *fgd_pos = NULL; FGInterface cur_view_fdm; // Sky structures -FGEphemeris *ephem; SGSky *thesky; // hack @@ -418,8 +416,10 @@ void fgRenderFrame( void ) { cur_light_params.adj_fog_color, cur_light_params.sun_angle, cur_light_params.moon_angle, - ephem->getNumPlanets(), ephem->getPlanets(), - ephem->getNumStars(), ephem->getStars() ); + globals->get_ephem()->getNumPlanets(), + globals->get_ephem()->getPlanets(), + globals->get_ephem()->getNumStars(), + globals->get_ephem()->getStars() ); /* cout << "thesky->reposition( view_pos = " << view_pos[0] << " " << view_pos[1] << " " << view_pos[2] << endl; @@ -429,10 +429,10 @@ void fgRenderFrame( void ) { << " lat = " << cur_fdm_state->get_Latitude() << endl; cout << " sun_rot = " << cur_light_params.sun_rotation << " gst = " << SGTime::cur_time_params->getGst() << endl; - cout << " sun ra = " << ephem->getSunRightAscension() - << " sun dec = " << ephem->getSunDeclination() - << " moon ra = " << ephem->getMoonRightAscension() - << " moon dec = " << ephem->getMoonDeclination() << endl; */ + cout << " sun ra = " << globals->get_ephem()->getSunRightAscension() + << " sun dec = " << globals->get_ephem()->getSunDeclination() + << " moon ra = " << globals->get_ephem()->getMoonRightAscension() + << " moon dec = " << globals->get_ephem()->getMoonDeclination() << endl; */ thesky->reposition( view_pos, zero_elev, current_view.get_local_up(), @@ -441,10 +441,12 @@ void fgRenderFrame( void ) { cur_fdm_state->get_Altitude() * FEET_TO_METER, cur_light_params.sun_rotation, globals->get_time_params()->getGst(), - ephem->getSunRightAscension(), - ephem->getSunDeclination(), 50000.0, - ephem->getMoonRightAscension(), - ephem->getMoonDeclination(), 50000.0 ); + globals->get_ephem()->getSunRightAscension(), + globals->get_ephem()->getSunDeclination(), + 50000.0, + globals->get_ephem()->getMoonRightAscension(), + globals->get_ephem()->getMoonDeclination(), + 50000.0 ); } glEnable( GL_DEPTH_TEST ); @@ -693,7 +695,9 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) { l->UpdateAdjFog(); // Update solar system - ephem->update( globals->get_time_params(), cur_fdm_state->get_Latitude() ); + globals->get_ephem()->update( globals->get_time_params()->getMjd(), + globals->get_time_params()->getLst(), + cur_fdm_state->get_Latitude() ); // Update radio stack model current_radiostack->update( cur_fdm_state->get_Longitude(), @@ -1390,8 +1394,11 @@ int main( int argc, char **argv ) { // Initialize the sky FGPath ephem_data_path( current_options.get_fg_root() ); ephem_data_path.append( "Astro" ); - ephem = new FGEphemeris( ephem_data_path.c_str() ); - ephem->update( globals->get_time_params(), 0.0 ); + SGEphemeris *ephem = new SGEphemeris( ephem_data_path.c_str() ); + ephem->update( globals->get_time_params()->getMjd(), + globals->get_time_params()->getLst(), + 0.0 ); + globals->set_ephem( ephem ); FGPath sky_tex_path( current_options.get_fg_root() ); sky_tex_path.append( "Textures" ); @@ -1400,10 +1407,10 @@ int main( int argc, char **argv ) { thesky->texture_path( sky_tex_path.str() ); thesky->build( 550.0, 550.0, - ephem->getNumPlanets(), - ephem->getPlanets(), 60000.0, - ephem->getNumStars(), - ephem->getStars(), 60000.0 ); + globals->get_ephem()->getNumPlanets(), + globals->get_ephem()->getPlanets(), 60000.0, + globals->get_ephem()->getNumStars(), + globals->get_ephem()->getStars(), 60000.0 ); thesky->add_cloud_layer( 2600.0, 200.0, 50.0, 40000.0, SG_CLOUD_MOSTLY_SUNNY ); diff --git a/src/Time/moonpos.cxx b/src/Time/moonpos.cxx index 6a7e895d8..e3b30b34d 100644 --- a/src/Time/moonpos.cxx +++ b/src/Time/moonpos.cxx @@ -65,9 +65,6 @@ #include "moonpos.hxx" -// extern SolarSystem *solarSystem; -extern FGEphemeris *ephem; - #undef E @@ -283,7 +280,7 @@ void fgMoonPosition(time_t ssue, double *lon, double *lat) { * every ten minutes. (Comment added by Durk Talsma). ************************************************************************/ - ecliptic_to_equatorial( ephem->get_moon()->getLon(), + ecliptic_to_equatorial( globals->get_ephem()->get_moon()->getLon(), 0.0, &alpha, &delta ); tmp = alpha - (FG_2PI/24)*GST(ssue); if (tmp < -FG_PI) { @@ -315,8 +312,8 @@ static void fgMoonPositionGST(double gst, double *lon, double *lat) { /* lambda = moon_ecliptic_longitude(ssue); */ /* ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta); */ //ecliptic_to_equatorial (solarPosition.lonMoon, 0.0, &alpha, &delta); - ecliptic_to_equatorial( ephem->get_moon()->getLon(), - ephem->get_moon()->getLat(), + ecliptic_to_equatorial( globals->get_ephem()->get_moon()->getLon(), + globals->get_ephem()->get_moon()->getLat(), &alpha, &delta ); // tmp = alpha - (FG_2PI/24)*GST(ssue); diff --git a/src/Time/sunpos.cxx b/src/Time/sunpos.cxx index 68c35421c..c22f57f2a 100644 --- a/src/Time/sunpos.cxx +++ b/src/Time/sunpos.cxx @@ -67,9 +67,6 @@ #include "sunpos.hxx" -// extern SolarSystem *solarSystem; -extern FGEphemeris *ephem; - #undef E #define MeanObliquity (23.440592*(FG_2PI/360)) @@ -192,7 +189,7 @@ void fgSunPosition(time_t ssue, double *lon, double *lat) { * every ten minutes. (Comment added by Durk Talsma). ************************************************************************/ - ecliptic_to_equatorial( ephem->get_sun()->getLon(), + ecliptic_to_equatorial( globals->get_ephem()->get_sun()->getLon(), 0.0, &alpha, &delta ); tmp = alpha - (FG_2PI/24)*GST(ssue); if (tmp < -FG_PI) { @@ -224,8 +221,8 @@ static void fgSunPositionGST(double gst, double *lon, double *lat) { /* lambda = sun_ecliptic_longitude(ssue); */ /* ecliptic_to_equatorial(lambda, 0.0, &alpha, &delta); */ //ecliptic_to_equatorial (solarPosition.lonSun, 0.0, &alpha, &delta); - ecliptic_to_equatorial( ephem->get_sun()->getLon(), - ephem->get_sun()->getLat(), + ecliptic_to_equatorial( globals->get_ephem()->get_sun()->getLon(), + globals->get_ephem()->get_sun()->getLat(), &alpha, &delta ); // tmp = alpha - (FG_2PI/24)*GST(ssue); -- 2.39.5