]> git.mxchange.org Git - flightgear.git/commitdiff
Tidying up the SGEphemeris class.
authorcurt <curt>
Sat, 8 Jul 2000 05:09:24 +0000 (05:09 +0000)
committercurt <curt>
Sat, 8 Jul 2000 05:09:24 +0000 (05:09 +0000)
src/Main/globals.hxx
src/Main/main.cxx
src/Time/moonpos.cxx
src/Time/sunpos.cxx

index d21fce514b8f07df96b3bab8fd4860da3e1551f9..bc225f998a19de4647ce11b137cd7c1c9097e055 100644 (file)
@@ -25,6 +25,7 @@
 #define _GLOBALS_HXX
 
 
+#include <simgear/ephemeris/ephemeris.hxx>
 #include <simgear/timing/sg_time.hxx>
 
 
@@ -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; }
 };
 
 
index 1a93b585d71bb33783efbacb3a1161e5c5f9699d..179b7beb8cf27ff8bb002a99db1e3a52d57d3c83 100644 (file)
@@ -66,7 +66,6 @@
 
 #include <simgear/constants.h>  // for VERSION
 #include <simgear/debug/logstream.hxx>
-#include <simgear/ephemeris/ephemeris.hxx>
 #include <simgear/math/fg_geodesy.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/fg_random.h>
@@ -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 );
index 6a7e895d8e96b51fe7768dcff2347395a5a543a0..e3b30b34d7c8fc5fd9f93fb3fbf32009a7d48a51 100644 (file)
@@ -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);
index 68c35421cd9390a1015d6fb963391451eada1e2e..c22f57f2abc91308f4f44a09867b2aaa7f22220f 100644 (file)
@@ -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);