1
0
Fork 0

At dusk/dawn add/remove stars in stages.

This commit is contained in:
curt 1997-09-18 16:20:08 +00:00
parent 3b5f599f73
commit e17c832c36
3 changed files with 112 additions and 83 deletions

View file

@ -180,7 +180,7 @@ static void fgUpdateViewParams() {
x_8 = x_4 * x_4; x_8 = x_4 * x_4;
x_10 = x_8 * x_2; x_10 = x_8 * x_2;
ambient = 0.4 * pow(1.2, -x_10 / 30.0); ambient = 0.4 * pow(1.1, -x_10 / 30.0);
/* diffuse = 0.4 * cos(0.3 * x_2); /* diffuse = 0.4 * cos(0.3 * x_2);
if ( t->sun_angle > FG_PI_2 + 0.05 ) { if ( t->sun_angle > FG_PI_2 + 0.05 ) {
@ -575,9 +575,12 @@ int main( int argc, char *argv[] ) {
/* $Log$ /* $Log$
/* Revision 1.18 1997/09/16 22:14:51 curt /* Revision 1.19 1997/09/18 16:20:08 curt
/* Tweaked time of day lighting equations. Don't draw stars during the day. /* At dusk/dawn add/remove stars in stages.
/* /*
* Revision 1.18 1997/09/16 22:14:51 curt
* Tweaked time of day lighting equations. Don't draw stars during the day.
*
* Revision 1.17 1997/09/16 15:50:29 curt * Revision 1.17 1997/09/16 15:50:29 curt
* Working on star alignment and time issues. * Working on star alignment and time issues.
* *

View file

@ -49,7 +49,8 @@
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600))) #define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
static GLint stars; /* Define four structures, each with varying amounts of stars */
static GLint stars[FG_STAR_LEVELS];
/* Initialize the Star Management Subsystem */ /* Initialize the Star Management Subsystem */
@ -62,8 +63,7 @@ void fgStarsInit() {
double right_ascension, declination, magnitude; double right_ascension, declination, magnitude;
double ra_save, decl_save; double ra_save, decl_save;
double ra_save1, decl_save1; double ra_save1, decl_save1;
double ra_save2, decl_save2; int count, i, max_stars;
int count;
g = &general; g = &general;
@ -73,20 +73,23 @@ void fgStarsInit() {
strcat(path, "/Scenery/"); strcat(path, "/Scenery/");
strcat(path, "Stars.dat"); strcat(path, "Stars.dat");
printf("Loading Stars: %s\n", path); max_stars = FG_MAX_STARS;
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
printf("Loading %d Stars: %s\n", max_stars, path);
if ( (fd = fopen(path, "r")) == NULL ) { if ( (fd = fopen(path, "r")) == NULL ) {
printf("Cannot open star file: '%s'\n", path); printf("Cannot open star file: '%s'\n", path);
return; return;
} }
stars = glGenLists(1); stars[i] = glGenLists(1);
glNewList( stars, GL_COMPILE ); glNewList( stars[i], GL_COMPILE );
glBegin( GL_POINTS ); glBegin( GL_POINTS );
/* read in each line of the file */ /* read in each line of the file */
count = 0; count = 0;
while ( (fgets(line, 256, fd) != NULL) && (count < FG_MAX_STARS) ) { while ( (fgets(line, 256, fd) != NULL) && (count < max_stars) ) {
front = line; front = line;
/* printf("Read line = %s", front); */ /* printf("Read line = %s", front); */
@ -119,13 +122,13 @@ void fgStarsInit() {
&right_ascension, &declination, &magnitude); &right_ascension, &declination, &magnitude);
if ( strcmp(name, "Hamal") == 0 ) { if ( strcmp(name, "Hamal") == 0 ) {
printf("\n*** Marking %s\n\n", name); printf(" *** Marking %s\n", name);
ra_save = right_ascension; ra_save = right_ascension;
decl_save = declination; decl_save = declination;
} }
if ( strcmp(name, "Algenib") == 0 ) { if ( strcmp(name, "Algenib") == 0 ) {
printf("\n*** Marking %s\n\n", name); printf(" *** Marking %s\n", name);
ra_save1 = right_ascension; ra_save1 = right_ascension;
decl_save1 = declination; decl_save1 = declination;
} }
@ -136,10 +139,10 @@ void fgStarsInit() {
/* scale magnitudes again so they look ok */ /* scale magnitudes again so they look ok */
if ( magnitude > 1.0 ) { magnitude = 1.0; } if ( magnitude > 1.0 ) { magnitude = 1.0; }
if ( magnitude < 0.0 ) { magnitude = 0.0; } if ( magnitude < 0.0 ) { magnitude = 0.0; }
magnitude = magnitude * 0.7 + 0.3; 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); */ name, right_ascension, declination, magnitude);
glColor3f( magnitude, magnitude, magnitude ); glColor3f( magnitude, magnitude, magnitude );
glVertex3f( 190000.0 * sin(right_ascension) * cos(declination), glVertex3f( 190000.0 * sin(right_ascension) * cos(declination),
@ -155,6 +158,7 @@ void fgStarsInit() {
glEnd(); glEnd();
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
glColor3f(1.0, 0.0, 0.0); glColor3f(1.0, 0.0, 0.0);
glVertex3f( 190000.0 * sin(ra_save-0.2) * cos(decl_save-0.2), glVertex3f( 190000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
@ -188,6 +192,9 @@ void fgStarsInit() {
glEnd(); glEnd();
glEndList(); glEndList();
max_stars /= 2;
}
} }
@ -198,6 +205,7 @@ void fgStarsRender() {
struct fgTIME *t; struct fgTIME *t;
double angle; double angle;
static double warp = 0; static double warp = 0;
int i;
f = &current_aircraft.flight; f = &current_aircraft.flight;
t = &cur_time_params; t = &cur_time_params;
@ -205,8 +213,19 @@ void fgStarsRender() {
/* FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise */ /* FG_PI_2 + 0.1 is about 6 degrees after sundown and before sunrise */
if ( t->sun_angle > (FG_PI_2 + 0.1 ) ) { if ( t->sun_angle > (FG_PI_2 + 5 * DEG_TO_RAD ) ) {
printf("RENDERING STARS (night)\n"); /* determine which star structure to draw */
if ( t->sun_angle > (FG_PI_2 + 7.25 * DEG_TO_RAD ) ) {
i = 0;
} else if ( t->sun_angle > (FG_PI_2 + 6.50 * DEG_TO_RAD ) ) {
i = 1;
} else if ( t->sun_angle > (FG_PI_2 + 5.75 * DEG_TO_RAD ) ) {
i = 2;
} else {
i = 3;
}
printf("RENDERING STARS = %d (night)\n", i);
glDisable( GL_FOG ); glDisable( GL_FOG );
glDisable( GL_LIGHTING ); glDisable( GL_LIGHTING );
@ -221,7 +240,7 @@ void fgStarsRender() {
printf("Rotating stars by %.2f + %.2f\n", -angle * RAD_TO_DEG, printf("Rotating stars by %.2f + %.2f\n", -angle * RAD_TO_DEG,
-warp * RAD_TO_DEG); -warp * RAD_TO_DEG);
glCallList(stars); glCallList(stars[i]);
glPopMatrix(); glPopMatrix();
glEnable( GL_LIGHTING ); glEnable( GL_LIGHTING );
@ -233,9 +252,12 @@ void fgStarsRender() {
/* $Log$ /* $Log$
/* Revision 1.8 1997/09/16 22:14:52 curt /* Revision 1.9 1997/09/18 16:20:09 curt
/* Tweaked time of day lighting equations. Don't draw stars during the day. /* At dusk/dawn add/remove stars in stages.
/* /*
* Revision 1.8 1997/09/16 22:14:52 curt
* Tweaked time of day lighting equations. Don't draw stars during the day.
*
* Revision 1.7 1997/09/16 15:50:31 curt * Revision 1.7 1997/09/16 15:50:31 curt
* Working on star alignment and time issues. * Working on star alignment and time issues.
* *

View file

@ -29,6 +29,7 @@
#define FG_MAX_STARS 500 #define FG_MAX_STARS 500
#define FG_STAR_LEVELS 4 /* how many star transitions */
#define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */ #define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */
/* Initialize the Star Management Subsystem */ /* Initialize the Star Management Subsystem */
@ -42,9 +43,12 @@ void fgStarsRender();
/* $Log$ /* $Log$
/* Revision 1.4 1997/09/05 01:36:00 curt /* Revision 1.5 1997/09/18 16:20:09 curt
/* Working on getting stars right. /* At dusk/dawn add/remove stars in stages.
/* /*
* Revision 1.4 1997/09/05 01:36:00 curt
* Working on getting stars right.
*
* Revision 1.3 1997/08/29 17:55:28 curt * Revision 1.3 1997/08/29 17:55:28 curt
* Worked on properly aligning the stars. * Worked on properly aligning the stars.
* *