From 2e27909b9ea05b0e42d126f4342c79e4cb4794a1 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 5 Jan 1998 18:44:33 +0000 Subject: [PATCH] Add an option to advance/decrease time from keyboard. --- Main/GLUTkey.c | 21 +++++++++++++++++++-- Main/fg_init.c | 9 ++++++--- Scenery/moon.c | 19 +++++++++++-------- Scenery/sun.c | 17 ++++++++++------- Simulator/make.inc | 5 ++++- Time/fg_time.c | 19 +++++++++++-------- Time/fg_time.h | 14 ++++++++++++-- 7 files changed, 73 insertions(+), 31 deletions(-) diff --git a/Main/GLUTkey.c b/Main/GLUTkey.c index 8e178befb..22a5b526f 100644 --- a/Main/GLUTkey.c +++ b/Main/GLUTkey.c @@ -48,10 +48,12 @@ extern int displayInstruments; /* Handle keyboard events */ void GLUTkey(unsigned char k, int x, int y) { struct fgCONTROLS *c; + struct fgTIME *t; struct fgVIEW *v; struct fgWEATHER *w; c = ¤t_aircraft.controls; + t = &cur_time_params; v = ¤t_view; w = ¤t_weather; @@ -87,6 +89,12 @@ void GLUTkey(unsigned char k, int x, int y) { case 72: /* H key */ show_hud = !show_hud; return; + case 77: /* M key */ + t->warp -= 60; + return; + case 84: /* T key */ + t->warp_delta -= 30; + return; case 87: /* W key */ displayInstruments = !displayInstruments; return; @@ -134,6 +142,12 @@ void GLUTkey(unsigned char k, int x, int y) { case 51: /* numeric keypad 3 (Pg Dn) */ fgThrottleMove(0, -0.01); return; + case 109: /* m key */ + t->warp += 60; + return; + case 116: /* t key */ + t->warp_delta += 30; + return; case 122: /* z key */ w->visibility *= 1.10; xglFogf(GL_FOG_END, w->visibility); @@ -229,9 +243,12 @@ void GLUTspecialkey(int k, int x, int y) { /* $Log$ -/* Revision 1.24 1997/12/30 16:36:46 curt -/* Merged in Durk's changes ... +/* Revision 1.25 1998/01/05 18:44:34 curt +/* Add an option to advance/decrease time from keyboard. /* + * Revision 1.24 1997/12/30 16:36:46 curt + * Merged in Durk's changes ... + * * Revision 1.23 1997/12/15 23:54:44 curt * Add xgl wrappers for debugging. * Generate terrain normals on the fly. diff --git a/Main/fg_init.c b/Main/fg_init.c index 60bbc65b8..7e35e9203 100644 --- a/Main/fg_init.c +++ b/Main/fg_init.c @@ -217,7 +217,7 @@ void fgInitSubsystems( void ) { fgEventRegister( "fgSunInit()", fgSunInit, FG_EVENT_READY, 600000 ); /* Intialize the moon's position */ - fgEventRegister( "fgMoonInit()", fgSunInit, FG_EVENT_READY, 600000 ); + fgEventRegister( "fgMoonInit()", fgMoonInit, FG_EVENT_READY, 600000 ); /* Initialize the "sky" */ fgSkyInit(); @@ -267,9 +267,12 @@ void fgInitSubsystems( void ) { /* $Log$ -/* Revision 1.26 1997/12/30 23:09:04 curt -/* Tweaking initialization sequences. +/* Revision 1.27 1998/01/05 18:44:35 curt +/* Add an option to advance/decrease time from keyboard. /* + * Revision 1.26 1997/12/30 23:09:04 curt + * Tweaking initialization sequences. + * * Revision 1.25 1997/12/30 22:22:33 curt * Further integration of event manager. * diff --git a/Scenery/moon.c b/Scenery/moon.c index bc2592b05..4f4652be4 100644 --- a/Scenery/moon.c +++ b/Scenery/moon.c @@ -273,6 +273,10 @@ void fgMoonInit() { moonPos.Declination); #endif + xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); + yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); + zMoon = 60000.0 * sin(moonPos.Declination); + if ( !dl_exists ) { dl_exists = 1; @@ -285,12 +289,6 @@ void fgMoonInit() { xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */ - xMoon = 60000.0 * cos(moonPos.RightAscension) * - cos(moonPos.Declination); - yMoon = 60000.0 * sin(moonPos.RightAscension) * - cos(moonPos.Declination); - zMoon = 60000.0 * sin(moonPos.Declination); - glutSolidSphere(1.0, 10, 10); xglEndList(); @@ -303,6 +301,8 @@ void fgMoonRender() { struct fgLIGHT *l; GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 }; + /* printf("Rendering moon\n"); */ + l = &cur_light_params; xglMaterialfv(GL_FRONT, GL_AMBIENT, l->sky_color ); @@ -319,9 +319,12 @@ void fgMoonRender() { /* $Log$ -/* Revision 1.14 1997/12/30 20:47:50 curt -/* Integrated new event manager with subsystem initializations. +/* Revision 1.15 1998/01/05 18:44:35 curt +/* Add an option to advance/decrease time from keyboard. /* + * Revision 1.14 1997/12/30 20:47:50 curt + * Integrated new event manager with subsystem initializations. + * * Revision 1.13 1997/12/30 16:41:00 curt * Added log at end of file. * diff --git a/Scenery/sun.c b/Scenery/sun.c index 5aa32341e..d68d179a9 100644 --- a/Scenery/sun.c +++ b/Scenery/sun.c @@ -106,6 +106,10 @@ void fgSunInit() { sunPos.Declination); #endif + xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination); + ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination); + zSun = 60000.0 * sin(sunPos.Declination); + if ( !dl_exists ) { dl_exists = 1; @@ -114,10 +118,6 @@ void fgSunInit() { sun_obj = xglGenLists(1); xglNewList(sun_obj, GL_COMPILE ); - xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination); - ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination); - zSun = 60000.0 * sin(sunPos.Declination); - glutSolidSphere(1.0, 10, 10); xglEndList(); @@ -190,10 +190,13 @@ void fgSunRender() { /* $Log$ -/* Revision 1.11 1997/12/30 23:09:40 curt -/* Worked on winding problem without luck, so back to calling glFrontFace() -/* 3 times for each scenery area. +/* Revision 1.12 1998/01/05 18:44:36 curt +/* Add an option to advance/decrease time from keyboard. /* + * Revision 1.11 1997/12/30 23:09:40 curt + * Worked on winding problem without luck, so back to calling glFrontFace() + * 3 times for each scenery area. + * * Revision 1.10 1997/12/30 20:47:54 curt * Integrated new event manager with subsystem initializations. * diff --git a/Simulator/make.inc b/Simulator/make.inc index 67fe07727..c529906d1 100644 --- a/Simulator/make.inc +++ b/Simulator/make.inc @@ -66,7 +66,7 @@ TAR = tar # - #--------------------------------------------------------------------------- -GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(FG_VERSION)\" +GLOBAL_CFLAGS = -Wall -DVERSION=\"$(FG_VERSION)\" #--------------------------------------------------------------------------- @@ -159,6 +159,9 @@ FG_CFLAGS = $(GLOBAL_CFLAGS) $(FG_DEBUG_FLAGS) #--------------------------------------------------------------------------- # $Log$ +# Revision 1.29 1998/01/05 18:44:33 curt +# Add an option to advance/decrease time from keyboard. +# # Revision 1.28 1997/12/30 23:08:50 curt # Version 0.21 # diff --git a/Time/fg_time.c b/Time/fg_time.c index e7d921c06..a5d25af43 100644 --- a/Time/fg_time.c +++ b/Time/fg_time.c @@ -56,6 +56,8 @@ void fgTimeInit(struct fgTIME *t) { printf("Initializing Time\n"); t->gst_diff = -9999.0; + t->warp = 0; + t->warp_delta = 0; } @@ -238,17 +240,15 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) { void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) { double gst_precise, gst_course; - static long int warp = 0; printf("Updating time\n"); /* get current Unix calendar time (in seconds) */ /* warp = 60; */ - warp += 0; - t->cur_time = time(NULL) + (0) * 60 * 60; - t->cur_time += warp; - printf(" Current Unix calendar time = %ld warp = %ld\n", - t->cur_time, warp); + t->warp += t->warp_delta; + t->cur_time = time(NULL) + t->warp; + printf(" Current Unix calendar time = %ld warp = %ld delta = %ld\n", + t->cur_time, t->warp, t->warp_delta); /* get GMT break down for current time */ t->gmt = gmtime(&t->cur_time); @@ -298,9 +298,12 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) { /* $Log$ -/* Revision 1.25 1997/12/31 17:46:50 curt -/* Tweaked fg_time.c to be able to use ftime() instead of gettimeofday() +/* Revision 1.26 1998/01/05 18:44:36 curt +/* Add an option to advance/decrease time from keyboard. /* + * Revision 1.25 1997/12/31 17:46:50 curt + * Tweaked fg_time.c to be able to use ftime() instead of gettimeofday() + * * Revision 1.24 1997/12/30 22:22:42 curt * Further integration of event manager. * diff --git a/Time/fg_time.h b/Time/fg_time.h index a1743f90f..9f98ac6d2 100644 --- a/Time/fg_time.h +++ b/Time/fg_time.h @@ -55,6 +55,13 @@ struct fgTIME { sidereal time algorithm result and the course result. course + diff has good accuracy for the short term */ + + long int warp; /* An offset in seconds from the true time. + Allows us to adjust the effective time of day. */ + + long int warp_delta; /* How much to change the value of warp each + iteration. Allows us to make time + progress faster than normal. */ }; extern struct fgTIME cur_time_params; @@ -92,9 +99,12 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t); /* $Log$ -/* Revision 1.11 1997/12/19 23:35:07 curt -/* Lot's of tweaking with sky rendering and lighting. +/* Revision 1.12 1998/01/05 18:44:37 curt +/* Add an option to advance/decrease time from keyboard. /* + * Revision 1.11 1997/12/19 23:35:07 curt + * Lot's of tweaking with sky rendering and lighting. + * * Revision 1.10 1997/12/15 23:55:07 curt * Add xgl wrappers for debugging. * Generate terrain normals on the fly. -- 2.39.2