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);
+
+
+
+
+
double rightAscension, declination;
double r, R, s, FV;
double magnitude;
+ double lonEcl, latEcl;
double fgCalcEccAnom(double M, double e);
double fgCalcActTime(fgTIME *t);
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);
};
*magn = magnitude;
}
+inline double CelestialBody::getLon()
+{
+ return lonEcl;
+}
+
+inline double CelestialBody::getLat()
+{
+ return latEcl;
+}
#endif // _CELESTIALBODY_H_
* (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)
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.)
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;
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.
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)
-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)
-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);
// 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 *
/************************************************************************
- * 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.
*
* 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);
-
- //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);
-
- 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);
+ 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,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
+
+ }
+ else
+ {
+ }
}
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();
};
#include <XGL/xgl.h>
#include <Debug/logstream.hxx>
#include <Time/sunpos.hxx>
+#include <Time/moonpos.hxx>
#include "solarsystem.hxx"
/***************************************************************************
displayList = 0;
};
-/* --------------------------------------------------------------------------
- the destructor for class SolarSystem;
- danger: Huge Explosions ahead! (-:))
- ------------------------------------------------------------------------*/
+/**************************************************************************
+ * the destructor for class SolarSystem;
+ **************************************************************************/
SolarSystem::~SolarSystem()
{
delete ourSun;
delete saturn;
delete uranus;
delete neptune;
- //delete pluto;
}
/****************************************************************************
* void SolarSystem::rebuild()
***************************************************************************/
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);
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);
-
- // 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;
+ // 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...
- 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
- }
+ earthsMoon->newImage();
+ // Step 2b: Add the sun
+ //xglPushMatrix();
+ //{
+ ourSun->newImage();
+ //}
+ //xglPopMatrix();
// Step 2c: Add the planets
xglBegin(GL_POINTS);
mercury->getPos(&ra, &dec, &magnitude);addPlanetToList(ra, dec, magnitude);
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);
# define exception c_exception
#endif
#include <math.h>
-
+#include <Time/sunpos.hxx>
+#include <Debug/logstream.hxx>
+#include <Time/light.hxx>
#include "star.hxx"
/*************************************************************************
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)
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
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
+ }
+}
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();
};
return w;
}
-inline double Star::getLon()
-{
- return longitude;
-}
-
inline double Star::getxs()
{
return xs;