From: curt Date: Tue, 15 Jun 1999 19:55:31 +0000 (+0000) Subject: Updates contributed by Durk Talsma. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=5872f0fd68c8a4c5c555072ee7ea117277650af3;p=flightgear.git Updates contributed by Durk Talsma. --- diff --git a/Simulator/Astro/moon.cxx b/Simulator/Astro/moon.cxx index 104cf2dc2..d109942a2 100644 --- a/Simulator/Astro/moon.cxx +++ b/Simulator/Astro/moon.cxx @@ -339,28 +339,8 @@ void Moon::newImage() { FG_LOG( FG_ASTRO, FG_INFO, "Generating Moon Image" ); - /* - x_2 = moon_angle * moon_angle; - x_4 = x_2 * x_2; - x_8 = x_4 * x_4; - x_10 = x_8 * x_2; - ambient = (float)(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] = ((ambient * 6.0) - 1.0); // minimum value = 0.8 - amb[1] = ((ambient * 11.0) - 3.0); // minimum value = 0.3 - amb[2] = ((ambient * 12.0) - 3.6); // minimum value = 0.0 - amb[3] = 1.00; - - if (amb[0] > 1.0) amb[0] = 1.0; - if (amb[1] > 1.0) amb[1] = 1.0; - if (amb[2] > 1.0) amb[2] = 1.0; - xglColor3fv(amb); - xglColor3f(1.0, 1.0, 1.0); */ xglPushMatrix(); { - //xglRotatef(-90, 0.0, 0.0, 1.0); xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0); xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0); @@ -368,12 +348,13 @@ void Moon::newImage() "Ra = (" << (RAD_TO_DEG *rightAscension) << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); xglTranslatef(0.0, 60000.0, 0.0); - glEnable(GL_BLEND); // BLEND ENABLED + glEnable(GL_BLEND); // BLEND ENABLED + // Draw the halo... if (current_options.get_textures()) { glBlendFunc(GL_SRC_ALPHA, GL_ONE); - glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED + glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, moon_halotexid); @@ -385,7 +366,7 @@ void Moon::newImage() glEnd(); } - xglEnable(GL_LIGHTING); // LIGHTING ENABLED + xglEnable(GL_LIGHTING); // LIGHTING ENABLED xglEnable( GL_LIGHT0 ); // set lighting parameters xglLightfv(GL_LIGHT0, GL_AMBIENT, white ); @@ -395,76 +376,24 @@ void Moon::newImage() xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor); //glEnable(GL_TEXTURE_2D); + glBlendFunc(GL_ONE, GL_ONE); //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + // Draw the moon-proper + if (current_options.get_textures()) { glBindTexture(GL_TEXTURE_2D, moon_texid); - // glDisable(GL_LIGHTING); // LIGHTING DISABLED gluQuadricTexture(moonObject, GL_TRUE ); - // glDisable(GL_LIGHTING); - // glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED } - //glDisable(GL_LIGHTING); // for testing - //glDisable(GL_BLEND); // also for testing - //glColor3f(1.0, 0.0, 0.0); // also also for testing gluSphere(moonObject, moonSize, 12, 12 ); - //glDisable(GL_LIGHTING); // LIGHTING DISABLED - //glColor4fv(white); - //glBlendFunc(GL_ZERO, GL_SRC_COLOR); // Set alpha to zero - //gluSphere(moonObject, moonSize, 12, 12 ); - glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED - glDisable(GL_BLEND); // BLEND DISABLED + glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED + glDisable(GL_BLEND); // BLEND DISABLED } xglPopMatrix(); - glDisable(GL_LIGHTING); - } - else - { - } -} - - -void Moon::castShadow() -{ - fgLIGHT *l = &cur_light_params; - float moon_angle = l->moon_angle; - - /*double x_2, x_4, x_8, x_10; - GLfloat ambient; - GLfloat amb[4];*/ - int moonSize = 750; - - GLfloat moonColor[4] = {0.85, 0.75, 0.35, 1.0}; - GLfloat black[4] = {0.0, 0.0, 0.0, 1.0}; - GLfloat white[4] = {1.0, 1.0, 1.0, 0.0}; - - if( moon_angle*RAD_TO_DEG < 100 ) - { - xglPushMatrix(); - { - //xglRotatef(-90, 0.0, 0.0, 1.0); - xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0); - xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0); - - FG_LOG( FG_GENERAL, FG_INFO, - "Ra = (" << (RAD_TO_DEG *rightAscension) - << "), Dec= (" << (RAD_TO_DEG *declination) << ")" ); - xglTranslatef(0.0, 60000.0, 0.0); - glEnable(GL_BLEND); // BLEND ENABLED - - glDisable(GL_LIGHTING); // LIGHTING DISABLED - //glColor4fv(white); - glColor4f(1.0, 1.0, 1.0, 0.0); - glBlendFunc(GL_ZERO, GL_SRC_COLOR); // Set alpha to zero - //glBlendFunc(GL_ZERO,GL_ZERO); - gluSphere(moonObject, moonSize, 12, 12 ); - glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED - glDisable(GL_BLEND); // BLEND DISABLED - } - xglPopMatrix(); - + glDisable(GL_LIGHTING); // Lighting Disabled. + } else { diff --git a/Simulator/Astro/moon.hxx b/Simulator/Astro/moon.hxx index 5f728bea2..62451601e 100644 --- a/Simulator/Astro/moon.hxx +++ b/Simulator/Astro/moon.hxx @@ -50,7 +50,6 @@ public: ~Moon(); void updatePosition(FGTime *t, Star *ourSun); void newImage(); - void castShadow(); }; diff --git a/Simulator/Astro/solarsystem.cxx b/Simulator/Astro/solarsystem.cxx index dee40dce3..56c78d8e8 100644 --- a/Simulator/Astro/solarsystem.cxx +++ b/Simulator/Astro/solarsystem.cxx @@ -135,16 +135,11 @@ void SolarSystem::rebuild() // Step 2a: Add the moon... // Not that it is preferred to draw the moon first, and the sun next, in order to mime a // solar eclipse. This is yet untested though... + // Euhh, actually the ecplise doesn't work... earthsMoon->newImage(); // Step 2b: Add the sun - //xglPushMatrix(); - //{ - //ourSun->drawHalo(); - //earthsMoon->castShadow(); ourSun->newImage(); - //} - //xglPopMatrix(); // Step 2c: Add the planets xglBegin(GL_POINTS); mercury->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude); diff --git a/Simulator/Astro/star.cxx b/Simulator/Astro/star.cxx index 2e7393d8f..e41c7eaf4 100644 --- a/Simulator/Astro/star.cxx +++ b/Simulator/Astro/star.cxx @@ -238,9 +238,6 @@ void Star::newImage(void) glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED glEnable(GL_BLEND); // BLEND ENABLED - //glEnable(GL_TEXTURE_2D); - //glEnable(GL_BLEND); - //glDisable(GL_LIGHTING); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glBindTexture(GL_TEXTURE_2D, sun_texid); @@ -252,30 +249,15 @@ void Star::newImage(void) glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000); glEnd(); } - xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED - glDisable(GL_BLEND); // BLEND DISABLED + xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED + xglDisable(GL_BLEND); // BLEND DISABLED } glPopMatrix(); - glDisable(GL_LIGHTING); - /*glPushMatrix(); // Draw a black object, that serves as the moon's shadow. - { - xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0); - xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0); - xglTranslatef(0,60000,0); - //xglTranslatef(0,58600,0); - //gluSphere( SunObject, sun_size, 10, 10 ); - glEnable(GL_BLEND); - glBlendFunc(GL_ZERO, GL_ZERO); - xglColor4f(0.0, 0.0, 0.0, 0.0); - gluSphere( SunObject, sun_size, 10, 10 ); - } - glPopMatrix();*/ - glDisable(GL_BLEND); + glDisable(GL_LIGHTING); //LIGHTING DISABLED + glDisable(GL_BLEND); //BLEND DISABLED glPushMatrix(); { - //xglEnable(GL_BLEND); - //xglBlendFunc(GL_SRC_ALPHA, GL_ONE); xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0); xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0); xglColor4fv(amb); @@ -287,76 +269,3 @@ void Star::newImage(void) glDisable(GL_BLEND); // BLEND DISABLED } } - - -void Star::drawHalo(void) -{ - /*static float stars[3]; - stars[0] = 0.0; - stars[1] = 0.0; - stars[2] = 1.0;*/ - - fgLIGHT *l = &cur_light_params; - float sun_angle = l->sun_angle; - - if( sun_angle*RAD_TO_DEG < 100 ) { // else no need to draw sun - - - double x_2, x_4, x_8, x_10; - GLfloat ambient; - GLfloat amb[4]; - int sun_size = 750; - - // daily variation sun gets larger near horizon - /*if(sun_angle*RAD_TO_DEG > 84.0 && sun_angle*RAD_TO_DEG < 95) - { - double sun_grow = 9*fabs(94-sun_angle*RAD_TO_DEG); - sun_size = (int)(sun_size + sun_size * cos(sun_grow*DEG_TO_RAD)); - }*/ - x_2 = sun_angle * sun_angle; - x_4 = x_2 * x_2; - x_8 = x_4 * x_4; - x_10 = x_8 * x_2; - ambient = (float)(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] = ((ambient * 6.0) - 1.0); // minimum value = 0.8 - amb[1] = ((ambient * 11.0) - 3.0); // minimum value = 0.3 - amb[2] = ((ambient * 12.0) - 3.6); // minimum value = 0.0 - amb[3] = 1.00; - - if (amb[0] > 1.0) amb[0] = 1.0; - if (amb[1] > 1.0) amb[1] = 1.0; - if (amb[2] > 1.0) amb[2] = 1.0; - xglColor3fv(amb); - glPushMatrix(); - { - xglRotatef(((RAD_TO_DEG * rightAscension)- 90.0), 0.0, 0.0, 1.0); - xglRotatef((RAD_TO_DEG * declination), 1.0, 0.0, 0.0); - xglTranslatef(0,60000,0); - if (current_options.get_textures()) - { - glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED - glEnable(GL_BLEND); // BLEND ENABLED - - //glEnable(GL_TEXTURE_2D); - //glEnable(GL_BLEND); - //glDisable(GL_LIGHTING); - //glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - //glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glBindTexture(GL_TEXTURE_2D, sun_texid); - - glBegin(GL_QUADS); - glTexCoord2f(0.0f, 0.0f); glVertex3f(-5000, 0.0, -5000); - glTexCoord2f(1.0f, 0.0f); glVertex3f( 5000, 0.0, -5000); - glTexCoord2f(1.0f, 1.0f); glVertex3f( 5000, 0.0, 5000); - glTexCoord2f(0.0f, 1.0f); glVertex3f(-5000, 0.0, 5000); - glEnd(); - } - xglDisable(GL_TEXTURE_2D); // TEXTURE DISABLED - glDisable(GL_BLEND); // BLEND DISABLED - } - glPopMatrix(); - } -} diff --git a/Simulator/Astro/star.hxx b/Simulator/Astro/star.hxx index 0de6713ac..6eb7a4c90 100644 --- a/Simulator/Astro/star.hxx +++ b/Simulator/Astro/star.hxx @@ -51,7 +51,6 @@ public: double getys(); double getDistance(); void newImage(); - void drawHalo(); };