Incorporated code changes contributed by Charlie Hotchkiss

<chotchkiss@namg.us.anritsu.com>
This commit is contained in:
curt
1998-02-12 21:58:27 +00:00
committed by Tim Moore
parent 9797633e5c
commit 28e2a0560c
7 changed files with 126 additions and 91 deletions

View File

@@ -101,6 +101,8 @@ double fgCalcEccAnom(double M, double e)
}
// 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)
{
@@ -119,49 +121,51 @@ 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");
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,
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);
}
} 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;
}
@@ -183,12 +187,16 @@ void fgSolarSystemUpdate(struct OrbElements *planet, struct fgTIME t)
/* $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
*

View File

@@ -73,7 +73,7 @@ double fgCalcEccAnom(double M, double e);
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);
@@ -81,9 +81,13 @@ 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
*

View File

@@ -131,7 +131,7 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
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"
@@ -188,7 +188,7 @@ void fgPlanetsInit( void )
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) );
}
@@ -204,12 +204,16 @@ void fgPlanetsRender( void ) {
/* $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
*

View File

@@ -32,17 +32,21 @@ struct CelestialCoord fgCalculatePlanet(struct OrbElements planet,
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
*

View File

@@ -56,7 +56,7 @@
/* Initialize the Star Management Subsystem */
void fgStarsInit( void ) {
int fgStarsInit( void ) {
FILE *fd;
struct fgGENERAL *g;
/* struct CelestialCoord pltPos; */
@@ -81,15 +81,15 @@ void fgStarsInit( void ) {
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 );
@@ -114,7 +114,7 @@ void fgStarsInit( void ) {
/* blank line */
} else {
/* star data line */
/* get name */
end = front;
while ( end[0] != ',' ) {
@@ -125,24 +125,24 @@ void fgStarsInit( void ) {
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;
@@ -150,19 +150,19 @@ void fgStarsInit( void ) {
/* 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 */
@@ -205,11 +205,13 @@ void fgStarsInit( void ) {
50000.0 * sin(decl_save1+0.2) );
xglEnd();
*/
xglEndList();
max_stars /= 2;
}
return 1; // OK, we got here because initialization worked.
}
@@ -253,9 +255,13 @@ void fgStarsRender( void ) {
/* $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
*

View File

@@ -33,7 +33,7 @@
#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 );
@@ -44,9 +44,13 @@ extern struct fgTIME cur_time_params;
/* $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.

View File

@@ -114,8 +114,9 @@ void fgSunInit( void ) {
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);
@@ -155,12 +156,12 @@ void fgSunInit( void ) {
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 );
@@ -195,9 +196,13 @@ void fgSunRender( void ) {
/* $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.