From 46e6042aab98fcae28c775b749a88edfac90f342 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 19 Dec 1997 16:44:57 +0000 Subject: [PATCH] Working on scene rendering order and options. --- Cockpit/depend | 10 -------- Main/GLUTmain.c | 63 +++++++++++++++++++++++++++++++++++++++++------- Main/depend | 27 ++++++++++++--------- Main/fg_init.c | 24 ++++++++++++++---- Scenery/Makefile | 5 +++- Scenery/astro.c | 13 ++++------ Scenery/depend | 34 +++++++++++++++++--------- Scenery/moon.c | 2 +- Scenery/sky.c | 15 ++++-------- Time/depend | 2 +- 10 files changed, 128 insertions(+), 67 deletions(-) diff --git a/Cockpit/depend b/Cockpit/depend index 1e0cb8cc7..d5e9f450e 100644 --- a/Cockpit/depend +++ b/Cockpit/depend @@ -18,13 +18,3 @@ hud.o: hud.c hud.h ../Aircraft/aircraft.h \ ../Scenery/scenery.h ../Scenery/../Include/types.h ../Math/mat3.h \ ../Math/polar.h ../Math/../Include/types.h ../Time/fg_timer.h \ ../Math/fg_random.h ../Weather/weather.h -test.o: test.c test.h ../Aircraft/aircraft.h \ - ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \ - ../Aircraft/../Flight/LaRCsim/ls_interface.h \ - ../Aircraft/../Flight/LaRCsim/../flight.h \ - ../Aircraft/../Controls/controls.h \ - ../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \ - ../Controls/controls.h ../Include/constants.h ../Scenery/mesh.h \ - ../Scenery/scenery.h ../Scenery/../Include/types.h ../Math/mat3.h \ - ../Math/polar.h ../Math/../Include/types.h ../Time/fg_timer.h \ - ../Math/fg_random.h ../Weather/weather.h diff --git a/Main/GLUTmain.c b/Main/GLUTmain.c index 49a121b63..6556ca983 100644 --- a/Main/GLUTmain.c +++ b/Main/GLUTmain.c @@ -46,8 +46,11 @@ #include "../Math/mat3.h" #include "../Math/polar.h" #include "../Scenery/mesh.h" +#include "../Scenery/moon.h" #include "../Scenery/scenery.h" #include "../Scenery/sky.h" +#include "../Scenery/stars.h" +#include "../Scenery/sun.h" #include "../Time/fg_time.h" #include "../Time/fg_timer.h" #include "../Time/sunpos.h" @@ -89,9 +92,6 @@ static void fgInitVisuals() { t = &cur_time_params; w = ¤t_weather; - xglEnable( GL_DEPTH_TEST ); - /* xglFrontFace(GL_CW); */ - xglEnable( GL_CULL_FACE ); /* xglDisable( GL_DITHER ); */ @@ -218,22 +218,64 @@ static void fgUpdateViewParams() { **************************************************************************/ static void fgUpdateVisuals( void ) { + struct fgTIME *t; + struct fgVIEW *v; + double angle; + static double lastAstroUpdate = 0; + + t = &cur_time_params; + v = ¤t_view; + /* update view volume parameters */ fgUpdateViewParams(); - xglClear( /* GL_COLOR_BUFFER_BIT | */ GL_DEPTH_BUFFER_BIT ); + xglClear( GL_DEPTH_BUFFER_BIT /* | GL_COLOR_BUFFER_BIT */ ); /* Tell GL we are switching to model view parameters */ xglMatrixMode(GL_MODELVIEW); /* xglLoadIdentity(); */ /* draw sky */ + xglDisable( GL_DEPTH_TEST ); + xglDisable( GL_LIGHTING ); + xglDisable( GL_CULL_FACE ); + xglShadeModel( GL_SMOOTH ); fgSkyRender(); - /* draw astronomical objects */ - /* fgAstroRender(); */ - + /* a hack: Force sun and moon position to be updated on an hourly basis */ + if (((t->gst - lastAstroUpdate) > 1) || (t->gst < lastAstroUpdate)) { + lastAstroUpdate = t->gst; + fgSunInit(); + fgMoonInit(); + } + + /* setup transformation for drawing astronomical objects */ + xglPushMatrix(); + /* Translate to view position */ + xglTranslatef( v->view_pos.x, v->view_pos.y, v->view_pos.z ); + /* Rotate based on gst (side real time) */ + angle = t->gst * 15.041085; /* should be 15.041085, Curt thought it was 15*/ + /* printf("Rotating astro objects by %.2f degrees\n",angle); */ + xglRotatef( angle, 0.0, 0.0, -1.0 ); + + /* draw stars and planets */ + xglDisable( GL_FOG ); + fgStarsRender(); + + /* draw the sun */ + fgSunRender(); + + /* render the moon */ + xglEnable( GL_LIGHTING ); + xglEnable( GL_CULL_FACE ); + fgMoonRender(); + + xglPopMatrix(); + /* draw scenery */ + xglShadeModel( GL_FLAT ); + xglEnable( GL_DEPTH_TEST ); + xglEnable( GL_FOG ); fgSceneryRender(); /* display HUD */ @@ -569,9 +611,12 @@ int main( int argc, char *argv[] ) { /* $Log$ -/* Revision 1.35 1997/12/18 23:32:32 curt -/* First stab at sky dome actually starting to look reasonable. :-) +/* Revision 1.36 1997/12/19 16:44:57 curt +/* Working on scene rendering order and options. /* + * Revision 1.35 1997/12/18 23:32:32 curt + * First stab at sky dome actually starting to look reasonable. :-) + * * Revision 1.34 1997/12/17 23:13:34 curt * Began working on rendering a sky. * diff --git a/Main/depend b/Main/depend index 0fac299af..01b1374e7 100644 --- a/Main/depend +++ b/Main/depend @@ -1,11 +1,11 @@ -GLUTkey.o: GLUTkey.c 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/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ ../Math/mat3.h ../Include/constants.h ../Aircraft/aircraft.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ ../Aircraft/../Controls/../Include/limits.h ../Weather/weather.h -GLUTmain.o: GLUTmain.c GLUTkey.h fg_init.h views.h ../Include/types.h \ - ../Flight/flight.h ../Flight/Slew/slew.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 \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ ../Math/mat3.h ../Include/constants.h ../Include/general.h \ ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \ @@ -14,10 +14,13 @@ GLUTmain.o: GLUTmain.c GLUTkey.h fg_init.h views.h ../Include/types.h \ ../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \ ../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \ ../Joystick/joystick.h ../Math/fg_geodesy.h ../Math/polar.h \ - ../Math/../Include/types.h ../Scenery/mesh.h ../Scenery/scenery.h \ - ../Scenery/../Include/types.h ../Time/fg_time.h \ - ../Time/../Include/types.h ../Time/../Flight/flight.h \ - ../Time/fg_timer.h ../Time/sunpos.h ../Weather/weather.h + ../Math/../Include/types.h ../Scenery/mesh.h ../Scenery/moon.h \ + ../Scenery/orbits.h ../Scenery/../Time/fg_time.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/sun.h ../Time/fg_time.h ../Time/fg_timer.h \ + ../Time/sunpos.h ../Time/../Include/types.h ../Weather/weather.h fg_init.o: fg_init.c fg_init.h views.h ../Include/types.h \ ../Flight/flight.h ../Flight/Slew/slew.h \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ @@ -28,10 +31,12 @@ fg_init.o: fg_init.c fg_init.h views.h ../Include/types.h \ ../Cockpit/hud.h ../Cockpit/../Aircraft/aircraft.h \ ../Cockpit/../Flight/flight.h ../Cockpit/../Controls/controls.h \ ../Joystick/joystick.h ../Math/fg_random.h ../Scenery/mesh.h \ - ../Scenery/astro.h ../Scenery/stars.h ../Scenery/scenery.h \ - ../Scenery/../Include/types.h ../Time/fg_time.h \ - ../Time/../Include/types.h ../Time/../Flight/flight.h \ - ../Time/sunpos.h ../Weather/weather.h + ../Scenery/moon.h ../Scenery/orbits.h ../Scenery/../Time/fg_time.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/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 \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ ../Flight/LaRCsim/../flight.h ../Math/mat3.h ../Include/constants.h \ diff --git a/Main/fg_init.c b/Main/fg_init.c index 388333784..d7e9991c4 100644 --- a/Main/fg_init.c +++ b/Main/fg_init.c @@ -38,9 +38,11 @@ #include "../Joystick/joystick.h" #include "../Math/fg_random.h" #include "../Scenery/mesh.h" -#include "../Scenery/astro.h" +#include "../Scenery/moon.h" #include "../Scenery/scenery.h" #include "../Scenery/sky.h" +#include "../Scenery/stars.h" +#include "../Scenery/sun.h" #include "../Time/fg_time.h" #include "../Time/sunpos.h" #include "../Weather/weather.h" @@ -179,8 +181,17 @@ void fgInitSubsystems( void ) { } */ - /* Initialize Astronomical Objects */ - fgAstroInit(); + /* Initialize the orbital elements of sun, moon and mayor planets */ + fgSolarSystemInit(*t); + + /* Initialize the Stars subsystem */ + fgStarsInit(); + + /* Initialize the sun's position */ + fgSunInit(); + + /* Intialize the moon's position */ + fgMoonInit(); /* Initialize the "sky" */ fgSkyInit(); @@ -224,9 +235,12 @@ void fgInitSubsystems( void ) { /* $Log$ -/* Revision 1.20 1997/12/18 23:32:33 curt -/* First stab at sky dome actually starting to look reasonable. :-) +/* Revision 1.21 1997/12/19 16:45:00 curt +/* Working on scene rendering order and options. /* + * Revision 1.20 1997/12/18 23:32:33 curt + * First stab at sky dome actually starting to look reasonable. :-) + * * Revision 1.19 1997/12/17 23:13:36 curt * Began working on rendering a sky. * diff --git a/Scenery/Makefile b/Scenery/Makefile index a74585110..2977fee0a 100644 --- a/Scenery/Makefile +++ b/Scenery/Makefile @@ -26,7 +26,7 @@ TARGET = libScenery.a -CFILES = astro.c common.c geometry.c mesh.c moon.c obj.c orbits.c planets.c \ +CFILES = common.c geometry.c mesh.c moon.c obj.c orbits.c planets.c \ scenery.c sky.c stars.c sun.c OFILES = $(CFILES:.c=.o) @@ -99,6 +99,9 @@ geometry.o: #--------------------------------------------------------------------------- # $Log$ +# Revision 1.26 1997/12/19 16:45:01 curt +# Working on scene rendering order and options. +# # Revision 1.25 1997/12/17 23:13:45 curt # Began working on rendering the sky. # diff --git a/Scenery/astro.c b/Scenery/astro.c index 4e1558e74..d49af7010 100644 --- a/Scenery/astro.c +++ b/Scenery/astro.c @@ -87,9 +87,6 @@ void fgAstroRender() { fgMoonInit(); } - /* Disable fog effects */ - xglDisable( GL_FOG ); - /* set the sun position */ /* xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec_inv ); */ @@ -115,16 +112,16 @@ void fgAstroRender() { fgSunRender(); xglPopMatrix(); - - /* reenable fog effects */ - xglEnable( GL_FOG ); } /* $Log$ -/* Revision 1.9 1997/12/18 23:32:35 curt -/* First stab at sky dome actually starting to look reasonable. :-) +/* Revision 1.10 1997/12/19 16:45:01 curt +/* Working on scene rendering order and options. /* + * Revision 1.9 1997/12/18 23:32:35 curt + * First stab at sky dome actually starting to look reasonable. :-) + * * Revision 1.8 1997/12/15 23:54:57 curt * Add xgl wrappers for debugging. * Generate terrain normals on the fly. diff --git a/Scenery/depend b/Scenery/depend index 86a023475..5c3cceec6 100644 --- a/Scenery/depend +++ b/Scenery/depend @@ -1,6 +1,6 @@ -astro.o: astro.c astro.h stars.h moon.h orbits.h ../Time/fg_time.h \ - ../Time/../Include/types.h ../Time/../Flight/flight.h \ - ../Time/../Flight/Slew/slew.h \ +astro.o: astro.c ../XGL/xgl.h astro.h stars.h moon.h orbits.h \ + ../Time/fg_time.h ../Time/../Include/types.h \ + ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h planets.h sun.h \ ../Include/constants.h ../Include/general.h ../Main/views.h \ @@ -13,13 +13,15 @@ geometry.o: geometry.c geometry.h mesh.h mesh.o: mesh.c ../Include/constants.h ../Include/types.h \ ../Math/fg_geodesy.h ../Math/fg_random.h ../Math/mat3.h \ ../Math/polar.h ../Math/../Include/types.h mesh.h common.h scenery.h -moon.o: moon.c orbits.h ../Time/fg_time.h ../Time/../Include/types.h \ - ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ +moon.o: moon.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h moon.h ../Include/general.h \ ../Main/views.h ../Main/../Include/types.h ../Main/../Flight/flight.h \ ../Main/../Math/mat3.h -obj.o: obj.c obj.h scenery.h ../Include/types.h ../Math/mat3.h +obj.o: obj.c ../XGL/xgl.h obj.h scenery.h ../Include/types.h \ + ../Math/mat3.h orbits.o: orbits.c orbits.h ../Time/fg_time.h \ ../Time/../Include/types.h ../Time/../Flight/flight.h \ ../Time/../Flight/Slew/slew.h \ @@ -29,10 +31,20 @@ planets.o: planets.c ../Time/fg_time.h ../Time/../Include/types.h \ ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h orbits.h planets.h sun.h -scenery.o: scenery.c ../Include/general.h astro.h stars.h obj.h \ - scenery.h ../Include/types.h -stars.o: stars.c orbits.h ../Time/fg_time.h ../Time/../Include/types.h \ - ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ +scenery.o: scenery.c ../XGL/xgl.h ../Include/general.h astro.h stars.h \ + obj.h scenery.h ../Include/types.h +sky.o: sky.c ../XGL/xgl.h sky.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ + ../Time/../Flight/LaRCsim/ls_interface.h \ + ../Time/../Flight/LaRCsim/../flight.h ../Aircraft/aircraft.h \ + ../Aircraft/../Flight/flight.h ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../Include/limits.h ../Flight/flight.h \ + ../Include/constants.h ../Main/views.h ../Main/../Include/types.h \ + ../Main/../Flight/flight.h ../Main/../Math/mat3.h ../Math/fg_random.h +stars.o: stars.c ../XGL/xgl.h orbits.h ../Time/fg_time.h \ + ../Time/../Include/types.h ../Time/../Flight/flight.h \ + ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h planets.h stars.h \ ../Include/constants.h ../Include/general.h ../Aircraft/aircraft.h \ @@ -40,7 +52,7 @@ stars.o: stars.c orbits.h ../Time/fg_time.h ../Time/../Include/types.h \ ../Aircraft/../Controls/../Include/limits.h ../Main/views.h \ ../Main/../Include/types.h ../Main/../Flight/flight.h \ ../Main/../Math/mat3.h -sun.o: sun.c ../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/LaRCsim/ls_interface.h \ ../Time/../Flight/LaRCsim/../flight.h ../Main/views.h \ diff --git a/Scenery/moon.c b/Scenery/moon.c index 203d70bf2..17446e300 100644 --- a/Scenery/moon.c +++ b/Scenery/moon.c @@ -258,7 +258,7 @@ void fgMoonInit() { cos(moonPos.Declination); zMoon = 60000.0 * sin(moonPos.Declination); - glutSolidSphere(1.0, 15, 15); + glutSolidSphere(1.0, 10, 10); xglEndList(); } diff --git a/Scenery/sky.c b/Scenery/sky.c index ef81c8b53..dc2628379 100644 --- a/Scenery/sky.c +++ b/Scenery/sky.c @@ -107,10 +107,6 @@ void fgSkyRender() { printf("Rendering the sky.\n"); - xglDisable( GL_LIGHTING ); - xglDisable( GL_CULL_FACE ); - xglShadeModel( GL_SMOOTH ); - xglPushMatrix(); /* Translate to view position */ @@ -159,17 +155,16 @@ void fgSkyRender() { xglEnd(); xglPopMatrix(); - - xglShadeModel( GL_FLAT ); - xglEnable( GL_CULL_FACE ); - xglEnable( GL_LIGHTING ); } /* $Log$ -/* Revision 1.3 1997/12/18 23:32:36 curt -/* First stab at sky dome actually starting to look reasonable. :-) +/* Revision 1.4 1997/12/19 16:45:02 curt +/* Working on scene rendering order and options. /* + * Revision 1.3 1997/12/18 23:32:36 curt + * First stab at sky dome actually starting to look reasonable. :-) + * * Revision 1.2 1997/12/18 04:07:03 curt * Worked on properly translating and positioning the sky dome. * diff --git a/Time/depend b/Time/depend index 8eb45bb22..20661a2b4 100644 --- a/Time/depend +++ b/Time/depend @@ -3,7 +3,7 @@ fg_time.o: fg_time.c fg_time.h ../Include/types.h ../Flight/flight.h \ ../Flight/LaRCsim/../flight.h ../Include/constants.h \ ../Time/fg_time.h fg_timer.o: fg_timer.c fg_timer.h -sidereal.o: sidereal.c ../Include/constants.h +sptest.o: sptest.c sunpos.h ../Include/types.h ../Include/constants.h sunpos.o: sunpos.c sunpos.h ../Include/types.h fg_time.h \ ../Flight/flight.h ../Flight/Slew/slew.h \ ../Flight/LaRCsim/ls_interface.h ../Flight/LaRCsim/../flight.h \ -- 2.39.2