From: curt Date: Fri, 12 Dec 1997 19:52:47 +0000 (+0000) Subject: Working on lightling and material properties. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=40f0747fac4efa700824e16e5126ab8fd00acc1a;p=flightgear.git Working on lightling and material properties. --- diff --git a/Main/GLUTmain.c b/Main/GLUTmain.c index 912acfcc1..cea1a88e9 100644 --- a/Main/GLUTmain.c +++ b/Main/GLUTmain.c @@ -103,9 +103,9 @@ static void fgInitVisuals() { to unit length after transformation. See glNormal. */ glEnable( GL_NORMALIZE ); - glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); glEnable( GL_LIGHTING ); glEnable( GL_LIGHT0 ); + glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); glShadeModel( GL_FLAT ); /* glShadeModel( GL_SMOOTH ); */ @@ -133,7 +133,7 @@ static void fgUpdateViewParams() { struct fgVIEW *v; double x_2, x_4, x_8, x_10; - double ambient, diffuse, sky_brightness; + double light, 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}; @@ -174,15 +174,9 @@ static void fgUpdateViewParams() { x_8 = x_4 * x_4; x_10 = x_8 * x_2; - ambient = 0.4 * pow(1.1, -x_10 / 30.0); - - /* diffuse = 0.4 * cos(0.3 * x_2); - if ( t->sun_angle > FG_PI_2 + 0.05 ) { - diffuse = 0.0; - } - */ - - diffuse = ambient; + light = pow(1.1, -x_10 / 30.0); + ambient = 0.3 * light; + diffuse = 0.7 * light; sky_brightness = 0.85 * pow(1.2, -x_8 / 20.0) + 0.15; @@ -240,6 +234,9 @@ static void fgUpdateVisuals( void ) { /* draw scenery */ fgSceneryRender(); + /* draw astronomical objects */ + fgAstroRender(); + /* display HUD */ if( show_hud ) fgCockpitUpdate(); @@ -573,10 +570,13 @@ int main( int argc, char *argv[] ) { /* $Log$ -/* 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.30 1997/12/12 19:52:47 curt +/* Working on lightling and material properties. /* + * 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 {}" diff --git a/Main/fg_init.c b/Main/fg_init.c index 5ec674cac..d26e278c5 100644 --- a/Main/fg_init.c +++ b/Main/fg_init.c @@ -103,8 +103,8 @@ void fgInitSubsystems( void ) { /* 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_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 */ @@ -115,7 +115,7 @@ 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_Runway_altitude = 8500.0; FG_Altitude = FG_Runway_altitude + 3.758099; printf("Initial position is: (%.4f, %.4f, %.2f)\n", @@ -130,9 +130,7 @@ void fgInitSubsystems( void ) { /* Initial Orientation */ FG_Phi = -2.658474E-06; FG_Theta = 7.401790E-03; - /* FG_Psi = 270.0 * DEG_TO_RAD; */ - FG_Psi = 258.0 * DEG_TO_RAD; - /* FG_Psi = 0.0 * DEG_TO_RAD; */ + FG_Psi = 270.0 * DEG_TO_RAD; /* Initial Angular B rates */ FG_P_body = 7.206685E-05; @@ -220,10 +218,13 @@ void fgInitSubsystems( void ) { /* $Log$ -/* 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.16 1997/12/12 19:52:48 curt +/* Working on lightling and material properties. /* + * 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 {}" diff --git a/Scenery/astro.c b/Scenery/astro.c index a9f10392d..bf5cd5e38 100644 --- a/Scenery/astro.c +++ b/Scenery/astro.c @@ -89,6 +89,9 @@ void fgAstroRender() { /* Disable fog effects */ glDisable( GL_FOG ); + /* set the sun position */ + /* glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec_inv );*/ + glPushMatrix(); /* Translate to view position */ @@ -118,10 +121,13 @@ void fgAstroRender() { /* $Log$ -/* 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.5 1997/12/12 19:52:54 curt +/* Working on lightling and material properties. /* + * 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 {}" diff --git a/Scenery/moon.c b/Scenery/moon.c index d8c82cdd3..f9ce58bb1 100644 --- a/Scenery/moon.c +++ b/Scenery/moon.c @@ -225,10 +225,18 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params, void fgMoonInit() { + struct fgLIGHT *l; + static GLfloat moon_color[4] = { 1.0, 1.0, 1.0, 1.0 }; // int i; + + l = &cur_light_params; + moon = glGenLists(1); glNewList(moon, GL_COMPILE ); + /* glMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear); + glMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */ + fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params); moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0], cur_time_params); @@ -245,7 +253,6 @@ void fgMoonInit() { yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); zMoon = 60000.0 * sin(moonPos.Declination); - glColor3f(1.0, 1.0, 1.0); glutSolidSphere(1.0, 10, 10); glEndList(); @@ -255,13 +262,13 @@ void fgMoonInit() { /* Draw the moon */ void fgMoonRender() { struct fgLIGHT *l; - GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; + GLfloat moon_color[4] = { 1.0, 1.0, 1.0, 1.0 }; l = &cur_light_params; /* set lighting parameters */ glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear ); - glLightfv(GL_LIGHT0, GL_DIFFUSE, color ); + glLightfv(GL_LIGHT0, GL_DIFFUSE, moon_color ); glPushMatrix(); glTranslatef(xMoon, yMoon, zMoon); diff --git a/Scenery/obj.c b/Scenery/obj.c index a3ddb81fb..1fd44a582 100644 --- a/Scenery/obj.c +++ b/Scenery/obj.c @@ -48,7 +48,9 @@ float normals[MAXNODES][3]; /* Load a .obj file and generate the GL call list */ GLint fgObjLoad(char *path) { char line[256], winding[256]; - static GLfloat color[4] = { 0.5, 0.5, 0.25, 1.0 }; + static GLfloat terrain_color[4] = { 0.6, 0.6, 0.25, 1.0 }; + static GLfloat terrain_ambient[4]; + static GLfloat terrain_diffuse[4]; double v1[3], v2[3], approx_normal[3], dot_prod, temp; struct fgCartesianPoint ref; GLint area; @@ -64,8 +66,13 @@ GLint fgObjLoad(char *path) { area = glGenLists(1); glNewList(area, GL_COMPILE); - /* glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color ); */ - glColor3fv(color); + for ( i = 0; i < 4; i++ ) { + terrain_ambient[i] = terrain_color[i]; + terrain_diffuse[i] = terrain_color[i]; + } + + glMaterialfv(GL_FRONT, GL_AMBIENT, terrain_ambient); + glMaterialfv(GL_FRONT, GL_DIFFUSE, terrain_diffuse); first = 1; ncount = 1; @@ -252,9 +259,12 @@ GLint fgObjLoad(char *path) { /* $Log$ -/* Revision 1.8 1997/12/10 01:19:51 curt -/* Tweaks for verion 0.15 release. +/* Revision 1.9 1997/12/12 19:52:57 curt +/* Working on lightling and material properties. /* + * Revision 1.8 1997/12/10 01:19:51 curt + * Tweaks for verion 0.15 release. + * * Revision 1.7 1997/12/08 22:51:17 curt * Enhanced to handle ccw and cw tri-stripe winding. This is a temporary * admission of defeat. I will eventually go back and get all the stripes diff --git a/Scenery/scenery.c b/Scenery/scenery.c index 7c27c8d54..fb7c570f7 100644 --- a/Scenery/scenery.c +++ b/Scenery/scenery.c @@ -81,16 +81,17 @@ void fgSceneryUpdate(double lon, double lat, double elev) { /* Render out the current scene */ void fgSceneryRender() { glCallList(area_terrain); - - fgAstroRender(); } /* $Log$ -/* Revision 1.25 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 {}" +/* Revision 1.26 1997/12/12 19:52:58 curt +/* Working on lightling and material properties. /* + * Revision 1.25 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 {}" + * * Revision 1.24 1997/12/08 22:51:18 curt * Enhanced to handle ccw and cw tri-stripe winding. This is a temporary * admission of defeat. I will eventually go back and get all the stripes diff --git a/Scenery/stars.c b/Scenery/stars.c index e0c9629f4..692ceaba1 100644 --- a/Scenery/stars.c +++ b/Scenery/stars.c @@ -123,17 +123,21 @@ void fgStarsInit() { sscanf(front, "%lf,%lf,%lf\n", &right_ascension, &declination, &magnitude); + /* if ( strcmp(name, "Betelgeuse") == 0 ) { printf(" *** Marking %s\n", name); ra_save = right_ascension; decl_save = declination; } + */ + /* if ( strcmp(name, "Alnilam") == 0 ) { printf(" *** Marking %s\n", name); ra_save1 = right_ascension; decl_save1 = declination; } + */ /* scale magnitudes to (0.0 - 1.0) */ magnitude = (0.0 - magnitude) / 5.0 + 1.0; @@ -175,6 +179,7 @@ void fgStarsInit() { } glEnd(); + /* glBegin(GL_LINE_LOOP); glColor3f(1.0, 0.0, 0.0); glVertex3f( 190000.0 * cos(ra_save-0.2) * cos(decl_save-0.2), @@ -190,7 +195,9 @@ void fgStarsInit() { 190000.0 * sin(ra_save-0.2) * cos(decl_save+0.2), 190000.0 * sin(decl_save+0.2) ); glEnd(); + */ + /* glBegin(GL_LINE_LOOP); glColor3f(0.0, 1.0, 0.0); glVertex3f( 190000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2), @@ -206,6 +213,7 @@ void fgStarsInit() { 190000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2), 190000.0 * sin(decl_save1+0.2) ); glEnd(); + */ glEndList(); @@ -256,10 +264,13 @@ void fgStarsRender() { /* $Log$ -/* Revision 1.18 1997/12/10 22:37:52 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.19 1997/12/12 19:53:00 curt +/* Working on lightling and material properties. /* + * Revision 1.18 1997/12/10 22:37:52 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.17 1997/12/09 04:25:33 curt * Working on adding a global lighting params structure. * diff --git a/Time/fg_time.c b/Time/fg_time.c index bb230f978..2fbb83eed 100644 --- a/Time/fg_time.c +++ b/Time/fg_time.c @@ -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 += 0; + warp += 240; /* warp = 60; */ - t->cur_time = time(NULL) + (12) * 60 * 60; + 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); @@ -285,10 +285,13 @@ void fgTimeUpdate(struct fgFLIGHT *f, struct fgTIME *t) { /* $Log$ -/* 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.17 1997/12/12 19:53:04 curt +/* Working on lightling and material properties. /* + * 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 {}"