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.
This commit is contained in:
curt 2003-06-09 20:19:52 +00:00
parent e053941467
commit f8201e6478
3 changed files with 62 additions and 52 deletions

View File

@ -47,20 +47,20 @@
#endif #endif
// in meters of course // proportions of max dimensions fed to the build() routine
static const float center_elev = 0.3125; static const float center_elev = 1.0;
static const float upper_radius = 0.6250; static const float upper_radius = 0.6;
static const float upper_elev = 0.2500; static const float upper_elev = 0.15;
static const float middle_radius = 0.8750; static const float middle_radius = 0.9;
static const float middle_elev = 0.1000; static const float middle_elev = 0.08;
static const float lower_radius = 0.8750; static const float lower_radius = 1.0;
static const float lower_elev = 0.0000; static const float lower_elev = 0.0;
static const float bottom_radius = 0.6250; static const float bottom_radius = 0.8;
static const float bottom_elev = -0.0250; static const float bottom_elev = -0.1;
// Set up dome rendering callbacks // Set up dome rendering callbacks
@ -105,7 +105,7 @@ SGSkyDome::~SGSkyDome( void ) {
ssgBranch * SGSkyDome::build( double hscale, double vscale ) { ssgBranch * SGSkyDome::build( double hscale, double vscale ) {
sgVec4 color; sgVec4 color;
float theta; double theta;
int i; int i;
// set up the state // set up the state
@ -155,18 +155,18 @@ ssgBranch * SGSkyDome::build( double hscale, double vscale ) {
upper_elev * vscale ); upper_elev * vscale );
sgSetVec3( middle_vertex[i], sgSetVec3( middle_vertex[i],
cos((double)theta) * middle_radius * hscale, cos(theta) * middle_radius * hscale,
sin((double)theta) * middle_radius * hscale, sin(theta) * middle_radius * hscale,
middle_elev * vscale ); middle_elev * vscale );
sgSetVec3( lower_vertex[i], sgSetVec3( lower_vertex[i],
cos((double)theta) * lower_radius * hscale, cos(theta) * lower_radius * hscale,
sin((double)theta) * lower_radius * hscale, sin(theta) * lower_radius * hscale,
lower_elev * vscale ); lower_elev * vscale );
sgSetVec3( bottom_vertex[i], sgSetVec3( bottom_vertex[i],
cos((double)theta) * bottom_radius * hscale, cos(theta) * bottom_radius * hscale,
sin((double)theta) * bottom_radius * hscale, sin(theta) * bottom_radius * hscale,
bottom_elev * vscale ); bottom_elev * vscale );
} }

View File

@ -71,7 +71,7 @@ static const double J2000 = 2451545.0 - MJD0;
static const double SIDRATE = 0.9972695677; 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 ) const string& root, time_t init_time )
{ {
SG_LOG( SG_EVENT, SG_INFO, "Initializing Time" ); SG_LOG( SG_EVENT, SG_INFO, "Initializing Time" );
@ -96,7 +96,7 @@ void SGTime::init( double lon, double lat,
<< zone.str() ); << zone.str() );
tzContainer = new SGTimeZoneContainer( zone.c_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); SGGeoCoord* nearestTz = tzContainer->getNearest(location);
SGPath name( root ); 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 // 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; double gst_precise, gst_course;
#if defined(_MSC_VER) || defined(__MINGW32__) #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; 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 { } else {
// course + difference should drift off very slowly // course + difference should drift off very slowly
gst = sidereal_course( cur_time, gmt, 0.00 ) + gst_diff; 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, SG_LOG( SG_EVENT, SG_DEBUG,
" Current lon=0.00 Sidereal Time = " << gst ); " Current lon=0.00 Sidereal Time = " << gst );
SG_LOG( SG_EVENT, SG_DEBUG, SG_LOG( SG_EVENT, SG_DEBUG,
" Current LOCAL Sidereal Time = " << lst << " (" " 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 << ")" ); << ") (diff = " << gst_diff << ")" );
} }
// Given lon/lat, update timezone information and local_offset // 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 // sanity checking
if ( lon < -SGD_PI || lon > SGD_PI ) { if ( lon_rad < -SGD_PI || lon_rad> SGD_PI ) {
// not within -180 ... 180 // 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 // not within -90 ... 90
lat = 0.0; lat_rad = 0.0;
} }
if ( lon != lon ) { if ( lon_rad != lon_rad ) {
// only true if lon == nan // only true if lon_rad == nan
SG_LOG( SG_EVENT, SG_ALERT, " Detected lon == nan, resetting to 0.0" ); SG_LOG( SG_EVENT, SG_ALERT,
lon = 0.0; " Detected lon_rad == nan, resetting to 0.0" );
lon_rad = 0.0;
} }
if ( lat != lat ) { if ( lat_rad != lat_rad ) {
// only true if lat == nan // only true if lat_rad == nan
SG_LOG( SG_EVENT, SG_ALERT, " Detected lat == nan, resetting to 0.0" ); SG_LOG( SG_EVENT, SG_ALERT,
lat = 0.0; " Detected lat_rad == nan, resetting to 0.0" );
lat_rad = 0.0;
} }
time_t currGMT; time_t currGMT;
time_t aircraftLocalTime; 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); SGGeoCoord* nearestTz = tzContainer->getNearest(location);
SGPath zone( root ); SGPath zone( root );
zone.append ( nearestTz->getDescription() ); zone.append ( nearestTz->getDescription() );

View File

@ -104,6 +104,10 @@ private:
// gst_diff has pretty good accuracy over the span of a couple hours // gst_diff has pretty good accuracy over the span of a couple hours
double gst_diff; double gst_diff;
/** init common constructor code */
void init( double lon_rad, double lat_rad, const string& root,
time_t init_time );
public: public:
/** Default constructor */ /** Default constructor */
@ -120,12 +124,13 @@ public:
* If you don't know your position when you call the SGTime * If you don't know your position when you call the SGTime
* constructor, you can just use the first form (which assumes 0, * constructor, you can just use the first form (which assumes 0,
* 0). * 0).
* @param lon current longitude * @param lon_rad current longitude (radians)
* @param lat current latitude * @param lat_rad current latitude (radians)
* @param root root path point to data file location (timezone, etc.) * @param root root path point to data file location (timezone, etc.)
* @param init_time provide an initialization time, 0 means use * @param init_time provide an initialization time, 0 means use
current clock time */ 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. * Create an instance given a data file path.
@ -136,9 +141,6 @@ public:
/** Destructor */ /** Destructor */
~SGTime(); ~SGTime();
/** init common constructor code */
void init( double lon, double lat, const string& root, time_t init_time /* = 0 */ );
/** /**
* Update the time related variables. * Update the time related variables.
* The update() method requires you to pass in your position and * 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() * you to offset "sim" time relative to "real" time. The update()
* method is designed to be called by the host application before * method is designed to be called by the host application before
* every frame. * every frame.
* @param lon current longitude * @param lon_rad current longitude (radians)
* @param lat current latitude * @param lat_rad current latitude (radians)
* @param ct specify a unix time, otherwise specify 0 to use current * @param ct specify a unix time, otherwise specify 0 to use current
clock time clock time
* @param warp an optional time offset specified in seconds. This * @param warp an optional time offset specified in seconds. This
* allows us to advance or rewind "time" if we choose to. */ * 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 * 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 * enough that your timezone may have changed as well. In the
* FlightGear project we call updateLocal() every few minutes from * FlightGear project we call updateLocal() every few minutes from
* our periodic event manager. * our periodic event manager.
* @param lon current longitude * @param lon_rad current longitude (radians)
* @param lat current latitude * @param lat_rad current latitude (radians)
* @param root base path containing time zone directory */ * @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 */ /** @return current system/unix time in seconds */
inline time_t get_cur_time() const { return cur_time; }; inline time_t get_cur_time() const { return cur_time; };