1
0
Fork 0

Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.

This commit is contained in:
curt 1997-12-22 04:14:28 +00:00
parent 3c398c79ca
commit 45ed7c79f8
7 changed files with 174 additions and 49 deletions

View file

@ -124,8 +124,7 @@ static void fgUpdateViewParams() {
/* base sky color */ /* base sky color */
GLfloat base_sky_color[4] = {0.60, 0.60, 0.90, 1.0}; GLfloat base_sky_color[4] = {0.60, 0.60, 0.90, 1.0};
/* base fog color */ /* base fog color */
/* GLfloat base_fog_color[4] = {0.70, 0.70, 0.70, 1.0}; */ GLfloat base_fog_color[4] = {0.70, 0.70, 0.70, 1.0};
GLfloat base_fog_color[4] = {1.00, 0.00, 0.00, 1.0};
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
@ -134,7 +133,7 @@ static void fgUpdateViewParams() {
t = &cur_time_params; t = &cur_time_params;
v = &current_view; v = &current_view;
fgViewUpdate(f, v); fgViewUpdate(f, v, l);
/* Tell GL we are about to modify the projection parameters */ /* Tell GL we are about to modify the projection parameters */
xglMatrixMode(GL_PROJECTION); xglMatrixMode(GL_PROJECTION);
@ -144,13 +143,27 @@ static void fgUpdateViewParams() {
xglMatrixMode(GL_MODELVIEW); xglMatrixMode(GL_MODELVIEW);
xglLoadIdentity(); xglLoadIdentity();
/* set up our view volume */ /* set up our view volume (default) */
gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z, gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
v->view_pos.x + v->view_forward[0], v->view_pos.x + v->view_forward[0],
v->view_pos.y + v->view_forward[1], v->view_pos.y + v->view_forward[1],
v->view_pos.z + v->view_forward[2], v->view_pos.z + v->view_forward[2],
v->view_up[0], v->view_up[1], v->view_up[2]); v->view_up[0], v->view_up[1], v->view_up[2]);
/* lock view horizontally towards sun (testing) */
/* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
v->view_pos.x + v->surface_to_sun[0],
v->view_pos.y + v->surface_to_sun[1],
v->view_pos.z + v->surface_to_sun[2],
v->view_up[0], v->view_up[1], v->view_up[2]); */
/* lock view horizontally towards south (testing) */
/* gluLookAt(v->view_pos.x, v->view_pos.y, v->view_pos.z,
v->view_pos.x + v->surface_south[0],
v->view_pos.y + v->surface_south[1],
v->view_pos.z + v->surface_south[2],
v->view_up[0], v->view_up[1], v->view_up[2]); */
/* set the sun position */ /* set the sun position */
xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec ); xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
@ -203,7 +216,7 @@ static void fgUpdateViewParams() {
* Update all Visuals (redraws anything graphics related) * Update all Visuals (redraws anything graphics related)
**************************************************************************/ **************************************************************************/
static void fgUpdateVisuals( void ) { static void fgRenderFrame( void ) {
struct fgLIGHT *l; struct fgLIGHT *l;
struct fgTIME *t; struct fgTIME *t;
struct fgVIEW *v; struct fgVIEW *v;
@ -502,7 +515,7 @@ static void fgMainLoop( void ) {
fgAircraftOutputCurrent(a); fgAircraftOutputCurrent(a);
/* redraw display */ /* redraw display */
fgUpdateVisuals(); fgRenderFrame();
} }
@ -589,7 +602,7 @@ int main( int argc, char *argv[] ) {
xglutIdleFunc( fgMainLoop ); xglutIdleFunc( fgMainLoop );
/* draw the scene */ /* draw the scene */
xglutDisplayFunc( fgUpdateVisuals ); xglutDisplayFunc( fgRenderFrame );
/* pass control off to the GLUT event handler */ /* pass control off to the GLUT event handler */
glutMainLoop(); glutMainLoop();
@ -607,9 +620,12 @@ int main( int argc, char *argv[] ) {
/* $Log$ /* $Log$
/* Revision 1.37 1997/12/19 23:34:03 curt /* Revision 1.38 1997/12/22 04:14:28 curt
/* Lot's of tweaking with sky rendering and lighting. /* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
/* /*
* Revision 1.37 1997/12/19 23:34:03 curt
* Lot's of tweaking with sky rendering and lighting.
*
* Revision 1.36 1997/12/19 16:44:57 curt * Revision 1.36 1997/12/19 16:44:57 curt
* Working on scene rendering order and options. * Working on scene rendering order and options.
* *

View file

@ -1,44 +1,46 @@
GLUTkey.o: GLUTkey.c ../XGL/xgl.h GLUTkey.h views.h ../Include/types.h \ GLUTkey.o: GLUTkey.c ../XGL/xgl.h GLUTkey.h views.h ../Include/types.h \
../Flight/flight.h ../Flight/Slew/slew.h \ ../Flight/flight.h ../Flight/Slew/slew.h \
../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \
../Math/mat3.h ../Include/constants.h ../Aircraft/aircraft.h \ ../Math/mat3.h ../Time/fg_time.h ../Time/../Include/types.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ ../Time/../Flight/flight.h ../Include/constants.h \
../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../Include/limits.h ../Weather/weather.h ../Aircraft/../Controls/../Include/limits.h ../Weather/weather.h
GLUTmain.o: GLUTmain.c ../XGL/xgl.h GLUTkey.h fg_init.h views.h \ GLUTmain.o: GLUTmain.c ../XGL/xgl.h GLUTkey.h fg_init.h views.h \
../Include/types.h ../Flight/flight.h ../Flight/Slew/slew.h \ ../Include/types.h ../Flight/flight.h ../Flight/Slew/slew.h \
../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \
../Math/mat3.h ../Include/constants.h ../Include/general.h \ ../Math/mat3.h ../Time/fg_time.h ../Time/../Include/types.h \
../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ ../Time/../Flight/flight.h ../Include/constants.h \
../Aircraft/../Controls/controls.h \ ../Include/general.h ../Aircraft/aircraft.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../Include/limits.h ../Cockpit/cockpit.h \ ../Aircraft/../Controls/../Include/limits.h ../Cockpit/cockpit.h \
../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \ ../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \
../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \ ../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \
../Joystick/joystick.h ../Math/fg_geodesy.h ../Math/polar.h \ ../Joystick/joystick.h ../Math/fg_geodesy.h ../Math/polar.h \
../Math/../Include/types.h ../Scenery/mesh.h ../Scenery/moon.h \ ../Math/../Include/types.h ../Scenery/mesh.h ../Scenery/moon.h \
../Scenery/orbits.h ../Scenery/../Time/fg_time.h \ ../Scenery/orbits.h ../Scenery/../Time/fg_time.h ../Scenery/scenery.h \
../Scenery/../Time/../Include/types.h \
../Scenery/../Time/../Flight/flight.h ../Scenery/scenery.h \
../Scenery/../Include/types.h ../Scenery/sky.h ../Scenery/stars.h \ ../Scenery/../Include/types.h ../Scenery/sky.h ../Scenery/stars.h \
../Scenery/sun.h ../Time/fg_time.h ../Time/fg_timer.h \ ../Scenery/sun.h ../Time/fg_timer.h ../Time/sunpos.h \
../Time/sunpos.h ../Time/../Include/types.h ../Weather/weather.h ../Weather/weather.h
fg_init.o: fg_init.c fg_init.h views.h ../Include/types.h \ fg_init.o: fg_init.c fg_init.h views.h ../Include/types.h \
../Flight/flight.h ../Flight/Slew/slew.h \ ../Flight/flight.h ../Flight/Slew/slew.h \
../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \
../Math/mat3.h ../Include/constants.h ../Include/general.h \ ../Math/mat3.h ../Time/fg_time.h ../Time/../Include/types.h \
../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ ../Time/../Flight/flight.h ../Include/constants.h \
../Aircraft/../Controls/controls.h \ ../Include/general.h ../Aircraft/aircraft.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../Include/limits.h ../Cockpit/cockpit.h \ ../Aircraft/../Controls/../Include/limits.h ../Cockpit/cockpit.h \
../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \ ../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \
../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \ ../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \
../Joystick/joystick.h ../Math/fg_random.h ../Scenery/mesh.h \ ../Joystick/joystick.h ../Math/fg_random.h ../Scenery/mesh.h \
../Scenery/moon.h ../Scenery/orbits.h ../Scenery/../Time/fg_time.h \ ../Scenery/moon.h ../Scenery/orbits.h ../Scenery/../Time/fg_time.h \
../Scenery/../Time/../Include/types.h \ ../Scenery/scenery.h ../Scenery/../Include/types.h ../Scenery/sky.h \
../Scenery/../Time/../Flight/flight.h ../Scenery/scenery.h \ ../Scenery/stars.h ../Scenery/sun.h ../Time/sunpos.h \
../Scenery/../Include/types.h ../Scenery/sky.h ../Scenery/stars.h \ ../Weather/weather.h
../Scenery/sun.h ../Time/fg_time.h ../Time/sunpos.h \
../Time/../Include/types.h ../Weather/weather.h
views.o: views.c views.h ../Include/types.h ../Flight/flight.h \ views.o: views.c views.h ../Include/types.h ../Flight/flight.h \
../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \
../Flight/LaRCsim/../flight.h ../Math/mat3.h ../Include/constants.h \ ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../Time/fg_time.h \
../Math/polar.h ../Math/../Include/types.h ../Scenery/scenery.h \ ../Time/../Include/types.h ../Time/../Flight/flight.h \
../Include/constants.h ../Math/polar.h ../Math/../Include/types.h \
../Math/vector.h ../Math/../Math/mat3.h ../Scenery/scenery.h \
../Scenery/../Include/types.h ../Scenery/../Include/types.h

View file

@ -31,7 +31,9 @@
#include "../Flight/flight.h" #include "../Flight/flight.h"
#include "../Math/mat3.h" #include "../Math/mat3.h"
#include "../Math/polar.h" #include "../Math/polar.h"
#include "../Math/vector.h"
#include "../Scenery/scenery.h" #include "../Scenery/scenery.h"
#include "../Time/fg_time.h"
/* This is a record containing current view parameters */ /* This is a record containing current view parameters */
@ -46,9 +48,10 @@ void fgViewInit(struct fgVIEW *v) {
/* Update the view parameters */ /* Update the view parameters */
void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v) { void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l) {
MAT3vec vec, forward; MAT3vec vec, forward, v0, minus_z;
MAT3mat R, TMP, UP, LOCAL, VIEW; MAT3mat R, TMP, UP, LOCAL, VIEW;
double ntmp;
/* calculate the cartesion coords of the current lat/lon/0 elev */ /* calculate the cartesion coords of the current lat/lon/0 elev */
v->cur_zero_elev = fgPolarToCart(FG_Longitude, FG_Lat_geocentric, v->cur_zero_elev = fgPolarToCart(FG_Longitude, FG_Lat_geocentric,
@ -67,6 +70,16 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v) {
printf("View pos = %.4f, %.4f, %.4f\n", printf("View pos = %.4f, %.4f, %.4f\n",
v->view_pos.x, v->view_pos.y, v->view_pos.z); v->view_pos.x, v->view_pos.y, v->view_pos.z);
/* make a vector to the current view position */
MAT3_SET_VEC(v0, v->view_pos.x, v->view_pos.y, v->view_pos.z);
/* calculate vector to sun's position on the earth's surface */
v->to_sun[0] = l->fg_sunpos.x - (v->view_pos.x + scenery.center.x);
v->to_sun[1] = l->fg_sunpos.y - (v->view_pos.y + scenery.center.y);
v->to_sun[2] = l->fg_sunpos.z - (v->view_pos.z + scenery.center.z);
printf("Vector to sun = %.2f %.2f %.2f\n",
v->to_sun[0], v->to_sun[1], v->to_sun[2]);
/* Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw) */ /* Derive the LOCAL aircraft rotation matrix (roll, pitch, yaw) */
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0); MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
MAT3rotate(R, vec, FG_Phi); MAT3rotate(R, vec, FG_Phi);
@ -136,13 +149,44 @@ void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v) {
MAT3rotate(TMP, v->view_up, v->view_offset); MAT3rotate(TMP, v->view_up, v->view_offset);
MAT3mult_vec(v->view_forward, forward, TMP); MAT3mult_vec(v->view_forward, forward, TMP);
/* Given a vector from the view position to the point on the
* earth's surface the sun is directly over, map into onto the
* local plane representing "horizontal". */
map_vec_onto_cur_surface_plane(v->local_up, v0, v->to_sun,
v->surface_to_sun);
MAT3_NORMALIZE_VEC(v->surface_to_sun, ntmp);
printf("Surface direction to sun is %.2f %.2f %.2f\n",
v->surface_to_sun[0], v->surface_to_sun[1], v->surface_to_sun[2]);
/* printf("Should be close to zero = %.2f\n",
MAT3_DOT_PRODUCT(v->local_up, v->surface_to_sun)); */
/* Given a vector pointing straight down (-Z), map into onto the
* local plane representing "horizontal". This should give us the
* local direction for moving "south". */
MAT3_SET_VEC(minus_z, 0.0, 0.0, -1.0);
map_vec_onto_cur_surface_plane(v->local_up, v0, minus_z, v->surface_south);
MAT3_NORMALIZE_VEC(v->surface_south, ntmp);
/* printf("Surface direction directly south %.2f %.2f %.2f\n",
v->surface_south[0], v->surface_south[1], v->surface_south[2]); */
/* now calculate the surface east vector */
MAT3rotate(TMP, v->view_up, FG_PI_2);
MAT3mult_vec(v->surface_east, v->surface_south, TMP);
/* printf("Surface direction directly east %.2f %.2f %.2f\n",
v->surface_east[0], v->surface_east[1], v->surface_east[2]); */
/* printf("Should be close to zero = %.2f\n",
MAT3_DOT_PRODUCT(v->surface_south, v->surface_east)); */
} }
/* $Log$ /* $Log$
/* Revision 1.5 1997/12/18 04:07:02 curt /* Revision 1.6 1997/12/22 04:14:32 curt
/* Worked on properly translating and positioning the sky dome. /* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
/* /*
* Revision 1.5 1997/12/18 04:07:02 curt
* Worked on properly translating and positioning the sky dome.
*
* Revision 1.4 1997/12/17 23:13:36 curt * Revision 1.4 1997/12/17 23:13:36 curt
* Began working on rendering a sky. * Began working on rendering a sky.
* *

View file

@ -31,14 +31,47 @@
#include "../Include/types.h" #include "../Include/types.h"
#include "../Flight/flight.h" #include "../Flight/flight.h"
#include "../Math/mat3.h" #include "../Math/mat3.h"
#include "../Time/fg_time.h"
/* Define a structure containing view information */ /* Define a structure containing view information */
struct fgVIEW { struct fgVIEW {
/* view position translated to scenery.center */
struct fgCartesianPoint view_pos; struct fgCartesianPoint view_pos;
/* cartesion coordinates of current lon/lat if at sea level
* translated to scenery.center*/
struct fgCartesianPoint cur_zero_elev; struct fgCartesianPoint cur_zero_elev;
MAT3vec local_up, view_up, view_forward;
double view_offset, goal_view_offset; /* vector in cartesian coordinates from current position to the
* postion on the earth's surface the sun is directly over */
MAT3vec to_sun;
/* surface direction to go to head towards sun */
MAT3vec surface_to_sun;
/* surface vector heading south */
MAT3vec surface_south;
/* surface vector heading east (used to unambiguously align sky with sun) */
MAT3vec surface_east;
/* local up vector (normal to the plane tangent to the earth's
* surface at the spot we are directly above */
MAT3vec local_up;
/* up vector for the view (usually point straight up through the
* top of the aircraft */
MAT3vec view_up;
/* the vector pointing straight out the nose of the aircraft */
MAT3vec view_forward;
/* the current offset from forward for viewing */
double view_offset;
/* the goal view offset for viewing (used for smooth view changes) */
double goal_view_offset;
}; };
@ -49,16 +82,19 @@ extern struct fgVIEW current_view;
void fgViewInit(struct fgVIEW *v); void fgViewInit(struct fgVIEW *v);
/* Update the view parameters */ /* Update the view parameters */
void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v); void fgViewUpdate(struct fgFLIGHT *f, struct fgVIEW *v, struct fgLIGHT *l);
#endif /* VIEWS_H */ #endif /* VIEWS_H */
/* $Log$ /* $Log$
/* Revision 1.4 1997/12/17 23:13:36 curt /* Revision 1.5 1997/12/22 04:14:32 curt
/* Began working on rendering a sky. /* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
/* /*
* Revision 1.4 1997/12/17 23:13:36 curt
* Began working on rendering a sky.
*
* Revision 1.3 1997/12/15 23:54:51 curt * Revision 1.3 1997/12/15 23:54:51 curt
* Add xgl wrappers for debugging. * Add xgl wrappers for debugging.
* Generate terrain normals on the fly. * Generate terrain normals on the fly.

View file

@ -5,8 +5,9 @@ astro.o: astro.c ../XGL/xgl.h astro.h stars.h moon.h orbits.h \
../Time/../Flight/LaRCsim/../flight.h planets.h sun.h \ ../Time/../Flight/LaRCsim/../flight.h planets.h sun.h \
../Include/constants.h ../Include/general.h ../Main/views.h \ ../Include/constants.h ../Include/general.h ../Main/views.h \
../Main/../Include/types.h ../Main/../Flight/flight.h \ ../Main/../Include/types.h ../Main/../Flight/flight.h \
../Main/../Math/mat3.h ../Aircraft/aircraft.h \ ../Main/../Math/mat3.h ../Main/../Time/fg_time.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../Include/limits.h ../Aircraft/../Controls/../Include/limits.h
common.o: common.c common.h common.o: common.c common.h
geometry.o: geometry.c geometry.h mesh.h geometry.o: geometry.c geometry.h mesh.h
@ -19,7 +20,7 @@ moon.o: moon.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \
../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/ls_interface.h \
../Time/../Flight/LaRCsim/../flight.h moon.h ../Include/general.h \ ../Time/../Flight/LaRCsim/../flight.h moon.h ../Include/general.h \
../Main/views.h ../Main/../Include/types.h ../Main/../Flight/flight.h \ ../Main/views.h ../Main/../Include/types.h ../Main/../Flight/flight.h \
../Main/../Math/mat3.h ../Main/../Math/mat3.h ../Main/../Time/fg_time.h
obj.o: obj.c ../XGL/xgl.h obj.h scenery.h ../Include/types.h \ obj.o: obj.c ../XGL/xgl.h obj.h scenery.h ../Include/types.h \
../Math/mat3.h ../Math/mat3.h
orbits.o: orbits.c orbits.h ../Time/fg_time.h \ orbits.o: orbits.c orbits.h ../Time/fg_time.h \
@ -41,7 +42,8 @@ sky.o: sky.c ../XGL/xgl.h sky.h ../Time/fg_time.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \ ../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \
../Include/constants.h ../Main/views.h ../Main/../Include/types.h \ ../Include/constants.h ../Main/views.h ../Main/../Include/types.h \
../Main/../Flight/flight.h ../Main/../Math/mat3.h ../Math/fg_random.h ../Main/../Flight/flight.h ../Main/../Math/mat3.h \
../Main/../Time/fg_time.h ../Math/fg_random.h
stars.o: stars.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \ stars.o: stars.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \
../Time/../Include/types.h ../Time/../Flight/flight.h \ ../Time/../Include/types.h ../Time/../Flight/flight.h \
../Time/../Flight/Slew/slew.h \ ../Time/../Flight/Slew/slew.h \
@ -51,10 +53,10 @@ stars.o: stars.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../Include/limits.h ../Main/views.h \ ../Aircraft/../Controls/../Include/limits.h ../Main/views.h \
../Main/../Include/types.h ../Main/../Flight/flight.h \ ../Main/../Include/types.h ../Main/../Flight/flight.h \
../Main/../Math/mat3.h ../Main/../Math/mat3.h ../Main/../Time/fg_time.h
sun.o: sun.c ../XGL/xgl.h ../Time/fg_time.h ../Time/../Include/types.h \ sun.o: sun.c ../XGL/xgl.h ../Time/fg_time.h ../Time/../Include/types.h \
../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \
../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/ls_interface.h \
../Time/../Flight/LaRCsim/../flight.h ../Main/views.h \ ../Time/../Flight/LaRCsim/../flight.h ../Main/views.h \
../Main/../Include/types.h ../Main/../Flight/flight.h \ ../Main/../Include/types.h ../Main/../Flight/flight.h \
../Main/../Math/mat3.h orbits.h sun.h ../Main/../Math/mat3.h ../Main/../Time/fg_time.h orbits.h sun.h

View file

@ -99,7 +99,7 @@ void fgSkyRender() {
struct fgFLIGHT *f; struct fgFLIGHT *f;
struct fgLIGHT *l; struct fgLIGHT *l;
struct fgVIEW *v; struct fgVIEW *v;
float inner_color[4], middle_color[4], diff; float inner_color[4], middle_color[4], diff, east_dot, dot, angle;
int i; int i;
f = &current_aircraft.flight; f = &current_aircraft.flight;
@ -125,6 +125,25 @@ void fgSkyRender() {
xglPushMatrix(); xglPushMatrix();
/* calculate the angle between v->surface_to_sun and
* v->surface_east. We do this so we can sort out the acos()
* ambiguity. I wish I could think of a more efficient way ... :-( */
east_dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_east);
printf(" East dot product = %.2f\n", east_dot);
/* calculate the angle between v->surface_to_sun and
* v->surface_south. this is how much we have to rotate the sky
* for it to align with the sun */
dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_south);
printf(" Dot product = %.2f\n", dot);
if ( east_dot >= 0 ) {
angle = acos(dot);
} else {
angle = -acos(dot);
}
printf(" Sky needs to rotate = %.3f rads = %.1f degrees.\n",
angle, angle * RAD_TO_DEG);
/* Translate to view position */ /* Translate to view position */
xglTranslatef( v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z ); xglTranslatef( v->cur_zero_elev.x, v->cur_zero_elev.y, v->cur_zero_elev.z );
/* printf(" Translated to %.2f %.2f %.2f\n", /* printf(" Translated to %.2f %.2f %.2f\n",
@ -135,6 +154,7 @@ void fgSkyRender() {
FG_Latitude * RAD_TO_DEG); FG_Latitude * RAD_TO_DEG);
xglRotatef( FG_Longitude * RAD_TO_DEG, 0.0, 0.0, 1.0 ); xglRotatef( FG_Longitude * RAD_TO_DEG, 0.0, 0.0, 1.0 );
xglRotatef( 90.0 - FG_Latitude * RAD_TO_DEG, 0.0, 1.0, 0.0 ); xglRotatef( 90.0 - FG_Latitude * RAD_TO_DEG, 0.0, 1.0, 0.0 );
xglRotatef( angle * RAD_TO_DEG, 0.0, 0.0, 1.0 );
/* Draw inner/center section of sky*/ /* Draw inner/center section of sky*/
xglBegin( GL_TRIANGLE_FAN ); xglBegin( GL_TRIANGLE_FAN );
@ -156,8 +176,10 @@ void fgSkyRender() {
xglVertex3fv( sky_inner[i] ); xglVertex3fv( sky_inner[i] );
} }
xglColor4fv( middle_color ); xglColor4fv( middle_color );
xglColor4f(1.0, 0.0, 0.0, 1.0);
xglVertex3fv( sky_middle[0] ); xglVertex3fv( sky_middle[0] );
xglColor4fv( inner_color ); xglColor4fv( inner_color );
xglColor4f(1.0, 0.0, 0.0, 1.0);
xglVertex3fv( sky_inner[0] ); xglVertex3fv( sky_inner[0] );
xglEnd(); xglEnd();
@ -180,9 +202,12 @@ void fgSkyRender() {
/* $Log$ /* $Log$
/* Revision 1.5 1997/12/19 23:34:59 curt /* Revision 1.6 1997/12/22 04:14:34 curt
/* Lot's of tweaking with sky rendering and lighting. /* Aligned sky with sun so dusk/dawn effects can be correct relative to the sun.
/* /*
* Revision 1.5 1997/12/19 23:34:59 curt
* Lot's of tweaking with sky rendering and lighting.
*
* Revision 1.4 1997/12/19 16:45:02 curt * Revision 1.4 1997/12/19 16:45:02 curt
* Working on scene rendering order and options. * Working on scene rendering order and options.
* *

View file

@ -9,6 +9,6 @@ sunpos.o: sunpos.c sunpos.h ../Include/types.h fg_time.h \
../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \
../Include/constants.h ../Main/views.h ../Main/../Include/types.h \ ../Include/constants.h ../Main/views.h ../Main/../Include/types.h \
../Main/../Flight/flight.h ../Main/../Math/mat3.h \ ../Main/../Flight/flight.h ../Main/../Math/mat3.h \
../Math/fg_geodesy.h ../Math/mat3.h ../Math/polar.h \ ../Main/../Time/fg_time.h ../Math/fg_geodesy.h ../Math/mat3.h \
../Math/../Include/types.h ../Math/polar.h ../Math/../Include/types.h
ttest.o: ttest.c ttest.o: ttest.c