Changes contributed by Durk Talsma:

Here's a few changes I made to fg-0.58 this weekend. Included are the
following features:
- Sun and moon have a halo
- The moon has a light vector, moon_angle, etc. etc. so that we can have
  some moonlight during the night.
- Lot's of small changes tweakes, including some stuff Norman Vine sent
  me earlier.
This commit is contained in:
curt
1999-03-22 02:08:05 +00:00
committed by Tim Moore
parent 510b9ef07a
commit ca444b07bd
8 changed files with 440 additions and 124 deletions

View File

@@ -77,7 +77,10 @@ void CelestialBody::updatePosition(fgTIME *t, Star *ourSun)
xg = xh + ourSun->getxs();
yg = yh + ourSun->getys();
zg = zh;
lonEcl = atan2(yh, xh);
latEcl = atan2(zh, sqrt(xh*xh+yh*yh));
xe = xg;
ye = yg * cos(ecl) - zg * sin(ecl);
ze = yg * sin(ecl) + zg * cos(ecl);
@@ -167,3 +170,8 @@ double CelestialBody::fgCalcEccAnom(double M, double e)

View File

@@ -59,6 +59,7 @@ protected: // make the data protected, in order to give the inherit
double rightAscension, declination;
double r, R, s, FV;
double magnitude;
double lonEcl, latEcl;
double fgCalcEccAnom(double M, double e);
double fgCalcActTime(fgTIME *t);
@@ -73,6 +74,8 @@ public:
double Mf, double Ms, fgTIME *t);
void getPos(double *ra, double *dec);
void getPos(double *ra, double *dec, double *magnitude);
double getLon();
double getLat();
void updatePosition(fgTIME *t, Star *ourSun);
};
@@ -168,6 +171,15 @@ inline void CelestialBody::getPos(double* ra, double* dec, double* magn)
*magn = magnitude;
}
inline double CelestialBody::getLon()
{
return lonEcl;
}
inline double CelestialBody::getLat()
{
return latEcl;
}
#endif // _CELESTIALBODY_H_

View File

@@ -23,21 +23,19 @@
* (Log is kept at end of this file)
**************************************************************************/
#include <FDM/flight.hxx>
#include <string.h>
#include "moon.hxx"
#include <Debug/logstream.hxx>
#include <Objects/texload.h>
#include <FDM/flight.hxx>
#ifdef __BORLANDC__
# define exception c_exception
#endif
#include <math.h>
#include "moon.hxx"
static GLuint moon_texid;
static GLubyte *moon_texbuf;
/*************************************************************************
* Moon::Moon(fgTIME *t)
@@ -97,7 +95,95 @@ Moon::Moon(fgTIME *t) :
0,
GL_RGB, GL_UNSIGNED_BYTE,
moon_texbuf);
// setup the halo texture
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Moon Texture");
#ifdef GL_VERSION_1_1
xglGenTextures(1, &moon_halotexid);
xglBindTexture(GL_TEXTURE_2D, moon_halotexid);
#elif GL_EXT_texture_object
xglGenTexturesEXT(1, &moon_halotexid);
xglBindTextureEXT(GL_TEXTURE_2D, moon_halotexid);
#else
# error port me
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
setHalo();
glTexImage2D( GL_TEXTURE_2D,
0,
GL_RGBA,
256, 256,
0,
GL_RGBA, GL_UNSIGNED_BYTE,
moon_halotexbuf);
moonObject = gluNewQuadric();
}
Moon::~Moon()
{
//delete moonObject;
delete moon_texbuf;
delete moon_halotexbuf;
}
static int texWidth = 256; /* 64x64 is plenty */
void Moon::setHalo()
{
int texSize;
//void *textureBuf;
GLubyte *p;
int i,j;
double radius;
texSize = texWidth*texWidth;
moon_halotexbuf = new GLubyte[texSize*4];
if (!moon_halotexbuf)
return; // Ugly!
p = moon_halotexbuf;
radius = (double)(texWidth / 2);
for (i=0; i < texWidth; i++) {
for (j=0; j < texWidth; j++) {
double x, y, d;
x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y));
if (d < radius)
{
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice
*p = (int)((double)0xff * (t * t));
*(p+1) = (int)((double) 0xff * (t*t));
*(p+2) = (int)((double) 0xff * (t*t));
*(p+3) = 0x11;
}
else
{
*p = 0x00;
*(p+1) = 0x00;
*(p+2) = 0x00;
*(p+3) = 0x11;
}
p += 4;
}
}
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
// GL_LUMINANCE,
// GL_UNSIGNED_BYTE, textureBuf);
//free(textureBuf);
}
/*****************************************************************************
* void Moon::updatePosition(fgTIME *t, Star *ourSun)
* this member function calculates the actual topocentric position (i.e.)
@@ -107,7 +193,7 @@ Moon::Moon(fgTIME *t) :
void Moon::updatePosition(fgTIME *t, Star *ourSun)
{
double
eccAnom, ecl, lonecl, latecl, actTime,
eccAnom, ecl, actTime,
xv, yv, v, r, xh, yh, zh, xg, yg, zg, xe, ye, ze,
Ls, Lm, D, F, mpar, gclat, rho, HA, g,
geoRa, geoDec;
@@ -136,8 +222,8 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
zh = r * (sin(v+w) * sin(i));
// calculate the ecliptic latitude and longitude here
lonecl = atan2 (yh, xh);
latecl = atan2(zh, sqrt(xh*xh + yh*yh));
lonEcl = atan2 (yh, xh);
latEcl = atan2(zh, sqrt(xh*xh + yh*yh));
/* Calculate a number of perturbatioin, i.e. disturbances caused by the
* gravitational infuence of the sun and the other major planets.
@@ -147,7 +233,7 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
D = Lm - Ls;
F = Lm - N;
lonecl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
lonEcl += DEG_TO_RAD * (-1.274 * sin (M - 2*D)
+0.658 * sin (2*D)
-0.186 * sin(ourSun->getM())
-0.059 * sin(2*M - 2*D)
@@ -160,7 +246,7 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
-0.015 * sin(2*F - 2*D)
+0.011 * sin(M - 4*D)
);
latecl += DEG_TO_RAD * (-0.173 * sin(F-2*D)
latEcl += DEG_TO_RAD * (-0.173 * sin(F-2*D)
-0.055 * sin(M - F - 2*D)
-0.046 * sin(M + F - 2*D)
+0.033 * sin(F + 2*D)
@@ -170,9 +256,9 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
-0.46 * cos(2*D)
);
FG_LOG(FG_GENERAL, FG_INFO, "Running moon update");
xg = r * cos(lonecl) * cos(latecl);
yg = r * sin(lonecl) * cos(latecl);
zg = r * sin(latecl);
xg = r * cos(lonEcl) * cos(latEcl);
yg = r * sin(lonEcl) * cos(latEcl);
zg = r * sin(latEcl);
xe = xg;
ye = yg * cos(ecl) -zg * sin(ecl);
@@ -185,7 +271,7 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
// topocentric ra and dec. i.e. the position as seen from the
// surface of the earth, instead of the center of the earth
// First calculates the moon's parrallax, that is, the apparent size of the
// First calculate the moon's parrallax, that is, the apparent size of the
// (equatorial) radius of the earth, as seen from the moon
mpar = asin ( 1 / r);
gclat = f->get_Latitude() - 0.003358 *
@@ -202,7 +288,7 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
/************************************************************************
* void Moon::newImage(float ra, float dec)
* void Moon::newImage()
*
* This function regenerates a new visual image of the moon, which is added to
* solarSystem display list.
@@ -211,24 +297,93 @@ void Moon::updatePosition(fgTIME *t, Star *ourSun)
*
* return value: none
**************************************************************************/
void Moon::newImage(float ra, float dec)
void Moon::newImage()
{
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, moon_texid);
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;
//xglRotatef(-90, 0.0, 0.0, 1.0);
xglRotatef(((RAD_TO_DEG * ra)- 90.0), 0.0, 0.0, 1.0);
xglRotatef((RAD_TO_DEG * dec), 1.0, 0.0, 0.0);
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,1.0};
if( moon_angle*RAD_TO_DEG < 100 )
{
/*
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);
FG_LOG( FG_GENERAL, FG_INFO,
"Ra = (" << (RAD_TO_DEG *rightAscension)
<< "), Dec= (" << (RAD_TO_DEG *declination) << ")" );
xglTranslatef(0.0, 58600.0, 0.0);
glEnable(GL_TEXTURE_2D); // TEXTURE ENABLED
glEnable(GL_BLEND); // BLEND ENABLED
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBindTexture(GL_TEXTURE_2D, moon_halotexid);
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();
xglEnable(GL_LIGHTING); // LIGHTING ENABLED
xglEnable( GL_LIGHT0 );
// set lighting parameters
xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
xglEnable( GL_CULL_FACE );
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
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);
glBindTexture(GL_TEXTURE_2D, moon_texid);
//glDisable(GL_LIGHTING); // LIGHTING DISABLED
gluQuadricTexture(moonObject, GL_TRUE );
gluSphere(moonObject, moonSize, 12, 12 );
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
}
xglPopMatrix();
glDisable(GL_LIGHTING); // LIGHTING DISABLED
FG_LOG( FG_GENERAL, FG_INFO,
"Ra = (" << (RAD_TO_DEG *ra)
<< "), Dec= (" << (RAD_TO_DEG *dec) << ")" );
xglTranslatef(0.0, 58600.0, 0.0);
Object = gluNewQuadric();
gluQuadricTexture( Object, GL_TRUE );
gluSphere( Object, 1367, 12, 12 );
glDisable(GL_TEXTURE_2D);
}
else
{
}
}

View File

@@ -38,13 +38,19 @@ class Moon : public CelestialBody
private:
void TexInit(); // This should move to the constructor eventually.
GLUquadricObj *Object;
GLUquadricObj *moonObject;
GLuint Sphere;
GLuint moon_texid;
GLuint moon_halotexid;
GLubyte *moon_texbuf;
GLubyte *moon_halotexbuf;
void setHalo();
public:
Moon ( fgTIME *t);
~Moon();
void updatePosition(fgTIME *t, Star *ourSun);
void newImage(float, float);
void newImage();
};

View File

@@ -40,6 +40,7 @@
#include <XGL/xgl.h>
#include <Debug/logstream.hxx>
#include <Time/sunpos.hxx>
#include <Time/moonpos.hxx>
#include "solarsystem.hxx"
/***************************************************************************
@@ -69,10 +70,9 @@ SolarSystem::SolarSystem(fgTIME *t)
displayList = 0;
};
/* --------------------------------------------------------------------------
the destructor for class SolarSystem;
danger: Huge Explosions ahead! (-:))
------------------------------------------------------------------------*/
/**************************************************************************
* the destructor for class SolarSystem;
**************************************************************************/
SolarSystem::~SolarSystem()
{
delete ourSun;
@@ -84,7 +84,6 @@ SolarSystem::~SolarSystem()
delete saturn;
delete uranus;
delete neptune;
//delete pluto;
}
/****************************************************************************
* void SolarSystem::rebuild()
@@ -97,19 +96,19 @@ SolarSystem::~SolarSystem()
***************************************************************************/
void SolarSystem::rebuild()
{
fgLIGHT *l = &cur_light_params;
//fgLIGHT *l = &cur_light_params;
fgTIME *t = &cur_time_params;
float x, y, z;
// float xx, yy,zz;
double sun_angle;
//float x, y, z;
//double sun_angle;
double ra, dec;
double x_2, x_4, x_8, x_10;
//double x_2, x_4, x_8, x_10;*/
double magnitude;
GLfloat ambient;
GLfloat amb[4];
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,1.0};
//GLfloat ambient;
//GLfloat amb[4];
glDisable(GL_LIGHTING);
// Step 1: update all the positions
ourSun->updatePosition(t);
@@ -123,75 +122,28 @@ void SolarSystem::rebuild()
neptune->updatePosition(t, ourSun);
fgUpdateSunPos(); // get the right sun angle (especially important when
// running for the first time.
// running for the first time).
fgUpdateMoonPos();
if (displayList)
xglDeleteLists(displayList, 1);
displayList = xglGenLists(1);
// Step 2: rebuild the display list
xglNewList( displayList, GL_COMPILE);
{
// Step 2a: Add the moon...
xglEnable( GL_LIGHTING );
xglEnable( GL_LIGHT0 );
// set lighting parameters
xglLightfv(GL_LIGHT0, GL_AMBIENT, white );
xglLightfv(GL_LIGHT0, GL_DIFFUSE, white );
xglEnable( GL_CULL_FACE );
// Enable blending, in order to effectively eliminate the dark side of the
// moon
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
earthsMoon->getPos(&ra, &dec);
xglMaterialfv(GL_FRONT, GL_AMBIENT, black);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, moonColor);
xglPushMatrix();
{
earthsMoon->newImage(ra,dec);
}
xglPopMatrix();
glDisable(GL_BLEND);
xglDisable(GL_LIGHTING);
// 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...
earthsMoon->newImage();
// Step 2b: Add the sun
sun_angle = l->sun_angle;
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 = (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;
sun_angle = l->sun_angle * RAD_TO_DEG;
if ( sun_angle < 100 ) {
ourSun->getPos(&ra, &dec);
double cos_dec = cos(dec) * 60000.0;
x = cos(ra) * cos_dec;
y = sin(ra) * cos_dec;
z = sin(dec) * 60000.0;
xglPushMatrix();
{
double sun_size = 1400.0;
xglTranslatef(x,y,z);
xglColor3fv(amb);
glutSolidSphere(sun_size, 10, 10);
}
glPopMatrix();
} else {
// sun angle > 100, no need to draw sun
}
//xglPushMatrix();
//{
ourSun->newImage();
//}
//xglPopMatrix();
// Step 2c: Add the planets
xglBegin(GL_POINTS);
mercury->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);

View File

@@ -62,21 +62,26 @@ private:
public:
SolarSystem(fgTIME *t);
Star *getSun();
CelestialBody *getSun();
CelestialBody *getMoon();
~SolarSystem();
static SolarSystem *theSolarSystem; // thanks to Bernie Bright!
void rebuild();
friend void solarSystemRebuild();
void draw();
};
inline Star * SolarSystem::getSun()
inline CelestialBody* SolarSystem::getSun()
{
return ourSun;
}
inline CelestialBody* SolarSystem::getMoon()
{
return earthsMoon;
}
inline void SolarSystem::draw()
{
xglCallList(displayList);

View File

@@ -27,7 +27,9 @@
# define exception c_exception
#endif
#include <math.h>
#include <Time/sunpos.hxx>
#include <Debug/logstream.hxx>
#include <Time/light.hxx>
#include "star.hxx"
/*************************************************************************
@@ -47,6 +49,100 @@ Star::Star(fgTIME *t) :
0.016709, -1.151E-9,
356.0470, 0.98560025850, t)
{
FG_LOG( FG_GENERAL, FG_INFO, "Initializing Sun Texture");
#ifdef GL_VERSION_1_1
xglGenTextures(1, &sun_texid);
xglBindTexture(GL_TEXTURE_2D, sun_texid);
#elif GL_EXT_texture_object
xglGenTexturesEXT(1, &sun_texid);
xglBindTextureEXT(GL_TEXTURE_2D, sun_texid);
#else
# error port me
#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
setTexture();
glTexImage2D( GL_TEXTURE_2D,
0,
GL_RGBA,
256, 256,
0,
GL_RGBA, GL_UNSIGNED_BYTE,
sun_texbuf);
SunObject = gluNewQuadric();
if(SunObject == NULL)
{
printf("gluNewQuadric(SunObject) failed !\n");
exit(0);
}
//SunList = 0;
distance = 0.0;
}
Star::~Star()
{
//delete SunObject;
delete [] sun_texbuf;
}
static int texWidth = 256; /* 64x64 is plenty */
void Star::setTexture()
{
int texSize;
//void *textureBuf;
GLubyte *p;
int i,j;
double radius;
texSize = texWidth*texWidth;
sun_texbuf = new GLubyte[texSize*4];
if (!sun_texbuf)
return; // Ugly!
p = sun_texbuf;
radius = (double)(texWidth / 2);
for (i=0; i < texWidth; i++) {
for (j=0; j < texWidth; j++) {
double x, y, d;
x = fabs((double)(i - (texWidth / 2)));
y = fabs((double)(j - (texWidth / 2)));
d = sqrt((x * x) + (y * y));
if (d < radius)
{
double t = 1.0 - (d / radius); // t is 1.0 at center, 0.0 at edge */
// inverse square looks nice
*p = (int)((double)0xff * (t * t));
*(p+1) = (int)((double) 0xff * (t*t));
*(p+2) = (int)((double) 0xff * (t*t));
*(p+3) = (int)((double) 0xff * (t*t));
}
else
{
*p = 0x00;
*(p+1) = 0x00;
*(p+2) = 0x00;
*(p+3) = 0x00;
}
p += 4;
}
}
//gluBuild2DMipmaps(GL_TEXTURE_2D, 1, texWidth, texWidth,
// GL_LUMINANCE,
// GL_UNSIGNED_BYTE, textureBuf);
//free(textureBuf);
}
/*************************************************************************
* void Jupiter::updatePosition(fgTIME *t, Star *ourSun)
@@ -71,12 +167,13 @@ void Star::updatePosition(fgTIME *t)
v = atan2 (yv, xv); // the sun's true anomaly
distance = r = sqrt (xv*xv + yv*yv); // and its distance
longitude = v + w; // the sun's true longitude
lonEcl = v + w; // the sun's true longitude
latEcl = 0;
// convert the sun's true longitude to ecliptic rectangular
// geocentric coordinates (xs, ys)
xs = r * cos (longitude);
ys = r * sin (longitude);
xs = r * cos (lonEcl);
ys = r * sin (lonEcl);
// convert ecliptic coordinates to equatorial rectangular
// geocentric coordinates
@@ -90,6 +187,85 @@ void Star::updatePosition(fgTIME *t)
declination = atan2 (ze, sqrt (xe*xe + ye*ye));
}
void Star::newImage(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);
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();
}
glPopMatrix();
xglDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
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,58600,0);
gluSphere( SunObject, sun_size, 10, 10 );
}
glPopMatrix();
glDisable(GL_TEXTURE_2D); // TEXTURE DISABLED
glDisable(GL_BLEND); // BLEND DISABLED
}
}

View File

@@ -32,19 +32,26 @@
class Star : public CelestialBody
{
private:
double longitude; // the sun's true longitude
//double longitude; // the sun's true longitude - this is depreciated by
// CelestialBody::lonEcl
double xs, ys; // the sun's rectangular geocentric coordinates
double distance; // the sun's distance to the earth
GLUquadricObj *SunObject;
GLuint sun_texid;
GLubyte *sun_texbuf;
void setTexture();
public:
Star (fgTIME *t);
~Star();
void updatePosition(fgTIME *t);
double getM();
double getw();
double getLon();
//double getLon();
double getxs();
double getys();
double getDistance();
void newImage();
};
@@ -59,11 +66,6 @@ inline double Star::getw()
return w;
}
inline double Star::getLon()
{
return longitude;
}
inline double Star::getxs()
{
return xs;