}
+// This function assumes that if the FILE ptr is valid that the contents
+// will be valid. Should we check the file for validity?
void fgReadOrbElements(struct OrbElements *dest, FILE *src)
{
}
while (!(strlen(line)));
sscanf(line, "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf\n",
- &dest->NFirst, &dest->NSec,
- &dest->iFirst, &dest->iSec,
- &dest->wFirst, &dest->wSec,
- &dest->aFirst, &dest->aSec,
- &dest->eFirst, &dest->eSec,
- &dest->MFirst, &dest->MSec);
+ &dest->NFirst, &dest->NSec,
+ &dest->iFirst, &dest->iSec,
+ &dest->wFirst, &dest->wSec,
+ &dest->aFirst, &dest->aSec,
+ &dest->eFirst, &dest->eSec,
+ &dest->MFirst, &dest->MSec);
}
-void fgSolarSystemInit(struct fgTIME t)
+int fgSolarSystemInit(struct fgTIME t)
{
- struct fgGENERAL *g;
- char path[80];
- int i;
- FILE *data;
+ struct fgGENERAL *g;
+ char path[80];
+ int i;
+ FILE *data;
+ int ret_val = 0;
- fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
+ fgPrintf( FG_ASTRO, FG_INFO, "Initializing solar system\n");
/* build the full path name to the orbital elements database file */
- g = &general;
- path[0] = '\0';
- strcat(path, g->root_dir);
- strcat(path, "/Scenery/");
- strcat(path, "Planets.dat");
-
- if ( (data = fopen(path, "r")) == NULL )
- {
- fgPrintf( FG_ASTRO, FG_ALERT,
- "Cannot open data file: '%s'\n", path);
- return;
- }
- /* printf(" reading datafile %s\n", path); */
- fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path);
-
- /* for all the objects... */
- for (i = 0; i < 9; i ++)
- {
- /* ...read from the data file ... */
- fgReadOrbElements(&pltOrbElements[i], data);
- /* ...and calculate the actual values */
- fgSolarSystemUpdate(&pltOrbElements[i], t);
- }
+ g = &general;
+ path[0] = '\0';
+ strcat(path, g->root_dir);
+ strcat(path, "/Scenery/");
+ strcat(path, "Planets.dat");
+ if ( (data = fopen(path, "r")) == NULL )
+ {
+ fgPrintf( FG_ASTRO, FG_ALERT,
+ "Cannot open data file: '%s'\n", path);
+ } else {
+ /* printf(" reading datafile %s\n", path); */
+ fgPrintf( FG_ASTRO, FG_INFO, " reading datafile %s\n", path);
+
+ /* for all the objects... */
+ for (i = 0; i < 9; i ++)
+ {
+ /* ...read from the data file ... */
+ fgReadOrbElements(&pltOrbElements[i], data);
+ /* ...and calculate the actual values */
+ fgSolarSystemUpdate(&pltOrbElements[i], t);
+ }
+ ret_val = 1;
+ }
+ return ret_val;
}
/* $Log$
-/* Revision 1.6 1998/02/03 23:20:11 curt
-/* Lots of little tweaks to fix various consistency problems discovered by
-/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
-/* passed arguments along to the real printf(). Also incorporated HUD changes
-/* by Michele America.
+/* Revision 1.7 1998/02/12 21:59:33 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.6 1998/02/03 23:20:11 curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf(). Also incorporated HUD changes
+ * by Michele America.
+ *
* Revision 1.5 1998/02/02 20:53:22 curt
* To version 0.29
*
double fgCalcActTime(struct fgTIME t);
void fgReadOrbElements(struct OrbElements *dest, FILE *src);
-void fgSolarSystemInit(struct fgTIME t);
+int fgSolarSystemInit(struct fgTIME t);
void fgSolarSystemUpdate(struct OrbElements *planets, struct fgTIME t);
/* $Log$
-/* Revision 1.4 1998/02/02 20:53:22 curt
-/* To version 0.29
+/* Revision 1.5 1998/02/12 21:59:35 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.4 1998/02/02 20:53:22 curt
+ * To version 0.29
+ *
* Revision 1.3 1998/01/22 02:59:27 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*
fgPrintf( FG_ASTRO, FG_ALERT, "index %d out of range !!!!\n", idx);
}
fgPrintf( FG_ASTRO, FG_DEBUG,
- " Planet found at %f (ra), %f (dec)\n",
+ " Planet found at %f (ra), %f (dec)\n",
result.RightAscension, result.Declination);
fgPrintf( FG_ASTRO, FG_DEBUG,
" Geocentric dist %f\n"
xglVertex3f( 50000.0 * cos(pltPos.RightAscension) *
cos(pltPos.Declination),
- 50000.0 * sin(pltPos.RightAscension) *
+ 50000.0 * sin(pltPos.RightAscension) *
cos(pltPos.Declination),
50000.0 * sin(pltPos.Declination) );
}
/* $Log$
-/* Revision 1.5 1998/02/03 23:20:12 curt
-/* Lots of little tweaks to fix various consistency problems discovered by
-/* Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
-/* passed arguments along to the real printf(). Also incorporated HUD changes
-/* by Michele America.
+/* Revision 1.6 1998/02/12 21:59:36 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.5 1998/02/03 23:20:12 curt
+ * Lots of little tweaks to fix various consistency problems discovered by
+ * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
+ * passed arguments along to the real printf(). Also incorporated HUD changes
+ * by Michele America.
+ *
* Revision 1.4 1998/02/02 20:53:23 curt
* To version 0.29
*
struct fgTIME t, int idx);
-void fgPlanetsInit();
-void fgPlanetsRender();
+void fgPlanetsInit( void );
+void fgPlanetsRender( void );
#endif /* PLANETS_H */
/* $Log$
-/* Revision 1.3 1998/02/02 20:53:23 curt
-/* To version 0.29
+/* Revision 1.4 1998/02/12 21:59:38 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.3 1998/02/02 20:53:23 curt
+ * To version 0.29
+ *
* Revision 1.2 1998/01/22 02:59:28 curt
* Changed #ifdef FILE_H to #ifdef _FILE_H
*
/* Initialize the Star Management Subsystem */
-void fgStarsInit( void ) {
+int fgStarsInit( void ) {
FILE *fd;
struct fgGENERAL *g;
/* struct CelestialCoord pltPos; */
max_stars = FG_MAX_STARS;
for ( i = 0; i < FG_STAR_LEVELS; i++ ) {
- fgPrintf( FG_ASTRO, FG_INFO,
+ fgPrintf( FG_ASTRO, FG_INFO,
" Loading %d Stars: %s\n", max_stars, path);
if ( (fd = fopen(path, "r")) == NULL ) {
- fgPrintf( FG_ASTRO, FG_ALERT,
+ fgPrintf( FG_ASTRO, FG_ALERT,
"Cannot open star file: '%s'\n", path);
- return;
+ 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 */
50000.0 * sin(decl_save1+0.2) );
xglEnd();
*/
-
+
xglEndList();
max_stars /= 2;
}
+
+ return 1; // OK, we got here because initialization worked.
}
/* $Log$
-/* Revision 1.7 1998/02/09 15:07:48 curt
-/* Minor tweaks.
+/* 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
*
#define FG_MIN_STAR_MAG 0.738750 /* magnitude of weakest star we'll display */
/* Initialize the Star Management Subsystem */
-void fgStarsInit( void );
+int fgStarsInit( void );
/* Draw the Stars */
void fgStarsRender( void );
/* $Log$
-/* Revision 1.3 1998/01/22 02:59:28 curt
-/* Changed #ifdef FILE_H to #ifdef _FILE_H
+/* Revision 1.4 1998/02/12 21:59:39 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.3 1998/01/22 02:59:28 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
* 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.
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
- fgPrintf( FG_ASTRO, FG_INFO,
- "Sun found at %f (ra), %f (dec)\n",
+
+ fgPrintf( FG_ASTRO, FG_INFO,
+ "Sun found at %f (ra), %f (dec)\n",
sunPos.RightAscension, sunPos.Declination);
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
if (amb[1] > 1.0) amb[1] = 1.0;
if (amb[2] > 1.0) amb[2] = 1.0;
- fgPrintf( FG_ASTRO, FG_DEBUG,
- "Color of the sun: %f, %f, %f\n"
- "Ambient value : %f\n"
- "Sun Angle : %f\n" ,
- amb[0], amb[1], amb[2], ambient, l->sun_angle);
-
+ fgPrintf( FG_ASTRO, FG_DEBUG,
+ "Color of the sun: %f, %f, %f\n"
+ "Ambient value : %f\n"
+ "Sun Angle : %f\n" ,
+ amb[0], amb[1], amb[2], ambient, l->sun_angle);
+
/* set lighting parameters */
/*xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, color );
/* $Log$
-/* Revision 1.5 1998/02/02 20:53:24 curt
-/* To version 0.29
+/* Revision 1.6 1998/02/12 21:59:39 curt
+/* Incorporated code changes contributed by Charlie Hotchkiss
+/* <chotchkiss@namg.us.anritsu.com>
/*
+ * Revision 1.5 1998/02/02 20:53:24 curt
+ * To version 0.29
+ *
* Revision 1.4 1998/01/27 00:47:50 curt
* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
* system and commandline/config file processing code.