1
0
Fork 0

Updates contributed by Durk Talsma.

This commit is contained in:
curt 1999-06-15 19:55:31 +00:00
parent c5427a287d
commit 5872f0fd68
5 changed files with 16 additions and 185 deletions

View file

@ -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
{

View file

@ -50,7 +50,6 @@ public:
~Moon();
void updatePosition(FGTime *t, Star *ourSun);
void newImage();
void castShadow();
};

View file

@ -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);

View file

@ -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();
}
}

View file

@ -51,7 +51,6 @@ public:
double getys();
double getDistance();
void newImage();
void drawHalo();
};