From a1294ea398d37ac26ab5a03a1ece00c2aefa3cda Mon Sep 17 00:00:00 2001 From: david Date: Sat, 6 Apr 2002 17:23:18 +0000 Subject: [PATCH] Viewer update from Jim Wilson: Minor patches to initial tower view code. Added calculation for "tower" at any airport, placed a couple fractions of a degree off the center. Moved the farplane from 100m to 5km so that "lookfrom" mode can see the model. 5km is still in a reasonable range for a depth buffer. Note that looking at a model anything but a small distance will cause some problems on older cards. Temporarily changed viewer to always report elevation/lon/lat of the aircraft in order to avoid a problem with the ground trim getting recalculated when tower and aircraft are on different tiles. --- src/Main/fg_init.cxx | 24 ++++++++++++++++++++++++ src/Main/fg_init.hxx | 4 ++++ src/Main/main.cxx | 5 ++++- src/Main/viewer.cxx | 13 +++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 84bcc0399..14b537639 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -349,6 +349,29 @@ bool fgSetPosFromAirportID( const string& id ) { } + +// Set current tower position lon/lat given an airport id +bool fgSetTowerPosFromAirportID( const string& id, double hdg ) { + FGAirport a; + // tower height hard coded for now... + float towerheight=50.0f; + + // make a little off the heading for 1 runway airports... + float fudge_lon = fabs(sin(hdg)) * .003f; + float fudge_lat = .003f - fudge_lon; + + if ( fgFindAirportID( id, &a ) ) { + fgSetDouble("/sim/tower/longitude-deg", a.longitude + fudge_lon); + fgSetDouble("/sim/tower/latitude-deg", a.latitude + fudge_lat); + fgSetDouble("/sim/tower/altitude-ft", a.elevation + towerheight); + return true; + } else { + return false; + } + +} + + // Set current_options lon/lat given an airport id and heading (degrees) bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ) { FGRunway r; @@ -1078,3 +1101,4 @@ void fgReInitSubsystems( void ) fgSetBool("/sim/freeze/master", false); } } + diff --git a/src/Main/fg_init.hxx b/src/Main/fg_init.hxx index 6ed654e7c..caba67dc5 100644 --- a/src/Main/fg_init.hxx +++ b/src/Main/fg_init.hxx @@ -77,6 +77,9 @@ bool fgFindAirportID( const string& id, FGAirport *a ); // Set pos given an airport id bool fgSetPosFromAirportID( const string& id ); +// Set tower position given an airport id +bool fgSetTowerPosFromAirportID( const string& id, double hdg ); + // Set position and heading given an airport id and heading (degrees) bool fgSetPosFromAirportIDandHdg( const string& id, double tgt_hdg ); @@ -91,3 +94,4 @@ SGTime *fgInitTime(); #endif // _FG_INIT_HXX + diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 9781bf653..e83f4b706 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -143,7 +143,7 @@ sgVec3 rway_ols; // ADA // Clip plane settings... float cockpit_nearplane = 0.01f; -float cockpit_farplane = 100.0f; +float cockpit_farplane = 5000.0f; float scene_nearplane = 0.5f; float scene_farplane = 120000.0f; @@ -1448,6 +1448,8 @@ int mainLoop( int argc, char **argv ) { // fgSetPosFromAirportID( fgGetString("/sim/startup/airport-id") ); fgSetPosFromAirportIDandHdg( fgGetString("/sim/startup/airport-id"), fgGetDouble("/orientation/heading-deg") ); + // set tower position (a little off the heading for single runway airports) + fgSetTowerPosFromAirportID( fgGetString("/sim/startup/airport-id"), fgGetDouble("orientation/heading") ); } SGTime *t = fgInitTime(); @@ -1938,3 +1940,4 @@ void fgUpdateDCS (void) { + diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx index bed93454b..749f650d1 100644 --- a/src/Main/viewer.cxx +++ b/src/Main/viewer.cxx @@ -26,6 +26,8 @@ #include +#include + #ifdef HAVE_CONFIG_H # include #endif @@ -521,6 +523,16 @@ FGViewer::recalc () sgCopyVec3(_zero_elev, _zero_elev_view_pos); sgCopyVec3(_view_pos, _relative_view_pos); + // FIXME: + // Doing this last recalc here for published values...where the airplane is + // This should be per aircraft or model (for published values) before + // multiple FDM can be done. + recalcPositionVectors(fgGetDouble("/position/longitude-deg"), + fgGetDouble("/position/latitude-deg"), + fgGetDouble("/position/altitude-deg")); + + + // Make the world up rotation matrix for eye positioin... sgMakeRotMat4( UP, _lon_deg, 0.0, -_lat_deg ); @@ -794,3 +806,4 @@ FGViewer::update (int dt) +