Further integration of event manager.
This commit is contained in:
parent
2ebbbe0053
commit
846a4d14d8
10 changed files with 149 additions and 126 deletions
|
@ -51,6 +51,7 @@
|
||||||
#include "../Scenery/sky.h"
|
#include "../Scenery/sky.h"
|
||||||
#include "../Scenery/stars.h"
|
#include "../Scenery/stars.h"
|
||||||
#include "../Scenery/sun.h"
|
#include "../Scenery/sun.h"
|
||||||
|
#include "../Time/event.h"
|
||||||
#include "../Time/fg_time.h"
|
#include "../Time/fg_time.h"
|
||||||
#include "../Time/fg_timer.h"
|
#include "../Time/fg_timer.h"
|
||||||
#include "../Time/sunpos.h"
|
#include "../Time/sunpos.h"
|
||||||
|
@ -122,16 +123,6 @@ static void fgUpdateViewParams() {
|
||||||
struct fgTIME *t;
|
struct fgTIME *t;
|
||||||
struct fgVIEW *v;
|
struct fgVIEW *v;
|
||||||
|
|
||||||
double x_2, x_4, x_8, x_10;
|
|
||||||
double light, ambient, diffuse, sky_brightness;
|
|
||||||
/* if the 4th field is 0.0, this specifies a direction ... */
|
|
||||||
/* base sky color */
|
|
||||||
GLfloat base_sky_color[4] = {0.60, 0.60, 0.90, 1.0};
|
|
||||||
/* base fog color */
|
|
||||||
GLfloat base_fog_color[4] = {0.70, 0.70, 0.70, 1.0};
|
|
||||||
|
|
||||||
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
|
||||||
|
|
||||||
f = ¤t_aircraft.flight;
|
f = ¤t_aircraft.flight;
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
t = &cur_time_params;
|
t = &cur_time_params;
|
||||||
|
@ -182,52 +173,6 @@ static void fgUpdateViewParams() {
|
||||||
|
|
||||||
/* set the sun position */
|
/* set the sun position */
|
||||||
xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
|
xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
|
||||||
|
|
||||||
/* calculate lighting parameters based on sun's relative angle to
|
|
||||||
* local up */
|
|
||||||
/* ya kind'a have to plot this to see how it works */
|
|
||||||
|
|
||||||
/* x = t->sun_angle^8 */
|
|
||||||
x_2 = l->sun_angle * l->sun_angle;
|
|
||||||
x_4 = x_2 * x_2;
|
|
||||||
x_8 = x_4 * x_4;
|
|
||||||
x_10 = x_8 * x_2;
|
|
||||||
|
|
||||||
light = pow(1.1, -x_10 / 30.0);
|
|
||||||
ambient = 0.2 * light;
|
|
||||||
diffuse = 0.9 * light;
|
|
||||||
|
|
||||||
sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
|
|
||||||
|
|
||||||
/* sky_brightness = 0.15; */ /* to force a dark sky (for testing) */
|
|
||||||
|
|
||||||
if ( ambient < 0.02 ) { ambient = 0.02; }
|
|
||||||
if ( diffuse < 0.0 ) { diffuse = 0.0; }
|
|
||||||
|
|
||||||
if ( sky_brightness < 0.1 ) { sky_brightness = 0.1; }
|
|
||||||
|
|
||||||
l->scene_ambient[0] = white[0] * ambient;
|
|
||||||
l->scene_ambient[1] = white[1] * ambient;
|
|
||||||
l->scene_ambient[2] = white[2] * ambient;
|
|
||||||
|
|
||||||
l->scene_diffuse[0] = white[0] * diffuse;
|
|
||||||
l->scene_diffuse[1] = white[1] * diffuse;
|
|
||||||
l->scene_diffuse[2] = white[2] * diffuse;
|
|
||||||
|
|
||||||
/* set fog color */
|
|
||||||
l->fog_color[0] = base_fog_color[0] * (ambient + diffuse);
|
|
||||||
l->fog_color[1] = base_fog_color[1] * (ambient + diffuse);
|
|
||||||
l->fog_color[2] = base_fog_color[2] * (ambient + diffuse);
|
|
||||||
l->fog_color[3] = base_fog_color[3];
|
|
||||||
|
|
||||||
/* set sky color */
|
|
||||||
l->sky_color[0] = base_sky_color[0] * sky_brightness;
|
|
||||||
l->sky_color[1] = base_sky_color[1] * sky_brightness;
|
|
||||||
l->sky_color[2] = base_sky_color[2] * sky_brightness;
|
|
||||||
l->sky_color[3] = base_sky_color[3];
|
|
||||||
|
|
||||||
/* mental note: this should really be done every 10-30 seconds I suppose */
|
|
||||||
fgSkyColorsInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -281,7 +226,6 @@ static void fgRenderFrame( void ) {
|
||||||
struct fgTIME *t;
|
struct fgTIME *t;
|
||||||
struct fgVIEW *v;
|
struct fgVIEW *v;
|
||||||
double angle;
|
double angle;
|
||||||
static double lastAstroUpdate = 0;
|
|
||||||
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||||
|
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
|
@ -305,13 +249,6 @@ static void fgRenderFrame( void ) {
|
||||||
xglShadeModel( GL_SMOOTH );
|
xglShadeModel( GL_SMOOTH );
|
||||||
fgSkyRender();
|
fgSkyRender();
|
||||||
|
|
||||||
/* a hack: Force sun and moon position to be updated on an hourly basis */
|
|
||||||
if (((t->gst - lastAstroUpdate) > 1) || (t->gst < lastAstroUpdate)) {
|
|
||||||
lastAstroUpdate = t->gst;
|
|
||||||
fgSunInit();
|
|
||||||
fgMoonInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* setup transformation for drawing astronomical objects */
|
/* setup transformation for drawing astronomical objects */
|
||||||
xglPushMatrix();
|
xglPushMatrix();
|
||||||
/* Translate to view position */
|
/* Translate to view position */
|
||||||
|
@ -385,9 +322,6 @@ void fgUpdateTimeDepCalcs(int multi_loop) {
|
||||||
/* printf("updating flight model x %d\n", multi_loop); */
|
/* printf("updating flight model x %d\n", multi_loop); */
|
||||||
fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
|
fgFlightModelUpdate(FG_LARCSIM, f, multi_loop);
|
||||||
|
|
||||||
/* refresh shared sun position and sun_vec */
|
|
||||||
fgUpdateSunPos(scenery.center);
|
|
||||||
|
|
||||||
/* update the view angle */
|
/* update the view angle */
|
||||||
for ( i = 0; i < multi_loop; i++ ) {
|
for ( i = 0; i < multi_loop; i++ ) {
|
||||||
if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
|
if ( fabs(v->goal_view_offset - v->view_offset) < 0.05 ) {
|
||||||
|
@ -525,6 +459,9 @@ static void fgMainLoop( void ) {
|
||||||
struct fgFLIGHT *f;
|
struct fgFLIGHT *f;
|
||||||
struct fgTIME *t;
|
struct fgTIME *t;
|
||||||
|
|
||||||
|
printf("Running Main Loop\n");
|
||||||
|
printf("======= ==== ====\n");
|
||||||
|
|
||||||
a = ¤t_aircraft;
|
a = ¤t_aircraft;
|
||||||
f = &a->flight;
|
f = &a->flight;
|
||||||
t = &cur_time_params;
|
t = &cur_time_params;
|
||||||
|
@ -539,11 +476,6 @@ static void fgMainLoop( void ) {
|
||||||
fgElevSet( -joy_y );
|
fgElevSet( -joy_y );
|
||||||
fgAileronSet( joy_x ); */
|
fgAileronSet( joy_x ); */
|
||||||
|
|
||||||
/* update the weather for our current position */
|
|
||||||
fgWeatherUpdate(FG_Longitude * RAD_TO_ARCSEC,
|
|
||||||
FG_Latitude * RAD_TO_ARCSEC,
|
|
||||||
FG_Altitude * FEET_TO_METER);
|
|
||||||
|
|
||||||
/* Calculate model iterations needed */
|
/* Calculate model iterations needed */
|
||||||
elapsed = fgGetTimeInterval();
|
elapsed = fgGetTimeInterval();
|
||||||
printf("Time interval is = %d, previous remainder is = %d\n", elapsed,
|
printf("Time interval is = %d, previous remainder is = %d\n", elapsed,
|
||||||
|
@ -566,7 +498,7 @@ static void fgMainLoop( void ) {
|
||||||
* eventually */
|
* eventually */
|
||||||
cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
|
cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
|
||||||
FG_Latitude * RAD_TO_ARCSEC);
|
FG_Latitude * RAD_TO_ARCSEC);
|
||||||
printf("Ground elevation is %.2f meters here.\n", cur_elev);
|
/* printf("Ground elevation is %.2f meters here.\n", cur_elev); */
|
||||||
/* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
|
/* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
|
||||||
|
|
||||||
if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
|
if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
|
||||||
|
@ -580,13 +512,15 @@ static void fgMainLoop( void ) {
|
||||||
FG_Altitude * FEET_TO_METER);
|
FG_Altitude * FEET_TO_METER);
|
||||||
}
|
}
|
||||||
|
|
||||||
fgAircraftOutputCurrent(a);
|
/* fgAircraftOutputCurrent(a); */
|
||||||
|
|
||||||
/* Process/manage pending events */
|
/* Process/manage pending events */
|
||||||
fgEventProcess();
|
fgEventProcess();
|
||||||
|
|
||||||
/* redraw display */
|
/* redraw display */
|
||||||
fgRenderFrame();
|
fgRenderFrame();
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -622,7 +556,7 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
f = ¤t_aircraft.flight;
|
f = ¤t_aircraft.flight;
|
||||||
|
|
||||||
printf("Flight Gear: prototype version %s\n\n", VERSION);
|
printf("Flight Gear: Version %s\n\n", VERSION);
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Initialize the Window/Graphics environment.
|
* Initialize the Window/Graphics environment.
|
||||||
|
@ -694,9 +628,12 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.43 1997/12/30 20:47:43 curt
|
/* Revision 1.44 1997/12/30 22:22:31 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.42 1997/12/30 16:36:47 curt
|
||||||
* Merged in Durk's changes ...
|
* Merged in Durk's changes ...
|
||||||
*
|
*
|
||||||
|
|
|
@ -188,6 +188,10 @@ void fgInitSubsystems( void ) {
|
||||||
/* Initialize the weather modeling subsystem */
|
/* Initialize the weather modeling subsystem */
|
||||||
fgWeatherInit();
|
fgWeatherInit();
|
||||||
|
|
||||||
|
/* update the weather for our current position */
|
||||||
|
fgEventRegister( "fgWeatherUpdate()", fgWeatherUpdate,
|
||||||
|
FG_EVENT_READY, 120000 );
|
||||||
|
|
||||||
/* Initialize the Cockpit subsystem */
|
/* Initialize the Cockpit subsystem */
|
||||||
if( fgCockpitInit( current_aircraft ) == NULL ) {
|
if( fgCockpitInit( current_aircraft ) == NULL ) {
|
||||||
printf( "Error in Cockpit initialization!\n" );
|
printf( "Error in Cockpit initialization!\n" );
|
||||||
|
@ -201,10 +205,10 @@ void fgInitSubsystems( void ) {
|
||||||
fgStarsInit();
|
fgStarsInit();
|
||||||
|
|
||||||
/* Initialize the sun's position */
|
/* Initialize the sun's position */
|
||||||
fgSunInit();
|
fgEventRegister( "fgSunInit()", fgSunInit, FG_EVENT_READY, 600000 );
|
||||||
|
|
||||||
/* Intialize the moon's position */
|
/* Intialize the moon's position */
|
||||||
fgMoonInit();
|
fgEventRegister( "fgMoonInit()", fgSunInit, FG_EVENT_READY, 600000 );
|
||||||
|
|
||||||
/* Initialize the "sky" */
|
/* Initialize the "sky" */
|
||||||
fgSkyInit();
|
fgSkyInit();
|
||||||
|
@ -233,7 +237,6 @@ void fgInitSubsystems( void ) {
|
||||||
FG_Altitude * FEET_TO_METER);
|
FG_Altitude * FEET_TO_METER);
|
||||||
/* end of thing that I just stuck in that I should probably move */
|
/* end of thing that I just stuck in that I should probably move */
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the flight model subsystem data structures base on
|
/* Initialize the flight model subsystem data structures base on
|
||||||
* above values */
|
* above values */
|
||||||
fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
|
fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
|
||||||
|
@ -247,14 +250,20 @@ void fgInitSubsystems( void ) {
|
||||||
/* Joystick support */
|
/* Joystick support */
|
||||||
fgJoystickInit( 0 );
|
fgJoystickInit( 0 );
|
||||||
|
|
||||||
|
/* One more try here to get the sky synced up */
|
||||||
|
fgSkyColorsInit();
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.24 1997/12/30 20:47:44 curt
|
/* Revision 1.25 1997/12/30 22:22:33 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.23 1997/12/30 16:36:50 curt
|
||||||
* Merged in Durk's changes ...
|
* Merged in Durk's changes ...
|
||||||
*
|
*
|
||||||
|
|
28
Main/views.c
28
Main/views.c
|
@ -69,8 +69,8 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
|
||||||
v->view_pos.y -= scenery.center.y;
|
v->view_pos.y -= scenery.center.y;
|
||||||
v->view_pos.z -= scenery.center.z;
|
v->view_pos.z -= scenery.center.z;
|
||||||
|
|
||||||
printf("View pos = %.4f, %.4f, %.4f\n",
|
/* printf("View pos = %.4f, %.4f, %.4f\n",
|
||||||
v->view_pos.x, v->view_pos.y, v->view_pos.z);
|
v->view_pos.x, v->view_pos.y, v->view_pos.z); */
|
||||||
|
|
||||||
/* make a vector to the current view position */
|
/* make a vector to the current view position */
|
||||||
MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
|
MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
|
||||||
|
@ -79,8 +79,8 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
|
||||||
v->to_sun[0] = l->fg_sunpos.x - (v->view_pos.x + scenery.center.x);
|
v->to_sun[0] = l->fg_sunpos.x - (v->view_pos.x + scenery.center.x);
|
||||||
v->to_sun[1] = l->fg_sunpos.y - (v->view_pos.y + scenery.center.y);
|
v->to_sun[1] = l->fg_sunpos.y - (v->view_pos.y + scenery.center.y);
|
||||||
v->to_sun[2] = l->fg_sunpos.z - (v->view_pos.z + scenery.center.z);
|
v->to_sun[2] = l->fg_sunpos.z - (v->view_pos.z + scenery.center.z);
|
||||||
printf("Vector to sun = %.2f %.2f %.2f\n",
|
/* printf("Vector to sun = %.2f %.2f %.2f\n",
|
||||||
v->to_sun[0], v->to_sun[1], v->to_sun[2]);
|
v->to_sun[0], v->to_sun[1], v->to_sun[2]); */
|
||||||
|
|
||||||
/* Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw) */
|
/* Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw) */
|
||||||
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
||||||
|
@ -125,8 +125,8 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
|
||||||
MAT3_SET_VEC(v->local_up, 1.0, 0.0, 0.0);
|
MAT3_SET_VEC(v->local_up, 1.0, 0.0, 0.0);
|
||||||
MAT3mult_vec(v->local_up, v->local_up, UP);
|
MAT3mult_vec(v->local_up, v->local_up, UP);
|
||||||
|
|
||||||
printf(" Local Up = (%.4f, %.4f, %.4f)\n",
|
/* printf("Local Up = (%.4f, %.4f, %.4f)\n",
|
||||||
v->local_up[0], v->local_up[1], v->local_up[2]);
|
v->local_up[0], v->local_up[1], v->local_up[2]); */
|
||||||
|
|
||||||
/* Alternative method to Derive local up vector based on
|
/* Alternative method to Derive local up vector based on
|
||||||
* *geodetic* coordinates */
|
* *geodetic* coordinates */
|
||||||
|
@ -145,8 +145,8 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
|
||||||
|
|
||||||
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
||||||
MAT3mult_vec(forward, vec, VIEW);
|
MAT3mult_vec(forward, vec, VIEW);
|
||||||
printf("Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1],
|
/* printf("Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1],
|
||||||
forward[2]);
|
forward[2]); */
|
||||||
|
|
||||||
MAT3rotate(TMP, v->view_up, v->view_offset);
|
MAT3rotate(TMP, v->view_up, v->view_offset);
|
||||||
MAT3mult_vec(v->view_forward, forward, TMP);
|
MAT3mult_vec(v->view_forward, forward, TMP);
|
||||||
|
@ -157,9 +157,8 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
|
||||||
map_vec_onto_cur_surface_plane(v->local_up, v0, v->to_sun,
|
map_vec_onto_cur_surface_plane(v->local_up, v0, v->to_sun,
|
||||||
v->surface_to_sun);
|
v->surface_to_sun);
|
||||||
MAT3_NORMALIZE_VEC(v->surface_to_sun, ntmp);
|
MAT3_NORMALIZE_VEC(v->surface_to_sun, ntmp);
|
||||||
printf("Surface direction to sun is %.2f %.2f %.2f\n",
|
/* printf("Surface direction to sun is %.2f %.2f %.2f\n",
|
||||||
v->surface_to_sun[0], v->surface_to_sun[1], v->surface_to_sun[2]);
|
v->surface_to_sun[0], v->surface_to_sun[1], v->surface_to_sun[2]); */
|
||||||
|
|
||||||
/* printf("Should be close to zero = %.2f\n",
|
/* printf("Should be close to zero = %.2f\n",
|
||||||
MAT3_DOT_PRODUCT(v->local_up, v->surface_to_sun)); */
|
MAT3_DOT_PRODUCT(v->local_up, v->surface_to_sun)); */
|
||||||
|
|
||||||
|
@ -183,9 +182,12 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.7 1997/12/30 20:47:45 curt
|
/* Revision 1.8 1997/12/30 22:22:33 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* 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.
|
* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
|
||||||
*
|
*
|
||||||
|
|
|
@ -247,7 +247,7 @@ void fgSkyRender() {
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
v = ¤t_view;
|
v = ¤t_view;
|
||||||
|
|
||||||
printf("Rendering the sky.\n");
|
/* printf("Rendering the sky.\n"); */
|
||||||
|
|
||||||
xglPushMatrix();
|
xglPushMatrix();
|
||||||
|
|
||||||
|
@ -255,20 +255,20 @@ void fgSkyRender() {
|
||||||
* v->surface_east. We do this so we can sort out the acos()
|
* v->surface_east. We do this so we can sort out the acos()
|
||||||
* ambiguity. I wish I could think of a more efficient way ... :-( */
|
* ambiguity. I wish I could think of a more efficient way ... :-( */
|
||||||
east_dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_east);
|
east_dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_east);
|
||||||
printf(" East dot product = %.2f\n", east_dot);
|
/* printf(" East dot product = %.2f\n", east_dot); */
|
||||||
|
|
||||||
/* calculate the angle between v->surface_to_sun and
|
/* calculate the angle between v->surface_to_sun and
|
||||||
* v->surface_south. this is how much we have to rotate the sky
|
* v->surface_south. this is how much we have to rotate the sky
|
||||||
* for it to align with the sun */
|
* for it to align with the sun */
|
||||||
dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_south);
|
dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_south);
|
||||||
printf(" Dot product = %.2f\n", dot);
|
/* printf(" Dot product = %.2f\n", dot); */
|
||||||
if ( east_dot >= 0 ) {
|
if ( east_dot >= 0 ) {
|
||||||
angle = acos(dot);
|
angle = acos(dot);
|
||||||
} else {
|
} else {
|
||||||
angle = -acos(dot);
|
angle = -acos(dot);
|
||||||
}
|
}
|
||||||
printf(" Sky needs to rotate = %.3f rads = %.1f degrees.\n",
|
/*printf(" Sky needs to rotate = %.3f rads = %.1f degrees.\n",
|
||||||
angle, angle * RAD_TO_DEG);
|
angle, angle * RAD_TO_DEG); */
|
||||||
|
|
||||||
/* Translate to view position */
|
/* Translate to view position */
|
||||||
xglTranslatef( v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z );
|
xglTranslatef( v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z );
|
||||||
|
@ -276,8 +276,8 @@ void fgSkyRender() {
|
||||||
v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z ); */
|
v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z ); */
|
||||||
|
|
||||||
/* Rotate to proper orientation */
|
/* Rotate to proper orientation */
|
||||||
printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
|
/* printf(" lon = %.2f lat = %.2f\n", FG_Longitude * RAD_TO_DEG,
|
||||||
FG_Latitude * RAD_TO_DEG);
|
FG_Latitude * RAD_TO_DEG); */
|
||||||
xglRotatef( FG_Longitude * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
xglRotatef( FG_Longitude * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
||||||
xglRotatef( 90.0 - FG_Latitude * RAD_TO_DEG, 0.0, 1.0, 0.0 );
|
xglRotatef( 90.0 - FG_Latitude * RAD_TO_DEG, 0.0, 1.0, 0.0 );
|
||||||
xglRotatef( angle * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
xglRotatef( angle * RAD_TO_DEG, 0.0, 0.0, 1.0 );
|
||||||
|
@ -329,9 +329,12 @@ void fgSkyRender() {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.10 1997/12/30 20:47:53 curt
|
/* Revision 1.11 1997/12/30 22:22:38 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.9 1997/12/30 13:06:57 curt
|
||||||
* A couple lighting tweaks ...
|
* A couple lighting tweaks ...
|
||||||
*
|
*
|
||||||
|
|
|
@ -266,21 +266,22 @@ void fgStarsRender() {
|
||||||
i = 3;
|
i = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("RENDERING STARS = %d (night)\n", i);
|
/* printf("RENDERING STARS = %d (night)\n", i); */
|
||||||
|
|
||||||
xglDisable( GL_LIGHTING );
|
|
||||||
xglCallList(stars[i]);
|
xglCallList(stars[i]);
|
||||||
xglEnable( GL_LIGHTING );
|
|
||||||
} else {
|
} else {
|
||||||
printf("not RENDERING STARS (day)\n");
|
/* printf("not RENDERING STARS (day)\n"); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.23 1997/12/30 20:47:53 curt
|
/* Revision 1.24 1997/12/30 22:22:39 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.22 1997/12/30 16:36:53 curt
|
||||||
* Merged in Durk's changes ...
|
* Merged in Durk's changes ...
|
||||||
*
|
*
|
||||||
|
|
16
Time/event.c
16
Time/event.c
|
@ -265,14 +265,17 @@ void fgEventPrintStats() {
|
||||||
if ( event_ptr > 0 ) {
|
if ( event_ptr > 0 ) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Event Stats\n");
|
printf("Event Stats\n");
|
||||||
printf("----- -----\n");
|
printf("-----------\n");
|
||||||
|
|
||||||
for ( i = 0; i < event_ptr; i++ ) {
|
for ( i = 0; i < event_ptr; i++ ) {
|
||||||
printf(" %s cum=%d min=%d max=%d count=%d ave=%.2f\n",
|
printf(" %-20s int=%.2fs cum=%d min=%d max=%d count=%d ave=%.2f\n",
|
||||||
events[i].description, events[i].cum_time,
|
events[i].description,
|
||||||
|
events[i].interval / 1000.0,
|
||||||
|
events[i].cum_time,
|
||||||
events[i].min_time, events[i].max_time, events[i].count,
|
events[i].min_time, events[i].max_time, events[i].count,
|
||||||
events[i].cum_time / (double)events[i].count);
|
events[i].cum_time / (double)events[i].count);
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,9 +335,12 @@ void fgEventProcess() {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.2 1997/12/30 20:47:58 curt
|
/* Revision 1.3 1997/12/30 22:22:42 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.1 1997/12/30 04:19:22 curt
|
||||||
* Initial revision.
|
* Initial revision.
|
||||||
*
|
*
|
||||||
|
|
|
@ -234,6 +234,8 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
||||||
double gst_precise, gst_course;
|
double gst_precise, gst_course;
|
||||||
static long int warp = 0;
|
static long int warp = 0;
|
||||||
|
|
||||||
|
printf("Updating time\n");
|
||||||
|
|
||||||
/* get current Unix calendar time (in seconds) */
|
/* get current Unix calendar time (in seconds) */
|
||||||
/* warp = 60; */
|
/* warp = 60; */
|
||||||
warp += 0;
|
warp += 0;
|
||||||
|
@ -290,9 +292,12 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.23 1997/12/30 20:47:58 curt
|
/* Revision 1.24 1997/12/30 22:22:42 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.22 1997/12/30 01:38:47 curt
|
||||||
* Switched back to per vertex normals and smooth shading for terrain.
|
* Switched back to per vertex normals and smooth shading for terrain.
|
||||||
*
|
*
|
||||||
|
|
|
@ -266,7 +266,15 @@ void fgUpdateSunPos() {
|
||||||
struct fgTIME *t;
|
struct fgTIME *t;
|
||||||
struct fgVIEW *v;
|
struct fgVIEW *v;
|
||||||
MAT3vec nup, nsun;
|
MAT3vec nup, nsun;
|
||||||
|
/* if the 4th field is 0.0, this specifies a direction ... */
|
||||||
|
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||||
|
/* base sky color */
|
||||||
|
GLfloat base_sky_color[4] = {0.60, 0.60, 0.90, 1.0};
|
||||||
|
/* base fog color */
|
||||||
|
GLfloat base_fog_color[4] = {0.70, 0.70, 0.70, 1.0};
|
||||||
double sun_gd_lat, sl_radius, temp;
|
double sun_gd_lat, sl_radius, temp;
|
||||||
|
double x_2, x_4, x_8, x_10;
|
||||||
|
double light, ambient, diffuse, sky_brightness;
|
||||||
static int time_warp = 0;
|
static int time_warp = 0;
|
||||||
|
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
|
@ -315,13 +323,59 @@ void fgUpdateSunPos() {
|
||||||
l->sun_angle = acos(MAT3_DOT_PRODUCT(nup, nsun));
|
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);
|
l->sun_angle);
|
||||||
|
|
||||||
|
/* calculate lighting parameters based on sun's relative angle to
|
||||||
|
* local up */
|
||||||
|
/* ya kind'a have to plot this to see how it works */
|
||||||
|
|
||||||
|
/* x = t->sun_angle^8 */
|
||||||
|
x_2 = l->sun_angle * l->sun_angle;
|
||||||
|
x_4 = x_2 * x_2;
|
||||||
|
x_8 = x_4 * x_4;
|
||||||
|
x_10 = x_8 * x_2;
|
||||||
|
|
||||||
|
light = pow(1.1, -x_10 / 30.0);
|
||||||
|
ambient = 0.2 * light;
|
||||||
|
diffuse = 0.9 * light;
|
||||||
|
|
||||||
|
sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
|
||||||
|
|
||||||
|
/* sky_brightness = 0.15; */ /* to force a dark sky (for testing) */
|
||||||
|
|
||||||
|
if ( ambient < 0.02 ) { ambient = 0.02; }
|
||||||
|
if ( diffuse < 0.0 ) { diffuse = 0.0; }
|
||||||
|
|
||||||
|
if ( sky_brightness < 0.1 ) { sky_brightness = 0.1; }
|
||||||
|
|
||||||
|
l->scene_ambient[0] = white[0] * ambient;
|
||||||
|
l->scene_ambient[1] = white[1] * ambient;
|
||||||
|
l->scene_ambient[2] = white[2] * ambient;
|
||||||
|
|
||||||
|
l->scene_diffuse[0] = white[0] * diffuse;
|
||||||
|
l->scene_diffuse[1] = white[1] * diffuse;
|
||||||
|
l->scene_diffuse[2] = white[2] * diffuse;
|
||||||
|
|
||||||
|
/* set fog color */
|
||||||
|
l->fog_color[0] = base_fog_color[0] * (ambient + diffuse);
|
||||||
|
l->fog_color[1] = base_fog_color[1] * (ambient + diffuse);
|
||||||
|
l->fog_color[2] = base_fog_color[2] * (ambient + diffuse);
|
||||||
|
l->fog_color[3] = base_fog_color[3];
|
||||||
|
|
||||||
|
/* set sky color */
|
||||||
|
l->sky_color[0] = base_sky_color[0] * sky_brightness;
|
||||||
|
l->sky_color[1] = base_sky_color[1] * sky_brightness;
|
||||||
|
l->sky_color[2] = base_sky_color[2] * sky_brightness;
|
||||||
|
l->sky_color[3] = base_sky_color[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.19 1997/12/30 20:47:59 curt
|
/* Revision 1.20 1997/12/30 22:22:43 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.18 1997/12/23 04:58:40 curt
|
||||||
* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
* Tweaked the sky coloring a bit to build in structures to allow finer rgb
|
||||||
* control.
|
* control.
|
||||||
|
|
|
@ -49,7 +49,7 @@ void fgWeatherInit(void) {
|
||||||
|
|
||||||
|
|
||||||
/* Update the weather parameters for the current position */
|
/* Update the weather parameters for the current position */
|
||||||
void fgWeatherUpdate(double lon, double lat, double alt) {
|
void fgWeatherUpdate() {
|
||||||
struct fgFLIGHT *f;
|
struct fgFLIGHT *f;
|
||||||
struct fgWEATHER *w;
|
struct fgWEATHER *w;
|
||||||
|
|
||||||
|
@ -64,9 +64,12 @@ void fgWeatherUpdate(double lon, double lat, double alt) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.9 1997/12/30 20:48:03 curt
|
/* Revision 1.10 1997/12/30 22:22:46 curt
|
||||||
/* Integrated new event manager with subsystem initializations.
|
/* Further integration of event manager.
|
||||||
/*
|
/*
|
||||||
|
* 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
|
* Revision 1.8 1997/12/11 04:43:58 curt
|
||||||
* Fixed sun vector and lighting problems. I thing the moon is now lit
|
* Fixed sun vector and lighting problems. I thing the moon is now lit
|
||||||
* correctly.
|
* correctly.
|
||||||
|
|
|
@ -40,17 +40,20 @@ extern struct fgWEATHER current_weather;
|
||||||
void fgWeatherInit(void);
|
void fgWeatherInit(void);
|
||||||
|
|
||||||
/* Update the weather parameters for the current position */
|
/* Update the weather parameters for the current position */
|
||||||
void fgWeatherUpdate(double lon, double lat, double alt);
|
void fgWeatherUpdate();
|
||||||
|
|
||||||
|
|
||||||
#endif /* WEATHER_H */
|
#endif /* WEATHER_H */
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.5 1997/12/10 22:37:56 curt
|
/* Revision 1.6 1997/12/30 22:22:47 curt
|
||||||
/* Prepended "fg" on the name of all global structures that didn't have it yet.
|
/* Further integration of event manager.
|
||||||
/* i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
|
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.5 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 {}"
|
||||||
|
*
|
||||||
* Revision 1.4 1997/08/27 03:30:39 curt
|
* Revision 1.4 1997/08/27 03:30:39 curt
|
||||||
* Changed naming scheme of basic shared structures.
|
* Changed naming scheme of basic shared structures.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue