coordinates (xs, ys) */
solarPosition.xs = r * cos(lonSun);
solarPosition.ys = r * sin(lonSun);
+ solarPosition.dist = r;
return solarPosition;
}
/* Initialize the Sun */
-void fgSunInit()
-{
-// int i;
-
- sun_obj = xglGenLists(1);
- xglNewList(sun_obj, GL_COMPILE );
+void fgSunInit() {
+ static int dl_exists = 0;
-// xglBegin( GL_POINTS );
+ printf("Initializing the Sun\n");
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
sunPos.Declination);
#endif
- /* give the moon a temporary color, for testing purposes */
-// xglColor3f( 0.0, 1.0, 0.0);
-// xglVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination),
- // 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination),
-// 190000.0 * sin(moonPos.Declination) );
- //xglVertex3f(0.0, 0.0, 0.0);
-// xglEnd();
-// xglColor3f(1.0, 1.0, 1.0);
- //xMoon = 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
- //yMoon = 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
- //zMoon = 190000.0 * sin(moonPos.Declination);
-
- xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
- ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
- zSun = 60000.0 * sin(sunPos.Declination);
-
-// xglPushMatrix();
-// xglTranslatef(x, y, z);
-// xglScalef(16622.8, 16622.8, 16622.8);
-// xglBegin(GL_TRIANGLES);
-// for (i = 0; i < 20; i++)
-// subdivide(&vdata[tindices[i][0]][0],
-// &vdata[tindices[i][1]][0],
-// &vdata[tindices[i][2]][0], 3);
-// glutSolidSphere(1.0, 25, 25);
-
-// xglEnd();
- //xglPopMatrix();
-
- glutSolidSphere(1.0, 10, 10);
-
- xglEndList();
+ if ( !dl_exists ) {
+ dl_exists = 1;
+
+ /* printf("First time through, creating sun display list\n"); */
+
+ sun_obj = xglGenLists(1);
+ xglNewList(sun_obj, GL_COMPILE );
+
+ xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
+ ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
+ zSun = 60000.0 * sin(sunPos.Declination);
+
+ glutSolidSphere(1.0, 10, 10);
+
+ xglEndList();
+ }
}
void fgSunRender() {
struct fgVIEW *v;
struct fgTIME *t;
- GLfloat color[4] = { 0.85, 0.65, 0.05, 1.0 };
- /* double x_2, x_4, x_8, x_10; */
- /* GLfloat ambient; */
- /* GLfloat amb[3], diff[3]; */
+ struct fgLIGHT *l;
+ /* GLfloat color[4] = { 0.85, 0.65, 0.05, 1.0 }; */
+ GLfloat color[4] = { 1.00, 1.00, 1.00, 1.00 };
+ double x_2, x_4, x_8, x_10;
+ GLfloat ambient;
+ GLfloat amb[3], diff[3];
t = &cur_time_params;
v = ¤t_view;
+ l = &cur_light_params;
- /* x_2 = t->sun_angle * t->sun_angle;
+ x_2 = l->sun_angle * l->sun_angle;
x_4 = x_2 * x_2;
x_8 = x_4 * x_4;
- x_10 = x_8 * x_2; */
+ x_10 = x_8 * x_2;
- /* ambient = (0.4 * pow(1.1, -x_10 / 30.0));
+ ambient = (0.4 * pow(1.1, -x_10 / 30.0));
if ( ambient < 0.3 ) ambient = 0.3;
if ( ambient > 1.0 ) ambient = 1.0;
+
amb[0] = 0.50 + ((ambient * 6.66) - 1.6);
amb[1] = 0.00 + ((ambient * 6.66) - 1.6);
amb[2] = 0.00 + ((ambient * 6.66) - 1.6);
diff[0] = 0.0;
diff[1] = 0.0;
diff[2] = 0.0;
- diff[3] = 0.0; */
+ diff[3] = 1.0;
/* set lighting parameters */
- /* xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
+ xglLightfv(GL_LIGHT0, GL_AMBIENT, color );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, color );
xglMaterialfv(GL_FRONT, GL_AMBIENT, amb);
- xglMaterialfv(GL_FRONT, GL_DIFFUSE, diff); */
+ xglMaterialfv(GL_FRONT, GL_DIFFUSE, diff);
+ xglMaterialfv(GL_FRONT, GL_SHININESS, diff);
+ xglMaterialfv(GL_FRONT, GL_EMISSION, diff);
+ xglMaterialfv(GL_FRONT, GL_SPECULAR, diff);
- xglDisable( GL_LIGHTING );
+ /* xglDisable( GL_LIGHTING ); */
xglPushMatrix();
xglTranslatef(xSun, ySun, zSun);
xglColor3f(0.85, 0.65, 0.05);
- /* xglColor3fv( color ); */
- /* xglutSolidSphere(1.0, 25, 25); */
xglCallList(sun_obj);
xglPopMatrix();
- xglEnable( GL_LIGHTING );
+ /* xglEnable( GL_LIGHTING ); */
}
/* $Log$
-/* Revision 1.6 1997/12/15 23:55:04 curt
-/* Add xgl wrappers for debugging.
-/* Generate terrain normals on the fly.
+/* Revision 1.10 1997/12/30 20:47:54 curt
+/* Integrated new event manager with subsystem initializations.
/*
+ * Revision 1.9 1997/12/30 16:36:54 curt
+ * Merged in Durk's changes ...
+ *
+ * Revision 1.8 1997/12/19 23:35:00 curt
+ * Lot's of tweaking with sky rendering and lighting.
+ *
+ * Revision 1.7 1997/12/17 23:12:16 curt
+ * Fixed so moon and sun display lists aren't recreate periodically.
+ *
+ * Revision 1.6 1997/12/15 23:55:04 curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
* Revision 1.5 1997/12/12 21:41:31 curt
* More light/material property tweaking ... still a ways off.
*