From: curt Date: Mon, 9 Jun 2003 20:19:52 +0000 (+0000) Subject: Make sky dome scaling values sensible (i.e. the sky dome will now fill up X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f8201e6478ec1ca1b6be977cd70f4c56d0c37c44;p=simgear.git Make sky dome scaling values sensible (i.e. the sky dome will now fill up the dimensions provided.) We draw the sky dome before everything else and draw it with depth buffer off so it really doesn't matter, but it just makes a little more sense this way. Updated a few doxygen comments. --- diff --git a/simgear/scene/sky/dome.cxx b/simgear/scene/sky/dome.cxx index 0824a322..813ef95d 100644 --- a/simgear/scene/sky/dome.cxx +++ b/simgear/scene/sky/dome.cxx @@ -47,20 +47,20 @@ #endif -// in meters of course -static const float center_elev = 0.3125; +// proportions of max dimensions fed to the build() routine +static const float center_elev = 1.0; -static const float upper_radius = 0.6250; -static const float upper_elev = 0.2500; +static const float upper_radius = 0.6; +static const float upper_elev = 0.15; -static const float middle_radius = 0.8750; -static const float middle_elev = 0.1000; +static const float middle_radius = 0.9; +static const float middle_elev = 0.08; -static const float lower_radius = 0.8750; -static const float lower_elev = 0.0000; +static const float lower_radius = 1.0; +static const float lower_elev = 0.0; -static const float bottom_radius = 0.6250; -static const float bottom_elev = -0.0250; +static const float bottom_radius = 0.8; +static const float bottom_elev = -0.1; // Set up dome rendering callbacks @@ -105,7 +105,7 @@ SGSkyDome::~SGSkyDome( void ) { ssgBranch * SGSkyDome::build( double hscale, double vscale ) { sgVec4 color; - float theta; + double theta; int i; // set up the state @@ -153,20 +153,20 @@ ssgBranch * SGSkyDome::build( double hscale, double vscale ) { cos(theta) * upper_radius * hscale, sin(theta) * upper_radius * hscale, upper_elev * vscale ); - + sgSetVec3( middle_vertex[i], - cos((double)theta) * middle_radius * hscale, - sin((double)theta) * middle_radius * hscale, + cos(theta) * middle_radius * hscale, + sin(theta) * middle_radius * hscale, middle_elev * vscale ); sgSetVec3( lower_vertex[i], - cos((double)theta) * lower_radius * hscale, - sin((double)theta) * lower_radius * hscale, + cos(theta) * lower_radius * hscale, + sin(theta) * lower_radius * hscale, lower_elev * vscale ); sgSetVec3( bottom_vertex[i], - cos((double)theta) * bottom_radius * hscale, - sin((double)theta) * bottom_radius * hscale, + cos(theta) * bottom_radius * hscale, + sin(theta) * bottom_radius * hscale, bottom_elev * vscale ); } diff --git a/simgear/timing/sg_time.cxx b/simgear/timing/sg_time.cxx index 05f00317..3d164e72 100644 --- a/simgear/timing/sg_time.cxx +++ b/simgear/timing/sg_time.cxx @@ -71,7 +71,7 @@ static const double J2000 = 2451545.0 - MJD0; static const double SIDRATE = 0.9972695677; -void SGTime::init( double lon, double lat, +void SGTime::init( double lon_rad, double lat_rad, const string& root, time_t init_time ) { SG_LOG( SG_EVENT, SG_INFO, "Initializing Time" ); @@ -96,7 +96,7 @@ void SGTime::init( double lon, double lat, << zone.str() ); tzContainer = new SGTimeZoneContainer( zone.c_str() ); - SGGeoCoord location( SGD_RADIANS_TO_DEGREES * lat, SGD_RADIANS_TO_DEGREES * lon ); + SGGeoCoord location( SGD_RADIANS_TO_DEGREES * lat_rad, SGD_RADIANS_TO_DEGREES * lon_rad ); SGGeoCoord* nearestTz = tzContainer->getNearest(location); SGPath name( root ); @@ -110,9 +110,10 @@ void SGTime::init( double lon, double lat, } } -SGTime::SGTime( double lon, double lat, const string& root, time_t init_time ) +SGTime::SGTime( double lon_rad, double lat_rad, const string& root, + time_t init_time ) { - init( lon, lat, root, init_time ); + init( lon_rad, lat_rad, root, init_time ); } @@ -196,7 +197,9 @@ static double sidereal_course( time_t cur_time, const struct tm *gmt, double lng // Update the time related variables -void SGTime::update( double lon, double lat, time_t ct, long int warp ) { +void SGTime::update( double lon_rad, double lat_rad, + time_t ct, long int warp ) +{ double gst_precise, gst_course; #if defined(_MSC_VER) || defined(__MINGW32__) @@ -251,46 +254,51 @@ void SGTime::update( double lon, double lat, time_t ct, long int warp ) { gst_diff = gst_precise - gst_course; - lst = sidereal_course( cur_time, gmt, -(lon * SGD_RADIANS_TO_DEGREES) ) + gst_diff; + lst = sidereal_course( cur_time, gmt, + -(lon_rad * SGD_RADIANS_TO_DEGREES) ) + gst_diff; } else { // course + difference should drift off very slowly gst = sidereal_course( cur_time, gmt, 0.00 ) + gst_diff; - lst = sidereal_course( cur_time, gmt, -(lon * SGD_RADIANS_TO_DEGREES) ) + gst_diff; + lst = sidereal_course( cur_time, gmt, + -(lon_rad * SGD_RADIANS_TO_DEGREES) ) + gst_diff; } SG_LOG( SG_EVENT, SG_DEBUG, " Current lon=0.00 Sidereal Time = " << gst ); SG_LOG( SG_EVENT, SG_DEBUG, " Current LOCAL Sidereal Time = " << lst << " (" - << sidereal_precise( mjd, -(lon * SGD_RADIANS_TO_DEGREES) ) + << sidereal_precise( mjd, -(lon_rad * SGD_RADIANS_TO_DEGREES) ) << ") (diff = " << gst_diff << ")" ); } // Given lon/lat, update timezone information and local_offset -void SGTime::updateLocal( double lon, double lat, const string& root ) { +void SGTime::updateLocal( double lon_rad, double lat_rad, const string& root ) { // sanity checking - if ( lon < -SGD_PI || lon > SGD_PI ) { + if ( lon_rad < -SGD_PI || lon_rad> SGD_PI ) { // not within -180 ... 180 - lon = 0.0; + lon_rad = 0.0; } - if ( lat < -SGD_PI * 0.5 || lat > SGD_PI * 0.5 ) { + if ( lat_rad < -SGD_PI * 0.5 || lat_rad > SGD_PI * 0.5 ) { // not within -90 ... 90 - lat = 0.0; + lat_rad = 0.0; } - if ( lon != lon ) { - // only true if lon == nan - SG_LOG( SG_EVENT, SG_ALERT, " Detected lon == nan, resetting to 0.0" ); - lon = 0.0; + if ( lon_rad != lon_rad ) { + // only true if lon_rad == nan + SG_LOG( SG_EVENT, SG_ALERT, + " Detected lon_rad == nan, resetting to 0.0" ); + lon_rad = 0.0; } - if ( lat != lat ) { - // only true if lat == nan - SG_LOG( SG_EVENT, SG_ALERT, " Detected lat == nan, resetting to 0.0" ); - lat = 0.0; + if ( lat_rad != lat_rad ) { + // only true if lat_rad == nan + SG_LOG( SG_EVENT, SG_ALERT, + " Detected lat_rad == nan, resetting to 0.0" ); + lat_rad = 0.0; } time_t currGMT; time_t aircraftLocalTime; - SGGeoCoord location( SGD_RADIANS_TO_DEGREES * lat, SGD_RADIANS_TO_DEGREES * lon ); + SGGeoCoord location( SGD_RADIANS_TO_DEGREES * lat_rad, + SGD_RADIANS_TO_DEGREES * lon_rad ); SGGeoCoord* nearestTz = tzContainer->getNearest(location); SGPath zone( root ); zone.append ( nearestTz->getDescription() ); diff --git a/simgear/timing/sg_time.hxx b/simgear/timing/sg_time.hxx index bf208475..fb23ddf5 100644 --- a/simgear/timing/sg_time.hxx +++ b/simgear/timing/sg_time.hxx @@ -104,6 +104,10 @@ private: // gst_diff has pretty good accuracy over the span of a couple hours double gst_diff; + /** init common constructor code */ + void init( double lon_rad, double lat_rad, const string& root, + time_t init_time ); + public: /** Default constructor */ @@ -120,12 +124,13 @@ public: * If you don't know your position when you call the SGTime * constructor, you can just use the first form (which assumes 0, * 0). - * @param lon current longitude - * @param lat current latitude + * @param lon_rad current longitude (radians) + * @param lat_rad current latitude (radians) * @param root root path point to data file location (timezone, etc.) * @param init_time provide an initialization time, 0 means use current clock time */ - SGTime( double lon, double lat, const string& root, time_t init_time /* = 0 */ ); + SGTime( double lon_rad, double lat_rad, const string& root, + time_t init_time ); /** * Create an instance given a data file path. @@ -136,9 +141,6 @@ public: /** Destructor */ ~SGTime(); - /** init common constructor code */ - void init( double lon, double lat, const string& root, time_t init_time /* = 0 */ ); - /** * Update the time related variables. * The update() method requires you to pass in your position and @@ -146,13 +148,13 @@ public: * you to offset "sim" time relative to "real" time. The update() * method is designed to be called by the host application before * every frame. - * @param lon current longitude - * @param lat current latitude + * @param lon_rad current longitude (radians) + * @param lat_rad current latitude (radians) * @param ct specify a unix time, otherwise specify 0 to use current clock time * @param warp an optional time offset specified in seconds. This * allows us to advance or rewind "time" if we choose to. */ - void update( double lon, double lat, time_t ct /* = 0 */, long int warp /* = 0 */ ); + void update( double lon_rad, double lat_rad, time_t ct, long int warp ); /** * Given lon/lat, update timezone information and local_offset @@ -161,10 +163,10 @@ public: * enough that your timezone may have changed as well. In the * FlightGear project we call updateLocal() every few minutes from * our periodic event manager. - * @param lon current longitude - * @param lat current latitude + * @param lon_rad current longitude (radians) + * @param lat_rad current latitude (radians) * @param root base path containing time zone directory */ - void updateLocal( double lon, double lat, const string& root ); + void updateLocal( double lon_rad, double lat_rad, const string& root ); /** @return current system/unix time in seconds */ inline time_t get_cur_time() const { return cur_time; };