1
0
Fork 0

Working on getting stars right.

This commit is contained in:
curt 1997-09-05 01:35:53 +00:00
parent b830d97782
commit ad22cbffca
5 changed files with 114 additions and 26 deletions

View file

@ -154,7 +154,7 @@ static void fgUpdateViewParams() {
/* Tell GL we are about to modify the projection parameters */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 1.0/win_ratio, 1.0, 200000.0);
gluPerspective(100.0, 1.0/win_ratio, 1.0, 200000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
@ -555,9 +555,12 @@ int main( int argc, char *argv[] ) {
/* $Log$
/* Revision 1.13 1997/09/04 02:17:34 curt
/* Shufflin' stuff.
/* Revision 1.14 1997/09/05 01:35:53 curt
/* Working on getting stars right.
/*
* Revision 1.13 1997/09/04 02:17:34 curt
* Shufflin' stuff.
*
* Revision 1.12 1997/08/27 21:32:24 curt
* Restructured view calculation code. Added stars.
*

View file

@ -80,7 +80,7 @@ void fgSceneryUpdate(double lon, double lat, double elev) {
/* Render out the current scene */
void fgSceneryRender() {
glPushMatrix();
glCallList(mesh_hack);
/* glCallList(mesh_hack); */
glPopMatrix();
fgStarsRender();
@ -88,9 +88,12 @@ void fgSceneryRender() {
/* $Log$
/* Revision 1.17 1997/08/29 17:55:27 curt
/* Worked on properly aligning the stars.
/* Revision 1.18 1997/09/05 01:35:59 curt
/* Working on getting stars right.
/*
* Revision 1.17 1997/08/29 17:55:27 curt
* Worked on properly aligning the stars.
*
* Revision 1.16 1997/08/27 21:32:29 curt
* Restructured view calculation code. Added stars.
*

View file

@ -57,8 +57,11 @@ void fgStarsInit() {
struct GENERAL *g;
char path[1024];
char line[256], name[256];
char *tmp_ptr;
char *front, *end;
double right_ascension, declination, magnitude;
double ra_save, decl_save;
double ra_save1, decl_save1;
double ra_save2, decl_save2;
GLfloat mag[4] = {0.0, 0.0, 0.0, 1.0};
int count;
@ -84,36 +87,105 @@ void fgStarsInit() {
/* read in each line of the file */
count = 0;
while ( (fgets(line, 256, fd) != NULL) && (count < FG_MAX_STARS) ) {
tmp_ptr = line;
front = line;
/* printf("Read line = %s", front); */
/* advance to first non-whitespace character */
while ( (tmp_ptr[0] == ' ') || (tmp_ptr[0] == '\t') ) {
tmp_ptr++;
while ( (front[0] == ' ') || (front[0] == '\t') ) {
front++;
}
if ( tmp_ptr[0] == '#' ) {
/* printf("Line length (after trimming) = %d\n", strlen(front)); */
if ( front[0] == '#' ) {
/* comment */
} else if ( strlen(tmp_ptr) == 0 ) {
} else if ( strlen(front) <= 1 ) {
/* blank line */
} else {
/* star data line */
fscanf(fd, "%s %lf %lf %lf\n",
name, &right_ascension, &declination, &magnitude);
/* printf("Found star: %d %s, %.3f %.3f %.3f\n", count,
name, right_ascension, declination, magnitude); */
count++;
/* get name */
end = front;
while ( end[0] != ',' ) {
end++;
}
end[0] = '\0';
strcpy(name, front);
front = end;
front++;
sscanf(front, "%lf,%lf,%lf\n",
&right_ascension, &declination, &magnitude);
if ( strcmp(name, "Deneb") == 0 ) {
printf("\n*** Marking %s\n\n", name);
ra_save = right_ascension;
decl_save = declination;
}
if ( strcmp(name, "Alderamin") == 0 ) {
printf("\n*** Marking %s\n\n", name);
ra_save1 = right_ascension;
decl_save1 = declination;
}
/* scale magnitudes to (0.0 - 1.0) */
magnitude = (-1.46 - magnitude) / 10.0 + 1.0;
/* scale magnitudes again so they look ok */
magnitude = magnitude * 0.8 + 0.2;
mag[0] = mag[1] = mag[2] = magnitude;
printf("Found star: %d %s, %.3f %.3f %.3f\n", count,
name, right_ascension, declination, magnitude);
glColor3f( mag[0], mag[1], mag[2] );
glVertex3f( 190000.0 * sin(right_ascension) * cos(declination),
190000.0 * cos(right_ascension) * cos(declination),
190000.0 * sin(declination) );
count++;
} /* if valid line */
} /* while */
fclose(fd);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(1.0, 0.0, 0.0);
glVertex3f( 190000.0 * sin(ra_save-0.2) * cos(decl_save-0.2),
190000.0 * cos(ra_save-0.2) * cos(decl_save-0.2),
190000.0 * sin(decl_save-0.2) );
glVertex3f( 190000.0 * sin(ra_save+0.2) * cos(decl_save-0.2),
190000.0 * cos(ra_save+0.2) * cos(decl_save-0.2),
190000.0 * sin(decl_save-0.2) );
glVertex3f( 190000.0 * sin(ra_save+0.2) * cos(decl_save+0.2),
190000.0 * cos(ra_save+0.2) * cos(decl_save+0.2),
190000.0 * sin(decl_save+0.2) );
glVertex3f( 190000.0 * sin(ra_save-0.2) * cos(decl_save+0.2),
190000.0 * cos(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 * sin(ra_save1-0.2) * cos(decl_save1-0.2),
190000.0 * cos(ra_save1-0.2) * cos(decl_save1-0.2),
190000.0 * sin(decl_save1-0.2) );
glVertex3f( 190000.0 * sin(ra_save1+0.2) * cos(decl_save1-0.2),
190000.0 * cos(ra_save1+0.2) * cos(decl_save1-0.2),
190000.0 * sin(decl_save1-0.2) );
glVertex3f( 190000.0 * sin(ra_save1+0.2) * cos(decl_save1+0.2),
190000.0 * cos(ra_save1+0.2) * cos(decl_save1+0.2),
190000.0 * sin(decl_save1+0.2) );
glVertex3f( 190000.0 * sin(ra_save1-0.2) * cos(decl_save1+0.2),
190000.0 * cos(ra_save1-0.2) * cos(decl_save1+0.2),
190000.0 * sin(decl_save1+0.2) );
glEnd();
glEndList();
}
@ -148,9 +220,12 @@ void fgStarsRender() {
/* $Log$
/* Revision 1.4 1997/09/04 02:17:38 curt
/* Shufflin' stuff.
/* Revision 1.5 1997/09/05 01:35:59 curt
/* Working on getting stars right.
/*
* Revision 1.4 1997/09/04 02:17:38 curt
* Shufflin' stuff.
*
* Revision 1.3 1997/08/29 17:55:28 curt
* Worked on properly aligning the stars.
*

View file

@ -28,8 +28,8 @@
#define STARS_H
#define FG_MAX_STARS 1000
#define FG_MAX_STARS 500
#define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */
/* Initialize the Star Management Subsystem */
void fgStarsInit();
@ -42,9 +42,12 @@ void fgStarsRender();
/* $Log$
/* Revision 1.3 1997/08/29 17:55:28 curt
/* Worked on properly aligning the stars.
/* 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
* Worked on properly aligning the stars.
*
* Revision 1.2 1997/08/27 21:32:30 curt
* Restructured view calculation code. Added stars.
*

View file

@ -271,6 +271,7 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
v = &current_view;
time_warp += 200; /* increase this to make the world spin real fast */
time_warp = 3600*10; /* increase this to make the world spin real fast */
fgSunPosition(time(NULL) + time_warp, &t->sun_lon, &sun_gd_lat);
@ -303,9 +304,12 @@ void fgUpdateSunPos(struct fgCartesianPoint scenery_center) {
/* $Log$
/* Revision 1.7 1997/09/04 02:17:40 curt
/* Shufflin' stuff.
/* Revision 1.8 1997/09/05 01:36:04 curt
/* Working on getting stars right.
/*
* Revision 1.7 1997/09/04 02:17:40 curt
* Shufflin' stuff.
*
* Revision 1.6 1997/08/27 03:30:37 curt
* Changed naming scheme of basic shared structures.
*