#include <time.h>
#include <GL/glut.h>
+#include "../XGL/xgl.h"
#include "orbits.h"
#include "planets.h"
#include "stars.h"
-#include "../constants.h"
-#include "../general.h"
+#include "../Include/constants.h"
+#include "../Include/general.h"
#include "../Aircraft/aircraft.h"
#include "../Main/views.h"
#include "../Time/fg_time.h"
double ra_save1, decl_save1;
int count, i, j, max_stars;
+ printf("Initializing stars\n");
+
g = &general;
/* build the full path name to the stars data base file */
max_stars = FG_MAX_STARS;
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
- printf("Loading %d Stars: %s\n", max_stars, path);
+ printf(" Loading %d Stars: %s\n", max_stars, path);
if ( (fd = fopen(path, "r")) == NULL ) {
printf("Cannot open star file: '%s'\n", path);
return;
}
- stars[i] = glGenLists(1);
- glNewList( stars[i], GL_COMPILE );
- glBegin( GL_POINTS );
+ stars[i] = xglGenLists(1);
+ xglNewList( stars[i], GL_COMPILE );
+ xglBegin( GL_POINTS );
/* read in each line of the file */
count = 0;
while ( (fgets(line, 256, fd) != NULL) && (count < max_stars) ) {
front = line;
- /* printf("Read line = %s", front); */
+ /* printf(" Read line = %s", front); */
/* advance to first non-whitespace character */
while ( (front[0] == ' ') || (front[0] == '\t') ) {
front++;
}
- /* printf("Line length (after trimming) = %d\n", strlen(front)); */
+ /* printf(" Line length (after trimming) = %d\n", strlen(front));*/
if ( front[0] == '#' ) {
/* comment */
if ( magnitude < 0.0 ) { magnitude = 0.0; }
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); */
- glColor3f( magnitude, magnitude, magnitude );
- /*glColor3f(0,0,0);*/
- glVertex3f( 190000.0 * cos(right_ascension) * cos(declination),
- 190000.0 * sin(right_ascension) * cos(declination),
- 190000.0 * sin(declination) );
+ xglColor3f( magnitude, magnitude, magnitude );
+ /*xglColor3f(0,0,0);*/
+ xglVertex3f( 50000.0 * cos(right_ascension) * cos(declination),
+ 50000.0 * sin(right_ascension) * cos(declination),
+ 50000.0 * sin(declination) );
count++;
} /* if valid line */
/* Add the planets to all four display lists */
for ( j = 2; j < 9; j++ ) {
pltPos = fgCalculatePlanet(pltOrbElements[j],
- pltOrbElements[0], cur_time_params);
- printf("Planet found at %f (ra), %f (dec)\n",
- pltPos.RightAscension, pltPos.Declination);
+ pltOrbElements[0], cur_time_params, j);
/* give the planets a temporary color, for testing purposes */
- glColor3f( 1.0, 0.0, 0.0);
- glVertex3f( 190000.0 * cos(pltPos.RightAscension) *
- cos(pltPos.Declination),
- 190000.0 * sin(pltPos.RightAscension) *
- cos(pltPos.Declination),
- 190000.0 * sin(pltPos.Declination) );
+ /* xglColor3f( 1.0, 0.0, 0.0); */
+
+ /* scale magnitudes to (0.0 - 1.0) */
+ magnitude = (0.0 - pltPos.magnitude) / 5.0 + 1.0;
+
+ /* scale magnitudes again so they look ok */
+ if ( magnitude > 1.0 ) { magnitude = 1.0; }
+ if ( magnitude < 0.0 ) { magnitude = 0.0; }
+ magnitude =
+ magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1);
+
+
+ xglColor3f(magnitude, magnitude, magnitude);
+
+ xglVertex3f( 50000.0 * cos(pltPos.RightAscension) *
+ cos(pltPos.Declination),
+ 50000.0 * sin(pltPos.RightAscension) *
+ cos(pltPos.Declination),
+ 50000.0 * sin(pltPos.Declination) );
}
- glEnd();
+ xglEnd();
/*
- glBegin(GL_LINE_LOOP);
- glColor3f(1.0, 0.0, 0.0);
- glVertex3f( 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) );
- glVertex3f( 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) );
- glVertex3f( 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) );
- glVertex3f( 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) );
- glEnd();
+ xglBegin(GL_LINE_LOOP);
+ xglColor3f(1.0, 0.0, 0.0);
+ 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();
*/
/*
- glBegin(GL_LINE_LOOP);
- glColor3f(0.0, 1.0, 0.0);
- glVertex3f( 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) );
- glVertex3f( 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) );
- glVertex3f( 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) );
- glVertex3f( 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) );
- glEnd();
+ xglBegin(GL_LINE_LOOP);
+ xglColor3f(0.0, 1.0, 0.0);
+ 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();
*/
- glEndList();
+ xglEndList();
max_stars /= 2;
}
printf("RENDERING STARS = %d (night)\n", i);
- glDisable( GL_LIGHTING );
- glCallList(stars[i]);
- glEnable( GL_LIGHTING );
+ xglDisable( GL_LIGHTING );
+ xglCallList(stars[i]);
+ xglEnable( GL_LIGHTING );
} else {
printf("not RENDERING STARS (day)\n");
}
/* $Log$
-/* Revision 1.19 1997/12/12 19:53:00 curt
-/* Working on lightling and material properties.
+/* Revision 1.23 1997/12/30 20:47:53 curt
+/* Integrated new event manager with subsystem initializations.
/*
+ * Revision 1.22 1997/12/30 16:36:53 curt
+ * Merged in Durk's changes ...
+ *
+ * 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.
+ *
* 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 {}"