+void fgPlanetsInit( void )
+{
+ struct fgLIGHT *l;
+ int i;
+ struct CelestialCoord pltPos;
+ double magnitude;
+
+ l = &cur_light_params;
+ /* if the display list was already built during a previous init,
+ then recycle it */
+
+ if (planets) {
+ xglDeleteLists(planets, 1);
+ }
+
+ planets = xglGenLists(1);
+ xglNewList( planets, GL_COMPILE );
+ xglBegin( GL_POINTS );
+
+
+ /* Add the planets to all four display lists */
+ for ( i = 2; i < 9; i++ ) {
+ fgSolarSystemUpdate(&(pltOrbElements[i]), cur_time_params);
+ pltPos = fgCalculatePlanet(pltOrbElements[i],
+ pltOrbElements[0], cur_time_params, i);
+
+ magnitude = (0.0 - pltPos.magnitude) / 5.0 + 1.0;
+
+ /* scale magnitudes again so they look ok */
+ /* magnitude =
+ magnitude * 0.7 + (((FG_STAR_LEVELS - 1) - i) * 0.1); */
+
+ /* the following statement could be made a little more sopisticated
+ for the moment: Stick to this one */
+ magnitude = magnitude * 0.7 + (3 * 0.1);
+ if ( magnitude > 1.0 ) { magnitude = 1.0; }
+ if ( magnitude < 0.0 ) { magnitude = 0.0; }
+
+ /* Add planets to the display list, based on sun_angle and current
+ magnitude It's pretty experimental... */
+
+ if ((double) (l->sun_angle - FG_PI_2) >
+ ((magnitude - 1.0) * -20 * DEG_TO_RAD))
+ {
+ xglColor3f (magnitude, magnitude, magnitude);
+ printf ("Sun Angle to Horizon (in Rads) = %f\n",
+ (double) (l->sun_angle - FG_PI_2));
+ printf ("Transformed Magnitude is :%f %f\n",
+ magnitude, (magnitude - 1.0) * -20 * DEG_TO_RAD);
+
+ xglVertex3f (50000.0 * cos (pltPos.RightAscension) *
+ cos (pltPos.Declination),
+ 50000.0 * sin (pltPos.RightAscension) *
+ cos (pltPos.Declination),
+ 50000.0 * sin (pltPos.Declination));
+ }
+ }
+ xglEnd();
+ xglEndList();
+
+}
+
+
+void fgPlanetsRender( void ) {
+ xglCallList(planets);
+}
+