Working on tweaking lighting.
This commit is contained in:
parent
4ab16fd58e
commit
330ff4ab53
4 changed files with 93 additions and 76 deletions
|
@ -144,10 +144,11 @@ static void fgUpdateViewParams() {
|
||||||
struct fgLIGHT *l;
|
struct fgLIGHT *l;
|
||||||
struct fgTIME *t;
|
struct fgTIME *t;
|
||||||
struct VIEW *v;
|
struct VIEW *v;
|
||||||
|
|
||||||
double x_2, x_4, x_8, x_10;
|
double x_2, x_4, x_8, x_10;
|
||||||
double ambient, diffuse, sky;
|
double ambient, diffuse, sky;
|
||||||
GLfloat color[4] = { 1.0, 1.0, 0.50, 1.0 };
|
GLfloat color[4] = { 1.0, 1.0, 0.50, 1.0 };
|
||||||
GLfloat amb[3], diff[3], fog[4], clear[4];
|
/* GLfloat amb[3], diff[3], fog[4], clear[4]; */
|
||||||
|
|
||||||
f = ¤t_aircraft.flight;
|
f = ¤t_aircraft.flight;
|
||||||
l = &cur_light_params;
|
l = &cur_light_params;
|
||||||
|
@ -203,31 +204,32 @@ static void fgUpdateViewParams() {
|
||||||
|
|
||||||
if ( sky < 0.0 ) { sky = 0.0; }
|
if ( sky < 0.0 ) { sky = 0.0; }
|
||||||
|
|
||||||
amb[0] = color[0] * ambient;
|
l->scene_ambient[0] = color[0] * ambient;
|
||||||
amb[1] = color[1] * ambient;
|
l->scene_ambient[1] = color[1] * ambient;
|
||||||
amb[2] = color[2] * ambient;
|
l->scene_ambient[2] = color[2] * ambient;
|
||||||
|
|
||||||
diff[0] = color[0] * diffuse;
|
l->scene_diffuse[0] = color[0] * diffuse;
|
||||||
diff[1] = color[1] * diffuse;
|
l->scene_diffuse[1] = color[1] * diffuse;
|
||||||
diff[2] = color[2] * diffuse;
|
l->scene_diffuse[2] = color[2] * diffuse;
|
||||||
|
|
||||||
/* set lighting parameters */
|
/* set lighting parameters */
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, amb );
|
glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_ambient );
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, diff );
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, l->scene_diffuse );
|
||||||
|
|
||||||
/* set fog color */
|
/* set fog color */
|
||||||
fog[0] = fgFogColor[0] * (ambient + diffuse);
|
l->scene_fog[0] = fgFogColor[0] * (ambient + diffuse);
|
||||||
fog[1] = fgFogColor[1] * (ambient + diffuse);
|
l->scene_fog[1] = fgFogColor[1] * (ambient + diffuse);
|
||||||
fog[2] = fgFogColor[2] * (ambient + diffuse);
|
l->scene_fog[2] = fgFogColor[2] * (ambient + diffuse);
|
||||||
fog[3] = fgFogColor[3];
|
l->scene_fog[3] = fgFogColor[3];
|
||||||
glFogfv (GL_FOG_COLOR, fog);
|
glFogfv (GL_FOG_COLOR, l->scene_fog);
|
||||||
|
|
||||||
/* set sky color */
|
/* set sky color */
|
||||||
clear[0] = fgClearColor[0] * sky;
|
l->scene_clear[0] = fgClearColor[0] * sky;
|
||||||
clear[1] = fgClearColor[1] * sky;
|
l->scene_clear[1] = fgClearColor[1] * sky;
|
||||||
clear[2] = fgClearColor[2] * sky;
|
l->scene_clear[2] = fgClearColor[2] * sky;
|
||||||
clear[3] = fgClearColor[3];
|
l->scene_clear[3] = fgClearColor[3];
|
||||||
glClearColor(clear[0], clear[1], clear[2], clear[3]);
|
glClearColor(l->scene_clear[0], l->scene_clear[1],
|
||||||
|
l->scene_clear[2], l->scene_clear[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -581,9 +583,12 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.26 1997/12/09 04:25:29 curt
|
/* Revision 1.27 1997/12/09 05:11:54 curt
|
||||||
/* Working on adding a global lighting params structure.
|
/* Working on tweaking lighting.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.26 1997/12/09 04:25:29 curt
|
||||||
|
* Working on adding a global lighting params structure.
|
||||||
|
*
|
||||||
* Revision 1.25 1997/12/08 22:54:09 curt
|
* Revision 1.25 1997/12/08 22:54:09 curt
|
||||||
* Enabled GL_CULL_FACE.
|
* Enabled GL_CULL_FACE.
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
#include "../Main/views.h"
|
#include "../Main/views.h"
|
||||||
#include "../Time/fg_time.h"
|
#include "../Time/fg_time.h"
|
||||||
|
|
||||||
struct CelestialCoord
|
struct CelestialCoord moonPos;
|
||||||
moonPos;
|
|
||||||
|
|
||||||
float xMoon, yMoon, zMoon;
|
float xMoon, yMoon, zMoon;
|
||||||
|
GLint moon;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
static GLfloat vdata[12][3] =
|
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}
|
{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
|
This section contains the code that generates a yellow
|
||||||
Icosahedron. It's under development... (of Course)
|
Icosahedron. It's under development... (of Course)
|
||||||
|
@ -226,18 +224,18 @@ struct CelestialCoord fgCalculateMoon(struct OrbElements params,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fgMoonInit()
|
void fgMoonInit() {
|
||||||
{
|
|
||||||
// int i;
|
// int i;
|
||||||
// moon = glGenLists(1);
|
moon = glGenLists(1);
|
||||||
// glNewList(moon, GL_COMPILE );
|
glNewList(moon, GL_COMPILE );
|
||||||
|
|
||||||
fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
|
fgSolarSystemUpdate(&(pltOrbElements[1]), cur_time_params);
|
||||||
moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0], cur_time_params);
|
moonPos = fgCalculateMoon(pltOrbElements[1], pltOrbElements[0],
|
||||||
#ifdef DEBUG
|
cur_time_params);
|
||||||
printf("Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension, moonPos.Declination);
|
#ifdef DEBUG
|
||||||
#endif
|
printf("Moon found at %f (ra), %f (dec)\n", moonPos.RightAscension,
|
||||||
glColor3f(1.0, 1.0, 0.0);
|
moonPos.Declination);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* xMoon = 90000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
|
/* xMoon = 90000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
|
||||||
yMoon = 90000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
yMoon = 90000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
||||||
|
@ -247,36 +245,32 @@ void fgMoonInit()
|
||||||
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
yMoon = 60000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
||||||
zMoon = 60000.0 * sin(moonPos.Declination);
|
zMoon = 60000.0 * sin(moonPos.Declination);
|
||||||
|
|
||||||
// glPushMatrix();
|
glColor3f(1.0, 1.0, 1.0);
|
||||||
// glBegin(GL_TRIANGLES);
|
glutSolidSphere(1.0, 10, 10);
|
||||||
/*
|
|
||||||
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);
|
|
||||||
|
|
||||||
// glEnd();
|
glEndList();
|
||||||
// glPopMatrix();
|
|
||||||
// glEndList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Draw the moon */
|
/* Draw the moon */
|
||||||
void fgMoonRender() {
|
void fgMoonRender() {
|
||||||
|
struct fgLIGHT *l;
|
||||||
GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 };
|
GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 };
|
||||||
|
|
||||||
|
l = &cur_light_params;
|
||||||
|
|
||||||
/* set lighting parameters */
|
/* set lighting parameters */
|
||||||
glLightfv(GL_LIGHT0, GL_AMBIENT, color );
|
glLightfv(GL_LIGHT0, GL_AMBIENT, l->scene_clear );
|
||||||
glLightfv(GL_LIGHT0, GL_DIFFUSE, color );
|
glLightfv(GL_LIGHT0, GL_DIFFUSE, color );
|
||||||
glMaterialfv(GL_FRONT, GL_AMBIENT, fgClearColor);
|
|
||||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, color);
|
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(xMoon, yMoon, zMoon);
|
glTranslatef(xMoon, yMoon, zMoon);
|
||||||
glScalef(1400, 1400, 1400);
|
glScalef(1400, 1400, 1400);
|
||||||
|
|
||||||
|
/* glColor3fv(color); */
|
||||||
/* glutSolidSphere(1.0, 25, 25); */
|
/* glutSolidSphere(1.0, 25, 25); */
|
||||||
glutSolidSphere(1.0, 15, 15);
|
glCallList(moon);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@
|
||||||
|
|
||||||
GLint sun;
|
GLint sun;
|
||||||
|
|
||||||
static struct CelestialCoord
|
static struct CelestialCoord sunPos;
|
||||||
sunPos;
|
|
||||||
|
|
||||||
float xSun, ySun, zSun;
|
float xSun, ySun, zSun;
|
||||||
|
|
||||||
|
@ -95,14 +94,19 @@ struct CelestialCoord fgCalculateSun(struct OrbElements params, struct fgTIME t)
|
||||||
void fgSunInit()
|
void fgSunInit()
|
||||||
{
|
{
|
||||||
// int i;
|
// int i;
|
||||||
// sun = glGenLists(1);
|
|
||||||
// glNewList(sun, GL_COMPILE );
|
sun = glGenLists(1);
|
||||||
|
glNewList(sun, GL_COMPILE );
|
||||||
|
|
||||||
// glBegin( GL_POINTS );
|
// glBegin( GL_POINTS );
|
||||||
|
|
||||||
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
|
fgSolarSystemUpdate(&(pltOrbElements[0]), cur_time_params);
|
||||||
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
|
sunPos = fgCalculateSun(pltOrbElements[0], cur_time_params);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Sun found at %f (ra), %f (dec)\n", sunPos.RightAscension, sunPos.Declination);
|
printf("Sun found at %f (ra), %f (dec)\n", sunPos.RightAscension,
|
||||||
#endif
|
sunPos.Declination);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* give the moon a temporary color, for testing purposes */
|
/* give the moon a temporary color, for testing purposes */
|
||||||
// glColor3f( 0.0, 1.0, 0.0);
|
// glColor3f( 0.0, 1.0, 0.0);
|
||||||
// glVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination),
|
// glVertex3f( 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination),
|
||||||
|
@ -114,6 +118,7 @@ void fgSunInit()
|
||||||
//xMoon = 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
|
//xMoon = 190000.0 * cos(moonPos.RightAscension) * cos(moonPos.Declination);
|
||||||
//yMoon = 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
//yMoon = 190000.0 * sin(moonPos.RightAscension) * cos(moonPos.Declination);
|
||||||
//zMoon = 190000.0 * sin(moonPos.Declination);
|
//zMoon = 190000.0 * sin(moonPos.Declination);
|
||||||
|
|
||||||
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
|
xSun = 60000.0 * cos(sunPos.RightAscension) * cos(sunPos.Declination);
|
||||||
ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
|
ySun = 60000.0 * sin(sunPos.RightAscension) * cos(sunPos.Declination);
|
||||||
zSun = 60000.0 * sin(sunPos.Declination);
|
zSun = 60000.0 * sin(sunPos.Declination);
|
||||||
|
@ -130,7 +135,11 @@ void fgSunInit()
|
||||||
|
|
||||||
// glEnd();
|
// glEnd();
|
||||||
//glPopMatrix();
|
//glPopMatrix();
|
||||||
// glEndList();
|
|
||||||
|
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); */
|
glMaterialfv(GL_FRONT, GL_DIFFUSE, diff); */
|
||||||
|
|
||||||
glDisable( GL_LIGHTING );
|
glDisable( GL_LIGHTING );
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glTranslatef(xSun, ySun, zSun);
|
glTranslatef(xSun, ySun, zSun);
|
||||||
glScalef(1400, 1400, 1400);
|
glScalef(1400, 1400, 1400);
|
||||||
glColor3fv( color );
|
|
||||||
|
/* glColor3fv( color ); */
|
||||||
/* glutSolidSphere(1.0, 25, 25); */
|
/* glutSolidSphere(1.0, 25, 25); */
|
||||||
glutSolidSphere(1.0, 10, 10);
|
glCallList(sun);
|
||||||
//glCallList(sun);
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
||||||
glEnable( GL_LIGHTING );
|
glEnable( GL_LIGHTING );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.2 1997/11/25 19:25:39 curt
|
/* Revision 1.3 1997/12/09 05:11:56 curt
|
||||||
/* Changes to integrate Durk's moon/sun code updates + clean up.
|
/* 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
|
* Revision 1.1 1997/10/25 03:16:11 curt
|
||||||
* Initial revision of code contributed by Durk Talsma.
|
* Initial revision of code contributed by Durk Talsma.
|
||||||
*
|
*
|
||||||
|
|
|
@ -233,7 +233,7 @@ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t) {
|
||||||
/* get current Unix calendar time (in seconds) */
|
/* get current Unix calendar time (in seconds) */
|
||||||
warp += 60;
|
warp += 60;
|
||||||
/* warp = 0; */
|
/* warp = 0; */
|
||||||
t->cur_time = time(NULL) + (0) * 60 * 60;
|
t->cur_time = time(NULL) + (12) * 60 * 60;
|
||||||
t->cur_time += warp;
|
t->cur_time += warp;
|
||||||
printf("Current Unix calendar time = %ld warp = %ld\n", t->cur_time, warp);
|
printf("Current Unix calendar time = %ld warp = %ld\n", t->cur_time, warp);
|
||||||
|
|
||||||
|
@ -285,9 +285,12 @@ void fgTimeUpdate(struct FLIGHT *f, struct fgTIME *t) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.12 1997/12/09 04:25:37 curt
|
/* Revision 1.13 1997/12/09 05:11:56 curt
|
||||||
/* Working on adding a global lighting params structure.
|
/* Working on tweaking lighting.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.12 1997/12/09 04:25:37 curt
|
||||||
|
* Working on adding a global lighting params structure.
|
||||||
|
*
|
||||||
* Revision 1.11 1997/11/25 19:25:40 curt
|
* Revision 1.11 1997/11/25 19:25:40 curt
|
||||||
* Changes to integrate Durk's moon/sun code updates + clean up.
|
* Changes to integrate Durk's moon/sun code updates + clean up.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue