From 7ea54d28cdf9793e4d8a00e87a396dc1662d4ee4 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 9 Dec 1997 05:11:54 +0000 Subject: [PATCH] Working on tweaking lighting. --- Scenery/moon.c | 66 +++++++++++++++++++++++--------------------------- Scenery/sun.c | 49 ++++++++++++++++++++++++------------- 2 files changed, 62 insertions(+), 53 deletions(-) diff --git a/Scenery/moon.c b/Scenery/moon.c index 56788d65..d8c82cdd 100644 --- a/Scenery/moon.c +++ b/Scenery/moon.c @@ -31,10 +31,10 @@ #include "../Main/views.h" #include "../Time/fg_time.h" -struct CelestialCoord - moonPos; +struct CelestialCoord moonPos; float xMoon, yMoon, zMoon; +GLint moon; /* static GLfloat vdata[12][3] = @@ -52,8 +52,6 @@ static GLuint tindices[20][3] = {6,1,10}, {9,0,11}, {9,11,2}, {9,2,5}, {7,2,11} };*/ -GLint moon; - /* ------------------------------------------------------------- This section contains the code that generates a yellow Icosahedron. It's under development... (of Course) @@ -226,57 +224,53 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params, } -void fgMoonInit() -{ +void fgMoonInit() { // int i; -// moon = glGenLists(1); -// glNewList(moon, GL_COMPILE ); - - fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params); - moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0], cur_time_params); - #ifdef DEBUG - printf("Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension, moonPos.Declination); - #endif - glColor3f(1.0, 1.0, 0.0); + moon = glGenLists(1); + glNewList(moon, GL_COMPILE ); - /* xMoon = 90000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); - yMoon = 90000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); - zMoon = 90000.0 * sin(moonPos.Declination); */ + fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params); + moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0], + cur_time_params); +#ifdef DEBUG + printf("Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension, + moonPos.Declination); +#endif - xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); - yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); - zMoon = 60000.0 * sin(moonPos.Declination); + /* xMoon = 90000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); + yMoon = 90000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); + zMoon = 90000.0 * sin(moonPos.Declination); */ -// glPushMatrix(); -// glBegin(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); + xMoon = 60000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination); + yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination); + zMoon = 60000.0 * sin(moonPos.Declination); -// glEnd(); -// glPopMatrix(); -// glEndList(); + glColor3f(1.0, 1.0, 1.0); + glutSolidSphere(1.0, 10, 10); + + glEndList(); } /* Draw the moon */ void fgMoonRender() { + struct fgLIGHT *l; GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; + l = &cur_light_params; + /* set lighting parameters */ - glLightfv(GL_LIGHT0, GL_AMBIENT, color ); + glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear ); glLightfv(GL_LIGHT0, GL_DIFFUSE, color ); - glMaterialfv(GL_FRONT, GL_AMBIENT, fgClearColor); - glMaterialfv(GL_FRONT, GL_DIFFUSE, color); glPushMatrix(); glTranslatef(xMoon, yMoon, zMoon); glScalef(1400, 1400, 1400); + + /* glColor3fv(color); */ /* glutSolidSphere(1.0, 25, 25); */ - glutSolidSphere(1.0, 15, 15); + glCallList(moon); + glPopMatrix(); } diff --git a/Scenery/sun.c b/Scenery/sun.c index 92e022f6..f4ae4e9b 100644 --- a/Scenery/sun.c +++ b/Scenery/sun.c @@ -30,8 +30,7 @@ GLint sun; -static struct CelestialCoord - sunPos; +static struct CelestialCoord sunPos; float xSun, ySun, zSun; @@ -95,15 +94,20 @@ struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t) void fgSunInit() { // int i; -// sun = glGenLists(1); -// glNewList(sun, GL_COMPILE ); + + sun = glGenLists(1); + glNewList(sun, GL_COMPILE ); + // glBegin( GL_POINTS ); - fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params); - sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params); - #ifdef DEBUG - printf("Sun found at %f (ra), %f (dec)\n", sunPos.RightAscension, sunPos.Declination); - #endif - /* give the moon a temporary color, for testing purposes */ + + fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params); + sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params); +#ifdef DEBUG + printf("Sun found at %f (ra), %f (dec)\n", sunPos.RightAscension, + sunPos.Declination); +#endif + + /* give the moon a temporary color, for testing purposes */ // glColor3f( 0.0, 1.0, 0.0); // glVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination), // 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination), @@ -114,6 +118,7 @@ void fgSunInit() //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); @@ -129,8 +134,12 @@ void fgSunInit() // glutSolidSphere(1.0, 25, 25); // glEnd(); - //glPopMatrix(); -// glEndList(); + //glPopMatrix(); + + glColor3f(0.85, 0.65, 0.05); + glutSolidSphere(1.0, 10, 10); + + glEndList(); } @@ -176,22 +185,28 @@ void fgSunRender() { glMaterialfv(GL_FRONT, GL_DIFFUSE, diff); */ glDisable( GL_LIGHTING ); + glPushMatrix(); glTranslatef(xSun, ySun, zSun); glScalef(1400, 1400, 1400); - glColor3fv( color ); + + /* glColor3fv( color ); */ /* glutSolidSphere(1.0, 25, 25); */ - glutSolidSphere(1.0, 10, 10); - //glCallList(sun); + glCallList(sun); + glPopMatrix(); + glEnable( GL_LIGHTING ); } /* $Log$ -/* Revision 1.2 1997/11/25 19:25:39 curt -/* Changes to integrate Durk's moon/sun code updates + clean up. +/* Revision 1.3 1997/12/09 05:11:56 curt +/* Working on tweaking lighting. /* + * Revision 1.2 1997/11/25 19:25:39 curt + * Changes to integrate Durk's moon/sun code updates + clean up. + * * Revision 1.1 1997/10/25 03:16:11 curt * Initial revision of code contributed by Durk Talsma. * -- 2.39.5