1
0
Fork 0

Updates to use new SGMagVar class from simgear.

This commit is contained in:
curt 2000-08-08 00:39:52 +00:00
parent 342842537d
commit 5103729ca0
5 changed files with 17 additions and 44 deletions

View file

@ -1457,7 +1457,7 @@ FGBFI::setCloudsASL (double cloudsASL)
double
FGBFI::getMagVar ()
{
return cur_magvar.get_magvar() * RAD_TO_DEG;
return globals->get_mag()->get_magvar() * RAD_TO_DEG;
}
@ -1467,7 +1467,7 @@ FGBFI::getMagVar ()
double
FGBFI::getMagDip ()
{
return cur_magvar.get_magdip() * RAD_TO_DEG;
return globals->get_mag()->get_magdip() * RAD_TO_DEG;
}

View file

@ -26,6 +26,7 @@
#include <simgear/ephemeris/ephemeris.hxx>
#include <simgear/magvar/magvar.hxx>
#include <simgear/timing/sg_time.hxx>
@ -50,6 +51,9 @@ private:
// Sky structures
SGEphemeris *ephem;
// Magnetic Variation
SGMagVar *mag;
public:
FGGlobals();
@ -71,6 +75,9 @@ public:
inline SGEphemeris *get_ephem() const { return ephem; }
inline void set_ephem( SGEphemeris *e ) { ephem = e; }
inline SGMagVar *get_mag() const { return mag; }
inline void set_mag( SGMagVar *m ) { mag = m; }
};

View file

@ -810,10 +810,10 @@ static void fgMainLoop( void ) {
}
// update magvar model
cur_magvar.update( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
cur_fdm_state->get_Altitude()* FEET_TO_METER,
globals->get_time_params()->getJD() );
globals->get_mag()->update( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
cur_fdm_state->get_Altitude()* FEET_TO_METER,
globals->get_time_params()->getJD() );
// Get elapsed time (in usec) for this past frame
elapsed = fgGetTimeInterval();
@ -1428,6 +1428,10 @@ int main( int argc, char **argv ) {
// thesky->add_cloud_layer( 1800.0, 400.0, 100.0, SG_CLOUD_OVERCAST );
// thesky->add_cloud_layer( 5000.0, 20.0, 10.0, SG_CLOUD_CIRRUS );
// Initialize MagVar model
SGMagVar *magvar = new SGMagVar();
globals->set_mag( magvar );
// Terrain branch
terrain = new ssgBranch;
terrain->setName( "Terrain" );

View file

@ -38,24 +38,6 @@
#include "tmp.hxx"
FGMagVar::FGMagVar() {
}
FGMagVar::~FGMagVar() {
}
void FGMagVar::update( double lon, double lat, double alt_m, double jd ) {
// Calculate local magnetic variation
double field[6];
// cout << "alt_m = " << alt_m << endl;
magvar = SGMagVar( lat, lon, alt_m / 1000.0, (long)jd, field );
magdip = atan(field[5]/sqrt(field[3]*field[3]+field[4]*field[4]));
}
FGMagVar cur_magvar;
// periodic time updater wrapper
void fgUpdateLocalTime() {
FGPath zone( current_options.get_fg_root() );

View file

@ -41,25 +41,5 @@ void fgUpdateLocalTime();
// update sky and lighting parameters
void fgUpdateSkyAndLightingParams();
class FGMagVar {
private:
double magvar;
double magdip;
public:
FGMagVar();
~FGMagVar();
void update( double lon, double lat, double alt_m, double jd );
double get_magvar() const { return magvar; }
double get_magdip() const { return magdip; }
};
extern FGMagVar cur_magvar;
#endif // _LIGHT_HXX