**************************************************************************/
-#ifdef WIN32
+#include <config.h>
+
+#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include <time.h>
#include <GL/glut.h>
-#include "../XGL/xgl.h"
-
-#include "orbits.h"
-#include "planets.h"
-#include "stars.h"
+#include <XGL/xgl.h>
-#include "../Include/constants.h"
-#include "../Include/general.h"
-#include "../Aircraft/aircraft.h"
-#include "../Main/views.h"
-#include "../Time/fg_time.h"
+#include <Astro/orbits.h>
+#include <Astro/planets.h>
+#include <Astro/stars.h>
+#include <Include/fg_constants.h>
+#include <Include/general.h>
+#include <Aircraft/aircraft.h>
+#include <Main/views.h>
+#include <Time/fg_time.h>
+#include <Main/fg_debug.h>
#define EpochStart (631065600)
#define DaysSinceEpoch(secs) (((secs)-EpochStart)*(1.0/(24*3600)))
/* Initialize the Star Management Subsystem */
-void fgStarsInit( void ) {
+int fgStarsInit( void ) {
FILE *fd;
- struct fgGENERAL *g;
- struct CelestialCoord pltPos;
+ fgGENERAL *g;
+ /* struct CelestialCoord pltPos; */
char path[1024];
char line[256], name[256];
char *front, *end;
double right_ascension, declination, magnitude;
- double ra_save, decl_save;
- double ra_save1, decl_save1;
- int count, i, j, max_stars;
+ /* double ra_save, decl_save; */
+ /* double ra_save1, decl_save1; */
+ int count, i, max_stars;
- printf("Initializing stars\n");
+ fgPrintf( FG_ASTRO, FG_INFO, "Initializing stars\n");
g = &general;
max_stars = FG_MAX_STARS;
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
- printf(" Loading %d Stars: %s\n", max_stars, path);
+ fgPrintf( FG_ASTRO, FG_INFO,
+ " Loading %d Stars: %s\n", max_stars, path);
if ( (fd = fopen(path, "r")) == NULL ) {
- printf("Cannot open star file: '%s'\n", path);
- return;
+ fgPrintf( FG_ASTRO, FG_ALERT,
+ "Cannot open star file: '%s'\n", path);
+ return 0; // Oops, lets not even try to continue. This is critical.
}
-
+
stars[i] = xglGenLists(1);
xglNewList( stars[i], GL_COMPILE );
xglBegin( GL_POINTS );
/* blank line */
} else {
/* star data line */
-
+
/* get name */
end = front;
while ( end[0] != ',' ) {
front = end;
front++;
- sscanf(front, "%lf,%lf,%lf\n",
+ 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, "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;
- }
- */
+ 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;
/* scale magnitudes again so they look ok */
if ( magnitude > 1.0 ) { magnitude = 1.0; }
if ( magnitude < 0.0 ) { magnitude = 0.0; }
- magnitude =
+ magnitude =
magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1);
/* printf(" Found star: %d %s, %.3f %.3f %.3f\n", count,
- name, right_ascension, declination, magnitude); */
+ name, right_ascension, declination, magnitude); */
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 */
+ } // valid line
} /* while */
fclose(fd);
- /* Add the planets to all four display lists */
- for ( j = 2; j < 9; j++ ) {
- pltPos = fgCalculatePlanet(pltOrbElements[j],
- pltOrbElements[0], cur_time_params, j);
- /* give the planets a temporary color, for testing purposes */
- /* 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) );
- }
xglEnd();
/*
50000.0 * sin(decl_save1+0.2) );
xglEnd();
*/
-
+
xglEndList();
max_stars /= 2;
}
+
+ return 1; // OK, we got here because initialization worked.
}
/* Draw the Stars */
void fgStarsRender( void ) {
- struct fgFLIGHT *f;
+ fgFLIGHT *f;
struct fgVIEW *v;
struct fgLIGHT *l;
struct fgTIME *t;
int i;
- f = ¤t_aircraft.flight;
+ f = current_aircraft.flight;
l = &cur_light_params;
t = &cur_time_params;
v = ¤t_view;
/* $Log$
-/* Revision 1.2 1998/01/19 18:40:18 curt
-/* Tons of little changes to clean up the code and to remove fatal errors
-/* when building with the c++ compiler.
+/* Revision 1.10 1998/04/03 21:52:51 curt
+/* Converting to Gnu autoconf system.
/*
+ * Revision 1.9 1998/03/14 00:27:12 curt
+ * Updated fgGENERAL to a "type" of struct.
+ *
+ * Revision 1.8 1998/02/12 21:59:38 curt
+ * Incorporated code changes contributed by Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
+ * Revision 1.7 1998/02/09 15:07:48 curt
+ * Minor tweaks.
+ *
+ * Revision 1.6 1998/02/02 20:53:23 curt
+ * To version 0.29
+ *
+ * Revision 1.5 1998/01/27 18:35:53 curt
+ * Minor tweaks.
+ *
+ * Revision 1.4 1998/01/27 00:47:49 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.3 1998/01/19 19:26:59 curt
+ * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+ * This should simplify things tremendously.
+ *
+ * Revision 1.2 1998/01/19 18:40:18 curt
+ * Tons of little changes to clean up the code and to remove fatal errors
+ * when building with the c++ compiler.
+ *
* Revision 1.1 1998/01/07 03:16:20 curt
* Moved from .../Src/Scenery/ to .../Src/Astro/
*