Integrated new event manager with subsystem initializations.
This commit is contained in:
parent
8fc35e70b4
commit
2ebbbe0053
19 changed files with 231 additions and 108 deletions
|
@ -50,6 +50,8 @@ struct fgCOCKPIT *fgCockpitInit( struct fgAIRCRAFT cur_aircraft )
|
|||
struct fgCOCKPIT *cockpit;
|
||||
Hptr hud;
|
||||
|
||||
printf("Initializing cockpit subsystem\n");
|
||||
|
||||
cockpit = (struct fgCOCKPIT *)calloc(sizeof(struct fgCOCKPIT),1);
|
||||
if( cockpit == NULL )
|
||||
return( NULL );
|
||||
|
@ -66,7 +68,8 @@ struct fgCOCKPIT *fgCockpitInit( struct fgAIRCRAFT cur_aircraft )
|
|||
|
||||
aircraft_cockpit = cockpit;
|
||||
|
||||
printf( "Code %d Status %d\n", cockpit->hud->code, cockpit->hud->status );
|
||||
printf(" Code %d Status %d\n", cockpit->hud->code,
|
||||
cockpit->hud->status );
|
||||
|
||||
return( cockpit );
|
||||
}
|
||||
|
@ -87,10 +90,13 @@ void fgCockpitUpdate()
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.3 1997/12/15 23:54:33 curt
|
||||
/* Add xgl wrappers for debugging.
|
||||
/* Generate terrain normals on the fly.
|
||||
/* Revision 1.4 1997/12/30 20:47:34 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.3 1997/12/15 23:54:33 curt
|
||||
* Add xgl wrappers for debugging.
|
||||
* Generate terrain normals on the fly.
|
||||
*
|
||||
* Revision 1.2 1997/12/10 22:37:38 curt
|
||||
* Prepended "fg" on the name of all global structures that didn't have it yet.
|
||||
* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
||||
|
|
11
FDM/flight.c
11
FDM/flight.c
|
@ -31,6 +31,8 @@
|
|||
int fgFlightModelInit(int model, struct fgFLIGHT *f, double dt) {
|
||||
int result;
|
||||
|
||||
printf("Initializing flight model\n");
|
||||
|
||||
if ( model == FG_LARCSIM ) {
|
||||
fgFlight_2_LaRCsim(f); /* translate FG to LaRCsim structure */
|
||||
fgLaRCsimInit(dt);
|
||||
|
@ -61,10 +63,13 @@ int fgFlightModelUpdate(int model, struct fgFLIGHT *f, int multiloop) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.4 1997/12/10 22:37:42 curt
|
||||
/* Prepended "fg" on the name of all global structures that didn't have it yet.
|
||||
/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
||||
/* Revision 1.5 1997/12/30 20:47:37 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.4 1997/12/10 22:37:42 curt
|
||||
* Prepended "fg" on the name of all global structures that didn't have it yet.
|
||||
* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
||||
*
|
||||
* Revision 1.3 1997/08/27 03:30:04 curt
|
||||
* Changed naming scheme of basic shared structures.
|
||||
*
|
||||
|
|
|
@ -41,8 +41,9 @@ static joy_y_dead_min=1000, joy_y_dead_max=-1000;
|
|||
|
||||
static int joystick_fd;
|
||||
|
||||
int fgJoystickInit( int joy_num )
|
||||
{
|
||||
int fgJoystickInit( int joy_num ) {
|
||||
printf("Initializing joystick\n");
|
||||
|
||||
#ifdef HAVE_JOYSTICK
|
||||
int status;
|
||||
char *fname;
|
||||
|
@ -235,7 +236,10 @@ int fgJoystickRead( double *joy_x, double *joy_y, int *joy_b1, int *joy_b2 )
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.1 1997/08/29 18:06:54 curt
|
||||
/* Initial revision.
|
||||
/* Revision 1.2 1997/12/30 20:47:40 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.1 1997/08/29 18:06:54 curt
|
||||
* Initial revision.
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -348,9 +348,9 @@ static void fgRenderFrame( void ) {
|
|||
fgSceneryRender();
|
||||
|
||||
/* display HUD */
|
||||
/* if( show_hud ) {
|
||||
if( show_hud ) {
|
||||
fgCockpitUpdate();
|
||||
} */
|
||||
}
|
||||
|
||||
/* display instruments */
|
||||
if (displayInstruments) {
|
||||
|
@ -512,6 +512,7 @@ void fgInitTimeDepCalcs() {
|
|||
}
|
||||
*/
|
||||
|
||||
|
||||
/* What should we do when we have nothing else to do? How about get
|
||||
* ready for the next move and update the display? */
|
||||
static void fgMainLoop( void ) {
|
||||
|
@ -555,6 +556,7 @@ static void fgMainLoop( void ) {
|
|||
printf("Model iterations needed = %d, new remainder = %d\n", multi_loop,
|
||||
remainder);
|
||||
|
||||
/* Run flight model */
|
||||
if ( ! use_signals ) {
|
||||
/* flight model */
|
||||
fgUpdateTimeDepCalcs(multi_loop);
|
||||
|
@ -580,6 +582,9 @@ static void fgMainLoop( void ) {
|
|||
|
||||
fgAircraftOutputCurrent(a);
|
||||
|
||||
/* Process/manage pending events */
|
||||
fgEventProcess();
|
||||
|
||||
/* redraw display */
|
||||
fgRenderFrame();
|
||||
}
|
||||
|
@ -689,9 +694,12 @@ int main( int argc, char *argv[] ) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.42 1997/12/30 16:36:47 curt
|
||||
/* Merged in Durk's changes ...
|
||||
/* Revision 1.43 1997/12/30 20:47:43 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.42 1997/12/30 16:36:47 curt
|
||||
* Merged in Durk's changes ...
|
||||
*
|
||||
* Revision 1.41 1997/12/30 13:06:56 curt
|
||||
* A couple lighting tweaks ...
|
||||
*
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "../Scenery/sky.h"
|
||||
#include "../Scenery/stars.h"
|
||||
#include "../Scenery/sun.h"
|
||||
#include "../Time/event.h"
|
||||
#include "../Time/fg_time.h"
|
||||
#include "../Time/sunpos.h"
|
||||
#include "../Weather/weather.h"
|
||||
|
@ -59,6 +60,9 @@ void fgInitGeneral( void ) {
|
|||
|
||||
g = &general;
|
||||
|
||||
printf("General Initialization\n");
|
||||
printf("======= ==============\n");
|
||||
|
||||
/* seed the random number generater */
|
||||
fg_srandom();
|
||||
|
||||
|
@ -69,6 +73,8 @@ void fgInitGeneral( void ) {
|
|||
exit(0);
|
||||
}
|
||||
printf("FG_ROOT = %s\n", g->root_dir);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,6 +93,8 @@ void fgInitSubsystems( void ) {
|
|||
t = &cur_time_params;
|
||||
v = ¤t_view;
|
||||
|
||||
printf("Initialize Subsystems\n");
|
||||
printf("========== ==========\n");
|
||||
|
||||
/****************************************************************
|
||||
* The following section sets up the flight model EOM parameters and
|
||||
|
@ -160,12 +168,19 @@ void fgInitSubsystems( void ) {
|
|||
/* fgSlewInit(-335340,162540, 15, 4.38); */
|
||||
/* fgSlewInit(-398673.28,120625.64, 53, 4.38); */
|
||||
|
||||
/* Initialize the event manager */
|
||||
fgEventInit();
|
||||
|
||||
/* Dump event stats every 60 seconds */
|
||||
fgEventRegister( "fgEventPrintStats()", fgEventPrintStats,
|
||||
FG_EVENT_READY, 60000 );
|
||||
|
||||
/* Initialize "time" */
|
||||
fgTimeInit(t);
|
||||
fgTimeUpdate(f, t);
|
||||
|
||||
/* Initialize shared sun position and sun_vec */
|
||||
fgUpdateSunPos(scenery.center);
|
||||
fgEventRegister( "fgUpdateSunPos()", fgUpdateSunPos, FG_EVENT_READY, 1000 );
|
||||
|
||||
/* Initialize view parameters */
|
||||
fgViewInit(v);
|
||||
|
@ -174,13 +189,10 @@ void fgInitSubsystems( void ) {
|
|||
fgWeatherInit();
|
||||
|
||||
/* Initialize the Cockpit subsystem */
|
||||
/*
|
||||
if( fgCockpitInit( current_aircraft ) == NULL )
|
||||
{
|
||||
if( fgCockpitInit( current_aircraft ) == NULL ) {
|
||||
printf( "Error in Cockpit initialization!\n" );
|
||||
exit( 1 );
|
||||
}
|
||||
*/
|
||||
|
||||
/* Initialize the orbital elements of sun, moon and mayor planets */
|
||||
fgSolarSystemInit(*t);
|
||||
|
@ -208,7 +220,7 @@ void fgInitSubsystems( void ) {
|
|||
* eventually */
|
||||
cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
|
||||
FG_Latitude * RAD_TO_DEG * 3600.0);
|
||||
printf("Ground elevation is %.2f meters here.\n", cur_elev);
|
||||
printf("True ground elevation is %.2f meters here.\n", cur_elev);
|
||||
if ( cur_elev > -9990.0 ) {
|
||||
FG_Runway_altitude = cur_elev * METER_TO_FEET;
|
||||
}
|
||||
|
@ -216,7 +228,7 @@ void fgInitSubsystems( void ) {
|
|||
if ( FG_Altitude < FG_Runway_altitude ) {
|
||||
FG_Altitude = FG_Runway_altitude + 3.758099;
|
||||
}
|
||||
printf("Updated position is: (%.4f, %.4f, %.2f)\n",
|
||||
printf("Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
|
||||
FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
|
||||
FG_Altitude * FEET_TO_METER);
|
||||
/* end of thing that I just stuck in that I should probably move */
|
||||
|
@ -227,20 +239,25 @@ void fgInitSubsystems( void ) {
|
|||
fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
|
||||
|
||||
/* To HUD or not to HUD */
|
||||
show_hud = 1;
|
||||
show_hud = 0;
|
||||
|
||||
/* Let's show the instrument panel */
|
||||
displayInstruments = 1;
|
||||
displayInstruments = 0;
|
||||
|
||||
/* Joystick support */
|
||||
fgJoystickInit( 0 );
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.23 1997/12/30 16:36:50 curt
|
||||
/* Merged in Durk's changes ...
|
||||
/* Revision 1.24 1997/12/30 20:47:44 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.23 1997/12/30 16:36:50 curt
|
||||
* Merged in Durk's changes ...
|
||||
*
|
||||
* Revision 1.22 1997/12/19 23:34:05 curt
|
||||
* Lot's of tweaking with sky rendering and lighting.
|
||||
*
|
||||
|
|
|
@ -42,6 +42,8 @@ struct fgVIEW current_view;
|
|||
|
||||
/* Initialize a view structure */
|
||||
void fgViewInit(struct fgVIEW *v) {
|
||||
printf("Initializing View parameters\n");
|
||||
|
||||
v->view_offset = 0.0;
|
||||
v->goal_view_offset = 0.0;
|
||||
}
|
||||
|
@ -181,9 +183,12 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.6 1997/12/22 04:14:32 curt
|
||||
/* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
||||
/* Revision 1.7 1997/12/30 20:47:45 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.6 1997/12/22 04:14:32 curt
|
||||
* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
||||
*
|
||||
* Revision 1.5 1997/12/18 04:07:02 curt
|
||||
* Worked on properly translating and positioning the sky dome.
|
||||
*
|
||||
|
|
|
@ -260,6 +260,8 @@ void fgMoonInit() {
|
|||
struct fgLIGHT *l;
|
||||
static int dl_exists = 0;
|
||||
|
||||
printf("Initializing the Moon\n");
|
||||
|
||||
l = &cur_light_params;
|
||||
|
||||
/* position the moon */
|
||||
|
@ -317,7 +319,10 @@ void fgMoonRender() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.13 1997/12/30 16:41:00 curt
|
||||
/* Added log at end of file.
|
||||
/* 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.
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -89,6 +89,8 @@ GLint fgObjLoad(char *path) {
|
|||
while ( fgets(line, 250, f) != NULL ) {
|
||||
if ( line[0] == '#' ) {
|
||||
/* comment -- ignore */
|
||||
} else if ( line[0] == '\n' ) {
|
||||
/* empty line -- ignore */
|
||||
} else if ( strncmp(line, "v ", 2) == 0 ) {
|
||||
/* node (vertex) */
|
||||
if ( ncount < MAXNODES ) {
|
||||
|
@ -121,7 +123,7 @@ GLint fgObjLoad(char *path) {
|
|||
}
|
||||
} else if ( strncmp(line, "winding ", 8) == 0 ) {
|
||||
sscanf(line+8, "%s", winding_str);
|
||||
printf("WINDING = %s\n", winding_str);
|
||||
printf(" WINDING = %s\n", winding_str);
|
||||
|
||||
/* can't call xglFrontFace() between xglBegin() & xglEnd() */
|
||||
xglEnd();
|
||||
|
@ -146,7 +148,7 @@ GLint fgObjLoad(char *path) {
|
|||
first = 0;
|
||||
}
|
||||
|
||||
printf("new tri strip = %s", line);
|
||||
/* printf(" new tri strip = %s", line); */
|
||||
sscanf(line, "t %d %d %d %d\n", &n1, &n2, &n3, &n4);
|
||||
|
||||
/* printf("(t) = "); */
|
||||
|
@ -315,9 +317,12 @@ GLint fgObjLoad(char *path) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.14 1997/12/30 01:38:46 curt
|
||||
/* Switched back to per vertex normals and smooth shading for terrain.
|
||||
/* Revision 1.15 1997/12/30 20:47:51 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.14 1997/12/30 01:38:46 curt
|
||||
* Switched back to per vertex normals and smooth shading for terrain.
|
||||
*
|
||||
* Revision 1.13 1997/12/18 23:32:36 curt
|
||||
* First stab at sky dome actually starting to look reasonable. :-)
|
||||
*
|
||||
|
|
|
@ -53,10 +53,11 @@ double fgCalcActTime(struct fgTIME t)
|
|||
actTime += (UT / 24.0);
|
||||
#define DEBUG 1
|
||||
#ifdef DEBUG
|
||||
printf("Actual Time:\n");
|
||||
printf("current day = %f\t", actTime);
|
||||
printf("GMT = %d, %d, %d, %d, %d, %d\n", year, t.gmt->tm_mon, t.gmt->tm_mday,
|
||||
t.gmt->tm_hour, t.gmt->tm_min, t.gmt->tm_sec);
|
||||
/* printf(" Actual Time:\n"); */
|
||||
/* printf(" current day = %f\t", actTime); */
|
||||
/* printf(" GMT = %d, %d, %d, %d, %d, %d\n",
|
||||
year, t.gmt->tm_mon, t.gmt->tm_mday,
|
||||
t.gmt->tm_hour, t.gmt->tm_min, t.gmt->tm_sec); */
|
||||
#endif
|
||||
return actTime;
|
||||
}
|
||||
|
@ -124,6 +125,8 @@ void fgSolarSystemInit(struct fgTIME t)
|
|||
int i;
|
||||
FILE *data;
|
||||
|
||||
printf("Initializing solar system\n");
|
||||
|
||||
/* build the full path name to the orbital elements database file */
|
||||
g = &general;
|
||||
path[0] = '\0';
|
||||
|
@ -137,7 +140,7 @@ void fgSolarSystemInit(struct fgTIME t)
|
|||
return;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf("reading datafile %s", path);
|
||||
printf(" reading datafile %s\n", path);
|
||||
#endif
|
||||
|
||||
/* for all the objects... */
|
||||
|
@ -170,10 +173,13 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.5 1997/12/15 23:55:02 curt
|
||||
/* Add xgl wrappers for debugging.
|
||||
/* Generate terrain normals on the fly.
|
||||
/* Revision 1.6 1997/12/30 20:47:52 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.5 1997/12/15 23:55:02 curt
|
||||
* Add xgl wrappers for debugging.
|
||||
* Generate terrain normals on the fly.
|
||||
*
|
||||
* Revision 1.4 1997/12/10 22:37:51 curt
|
||||
* Prepended "fg" on the name of all global structures that didn't have it yet.
|
||||
* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
||||
|
|
|
@ -120,20 +120,25 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
|
|||
default:
|
||||
printf("index %d out of range !!!!\n", idx);
|
||||
}
|
||||
printf("Geocentric dist %f\n"
|
||||
"Heliocentric dist %f\n"
|
||||
"Distance to the sun %f\n"
|
||||
"Phase angle %f\n"
|
||||
"Brightness %f\n", R, r, s, FV, result.magnitude);
|
||||
printf(" Planet found at %f (ra), %f (dec)\n",
|
||||
result.RightAscension, result.Declination);
|
||||
printf(" Geocentric dist %f\n"
|
||||
" Heliocentric dist %f\n"
|
||||
" Distance to the sun %f\n"
|
||||
" Phase angle %f\n"
|
||||
" Brightness %f\n", R, r, s, FV, result.magnitude);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.3 1997/12/30 16:36:52 curt
|
||||
/* Merged in Durk's changes ...
|
||||
/* Revision 1.4 1997/12/30 20:47:52 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.3 1997/12/30 16:36:52 curt
|
||||
* Merged in Durk's changes ...
|
||||
*
|
||||
* Revision 1.2 1997/12/12 21:41:29 curt
|
||||
* More light/material property tweaking ... still a ways off.
|
||||
*
|
||||
|
|
|
@ -52,6 +52,8 @@ struct fgSCENERY scenery;
|
|||
|
||||
/* Initialize the Scenery Management system */
|
||||
void fgSceneryInit() {
|
||||
printf("Initializing scenery subsystem\n");
|
||||
|
||||
/* set the default terrain detail level */
|
||||
scenery.terrain_skip = 6;
|
||||
}
|
||||
|
@ -74,7 +76,7 @@ void fgSceneryUpdate(double lon, double lat, double elev) {
|
|||
strcat(path, "/Scenery/");
|
||||
strcat(path, "mesa-e.obj");
|
||||
|
||||
printf("Loading Scenery: %s\n", path);
|
||||
printf(" Loading Scenery: %s\n", path);
|
||||
|
||||
area_terrain = fgObjLoad(path);
|
||||
}
|
||||
|
@ -100,10 +102,13 @@ void fgSceneryRender() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.28 1997/12/15 23:55:02 curt
|
||||
/* Add xgl wrappers for debugging.
|
||||
/* Generate terrain normals on the fly.
|
||||
/* Revision 1.29 1997/12/30 20:47:52 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.28 1997/12/15 23:55:02 curt
|
||||
* Add xgl wrappers for debugging.
|
||||
* Generate terrain normals on the fly.
|
||||
*
|
||||
* Revision 1.27 1997/12/12 21:41:30 curt
|
||||
* More light/material property tweaking ... still a ways off.
|
||||
*
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
|
||||
#include "sky.h"
|
||||
|
||||
#include "../Time/event.h"
|
||||
#include "../Time/fg_time.h"
|
||||
|
||||
#include "../Aircraft/aircraft.h"
|
||||
|
@ -75,7 +76,7 @@ void fgSkyVerticesInit() {
|
|||
float theta;
|
||||
int i;
|
||||
|
||||
printf("Generating the sky dome vertices.\n");
|
||||
printf(" Generating the sky dome vertices.\n");
|
||||
|
||||
for ( i = 0; i < 12; i++ ) {
|
||||
theta = (i * 30.0) * DEG_TO_RAD;
|
||||
|
@ -84,8 +85,8 @@ void fgSkyVerticesInit() {
|
|||
inner_vertex[i][1] = sin(theta) * INNER_RADIUS;
|
||||
inner_vertex[i][2] = INNER_ELEV;
|
||||
|
||||
printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
|
||||
sin(theta) * INNER_RADIUS);
|
||||
/* printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
|
||||
sin(theta) * INNER_RADIUS); */
|
||||
|
||||
middle_vertex[i][0] = cos((double)theta) * MIDDLE_RADIUS;
|
||||
middle_vertex[i][1] = sin((double)theta) * MIDDLE_RADIUS;
|
||||
|
@ -109,7 +110,7 @@ void fgSkyColorsInit() {
|
|||
|
||||
l = &cur_light_params;
|
||||
|
||||
printf("Generating the sky colors for each vertex.\n");
|
||||
printf(" Generating the sky colors for each vertex.\n");
|
||||
|
||||
/* setup for the possibility of sunset effects */
|
||||
sun_angle = l->sun_angle * RAD_TO_DEG;
|
||||
|
@ -169,6 +170,7 @@ void fgSkyColorsInit() {
|
|||
middle_amt[j] -= middle_diff[j];
|
||||
}
|
||||
|
||||
/*
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
|
@ -177,6 +179,7 @@ void fgSkyColorsInit() {
|
|||
printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
outer_color[i][0], outer_color[i][1], outer_color[i][2],
|
||||
outer_color[i][3]);
|
||||
*/
|
||||
}
|
||||
|
||||
for ( j = 0; j < 3; j++ ) {
|
||||
|
@ -206,6 +209,7 @@ void fgSkyColorsInit() {
|
|||
middle_amt[j] += middle_diff[j];
|
||||
}
|
||||
|
||||
/*
|
||||
printf("inner_color[%d] = %.2f %.2f %.2f %.2f\n", i, inner_color[i][0],
|
||||
inner_color[i][1], inner_color[i][2], inner_color[i][3]);
|
||||
printf("middle_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
|
@ -214,14 +218,20 @@ void fgSkyColorsInit() {
|
|||
printf("outer_color[%d] = %.2f %.2f %.2f %.2f\n", i,
|
||||
outer_color[i][0], outer_color[i][1], outer_color[i][2],
|
||||
outer_color[i][3]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the sky structure and colors */
|
||||
void fgSkyInit() {
|
||||
printf("Initializing the sky\n");
|
||||
|
||||
fgSkyVerticesInit();
|
||||
fgSkyColorsInit();
|
||||
|
||||
/* regester fgSkyColorsInit() as an event to be run periodically */
|
||||
fgEventRegister("fgSkyColorsInit()", fgSkyColorsInit,
|
||||
FG_EVENT_READY, 30000);
|
||||
}
|
||||
|
||||
|
||||
|
@ -319,9 +329,12 @@ void fgSkyRender() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.9 1997/12/30 13:06:57 curt
|
||||
/* A couple lighting tweaks ...
|
||||
/* Revision 1.10 1997/12/30 20:47:53 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.9 1997/12/30 13:06:57 curt
|
||||
* A couple lighting tweaks ...
|
||||
*
|
||||
* Revision 1.8 1997/12/23 04:58:38 curt
|
||||
* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
* control.
|
||||
|
|
|
@ -68,6 +68,8 @@ void fgStarsInit() {
|
|||
double ra_save1, decl_save1;
|
||||
int count, i, j, max_stars;
|
||||
|
||||
printf("Initializing stars\n");
|
||||
|
||||
g = &general;
|
||||
|
||||
/* build the full path name to the stars data base file */
|
||||
|
@ -79,7 +81,7 @@ void fgStarsInit() {
|
|||
max_stars = FG_MAX_STARS;
|
||||
|
||||
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
|
||||
printf("Loading %d Stars: %s\n", max_stars, path);
|
||||
printf(" Loading %d Stars: %s\n", max_stars, path);
|
||||
|
||||
if ( (fd = fopen(path, "r")) == NULL ) {
|
||||
printf("Cannot open star file: '%s'\n", path);
|
||||
|
@ -95,14 +97,14 @@ void fgStarsInit() {
|
|||
while ( (fgets(line, 256, fd) != NULL) && (count < max_stars) ) {
|
||||
front = line;
|
||||
|
||||
/* printf("Read line = %s", front); */
|
||||
/* printf(" Read line = %s", front); */
|
||||
|
||||
/* advance to first non-whitespace character */
|
||||
while ( (front[0] == ' ') || (front[0] == '\t') ) {
|
||||
front++;
|
||||
}
|
||||
|
||||
/* printf("Line length (after trimming) = %d\n", strlen(front)); */
|
||||
/* printf(" Line length (after trimming) = %d\n", strlen(front));*/
|
||||
|
||||
if ( front[0] == '#' ) {
|
||||
/* comment */
|
||||
|
@ -148,7 +150,7 @@ void fgStarsInit() {
|
|||
if ( magnitude < 0.0 ) { magnitude = 0.0; }
|
||||
magnitude =
|
||||
magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1);
|
||||
/* printf("Found star: %d %s, %.3f %.3f %.3f\n", count,
|
||||
/* printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
|
||||
name, right_ascension, declination, magnitude); */
|
||||
|
||||
xglColor3f( magnitude, magnitude, magnitude );
|
||||
|
@ -168,8 +170,6 @@ void fgStarsInit() {
|
|||
for ( j = 2; j < 9; j++ ) {
|
||||
pltPos = fgCalculatePlanet(pltOrbElements[j],
|
||||
pltOrbElements[0], cur_time_params, j);
|
||||
printf("Planet found at %f (ra), %f (dec)\n",
|
||||
pltPos.RightAscension, pltPos.Declination);
|
||||
/* give the planets a temporary color, for testing purposes */
|
||||
/* xglColor3f( 1.0, 0.0, 0.0); */
|
||||
|
||||
|
@ -278,9 +278,12 @@ void fgStarsRender() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.22 1997/12/30 16:36:53 curt
|
||||
/* Merged in Durk's changes ...
|
||||
/* Revision 1.23 1997/12/30 20:47:53 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.22 1997/12/30 16:36:53 curt
|
||||
* Merged in Durk's changes ...
|
||||
*
|
||||
* Revision 1.21 1997/12/19 23:35:00 curt
|
||||
* Lot's of tweaking with sky rendering and lighting.
|
||||
*
|
||||
|
|
|
@ -97,6 +97,8 @@ struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
|
|||
void fgSunInit() {
|
||||
static int dl_exists = 0;
|
||||
|
||||
printf("Initializing the Sun\n");
|
||||
|
||||
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
|
||||
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
|
||||
#ifdef DEBUG
|
||||
|
@ -188,9 +190,12 @@ void fgSunRender() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.9 1997/12/30 16:36:54 curt
|
||||
/* Merged in Durk's changes ...
|
||||
/* Revision 1.10 1997/12/30 20:47:54 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.9 1997/12/30 16:36:54 curt
|
||||
* Merged in Durk's changes ...
|
||||
*
|
||||
* Revision 1.8 1997/12/19 23:35:00 curt
|
||||
* Lot's of tweaking with sky rendering and lighting.
|
||||
*
|
||||
|
|
30
Time/event.c
30
Time/event.c
|
@ -142,6 +142,8 @@ void fgEventRun(int ptr) {
|
|||
|
||||
e = &events[ptr];
|
||||
|
||||
printf("Running %s\n", e->description);
|
||||
|
||||
/* record starting time */
|
||||
#ifdef USE_FTIME
|
||||
ftime(&e->last_run);
|
||||
|
@ -196,6 +198,7 @@ void fgEventRun(int ptr) {
|
|||
|
||||
/* Initialize the scheduling subsystem */
|
||||
void fgEventInit() {
|
||||
printf("Initializing event manager\n");
|
||||
event_ptr = 0;
|
||||
initq();
|
||||
}
|
||||
|
@ -208,6 +211,8 @@ int fgEventRegister(char *desc, void (*event)(), int status, int interval) {
|
|||
|
||||
e = &events[event_ptr];
|
||||
|
||||
printf("Registering event: %s\n", desc);
|
||||
|
||||
if ( strlen(desc) < 256 ) {
|
||||
strcpy(e->description, desc);
|
||||
} else {
|
||||
|
@ -257,13 +262,17 @@ void fgEventResume() {
|
|||
void fgEventPrintStats() {
|
||||
int i;
|
||||
|
||||
printf("Event Stats\n");
|
||||
if ( event_ptr > 0 ) {
|
||||
printf("\n");
|
||||
printf("Event Stats\n");
|
||||
printf("----- -----\n");
|
||||
|
||||
for ( i = 0; i < event_ptr; i++ ) {
|
||||
printf(" %s cum=%d min=%d max=%d count=%d ave=%.2f\n",
|
||||
events[i].description, events[i].cum_time, events[i].min_time,
|
||||
events[i].max_time, events[i].count,
|
||||
events[i].cum_time / (double)events[i].count);
|
||||
for ( i = 0; i < event_ptr; i++ ) {
|
||||
printf(" %s cum=%d min=%d max=%d count=%d ave=%.2f\n",
|
||||
events[i].description, events[i].cum_time,
|
||||
events[i].min_time, events[i].max_time, events[i].count,
|
||||
events[i].cum_time / (double)events[i].count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,7 +288,7 @@ void fgEventProcess() {
|
|||
#endif /* USE_FTIME */
|
||||
int i;
|
||||
|
||||
/* printf("Processing events\n"); */
|
||||
printf("Processing events\n");
|
||||
|
||||
/* get the current time */
|
||||
#ifdef USE_FTIME
|
||||
|
@ -323,7 +332,10 @@ void fgEventProcess() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.1 1997/12/30 04:19:22 curt
|
||||
/* Initial revision.
|
||||
/* Revision 1.2 1997/12/30 20:47:58 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.1 1997/12/30 04:19:22 curt
|
||||
* Initial revision.
|
||||
*
|
||||
*/
|
||||
|
|
|
@ -51,6 +51,8 @@ struct fgLIGHT cur_light_params;
|
|||
/* Initialize the time dependent variables */
|
||||
|
||||
void fgTimeInit(struct fgTIME *t) {
|
||||
printf("Initializing Time\n");
|
||||
|
||||
t->gst_diff = -9999.0;
|
||||
}
|
||||
|
||||
|
@ -118,7 +120,7 @@ double utc_gst (double mjd) {
|
|||
x /= 3600.0;
|
||||
gst = (1.0/SIDRATE)*hr + x;
|
||||
|
||||
printf("gst => %.4f\n", gst);
|
||||
printf(" gst => %.4f\n", gst);
|
||||
|
||||
return(gst);
|
||||
}
|
||||
|
@ -166,9 +168,11 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) {
|
|||
struct timezone tz;
|
||||
#endif
|
||||
|
||||
printf("COURSE: GMT = %d/%d/%2d %d:%02d:%02d\n",
|
||||
/*
|
||||
printf(" COURSE: GMT = %d/%d/%2d %d:%02d:%02d\n",
|
||||
gmt->tm_mon, gmt->tm_mday, gmt->tm_year,
|
||||
gmt->tm_hour, gmt->tm_min, gmt->tm_sec);
|
||||
*/
|
||||
|
||||
mt.tm_mon = 2;
|
||||
mt.tm_mday = 21;
|
||||
|
@ -193,19 +197,19 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) {
|
|||
|
||||
offset = -(timezone / 3600 - daylight);
|
||||
|
||||
printf("Raw time zone offset = %ld\n", timezone);
|
||||
printf("Daylight Savings = %d\n", daylight);
|
||||
/* printf(" Raw time zone offset = %ld\n", timezone); */
|
||||
/* printf(" Daylight Savings = %d\n", daylight); */
|
||||
|
||||
printf("Local hours from GMT = %ld\n", offset);
|
||||
/* printf(" Local hours from GMT = %ld\n", offset); */
|
||||
|
||||
start_gmt = start - timezone + (daylight * 3600);
|
||||
|
||||
printf("March 21 noon (CST) = %ld\n", start);
|
||||
printf("March 21 noon (GMT) = %ld\n", start_gmt);
|
||||
/* printf(" March 21 noon (CST) = %ld\n", start); */
|
||||
/* printf(" March 21 noon (GMT) = %ld\n", start_gmt); */
|
||||
|
||||
diff = (now - start_gmt) / (3600.0 * 24.0);
|
||||
|
||||
printf("Time since 3/21/%2d GMT = %.2f\n", gmt->tm_year, diff);
|
||||
/* printf(" Time since 3/21/%2d GMT = %.2f\n", gmt->tm_year, diff); */
|
||||
|
||||
part = fmod(diff, 1.0);
|
||||
days = diff - part;
|
||||
|
@ -217,8 +221,8 @@ double sidereal_course(struct tm *gmt, time_t now, double lng) {
|
|||
lst += 24.0;
|
||||
}
|
||||
|
||||
printf("days = %.1f hours = %.2f lon = %.2f lst = %.2f\n",
|
||||
days, hours, lng, lst);
|
||||
/* printf(" days = %.1f hours = %.2f lon = %.2f lst = %.2f\n",
|
||||
days, hours, lng, lst); */
|
||||
|
||||
return(lst);
|
||||
}
|
||||
|
@ -235,11 +239,12 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
|||
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);
|
||||
printf(" Current Unix calendar time = %ld warp = %ld\n",
|
||||
t->cur_time, warp);
|
||||
|
||||
/* get GMT break down for current time */
|
||||
t->gmt = gmtime(&t->cur_time);
|
||||
printf("Current GMT = %d/%d/%2d %d:%02d:%02d\n",
|
||||
printf(" Current GMT = %d/%d/%2d %d:%02d:%02d\n",
|
||||
t->gmt->tm_mon+1, t->gmt->tm_mday, t->gmt->tm_year,
|
||||
t->gmt->tm_hour, t->gmt->tm_min, t->gmt->tm_sec);
|
||||
|
||||
|
@ -253,15 +258,15 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
|||
|
||||
/* convert "back" to Julian date + partial day (as a fraction of one) */
|
||||
t->jd = t->mjd + MJD0;
|
||||
printf("Current Julian Date = %.5f\n", t->jd);
|
||||
printf(" Current Julian Date = %.5f\n", t->jd);
|
||||
|
||||
printf("Current Longitude = %.3f\n", FG_Longitude * RAD_TO_DEG);
|
||||
/* printf(" Current Longitude = %.3f\n", FG_Longitude * RAD_TO_DEG); */
|
||||
|
||||
/* Calculate local side real time */
|
||||
if ( t->gst_diff < -100.0 ) {
|
||||
/* first time through do the expensive calculation & cheap
|
||||
calculation to get the difference. */
|
||||
printf("First time, doing precise gst\n");
|
||||
printf(" First time, doing precise gst\n");
|
||||
t->gst = gst_precise = sidereal_precise(t->mjd, 0.00);
|
||||
gst_course = sidereal_course(t->gmt, t->cur_time, 0.00);
|
||||
t->gst_diff = gst_precise - gst_course;
|
||||
|
@ -277,17 +282,20 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
|||
sidereal_course(t->gmt, t->cur_time, -(FG_Longitude * RAD_TO_DEG))
|
||||
+ t->gst_diff;
|
||||
}
|
||||
/* printf("Current lon=0.00 Sidereal Time = %.3f\n", t->gst); */
|
||||
/* printf("Current LOCAL Sidereal Time = %.3f (%.3f) (diff = %.3f)\n",
|
||||
/* printf(" Current lon=0.00 Sidereal Time = %.3f\n", t->gst); */
|
||||
/* printf(" Current LOCAL Sidereal Time = %.3f (%.3f) (diff = %.3f)\n",
|
||||
t->lst, sidereal_precise(t->mjd, -(FG_Longitude * RAD_TO_DEG)),
|
||||
t->gst_diff); */
|
||||
}
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.22 1997/12/30 01:38:47 curt
|
||||
/* Switched back to per vertex normals and smooth shading for terrain.
|
||||
/* Revision 1.23 1997/12/30 20:47:58 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.22 1997/12/30 01:38:47 curt
|
||||
* Switched back to per vertex normals and smooth shading for terrain.
|
||||
*
|
||||
* Revision 1.21 1997/12/23 04:58:39 curt
|
||||
* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
* control.
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "../Math/mat3.h"
|
||||
#include "../Math/polar.h"
|
||||
|
||||
|
||||
#undef E
|
||||
|
||||
|
||||
|
@ -260,7 +261,7 @@ void fgSunPosition(time_t ssue, double *lon, double *lat) {
|
|||
|
||||
|
||||
/* update the cur_time_params structure with the current sun position */
|
||||
void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
|
||||
void fgUpdateSunPos() {
|
||||
struct fgLIGHT *l;
|
||||
struct fgTIME *t;
|
||||
struct fgVIEW *v;
|
||||
|
@ -272,6 +273,8 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
|
|||
t = &cur_time_params;
|
||||
v = ¤t_view;
|
||||
|
||||
printf(" Updating Sun position\n");
|
||||
|
||||
time_warp += 0; /* increase this to make the world spin real fast */
|
||||
|
||||
fgSunPosition(t->cur_time + time_warp, &l->sun_lon, &sun_gd_lat);
|
||||
|
@ -280,7 +283,7 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
|
|||
|
||||
l->fg_sunpos = fgPolarToCart(l->sun_lon, l->sun_gc_lat, sl_radius);
|
||||
|
||||
/* printf("Geodetic lat = %.5f Geocentric lat = %.5f\n", sun_gd_lat,
|
||||
/* printf(" Geodetic lat = %.5f Geocentric lat = %.5f\n", sun_gd_lat,
|
||||
t->sun_gc_lat); */
|
||||
|
||||
/* FALSE! (?> the sun position has to be translated just like
|
||||
|
@ -310,16 +313,19 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
|
|||
MAT3_NORMALIZE_VEC(nsun, temp);
|
||||
|
||||
l->sun_angle = acos(MAT3_DOT_PRODUCT(nup, nsun));
|
||||
printf("SUN ANGLE relative to current location = %.3f rads.\n",
|
||||
printf(" SUN ANGLE relative to current location = %.3f rads.\n",
|
||||
l->sun_angle);
|
||||
}
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.18 1997/12/23 04:58:40 curt
|
||||
/* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
/* control.
|
||||
/* Revision 1.19 1997/12/30 20:47:59 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.18 1997/12/23 04:58:40 curt
|
||||
* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||
* control.
|
||||
*
|
||||
* Revision 1.17 1997/12/15 23:55:08 curt
|
||||
* Add xgl wrappers for debugging.
|
||||
* Generate terrain normals on the fly.
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
#include "../Include/types.h"
|
||||
|
||||
/* update the cur_time_params structure with the current sun position */
|
||||
void fgUpdateSunPos(struct fgCartesianPoint scenery_center);
|
||||
void fgUpdateSunPos();
|
||||
|
||||
void fgSunPosition(time_t ssue, double *lon, double *lat);
|
||||
|
||||
|
|
|
@ -39,6 +39,8 @@ void fgWeatherInit(void) {
|
|||
|
||||
w = ¤t_weather;
|
||||
|
||||
printf("Initializing weather subsystem\n");
|
||||
|
||||
/* Configure some wind */
|
||||
/* FG_V_north_airmass = 15; */ /* ft/s =~ 10mph */
|
||||
|
||||
|
@ -62,10 +64,13 @@ void fgWeatherUpdate(double lon, double lat, double alt) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.8 1997/12/11 04:43:58 curt
|
||||
/* Fixed sun vector and lighting problems. I thing the moon is now lit
|
||||
/* correctly.
|
||||
/* Revision 1.9 1997/12/30 20:48:03 curt
|
||||
/* Integrated new event manager with subsystem initializations.
|
||||
/*
|
||||
* Revision 1.8 1997/12/11 04:43:58 curt
|
||||
* Fixed sun vector and lighting problems. I thing the moon is now lit
|
||||
* correctly.
|
||||
*
|
||||
* Revision 1.7 1997/12/10 22:37:56 curt
|
||||
* Prepended "fg" on the name of all global structures that didn't have it yet.
|
||||
* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
||||
|
|
Loading…
Reference in a new issue