date/time.
int moonSize = 750;
GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
- GLfloat black[4] = {0.0, 0.0,0.0,1.0};
- GLfloat white[4] = {1.0, 1.0,1.0,1.0};
+ GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
+ GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
if( moon_angle*RAD_TO_DEG < 100 )
{
FG_LOG( FG_GENERAL, FG_INFO,
"Ra = (" << (RAD_TO_DEG *rightAscension)
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
- xglTranslatef(0.0, 58600.0, 0.0);
+ xglTranslatef(0.0, 60000.0, 0.0);
glEnable(GL_BLEND); // BLEND ENABLED
if (current_options.get_textures())
if (current_options.get_textures())
{
glBindTexture(GL_TEXTURE_2D, moon_texid);
- //glDisable(GL_LIGHTING); // LIGHTING DISABLED
- gluQuadricTexture(moonObject, GL_TRUE );
+ // glDisable(GL_LIGHTING); // LIGHTING DISABLED
+ gluQuadricTexture(moonObject, GL_TRUE );
+ // glDisable(GL_LIGHTING);
+ // glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
}
+ //glDisable(GL_LIGHTING); // for testing
+ //glDisable(GL_BLEND); // also for testing
+ //glColor3f(1.0, 0.0, 0.0); // also also for testing
gluSphere(moonObject, moonSize, 12, 12 );
- glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
- glDisable(GL_BLEND); // BLEND DISABLED
+ //glDisable(GL_LIGHTING); // LIGHTING DISABLED
+ //glColor4fv(white);
+ //glBlendFunc(GL_ZERO, GL_SRC_COLOR); // Set alpha to zero
+ //gluSphere(moonObject, moonSize, 12, 12 );
+ glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
+ glDisable(GL_BLEND); // BLEND DISABLED
}
xglPopMatrix();
- glDisable(GL_LIGHTING); // LIGHTING DISABLED
-
+ glDisable(GL_LIGHTING);
}
else
{
}
+void Moon::castShadow()
+{
+ fgLIGHT *l = &cur_light_params;
+ float moon_angle = l->moon_angle;
+
+ /*double x_2, x_4, x_8, x_10;
+ GLfloat ambient;
+ GLfloat amb[4];*/
+ int moonSize = 750;
+ GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0};
+ GLfloat black[4] = {0.0, 0.0, 0.0, 1.0};
+ GLfloat white[4] = {1.0, 1.0, 1.0, 0.0};
+
+ if( moon_angle*RAD_TO_DEG < 100 )
+ {
+ xglPushMatrix();
+ {
+ //xglRotatef(-90, 0.0, 0.0, 1.0);
+ xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
+ xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
+
+ FG_LOG( FG_GENERAL, FG_INFO,
+ "Ra = (" << (RAD_TO_DEG *rightAscension)
+ << "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
+ xglTranslatef(0.0, 60000.0, 0.0);
+ glEnable(GL_BLEND); // BLEND ENABLED
+
+ glDisable(GL_LIGHTING); // LIGHTING DISABLED
+ //glColor4fv(white);
+ glColor4f(1.0, 1.0, 1.0, 0.0);
+ glBlendFunc(GL_ZERO, GL_SRC_COLOR); // Set alpha to zero
+ //glBlendFunc(GL_ZERO,GL_ZERO);
+ gluSphere(moonObject, moonSize, 12, 12 );
+ glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
+ glDisable(GL_BLEND); // BLEND DISABLED
+ }
+ xglPopMatrix();
-
-
-
+ }
+ else
+ {
+ }
+}
~Moon();
void updatePosition(FGTime *t, Star *ourSun);
void newImage();
+ void castShadow();
};
// Step 2b: Add the sun
//xglPushMatrix();
//{
- ourSun->newImage();
+ //ourSun->drawHalo();
+ //earthsMoon->castShadow();
+ ourSun->newImage();
//}
//xglPopMatrix();
// Step 2c: Add the planets
//glEnable(GL_BLEND);
//glDisable(GL_LIGHTING);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, sun_texid);
-
+
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000);
glEnd();
}
- xglDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
+ xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
+ glDisable(GL_BLEND); // BLEND DISABLED
}
+
glPopMatrix();
- glPushMatrix();
+ glDisable(GL_LIGHTING);
+ /*glPushMatrix(); // Draw a black object, that serves as the moon's shadow.
{
xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
- xglTranslatef(0,58600,0);
+ xglTranslatef(0,60000,0);
+ //xglTranslatef(0,58600,0);
+ //gluSphere( SunObject, sun_size, 10, 10 );
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_ZERO, GL_ZERO);
+ xglColor4f(0.0, 0.0, 0.0, 0.0);
gluSphere( SunObject, sun_size, 10, 10 );
}
+ glPopMatrix();*/
+ glDisable(GL_BLEND);
+ glPushMatrix();
+ {
+ //xglEnable(GL_BLEND);
+ //xglBlendFunc(GL_SRC_ALPHA, GL_ONE);
+ xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
+ xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
+ xglColor4fv(amb);
+ xglTranslatef(0,60000,0);
+ gluSphere( SunObject, sun_size, 10, 10 );
+ }
glPopMatrix();
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
}
}
+
+
+void Star::drawHalo(void)
+{
+ /*static float stars[3];
+ stars[0] = 0.0;
+ stars[1] = 0.0;
+ stars[2] = 1.0;*/
+
+ fgLIGHT *l = &cur_light_params;
+ float sun_angle = l->sun_angle;
+
+ if( sun_angle*RAD_TO_DEG < 100 ) { // else no need to draw sun
+
+
+ double x_2, x_4, x_8, x_10;
+ GLfloat ambient;
+ GLfloat amb[4];
+ int sun_size = 750;
+
+ // daily variation sun gets larger near horizon
+ /*if(sun_angle*RAD_TO_DEG > 84.0 && sun_angle*RAD_TO_DEG < 95)
+ {
+ double sun_grow = 9*fabs(94-sun_angle*RAD_TO_DEG);
+ sun_size = (int)(sun_size + sun_size * cos(sun_grow*DEG_TO_RAD));
+ }*/
+ x_2 = sun_angle * sun_angle;
+ x_4 = x_2 * x_2;
+ x_8 = x_4 * x_4;
+ x_10 = x_8 * x_2;
+ ambient = (float)(0.4 * pow (1.1, - x_10 / 30.0));
+ if (ambient < 0.3) ambient = 0.3;
+ if (ambient > 1.0) ambient = 1.0;
+
+ amb[0] = ((ambient * 6.0) - 1.0); // minimum value = 0.8
+ amb[1] = ((ambient * 11.0) - 3.0); // minimum value = 0.3
+ amb[2] = ((ambient * 12.0) - 3.6); // minimum value = 0.0
+ amb[3] = 1.00;
+
+ if (amb[0] > 1.0) amb[0] = 1.0;
+ if (amb[1] > 1.0) amb[1] = 1.0;
+ if (amb[2] > 1.0) amb[2] = 1.0;
+ xglColor3fv(amb);
+ glPushMatrix();
+ {
+ xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0);
+ xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0);
+ xglTranslatef(0,60000,0);
+ if (current_options.get_textures())
+ {
+ glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
+ glEnable(GL_BLEND); // BLEND ENABLED
+
+ //glEnable(GL_TEXTURE_2D);
+ //glEnable(GL_BLEND);
+ //glDisable(GL_LIGHTING);
+ //glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ glBindTexture(GL_TEXTURE_2D, sun_texid);
+
+ 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();
+ }
+ xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
+ glDisable(GL_BLEND); // BLEND DISABLED
+ }
+ glPopMatrix();
+ }
+}
double getys();
double getDistance();
void newImage();
+ void drawHalo();
};
#!/bin/sh
-WINDOW=YES
+WINDOW=NO
if [ $WINDOW = "YES" ]; then
# in a window (slow hack)
// draw stars and planets
fgStarsRender();
+ //xglEnable(GL_DEPTH_TEST);
SolarSystem::theSolarSystem->draw();
xglPopMatrix();
#include <Misc/fgstream.hxx>
#include <FDM/flight.hxx>
#include <Include/fg_constants.h>
+#include <Time/fg_time.hxx>
#include <Main/options.hxx>
#include "fg_serial.hxx"
tris_or_culled(0),
// Time options
- time_offset(0)
+ time_offset(0),
+ start_gst(0),
+ start_lst(0)
{
// set initial values/defaults
}
+long int fgOPTIONS::parse_date( const string& date)
+{
+ struct tm gmt;
+ char * date_str, num[256];
+ int i;
+ // initialize to zero
+ gmt.tm_sec = 0;
+ gmt.tm_min = 0;
+ gmt.tm_hour = 0;
+ gmt.tm_mday = 0;
+ gmt.tm_mon = 0;
+ gmt.tm_year = 0;
+ gmt.tm_isdst = 0; // ignore daylight savingtime for the moment
+ date_str = (char *)date.c_str();
+ // get year
+ if ( strlen(date_str) ) {
+ i = 0;
+ while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
+ num[i] = date_str[0];
+ date_str++;
+ i++;
+ }
+ if ( date_str[0] == ':' ) {
+ date_str++;
+ }
+ num[i] = '\0';
+ gmt.tm_year = atoi(num) - 1900;
+ }
+ // get month
+ if ( strlen(date_str) ) {
+ i = 0;
+ while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
+ num[i] = date_str[0];
+ date_str++;
+ i++;
+ }
+ if ( date_str[0] == ':' ) {
+ date_str++;
+ }
+ num[i] = '\0';
+ gmt.tm_mon = atoi(num) -1;
+ }
+ // get day
+ if ( strlen(date_str) ) {
+ i = 0;
+ while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
+ num[i] = date_str[0];
+ date_str++;
+ i++;
+ }
+ if ( date_str[0] == ':' ) {
+ date_str++;
+ }
+ num[i] = '\0';
+ gmt.tm_mday = atoi(num);
+ }
+ // get hour
+ if ( strlen(date_str) ) {
+ i = 0;
+ while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
+ num[i] = date_str[0];
+ date_str++;
+ i++;
+ }
+ if ( date_str[0] == ':' ) {
+ date_str++;
+ }
+ num[i] = '\0';
+ gmt.tm_hour = atoi(num);
+ }
+ // get minute
+ if ( strlen(date_str) ) {
+ i = 0;
+ while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
+ num[i] = date_str[0];
+ date_str++;
+ i++;
+ }
+ if ( date_str[0] == ':' ) {
+ date_str++;
+ }
+ num[i] = '\0';
+ gmt.tm_min = atoi(num);
+ }
+ // get second
+ if ( strlen(date_str) ) {
+ i = 0;
+ while ( (date_str[0] != ':') && (date_str[0] != '\0') ) {
+ num[i] = date_str[0];
+ date_str++;
+ i++;
+ }
+ if ( date_str[0] == ':' ) {
+ date_str++;
+ }
+ num[i] = '\0';
+ gmt.tm_sec = atoi(num);
+ }
+ time_t theTime = FGTime::cur_time_params->get_gmt(gmt.tm_year,
+ gmt.tm_mon,
+ gmt.tm_mday,
+ gmt.tm_hour,
+ gmt.tm_min,
+ gmt.tm_sec);
+ //printf ("Date is %s\n", ctime(&theTime));
+ //printf ("in seconds that is %d\n", theTime);
+ //exit(1);
+ return (theTime);
+}
+
+
// parse degree in the form of [+/-]hhh:mm:ss
double
fgOPTIONS::parse_degree( const string& degree_str) {
tile_diameter = tile_radius * 2 + 1;
} else if ( arg.find( "--time-offset=" ) != string::npos ) {
time_offset = parse_time_offset( (arg.substr(14)) );
+ } else if (arg.find( "--start-date-gmt=") != string::npos ) {
+ start_gst = parse_date( (arg.substr(17)) );
+ } else if (arg.find( "--start-data-lst=") != string::npos ) {
+ start_lst = parse_date( (arg.substr(17)) );
} else if ( arg == "--hud-tris" ) {
tris_or_culled = 0;
} else if ( arg == "--hud-culled" ) {
printf("Time Options:\n");
printf("\t--time-offset=[+-]hh:mm:ss: offset local time by this amount\n");
+ printf("\t--start-date-gmt=yyyy:mm:dd:hh:mm:ss: specify a starting date/time. Time is Greenwich Mean Time\n");
+ printf("\t--start-date-lst=yyyy:mm:dd:hh:mm:ss: specify a starting date/time. Uses local sidereal time\n");
}
// Time options
int time_offset; // Offset true time by this many seconds
+ long int start_gst; // Specify a greenwich sidereal time (gst)
+ long int start_lst; // Specify a local sidereal time (lst)
// Serial Ports, we currently support up to four channels
// fgSerialPortKind port_a_kind; // Port a kind
inline int get_tris_or_culled() const { return tris_or_culled; }
inline int get_time_offset() const { return time_offset; }
+ inline long int get_start_gst() const { return start_gst; };
+ inline long int get_start_lst() const { return start_lst; }
inline str_container get_port_options_list() const {
return port_options_list;
private:
double parse_time( const string& time_str );
+ long int parse_date( const string& date_str );
double parse_degree( const string& degree_str );
int parse_time_offset( const string& time_str );
int parse_tile_radius( const string& arg );
// Destructor
FGView::~FGView( void ) {
}
-
-
}
-// Initialize the time dependent variables
+// Initialize the time dependent variables (maybe I'll put this in the
+// constructor later)
void FGTime::init()
{
FG_LOG( FG_EVENT, FG_INFO, "Initializing Time" );
gst_diff = -9999.0;
FG_LOG( FG_EVENT, FG_DEBUG,
"time offset = " << current_options.get_time_offset() );
- warp = current_options.get_time_offset();
+ time_t timeOffset = current_options.get_time_offset();
+ time_t gstStart = current_options.get_start_gst();
+ time_t lstStart = current_options.get_start_lst();
+
+ // would it be better to put these sanity checks in the options
+ // parsing code? (CLO)
+ if (timeOffset && gstStart)
+ {
+ FG_LOG( FG_EVENT, FG_ALERT, "Error: you specified both a time offset and a gst. Confused now!" );
+ current_options.usage();
+ exit(1);
+ }
+ if (timeOffset && lstStart)
+ {
+ FG_LOG( FG_EVENT, FG_ALERT, "Error: you specified both a time offset and a lst. Confused now!" );
+ current_options.usage();
+ exit(1);
+ }
+ if (gstStart && lstStart)
+ {
+ FG_LOG( FG_EVENT, FG_ALERT, "Error: you specified both a time offset and a lst. Confused now!" );
+ current_options.usage();
+ exit(1);
+ }
+ cur_time = time(NULL);
+ if (gstStart)
+ warp = gstStart - cur_time;
+ else if (lstStart) // I need to use the time zone info for this one, but I'll do that later.
+ // Until then, Gst and LST are the same
+ {
+ warp = lstStart - cur_time;
+ }
+ else if (timeOffset)
+ {
+ warp = timeOffset;
+ }
+ else
+ {
+ warp = 0;
+ }
warp_delta = 0;
pause = current_options.get_pause();
}
double FGTime::sidereal_precise (double lng)
{
- double gst;
double lstTmp;
/* printf ("Current Lst on JD %13.5f at %8.4f degrees West: ",
lng *= DEG_TO_RAD;
// compute LST and print
- //gst = utc_gst ();
utc_gst();
lstTmp = gst - RADHR (lng);
lstTmp -= 24.0*floor(lst/24.0);
//gmt = t->gmt;
//now = t->cur_time;
now = cur_time;
- start_gmt = get_start_gmt(gmt->tm_year);
+ start_gmt = get_gmt(gmt->tm_year, 2, 21, 12, 0, 0);
FG_LOG( FG_EVENT, FG_DEBUG, " COURSE: GMT = " << format_time(gmt, tbuf) );
FG_LOG( FG_EVENT, FG_DEBUG, " March 21 noon (GMT) = " << start_gmt );
/******************************************************************
* The following are some functions that were included as FGTime
- * members, although they currenty don't make used of any of the
+ * members, although they currently don't make used of any of the
* class's variables. Maybe this'll change in the future
*****************************************************************/
// If you are having problems with incorrectly positioned astronomical
// bodies, this is a really good place to start looking.
-time_t FGTime::get_start_gmt(int year) {
+time_t FGTime::get_gmt(int year, int month, int day, int hour, int min, int sec)
+{
struct tm mt;
// For now we assume that if daylight is not defined in
# define TIMEZONE_OFFSET_WORKS 1
# endif
- mt.tm_mon = 2;
- mt.tm_mday = 21;
+ mt.tm_mon = month;
+ mt.tm_mday = day;
mt.tm_year = year;
- mt.tm_hour = 12;
- mt.tm_min = 0;
- mt.tm_sec = 0;
+ mt.tm_hour = hour;
+ mt.tm_min = min;
+ mt.tm_sec = sec;
mt.tm_isdst = -1; // let the system determine the proper time zone
# if defined( MK_TIME_IS_GMT )
// Some other stuff which were changed to FGTime members on
// questionable grounds -:)
- time_t get_start_gmt(int year);
+ // time_t get_start_gmt(int year);
+ time_t get_gmt(int year, int month, int day,
+ int hour, int minute, int second);
char* format_time( const struct tm* p, char* buf );
long int fix_up_timezone( long int timezone_orig );
};