1
0
Fork 0

Fixed sun vector and lighting problems. I thing the moon is now lit

correctly.
This commit is contained in:
curt 1997-12-11 04:43:53 +00:00
parent 28fad1d296
commit 09ee64ff67
10 changed files with 110 additions and 64 deletions

View file

@ -61,9 +61,6 @@ static GLfloat win_ratio = 1.0;
/* sun direction */
/* static GLfloat sun_vec[4] = {1.0, 0.0, 0.0, 0.0 }; */
/* if the 4th field is 0.0, this specifies a direction ... */
/* clear color (sky) */
GLfloat fgClearColor[4] = {0.60, 0.60, 0.90, 1.0};
/* fog color */
static GLfloat fgFogColor[4] = {0.65, 0.65, 0.85, 1.0};
@ -120,8 +117,8 @@ static void fgInitVisuals() {
/* glFogf (GL_FOG_DENSITY, w->visibility); */
/* glHint (GL_FOG_HINT, GL_FASTEST); */
glClearColor(fgClearColor[0], fgClearColor[1], fgClearColor[2],
fgClearColor[3]);
/* initial screen color */
glClearColor(0.0, 0.0, 0.0, 1.0);
}
@ -136,9 +133,11 @@ static void fgUpdateViewParams() {
struct fgVIEW *v;
double x_2, x_4, x_8, x_10;
double ambient, diffuse, sky;
GLfloat color[4] = { 1.0, 1.0, 0.50, 1.0 };
/* GLfloat amb[3], diff[3], fog[4], clear[4]; */
double ambient, diffuse, sky_brightness;
/* if the 4th field is 0.0, this specifies a direction ... */
/* clear color (sky) */
GLfloat sky_color[4] = {0.60, 0.60, 0.90, 1.0};
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
f = &current_aircraft.flight;
l = &cur_light_params;
@ -150,7 +149,7 @@ static void fgUpdateViewParams() {
/* Tell GL we are about to modify the projection parameters */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 1.0/win_ratio, 1.0, 200000.0);
gluPerspective(55.0, 1.0/win_ratio, 1.0, 200000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@ -185,22 +184,22 @@ static void fgUpdateViewParams() {
diffuse = ambient;
sky = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15;
/* sky = 0.15; */ /* to force a dark sky (for testing) */
/* sky_brightness = 0.15; */ /* to force a dark sky (for testing) */
if ( ambient < 0.1 ) { ambient = 0.1; }
if ( diffuse < 0.0 ) { diffuse = 0.0; }
if ( sky < 0.0 ) { sky = 0.0; }
if ( sky_brightness < 0.0 ) { sky_brightness = 0.0; }
l->scene_ambient[0] = color[0] * ambient;
l->scene_ambient[1] = color[1] * ambient;
l->scene_ambient[2] = color[2] * ambient;
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] = color[0] * diffuse;
l->scene_diffuse[1] = color[1] * diffuse;
l->scene_diffuse[2] = color[2] * diffuse;
l->scene_diffuse[0] = white[0] * diffuse;
l->scene_diffuse[1] = white[1] * diffuse;
l->scene_diffuse[2] = white[2] * diffuse;
/* set lighting parameters */
glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
@ -214,10 +213,11 @@ static void fgUpdateViewParams() {
glFogfv (GL_FOG_COLOR, l->scene_fog);
/* set sky color */
l->scene_clear[0] = fgClearColor[0] * sky;
l->scene_clear[1] = fgClearColor[1] * sky;
l->scene_clear[2] = fgClearColor[2] * sky;
l->scene_clear[3] = fgClearColor[3];
l->scene_clear[0] = sky_color[0] * sky_brightness;
l->scene_clear[1] = sky_color[1] * sky_brightness;
l->scene_clear[2] = sky_color[2] * sky_brightness;
l->scene_clear[3] = sky_color[3];
glClearColor(l->scene_clear[0], l->scene_clear[1],
l->scene_clear[2], l->scene_clear[3]);
}
@ -573,10 +573,14 @@ int main( int argc, char *argv[] ) {
/* $Log$
/* Revision 1.28 1997/12/10 22:37:45 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.29 1997/12/11 04:43:54 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.28 1997/12/10 22:37:45 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.27 1997/12/09 05:11:54 curt
* Working on tweaking lighting.
*

View file

@ -99,11 +99,12 @@ void fgInitSubsystems( void ) {
FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD;
FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD;
FG_Altitude = FG_Runway_altitude + 3.758099;
FG_Altitude = 10000;
/* Initial Position north of the city of Globe */
/* FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD; */
/* FG_Latitude = ( 120625.64 / 3600.0 ) * DEG_TO_RAD; */
FG_Longitude = ( -397867.44 / 3600.0 ) * DEG_TO_RAD;
FG_Latitude = ( 119548.21 / 3600.0 ) * DEG_TO_RAD;
/* FG_Altitude = 0.0 + 3.758099; */
/* Initial Position: 10125 Jewell St. NE */
@ -114,6 +115,8 @@ void fgInitSubsystems( void ) {
/* A random test position */
/* FG_Longitude = ( 88128.00 / 3600.0 ) * DEG_TO_RAD; */
/* FG_Latitude = ( 93312.00 / 3600.0 ) * DEG_TO_RAD; */
FG_Runway_altitude = 4500.0;
FG_Altitude = FG_Runway_altitude + 3.758099;
printf("Initial position is: (%.4f, %.4f, %.2f)\n",
FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG,
@ -127,7 +130,8 @@ void fgInitSubsystems( void ) {
/* Initial Orientation */
FG_Phi = -2.658474E-06;
FG_Theta = 7.401790E-03;
FG_Psi = 270.0 * DEG_TO_RAD;
/* FG_Psi = 270.0 * DEG_TO_RAD; */
FG_Psi = 258.0 * DEG_TO_RAD;
/* FG_Psi = 0.0 * DEG_TO_RAD; */
/* Initial Angular B rates */
@ -216,10 +220,14 @@ void fgInitSubsystems( void ) {
/* $Log$
/* Revision 1.14 1997/12/10 22:37:47 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.15 1997/12/11 04:43:55 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.14 1997/12/10 22:37:47 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.13 1997/11/25 19:25:32 curt
* Changes to integrate Durk's moon/sun code updates + clean up.
*

View file

@ -89,9 +89,6 @@ void fgAstroRender() {
/* Disable fog effects */
glDisable( GL_FOG );
/* reverse light direction so the moon is displayed properly */
glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec_inv );
glPushMatrix();
/* Translate to view position */
@ -121,10 +118,14 @@ void fgAstroRender() {
/* $Log$
/* Revision 1.3 1997/12/10 22:37:49 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/12/11 04:43:56 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.3 1997/12/10 22:37:49 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.2 1997/12/09 04:25:33 curt
* Working on adding a global lighting params structure.
*

View file

@ -35,7 +35,6 @@ extern struct CelestialCoord
extern float xMoon, yMoon, zMoon, xSun, ySun, zSun;
extern GLint moon, sun;
extern GLint stars[FG_STAR_LEVELS];
extern GLfloat fgClearColor[4];
/* Initialize Astronomical Objects */
@ -49,7 +48,11 @@ void fgAstroRender();
/* $Log$
/* Revision 1.1 1997/11/25 23:20:23 curt
/* Initial revision.
/* Revision 1.2 1997/12/11 04:43:56 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.1 1997/11/25 23:20:23 curt
* Initial revision.
*
*/

View file

@ -46,15 +46,18 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements Params,
struct fgTIME t);
extern struct OrbElements pltOrbElements[9];
extern GLfloat fgClearColor[4];
#endif /* _MOON_H_ */
/* $Log$
/* Revision 1.3 1997/11/25 19:25:35 curt
/* Changes to integrate Durk's moon/sun code updates + clean up.
/* Revision 1.4 1997/12/11 04:43:56 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.3 1997/11/25 19:25:35 curt
* Changes to integrate Durk's moon/sun code updates + clean up.
*
* Revision 1.2 1997/10/25 03:24:23 curt
* Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
*

View file

@ -29,7 +29,6 @@
struct SunPos fgCalcSunPos(struct OrbElements sunParams);
extern struct OrbElements pltOrbElements[9];
extern GLfloat fgClearColor[4];
/* Initialize the Sun */
void fgSunInit();
@ -42,9 +41,13 @@ void fgSunRender();
/* $Log$
/* Revision 1.2 1997/11/25 19:25:39 curt
/* Changes to integrate Durk's moon/sun code updates + clean up.
/* Revision 1.3 1997/12/11 04:43:56 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.2 1997/11/25 19:25:39 curt
* Changes to integrate Durk's moon/sun code updates + clean up.
*
* Revision 1.1 1997/10/25 03:16:12 curt
* Initial revision of code contributed by Durk Talsma.
*

View file

@ -30,7 +30,7 @@
#---------------------------------------------------------------------------
VERSION_MAJOR = 0
VERSION_MINOR = 16
VERSION_MINOR = 17
VERSION = $(VERSION_MAJOR).$(VERSION_MINOR)
@ -131,6 +131,10 @@ FG_CFLAGS = $(GLOBAL_CFLAGS)
#---------------------------------------------------------------------------
# $Log$
# Revision 1.22 1997/12/11 04:43:53 curt
# Fixed sun vector and lighting problems. I thing the moon is now lit
# correctly.
#
# Revision 1.21 1997/12/10 01:19:42 curt
# Tweaks for verion 0.15 release.
#

View file

@ -231,9 +231,9 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
static long int warp = 0;
/* get current Unix calendar time (in seconds) */
warp += 60;
/* warp = 0; */
t->cur_time = time(NULL) + (0) * 60 * 60;
warp += 0;
/* warp = 60; */
t->cur_time = time(NULL) + (12) * 60 * 60;
t->cur_time += warp;
printf("Current Unix calendar time = %ld warp = %ld\n", t->cur_time, warp);
@ -285,10 +285,14 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) {
/* $Log$
/* Revision 1.15 1997/12/10 22:37:54 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.16 1997/12/11 04:43:57 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.15 1997/12/10 22:37:54 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.14 1997/12/10 01:19:52 curt
* Tweaks for verion 0.15 release.
*

View file

@ -283,11 +283,19 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
/* printf("Geodetic lat = %.5f Geocentric lat = %.5f\n", sun_gd_lat,
t->sun_gc_lat); */
/* the sun position has to be translated just like everything else */
l->sun_vec_inv[0] = l->fg_sunpos.x - scenery_center.x;
l->sun_vec_inv[1] = l->fg_sunpos.y - scenery_center.y;
l->sun_vec_inv[2] = l->fg_sunpos.z - scenery_center.z;
MAT3_SCALE_VEC(l->sun_vec, l->sun_vec_inv, -1.0);
/* FALSE! (?> the sun position has to be translated just like
* everything else */
/* l->sun_vec_inv[0] = l->fg_sunpos.x - scenery_center.x; */
/* l->sun_vec_inv[1] = l->fg_sunpos.y - scenery_center.y; */
/* l->sun_vec_inv[2] = l->fg_sunpos.z - scenery_center.z; */
/* MAT3_SCALE_VEC(l->sun_vec, l->sun_vec_inv, -1.0); */
/* I think this will work better for generating the sun light vector */
l->sun_vec[0] = l->fg_sunpos.x;
l->sun_vec[1] = l->fg_sunpos.y;
l->sun_vec[2] = l->fg_sunpos.z;
MAT3_NORMALIZE_VEC(l->sun_vec, temp);
MAT3_SCALE_VEC(l->sun_vec_inv, l->sun_vec, -1.0);
/* make these are directional light sources only */
l->sun_vec[3] = 0.0;
@ -308,10 +316,14 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
/* $Log$
/* Revision 1.15 1997/12/10 22:37:55 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.16 1997/12/11 04:43:57 curt
/* Fixed sun vector and lighting problems. I thing the moon is now lit
/* correctly.
/*
* Revision 1.15 1997/12/10 22:37:55 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.14 1997/12/09 04:25:39 curt
* Working on adding a global lighting params structure.
*

View file

@ -42,7 +42,7 @@ void fgWeatherInit(void) {
/* Configure some wind */
/* FG_V_north_airmass = 15; */ /* ft/s =~ 10mph */
w->visibility = 60000.0; /* meters = 60km */
w->visibility = 45000.0; /* in meters */
}
@ -62,10 +62,14 @@ void fgWeatherUpdate(double lon, double lat, double alt) {
/* $Log$
/* 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 {}"
/* 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 {}"
*
* Revision 1.6 1997/08/27 03:30:38 curt
* Changed naming scheme of basic shared structures.
*