/* view parameters */
static GLfloat win_ratio = 1.0;
-/* fog color */
-static GLfloat fgFogColor[4] = {0.65, 0.65, 0.85, 1.0};
-
/* temporary hack */
/* pointer to scenery structure */
/* static GLint scenery, runway; */
xglEnable( GL_LIGHT0 );
xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
- xglShadeModel( GL_FLAT ); /* xglShadeModel( GL_SMOOTH ); */
-
- xglEnable( GL_FOG );
xglFogi (GL_FOG_MODE, GL_LINEAR);
/* xglFogf (GL_FOG_START, 1.0); */
xglFogf (GL_FOG_END, w->visibility);
- xglFogfv (GL_FOG_COLOR, fgFogColor);
/* xglFogf (GL_FOG_DENSITY, w->visibility); */
/* xglHint (GL_FOG_HINT, GL_FASTEST); */
-
- /* initial screen color */
- xglClearColor(0.0, 0.0, 0.0, 1.0);
}
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 ... */
- /* clear color (sky) */
- GLfloat sky_color[4] = {0.60, 0.60, 0.90, 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}; */
+ GLfloat base_fog_color[4] = {1.00, 0.00, 0.00, 1.0};
+
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
f = ¤t_aircraft.flight;
/* Tell GL we are about to modify the projection parameters */
xglMatrixMode(GL_PROJECTION);
xglLoadIdentity();
- gluPerspective(55.0, 1.0/win_ratio, 1.0, 200000.0);
+ gluPerspective(55.0, 1.0/win_ratio, 1.0, 100000.0);
xglMatrixMode(GL_MODELVIEW);
xglLoadIdentity();
/* calculate lighting parameters based on sun's relative angle to
* local up */
- /* ya kind'a have to plot this to see the magic */
+ /* 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;
if ( ambient < 0.1 ) { ambient = 0.1; }
if ( diffuse < 0.0 ) { diffuse = 0.0; }
- if ( sky_brightness < 0.0 ) { sky_brightness = 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_diffuse[1] = white[1] * diffuse;
l->scene_diffuse[2] = white[2] * diffuse;
- /* set lighting parameters */
- xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
- xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
-
/* set fog color */
- l->scene_fog[0] = fgFogColor[0] * (ambient + diffuse);
- l->scene_fog[1] = fgFogColor[1] * (ambient + diffuse);
- l->scene_fog[2] = fgFogColor[2] * (ambient + diffuse);
- l->scene_fog[3] = fgFogColor[3];
- xglFogfv (GL_FOG_COLOR, l->scene_fog);
+ 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->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];
-
- xglClearColor(l->scene_clear[0], l->scene_clear[1],
- l->scene_clear[2], l->scene_clear[3]);
+ 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];
}
**************************************************************************/
static void fgUpdateVisuals( void ) {
+ struct fgLIGHT *l;
struct fgTIME *t;
struct fgVIEW *v;
double angle;
static double lastAstroUpdate = 0;
+ GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
+ l = &cur_light_params;
t = &cur_time_params;
v = ¤t_view;
xglDisable( GL_DEPTH_TEST );
xglDisable( GL_LIGHTING );
xglDisable( GL_CULL_FACE );
+ xglDisable( GL_FOG );
xglShadeModel( GL_SMOOTH );
fgSkyRender();
xglRotatef( angle, 0.0, 0.0, -1.0 );
/* draw stars and planets */
- xglDisable( GL_FOG );
fgStarsRender();
/* draw the sun */
/* render the moon */
xglEnable( GL_LIGHTING );
+ /* set lighting parameters */
+ xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
+ xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
xglEnable( GL_CULL_FACE );
fgMoonRender();
xglShadeModel( GL_FLAT );
xglEnable( GL_DEPTH_TEST );
xglEnable( GL_FOG );
+ xglFogfv (GL_FOG_COLOR, l->fog_color);
+ /* set lighting parameters */
+ xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
+ xglLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
fgSceneryRender();
/* display HUD */
/* $Log$
-/* Revision 1.36 1997/12/19 16:44:57 curt
-/* Working on scene rendering order and options.
+/* Revision 1.37 1997/12/19 23:34:03 curt
+/* Lot's of tweaking with sky rendering and lighting.
/*
+ * Revision 1.36 1997/12/19 16:44:57 curt
+ * Working on scene rendering order and options.
+ *
* Revision 1.35 1997/12/18 23:32:32 curt
* First stab at sky dome actually starting to look reasonable. :-)
*
fgSolarSystemInit(*t);
/* Initialize the Stars subsystem */
- fgStarsInit();
+ fgStarsInit();
/* Initialize the sun's position */
- fgSunInit();
+ fgSunInit();
/* Intialize the moon's position */
- fgMoonInit();
+ fgMoonInit();
/* Initialize the "sky" */
fgSkyInit();
* the correct scenery data */
fgSceneryUpdate(FG_Latitude, FG_Longitude, FG_Altitude);
-
/* I'm just sticking this here for now, it should probably move
* eventually */
cur_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
/* $Log$
-/* Revision 1.21 1997/12/19 16:45:00 curt
-/* Working on scene rendering order and options.
+/* Revision 1.22 1997/12/19 23:34:05 curt
+/* Lot's of tweaking with sky rendering and lighting.
/*
+ * Revision 1.21 1997/12/19 16:45:00 curt
+ * Working on scene rendering order and options.
+ *
* Revision 1.20 1997/12/18 23:32:33 curt
* First stab at sky dome actually starting to look reasonable. :-)
*
/* Draw the moon */
void fgMoonRender() {
struct fgLIGHT *l;
- GLfloat moon_color[4] = { 1.0, 1.0, 1.0, 1.0 };
+ GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
l = &cur_light_params;
- /* set lighting parameters */
- xglLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear );
- xglLightfv(GL_LIGHT0, GL_DIFFUSE, moon_color );
-
- xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear );
- xglMaterialfv(GL_FRONT, GL_AMBIENT, moon_color );
- xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color);
+ xglMaterialfv(GL_FRONT, GL_AMBIENT, l->sky_color );
+ xglMaterialfv(GL_FRONT, GL_DIFFUSE, white);
xglPushMatrix();
xglTranslatef(xMoon, yMoon, zMoon);
xglScalef(1400, 1400, 1400);
- xglColor3fv(moon_color);
- /* glutSolidSphere(1.0, 25, 25); */
xglCallList(moon);
xglPopMatrix();
*/
/* in meters of course */
+#define CENTER_ELEV 25000.0
#define INNER_RADIUS 50000.0
#define INNER_ELEV 20000.0
#define MIDDLE_RADIUS 70000.0
-#define MIDDLE_ELEV 4000.0
+#define MIDDLE_ELEV 8000.0
#define OUTER_RADIUS 80000.0
#define OUTER_ELEV 0.0
-static float sky_center[12][3];
+static float sky_inner[12][3];
static float sky_middle[12][3];
static float sky_outer[12][3];
-/* (Re)generate the display list */
+/* Calculate the sky structure verticies */
void fgSkyInit() {
- struct fgLIGHT *l;
float theta;
int i;
- l = &cur_light_params;
-
printf("Generating the sky dome vertices.\n");
for ( i = 0; i < 12; i++ ) {
theta = (i * 30.0) * DEG_TO_RAD;
- sky_center[i][0] = cos(theta) * INNER_RADIUS;
- sky_center[i][1] = sin(theta) * INNER_RADIUS;
- sky_center[i][2] = INNER_ELEV;
+ sky_inner[i][0] = cos(theta) * INNER_RADIUS;
+ sky_inner[i][1] = sin(theta) * INNER_RADIUS;
+ sky_inner[i][2] = INNER_ELEV;
printf(" %.2f %.2f\n", cos(theta) * INNER_RADIUS,
sin(theta) * INNER_RADIUS);
/* Draw the Sky */
void fgSkyRender() {
struct fgFLIGHT *f;
+ struct fgLIGHT *l;
struct fgVIEW *v;
+ float inner_color[4], middle_color[4], diff;
int i;
f = ¤t_aircraft.flight;
+ l = &cur_light_params;
v = ¤t_view;
printf("Rendering the sky.\n");
+ /*
+ l->fog_color[0] = 1.0;
+ l->fog_color[1] = 0.0;
+ l->fog_color[2] = 0.0;
+ l->fog_color[3] = 1.0;
+ */
+
+ /* calculate transition colors between sky and fog */
+ for ( i = 0; i < 3; i++ ) {
+ diff = l->sky_color[i] - l->fog_color[i];
+ inner_color[i] = l->sky_color[i] - diff * 0.3;
+ middle_color[i] = l->sky_color[i] - diff * 1.0;
+ }
+ inner_color[3] = middle_color[3] = l->sky_color[3];
+
xglPushMatrix();
/* Translate to view position */
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 );
- /* xglMaterialfv(GL_FRONT, GL_AMBIENT, l->scene_clear);
- xglMaterialfv(GL_FRONT, GL_DIFFUSE, moon_color); */
-
/* Draw inner/center section of sky*/
xglBegin( GL_TRIANGLE_FAN );
- xglColor4f(0.0, 0.0, 1.0, 1.0);
- xglVertex3f(0.0, 0.0, INNER_ELEV);
- xglColor4f(0.2, 0.2, 0.8, 1.0);
+ xglColor4fv(l->sky_color);
+ xglVertex3f(0.0, 0.0, CENTER_ELEV);
+ xglColor4fv( inner_color );
for ( i = 0; i < 12; i++ ) {
- xglVertex3fv( sky_center[i] );
+ xglVertex3fv( sky_inner[i] );
}
- xglVertex3fv( sky_center[0] );
+ xglVertex3fv( sky_inner[0] );
xglEnd();
/* Draw the middle ring */
xglBegin( GL_TRIANGLE_STRIP );
for ( i = 0; i < 12; i++ ) {
+ xglColor4fv( middle_color );
xglVertex3fv( sky_middle[i] );
- xglVertex3fv( sky_center[i] );
+ xglColor4fv( inner_color );
+ xglVertex3fv( sky_inner[i] );
}
+ xglColor4fv( middle_color );
xglVertex3fv( sky_middle[0] );
- xglVertex3fv( sky_center[0] );
+ xglColor4fv( inner_color );
+ xglVertex3fv( sky_inner[0] );
xglEnd();
/* Draw the outer ring */
xglBegin( GL_TRIANGLE_STRIP );
for ( i = 0; i < 12; i++ ) {
+ xglColor4fv( l->fog_color );
xglVertex3fv( sky_outer[i] );
+ xglColor4fv( middle_color );
xglVertex3fv( sky_middle[i] );
}
+ xglColor4fv( l->fog_color );
xglVertex3fv( sky_outer[0] );
+ xglColor4fv( middle_color );
xglVertex3fv( sky_middle[0] );
xglEnd();
/* $Log$
-/* Revision 1.4 1997/12/19 16:45:02 curt
-/* Working on scene rendering order and options.
+/* Revision 1.5 1997/12/19 23:34:59 curt
+/* Lot's of tweaking with sky rendering and lighting.
/*
+ * Revision 1.4 1997/12/19 16:45:02 curt
+ * Working on scene rendering order and options.
+ *
* Revision 1.3 1997/12/18 23:32:36 curt
* First stab at sky dome actually starting to look reasonable. :-)
*
xglColor3f( magnitude, magnitude, magnitude );
/*xglColor3f(0,0,0);*/
- xglVertex3f( 190000.0 * cos(right_ascension) * cos(declination),
- 190000.0 * sin(right_ascension) * cos(declination),
- 190000.0 * sin(declination) );
+ xglVertex3f( 50000.0 * cos(right_ascension) * cos(declination),
+ 50000.0 * sin(right_ascension) * cos(declination),
+ 50000.0 * sin(declination) );
count++;
} /* if valid line */
pltPos.RightAscension, pltPos.Declination);
/* give the planets a temporary color, for testing purposes */
xglColor3f( 1.0, 0.0, 0.0);
- xglVertex3f( 190000.0 * cos(pltPos.RightAscension) *
+ xglVertex3f( 50000.0 * cos(pltPos.RightAscension) *
cos(pltPos.Declination),
- 190000.0 * sin(pltPos.RightAscension) *
+ 50000.0 * sin(pltPos.RightAscension) *
cos(pltPos.Declination),
- 190000.0 * sin(pltPos.Declination) );
+ 50000.0 * sin(pltPos.Declination) );
}
xglEnd();
/*
xglBegin(GL_LINE_LOOP);
xglColor3f(1.0, 0.0, 0.0);
- xglVertex3f( 190000.0 * cos(ra_save-0.2) * cos(decl_save-0.2),
- 190000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
- 190000.0 * sin(decl_save-0.2) );
- xglVertex3f( 190000.0 * cos(ra_save+0.2) * cos(decl_save-0.2),
- 190000.0 * sin(ra_save+0.2) * cos(decl_save-0.2),
- 190000.0 * sin(decl_save-0.2) );
- xglVertex3f( 190000.0 * cos(ra_save+0.2) * cos(decl_save+0.2),
- 190000.0 * sin(ra_save+0.2) * cos(decl_save+0.2),
- 190000.0 * sin(decl_save+0.2) );
- xglVertex3f( 190000.0 * cos(ra_save-0.2) * cos(decl_save+0.2),
- 190000.0 * sin(ra_save-0.2) * cos(decl_save+0.2),
- 190000.0 * sin(decl_save+0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save-0.2),
+ 50000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
+ 50000.0 * sin(decl_save-0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save-0.2),
+ 50000.0 * sin(ra_save+0.2) * cos(decl_save-0.2),
+ 50000.0 * sin(decl_save-0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save+0.2) * cos(decl_save+0.2),
+ 50000.0 * sin(ra_save+0.2) * cos(decl_save+0.2),
+ 50000.0 * sin(decl_save+0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save-0.2) * cos(decl_save+0.2),
+ 50000.0 * sin(ra_save-0.2) * cos(decl_save+0.2),
+ 50000.0 * sin(decl_save+0.2) );
xglEnd();
*/
/*
xglBegin(GL_LINE_LOOP);
xglColor3f(0.0, 1.0, 0.0);
- xglVertex3f( 190000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2),
- 190000.0 * sin(ra_save1-0.2) * cos(decl_save1-0.2),
- 190000.0 * sin(decl_save1-0.2) );
- xglVertex3f( 190000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2),
- 190000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2),
- 190000.0 * sin(decl_save1-0.2) );
- xglVertex3f( 190000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2),
- 190000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2),
- 190000.0 * sin(decl_save1+0.2) );
- xglVertex3f( 190000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2),
- 190000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2),
- 190000.0 * sin(decl_save1+0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2),
+ 50000.0 * sin(ra_save1-0.2) * cos(decl_save1-0.2),
+ 50000.0 * sin(decl_save1-0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2),
+ 50000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2),
+ 50000.0 * sin(decl_save1-0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2),
+ 50000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2),
+ 50000.0 * sin(decl_save1+0.2) );
+ xglVertex3f( 50000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2),
+ 50000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2),
+ 50000.0 * sin(decl_save1+0.2) );
xglEnd();
*/
/* $Log$
-/* Revision 1.20 1997/12/15 23:55:03 curt
-/* Add xgl wrappers for debugging.
-/* Generate terrain normals on the fly.
+/* Revision 1.21 1997/12/19 23:35:00 curt
+/* Lot's of tweaking with sky rendering and lighting.
/*
+ * Revision 1.20 1997/12/15 23:55:03 curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
* Revision 1.19 1997/12/12 19:53:00 curt
* Working on lightling and material properties.
*
xglTranslatef(xSun, ySun, zSun);
xglScalef(1400, 1400, 1400);
- xglColor3f(0.85, 0.65, 0.05);
+ xglColor4f(0.85, 0.65, 0.05, 1.0);
- /* xglColor3fv( color ); */
- /* xglutSolidSphere(1.0, 25, 25); */
xglCallList(sun_obj);
xglPopMatrix();
/* $Log$
-/* Revision 1.7 1997/12/17 23:12:16 curt
-/* Fixed so moon and sun display lists aren't recreate periodically.
+/* Revision 1.8 1997/12/19 23:35:00 curt
+/* Lot's of tweaking with sky rendering and lighting.
/*
+ * Revision 1.7 1997/12/17 23:12:16 curt
+ * Fixed so moon and sun display lists aren't recreate periodically.
+ *
* Revision 1.6 1997/12/15 23:55:04 curt
* Add xgl wrappers for debugging.
* Generate terrain normals on the fly.
/* Derived lighting values */
GLfloat scene_ambient[3]; /* ambient component */
GLfloat scene_diffuse[3]; /* diffuse component */
- GLfloat scene_fog[4]; /* fog color */
- GLfloat scene_clear[4]; /* clear screen color */
+ GLfloat fog_color[4]; /* fog color */
+ GLfloat sky_color[4]; /* clear screen color */
};
extern struct fgLIGHT cur_light_params;
/* $Log$
-/* Revision 1.10 1997/12/15 23:55:07 curt
-/* Add xgl wrappers for debugging.
-/* Generate terrain normals on the fly.
+/* 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.
+ *
* Revision 1.9 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 {}"