]> git.mxchange.org Git - flightgear.git/blobdiff - Astro/moon.cxx
Renamed class fgFLIGHT to class FGState as per request by JSB.
[flightgear.git] / Astro / moon.cxx
index bc7425ce4357fc64c4c929f3d77c3afe815079cf..6ca80c5aee8560c152eabc8960b47c51d94b4e70 100644 (file)
 
 #include <string.h>
 #include "moon.hxx"
-#include <Debug/fg_debug.h>
+#include <Debug/logstream.hxx>
 #include <Objects/texload.h>
 
+
+#ifdef __BORLANDC__
+#  define exception c_exception
+#endif
+#include <math.h>
+
 static GLuint moon_texid;
 static GLubyte *moon_texbuf;
 
@@ -51,7 +57,7 @@ Moon::Moon(fgTIME *t) :
   string tpath, fg_tpath;
   int width, height;
   
-  fgPrintf( FG_GENERAL, FG_INFO, "Initializing Moon Texture\n");
+  FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
 #ifdef GL_VERSION_1_1
   xglGenTextures(1, &moon_texid);
   xglBindTexture(GL_TEXTURE_2D, moon_texid);
@@ -77,9 +83,9 @@ Moon::Moon(fgTIME *t) :
     if ( (moon_texbuf = read_rgb_texture(fg_tpath.c_str(), &width, &height)) 
         == NULL )
     {
-      fgPrintf( FG_GENERAL, FG_EXIT, 
-               "Error in loading moon texture %s\n", tpath.c_str() );
-      exit(1);
+       FG_LOG( FG_GENERAL, FG_ALERT, 
+               "Error in loading moon texture " << tpath );
+       exit(-1);
     } 
   } 
 
@@ -106,10 +112,10 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
     geoRa, geoDec;
   
   fgAIRCRAFT *air;
-  fgFLIGHT *f;
+  FGState *f;
 
   air = &current_aircraft;
-  f = air->flight;
+  f = air->fdm_state;
  
   updateOrbElements(t);
   actTime = fgCalcActTime(t);
@@ -162,7 +168,7 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
   r += (-0.58 * cos(M - 2*D)
        -0.46 * cos(2*D)
        );
-  fgPrintf(FG_GENERAL, FG_INFO, "Running moon update\n");
+  FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
   xg = r * cos(lonecl) * cos(latecl);
   yg = r * sin(lonecl) * cos(latecl);
   zg = r *               sin(latecl);
@@ -181,8 +187,9 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
   // First calculates the moon's parrallax, that is, the apparent size of the 
   // (equatorial) radius of the earth, as seen from the moon 
   mpar = asin ( 1 / r);
-  gclat = FG_Latitude - 0.003358 * sin (2 * DEG_TO_RAD * FG_Latitude);
-  rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * FG_Latitude);
+  gclat = f->get_Latitude() - 0.003358 * 
+      sin (2 * DEG_TO_RAD * f->get_Latitude() );
+  rho = 0.99883 + 0.00167 * cos(2 * DEG_TO_RAD * f->get_Latitude());
   if (geoRa < 0)
     geoRa += (2*FG_PI);
   
@@ -213,8 +220,9 @@ void Moon::newImage(float ra, float dec)
   xglRotatef(((RAD_TO_DEG * ra)- 90.0), 0.0, 0.0, 1.0);
   xglRotatef((RAD_TO_DEG * dec), 1.0, 0.0, 0.0);
 
-  fgPrintf( FG_GENERAL, FG_INFO, 
-          "Ra = (%f), Dec= (%f)", (RAD_TO_DEG *ra), (RAD_TO_DEG *dec) );
+  FG_LOG( FG_GENERAL, FG_INFO, 
+         "Ra = (" << (RAD_TO_DEG *ra) 
+         << "), Dec= (" << (RAD_TO_DEG *dec) << ")" );
   xglTranslatef(0.0, 58600.0, 0.0);
   Object = gluNewQuadric();
   gluQuadricTexture( Object, GL_TRUE );