From fcfbba74dbf5702945f7df6e235ce51ffc6f092d Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 8 Apr 1999 19:53:46 +0000 Subject: [PATCH] Changed contributed by Durk Talsma: - Converted struct fgTIME to class FGTime - Don't draw textured moon/sun halos when --disable-textures requested --- Simulator/Astro/celestialBody.cxx | 2 +- Simulator/Astro/celestialBody.hxx | 22 +- Simulator/Astro/jupiter.cxx | 8 +- Simulator/Astro/jupiter.hxx | 4 +- Simulator/Astro/mars.cxx | 8 +- Simulator/Astro/mars.hxx | 4 +- Simulator/Astro/mercury.cxx | 8 +- Simulator/Astro/mercury.hxx | 4 +- Simulator/Astro/moon.cxx | 50 +++-- Simulator/Astro/moon.hxx | 4 +- Simulator/Astro/neptune.cxx | 8 +- Simulator/Astro/neptune.hxx | 4 +- Simulator/Astro/pluto.hxx | 2 +- Simulator/Astro/saturn.cxx | 8 +- Simulator/Astro/saturn.hxx | 4 +- Simulator/Astro/solarsystem.cxx | 6 +- Simulator/Astro/solarsystem.hxx | 2 +- Simulator/Astro/star.cxx | 51 +++-- Simulator/Astro/star.hxx | 4 +- Simulator/Astro/stars.cxx | 4 +- Simulator/Astro/stars.hxx | 3 +- Simulator/Astro/uranus.cxx | 8 +- Simulator/Astro/uranus.hxx | 4 +- Simulator/Astro/venus.cxx | 8 +- Simulator/Astro/venus.hxx | 4 +- Simulator/Main/3dfx.sh | 2 +- Simulator/Main/GLUTkey.cxx | 14 +- Simulator/Main/GLUTmain.cxx | 20 +- Simulator/Main/fg_init.cxx | 12 +- Simulator/Main/fg_serial.cxx | 42 ++-- Simulator/Time/fg_time.cxx | 338 ++++++++++++++++-------------- Simulator/Time/fg_time.hxx | 58 +++-- Simulator/Time/light.cxx | 4 +- Simulator/Time/moonpos.cxx | 8 +- Simulator/Time/sunpos.cxx | 8 +- 35 files changed, 396 insertions(+), 344 deletions(-) diff --git a/Simulator/Astro/celestialBody.cxx b/Simulator/Astro/celestialBody.cxx index 5f13edb5f..715cd6133 100644 --- a/Simulator/Astro/celestialBody.cxx +++ b/Simulator/Astro/celestialBody.cxx @@ -50,7 +50,7 @@ * return value: none * *************************************************************************/ -void CelestialBody::updatePosition(fgTIME *t, Star *ourSun) +void CelestialBody::updatePosition(FGTime *t, Star *ourSun) { double eccAnom, v, ecl, actTime, xv, yv, xh, yh, zh, xg, yg, zg, xe, ye, ze; diff --git a/Simulator/Astro/celestialBody.hxx b/Simulator/Astro/celestialBody.hxx index 31eaa5cc5..3deccc09f 100644 --- a/Simulator/Astro/celestialBody.hxx +++ b/Simulator/Astro/celestialBody.hxx @@ -61,8 +61,8 @@ protected: // make the data protected, in order to give the inherit double lonEcl, latEcl; double fgCalcEccAnom(double M, double e); - double fgCalcActTime(fgTIME *t); - void updateOrbElements(fgTIME *t); + double fgCalcActTime(FGTime *t); + void updateOrbElements(FGTime *t); public: CelestialBody(double Nf, double Ns, @@ -70,12 +70,12 @@ public: double wf, double ws, double af, double as, double ef, double es, - double Mf, double Ms, fgTIME *t); + double Mf, double Ms, FGTime *t); void getPos(double *ra, double *dec); void getPos(double *ra, double *dec, double *magnitude); double getLon(); double getLat(); - void updatePosition(fgTIME *t, Star *ourSun); + void updatePosition(FGTime *t, Star *ourSun); }; /***************************************************************************** @@ -103,7 +103,7 @@ inline CelestialBody::CelestialBody(double Nf, double Ns, double wf, double ws, double af, double as, double ef, double es, - double Mf, double Ms, fgTIME *t) + double Mf, double Ms, FGTime *t) { NFirst = Nf; NSec = Ns; iFirst = If; iSec = Is; @@ -115,15 +115,15 @@ inline CelestialBody::CelestialBody(double Nf, double Ns, }; /**************************************************************************** - * inline void CelestialBody::updateOrbElements(fgTIME *t) + * inline void CelestialBody::updateOrbElements(FGTime *t) * given the current time, this private member calculates the actual * orbital elements * - * Arguments: fgTIME *t: the current time: + * Arguments: FGTime *t: the current time: * * return value: none ***************************************************************************/ -inline void CelestialBody::updateOrbElements(fgTIME *t) +inline void CelestialBody::updateOrbElements(FGTime *t) { double actTime = fgCalcActTime(t); M = DEG_TO_RAD * (MFirst + (MSec * actTime)); @@ -134,7 +134,7 @@ inline void CelestialBody::updateOrbElements(fgTIME *t) a = aFirst + (aSec * actTime); } /***************************************************************************** - * inline double CelestialBody::fgCalcActTime(fgTIME *t) + * inline double CelestialBody::fgCalcActTime(FGTime *t) * this private member function returns the offset in days from the epoch for * wich the orbital elements are calculated (Jan, 1st, 2000). * @@ -142,9 +142,9 @@ inline void CelestialBody::updateOrbElements(fgTIME *t) * * return value: the (fractional) number of days until Jan 1, 2000. ****************************************************************************/ -inline double CelestialBody::fgCalcActTime(fgTIME *t) +inline double CelestialBody::fgCalcActTime(FGTime *t) { - return (t->mjd - 36523.5); + return (t->getMjd() - 36523.5); } /***************************************************************************** diff --git a/Simulator/Astro/jupiter.cxx b/Simulator/Astro/jupiter.cxx index 2f65504d4..668b586fb 100644 --- a/Simulator/Astro/jupiter.cxx +++ b/Simulator/Astro/jupiter.cxx @@ -31,13 +31,13 @@ #include "jupiter.hxx" /************************************************************************* - * Jupiter::Jupiter(fgTIME *t) + * Jupiter::Jupiter(FGTime *t) * Public constructor for class Jupiter * Argument: The current time. * the hard coded orbital elements for Jupiter are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Jupiter::Jupiter(fgTIME *t) : +Jupiter::Jupiter(FGTime *t) : CelestialBody(100.4542, 2.7685400E-5, 1.3030, -1.557E-7, 273.8777, 1.6450500E-5, @@ -48,13 +48,13 @@ Jupiter::Jupiter(fgTIME *t) : } /************************************************************************* - * void Jupiter::updatePosition(fgTIME *t, Star *ourSun) + * void Jupiter::updatePosition(FGTime *t, Star *ourSun) * * calculates the current position of Jupiter, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Jupiter specific equation *************************************************************************/ -void Jupiter::updatePosition(fgTIME *t, Star *ourSun) +void Jupiter::updatePosition(FGTime *t, Star *ourSun) { CelestialBody::updatePosition(t, ourSun); magnitude = -9.25 + 5*log10( r*R ) + 0.014 * FV; diff --git a/Simulator/Astro/jupiter.hxx b/Simulator/Astro/jupiter.hxx index d230b5679..fe8aadbf3 100644 --- a/Simulator/Astro/jupiter.hxx +++ b/Simulator/Astro/jupiter.hxx @@ -31,8 +31,8 @@ class Jupiter : public CelestialBody { public: - Jupiter (fgTIME *t); - void updatePosition(fgTIME *t, Star *ourSun); + Jupiter (FGTime *t); + void updatePosition(FGTime *t, Star *ourSun); }; #endif // _JUPITER_HXX_ diff --git a/Simulator/Astro/mars.cxx b/Simulator/Astro/mars.cxx index 1e2d79103..b5d269e6f 100644 --- a/Simulator/Astro/mars.cxx +++ b/Simulator/Astro/mars.cxx @@ -30,13 +30,13 @@ #include "mars.hxx" /************************************************************************* - * Mars::Mars(fgTIME *t) + * Mars::Mars(FGTime *t) * Public constructor for class Mars * Argument: The current time. * the hard coded orbital elements for Mars are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Mars::Mars(fgTIME *t) : +Mars::Mars(FGTime *t) : CelestialBody(49.55740, 2.1108100E-5, 1.8497, -1.78E-8, 286.5016, 2.9296100E-5, @@ -46,13 +46,13 @@ Mars::Mars(fgTIME *t) : { } /************************************************************************* - * void Mars::updatePosition(fgTIME *t, Star *ourSun) + * void Mars::updatePosition(FGTime *t, Star *ourSun) * * calculates the current position of Mars, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Mars specific equation *************************************************************************/ -void Mars::updatePosition(fgTIME *t, Star *ourSun) +void Mars::updatePosition(FGTime *t, Star *ourSun) { CelestialBody::updatePosition(t, ourSun); magnitude = -1.51 + 5*log10( r*R ) + 0.016 * FV; diff --git a/Simulator/Astro/mars.hxx b/Simulator/Astro/mars.hxx index 678a2fc35..2cc47c0c7 100644 --- a/Simulator/Astro/mars.hxx +++ b/Simulator/Astro/mars.hxx @@ -31,8 +31,8 @@ class Mars : public CelestialBody { public: - Mars ( fgTIME *t); - void updatePosition(fgTIME *t, Star *ourSun); + Mars ( FGTime *t); + void updatePosition(FGTime *t, Star *ourSun); }; #endif // _MARS_HXX_ diff --git a/Simulator/Astro/mercury.cxx b/Simulator/Astro/mercury.cxx index d58db1b74..e100dd989 100644 --- a/Simulator/Astro/mercury.cxx +++ b/Simulator/Astro/mercury.cxx @@ -30,13 +30,13 @@ #include "mercury.hxx" /************************************************************************* - * Mercury::Mercury(fgTIME *t) + * Mercury::Mercury(FGTime *t) * Public constructor for class Mercury * Argument: The current time. * the hard coded orbital elements for Mercury are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Mercury::Mercury(fgTIME *t) : +Mercury::Mercury(FGTime *t) : CelestialBody (48.33130, 3.2458700E-5, 7.0047, 5.00E-8, 29.12410, 1.0144400E-5, @@ -46,13 +46,13 @@ Mercury::Mercury(fgTIME *t) : { } /************************************************************************* - * void Mercury::updatePosition(fgTIME *t, Star *ourSun) + * void Mercury::updatePosition(FGTime *t, Star *ourSun) * * calculates the current position of Mercury, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Mercury specific equation *************************************************************************/ -void Mercury::updatePosition(fgTIME *t, Star *ourSun) +void Mercury::updatePosition(FGTime *t, Star *ourSun) { CelestialBody::updatePosition(t, ourSun); magnitude = -0.36 + 5*log10( r*R ) + 0.027 * FV + 2.2E-13 * pow(FV, 6); diff --git a/Simulator/Astro/mercury.hxx b/Simulator/Astro/mercury.hxx index b2d97c67d..914370b9d 100644 --- a/Simulator/Astro/mercury.hxx +++ b/Simulator/Astro/mercury.hxx @@ -31,8 +31,8 @@ class Mercury : public CelestialBody { public: - Mercury ( fgTIME *t); - void updatePosition(fgTIME *t, Star* ourSun); + Mercury ( FGTime *t); + void updatePosition(FGTime *t, Star* ourSun); }; #endif // _MERURY_HXX_ diff --git a/Simulator/Astro/moon.cxx b/Simulator/Astro/moon.cxx index a29c64c8d..4df64ae12 100644 --- a/Simulator/Astro/moon.cxx +++ b/Simulator/Astro/moon.cxx @@ -29,6 +29,7 @@ #include #include +#include
#ifdef __BORLANDC__ # define exception c_exception @@ -37,14 +38,14 @@ /************************************************************************* - * Moon::Moon(fgTIME *t) + * Moon::Moon(FGTime *t) * Public constructor for class Moon. Initializes the orbital elements and * sets up the moon texture. * Argument: The current time. * the hard coded orbital elements for Moon are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Moon::Moon(fgTIME *t) : +Moon::Moon(FGTime *t) : CelestialBody(125.1228, -0.0529538083, 5.1454, 0.00000, 318.0634, 0.1643573223, @@ -184,12 +185,12 @@ void Moon::setHalo() /***************************************************************************** - * void Moon::updatePosition(fgTIME *t, Star *ourSun) + * void Moon::updatePosition(FGTime *t, Star *ourSun) * this member function calculates the actual topocentric position (i.e.) * the position of the moon as seen from the current position on the surface * of the moon. ****************************************************************************/ -void Moon::updatePosition(fgTIME *t, Star *ourSun) +void Moon::updatePosition(FGTime *t, Star *ourSun) { double eccAnom, ecl, actTime, @@ -279,7 +280,7 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun) if (geoRa < 0) geoRa += (2*FG_PI); - HA = t->lst - (3.8197186 * geoRa); + HA = t->getLst() - (3.8197186 * geoRa); g = atan (tan(gclat) / cos ((HA / 3.8197186))); rightAscension = geoRa - mpar * rho * cos(gclat) * sin(HA) / cos (geoDec); declination = geoDec - mpar * rho * sin (gclat) * sin (g - geoDec) / sin(g); @@ -341,19 +342,22 @@ void Moon::newImage() "Ra = (" << (RAD_TO_DEG *rightAscension) << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); xglTranslatef(0.0, 58600.0, 0.0); - - glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED - glEnable(GL_BLEND); // BLEND ENABLED - glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glBindTexture(GL_TEXTURE_2D, moon_halotexid); - - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000); - glEnd(); + glEnable(GL_BLEND); // BLEND ENABLED + + if (current_options.get_textures()) + { + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glBindTexture(GL_TEXTURE_2D, moon_halotexid); + + glBegin(GL_QUADS); + glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000); + glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000); + glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000); + glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000); + glEnd(); + } xglEnable(GL_LIGHTING); // LIGHTING ENABLED xglEnable( GL_LIGHT0 ); @@ -368,10 +372,12 @@ void Moon::newImage() glBlendFunc(GL_ONE, GL_ONE); //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glBindTexture(GL_TEXTURE_2D, moon_texid); - //glDisable(GL_LIGHTING); // LIGHTING DISABLED - - gluQuadricTexture(moonObject, GL_TRUE ); + if (current_options.get_textures()) + { + glBindTexture(GL_TEXTURE_2D, moon_texid); + //glDisable(GL_LIGHTING); // LIGHTING DISABLED + gluQuadricTexture(moonObject, GL_TRUE ); + } gluSphere(moonObject, moonSize, 12, 12 ); glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED glDisable(GL_BLEND); // BLEND DISABLED diff --git a/Simulator/Astro/moon.hxx b/Simulator/Astro/moon.hxx index c27cbd3d8..62451601e 100644 --- a/Simulator/Astro/moon.hxx +++ b/Simulator/Astro/moon.hxx @@ -46,9 +46,9 @@ private: void setHalo(); public: - Moon ( fgTIME *t); + Moon ( FGTime *t); ~Moon(); - void updatePosition(fgTIME *t, Star *ourSun); + void updatePosition(FGTime *t, Star *ourSun); void newImage(); }; diff --git a/Simulator/Astro/neptune.cxx b/Simulator/Astro/neptune.cxx index cd4d2d71d..bbb5df6c7 100644 --- a/Simulator/Astro/neptune.cxx +++ b/Simulator/Astro/neptune.cxx @@ -30,13 +30,13 @@ #include "neptune.hxx" /************************************************************************* - * Neptune::Neptune(fgTIME *t) + * Neptune::Neptune(FGTime *t) * Public constructor for class Neptune * Argument: The current time. * the hard coded orbital elements for Neptune are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Neptune::Neptune(fgTIME *t) : +Neptune::Neptune(FGTime *t) : CelestialBody(131.7806, 3.0173000E-5, 1.7700, -2.550E-7, 272.8461, -6.027000E-6, @@ -46,13 +46,13 @@ Neptune::Neptune(fgTIME *t) : { } /************************************************************************* - * void Neptune::updatePosition(fgTIME *t, Star *ourSun) + * void Neptune::updatePosition(FGTime *t, Star *ourSun) * * calculates the current position of Neptune, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Neptune specific equation *************************************************************************/ -void Neptune::updatePosition(fgTIME *t, Star *ourSun) +void Neptune::updatePosition(FGTime *t, Star *ourSun) { CelestialBody::updatePosition(t, ourSun); magnitude = -6.90 + 5*log10 (r*R) + 0.001 *FV; diff --git a/Simulator/Astro/neptune.hxx b/Simulator/Astro/neptune.hxx index 98390c71e..8a8d00f1f 100644 --- a/Simulator/Astro/neptune.hxx +++ b/Simulator/Astro/neptune.hxx @@ -31,8 +31,8 @@ class Neptune : public CelestialBody { public: - Neptune ( fgTIME *t); - void updatePosition(fgTIME *t, Star *ourSun); + Neptune ( FGTime *t); + void updatePosition(FGTime *t, Star *ourSun); }; #endif // _NEPTUNE_HXX_ diff --git a/Simulator/Astro/pluto.hxx b/Simulator/Astro/pluto.hxx index 282e8684f..2f8393aab 100644 --- a/Simulator/Astro/pluto.hxx +++ b/Simulator/Astro/pluto.hxx @@ -30,7 +30,7 @@ class Pluto : public CelestialBody { public: - Pluto ( fgTIME t); + Pluto ( FGTime t); }; #endif // _PLUTO_HXX_ diff --git a/Simulator/Astro/saturn.cxx b/Simulator/Astro/saturn.cxx index 6a8a43cbb..10cce47d9 100644 --- a/Simulator/Astro/saturn.cxx +++ b/Simulator/Astro/saturn.cxx @@ -30,13 +30,13 @@ #include "saturn.hxx" /************************************************************************* - * Saturn::Saturn(fgTIME *t) + * Saturn::Saturn(FGTime *t) * Public constructor for class Saturn * Argument: The current time. * the hard coded orbital elements for Saturn are passed to * CelestialBody::CelestialBody(); ************************************************************************/ -Saturn::Saturn(fgTIME *t) : +Saturn::Saturn(FGTime *t) : CelestialBody(113.6634, 2.3898000E-5, 2.4886, -1.081E-7, 339.3939, 2.9766100E-5, @@ -47,13 +47,13 @@ Saturn::Saturn(fgTIME *t) : } /************************************************************************* - * void Saturn::updatePosition(fgTIME *t, Star *ourSun) + * void Saturn::updatePosition(FGTime *t, Star *ourSun) * * calculates the current position of Saturn, by calling the base class, * CelestialBody::updatePosition(); The current magnitude is calculated using * a Saturn specific equation *************************************************************************/ -void Saturn::updatePosition(fgTIME *t, Star *ourSun) +void Saturn::updatePosition(FGTime *t, Star *ourSun) { CelestialBody::updatePosition(t, ourSun); diff --git a/Simulator/Astro/saturn.hxx b/Simulator/Astro/saturn.hxx index 22bce6ccb..4cf4d004e 100644 --- a/Simulator/Astro/saturn.hxx +++ b/Simulator/Astro/saturn.hxx @@ -31,8 +31,8 @@ class Saturn : public CelestialBody { public: - Saturn ( fgTIME *t); - void updatePosition(fgTIME *t, Star *ourSun); + Saturn ( FGTime *t); + void updatePosition(FGTime *t, Star *ourSun); }; #endif // _SATURN_HXX_ diff --git a/Simulator/Astro/solarsystem.cxx b/Simulator/Astro/solarsystem.cxx index 08917b4d1..33bbe5456 100644 --- a/Simulator/Astro/solarsystem.cxx +++ b/Simulator/Astro/solarsystem.cxx @@ -45,10 +45,10 @@ /*************************************************************************** * default constructor for class SolarSystem: * or course there can only be one way to create an entire solar system -:) ) - * the fgTIME argument is needed to properly initialize the the current orbital + * the FGTime argument is needed to properly initialize the the current orbital * elements *************************************************************************/ -SolarSystem::SolarSystem(fgTIME *t) +SolarSystem::SolarSystem(FGTime *t) { if (theSolarSystem) { @@ -96,7 +96,7 @@ SolarSystem::~SolarSystem() void SolarSystem::rebuild() { //fgLIGHT *l = &cur_light_params; - fgTIME *t = &cur_time_params; + FGTime *t = FGTime::cur_time_params; //float x, y, z; //double sun_angle; double ra, dec; diff --git a/Simulator/Astro/solarsystem.hxx b/Simulator/Astro/solarsystem.hxx index 9b60c47bb..fe713d076 100644 --- a/Simulator/Astro/solarsystem.hxx +++ b/Simulator/Astro/solarsystem.hxx @@ -60,7 +60,7 @@ private: public: - SolarSystem(fgTIME *t); + SolarSystem(FGTime *t); CelestialBody *getSun(); CelestialBody *getMoon(); ~SolarSystem(); diff --git a/Simulator/Astro/star.cxx b/Simulator/Astro/star.cxx index 4752093df..8fa7fa906 100644 --- a/Simulator/Astro/star.cxx +++ b/Simulator/Astro/star.cxx @@ -29,10 +29,11 @@ #include