From cb071f4e56c7bbaf525cff3c13fe9791c3ac43b4 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 29 Feb 2000 17:13:02 +0000 Subject: [PATCH] Continuing work on ssg-ifying the sky dome. --- src/Main/fg_init.cxx | 3 --- src/Main/keyboard.cxx | 4 +++- src/Main/main.cxx | 44 ++++++++++++++++++++++++++++++++++++------- src/Main/options.cxx | 1 + src/Time/fg_time.cxx | 4 +++- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index ebe0a5f8d..75ddf1feb 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -472,9 +472,6 @@ bool fgInitSubsystems( void ) { exit(-1); } - // Initialize the "sky" - fgSkyInit(); - // Initialize the flight model subsystem data structures base on // above values diff --git a/src/Main/keyboard.cxx b/src/Main/keyboard.cxx index dcf0a7057..ce58ec8a9 100644 --- a/src/Main/keyboard.cxx +++ b/src/Main/keyboard.cxx @@ -75,7 +75,9 @@ static void local_update_sky_and_lighting_params( void ) { // fgSunInit(); SolarSystem::theSolarSystem->rebuild(); cur_light_params.Update(); - fgSkyColorsInit(); + current_sky.repaint( cur_light_params.sky_color, + cur_light_params.fog_color, + cur_light_params.sun_angle ); } diff --git a/src/Main/main.cxx b/src/Main/main.cxx index e97c4d376..d3ab52c99 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -145,6 +145,10 @@ ssgBranch *terrain = NULL; ssgSelector *penguin_sel = NULL; ssgTransform *penguin_pos = NULL; +// the sky needs to be drawn in a specific order, thus we use several +// "roots" so we can explicitely control this. +ssgRoot *sky = NULL; + #ifdef FG_NETWORK_OLK ssgSelector *fgd_sel = NULL; ssgTransform *fgd_pos = NULL; @@ -325,9 +329,25 @@ void fgRenderFrame( void ) { } */ xglShadeModel( GL_SMOOTH ); - if ( current_options.get_skyblend() ) { - fgSkyRender(); - } + + // if ( current_options.get_skyblend() ) { + // fgSkyRender(); + // } + sgVec3 zero_elev; + sgSetVec3( zero_elev, + current_view.get_cur_zero_elev().x(), + current_view.get_cur_zero_elev().y(), + current_view.get_cur_zero_elev().z() ); + + current_sky.reposition( zero_elev, + cur_fdm_state->get_Longitude(), + cur_fdm_state->get_Latitude(), + cur_light_params.sun_rotation ); + + xglPushMatrix(); + ssgSetCamera( current_view.VIEW ); + ssgCullAndDraw( sky ); + xglPopMatrix(); // xglDisable( GL_FOG ); @@ -1306,12 +1326,24 @@ int main( int argc, char **argv ) { ssgModelPath( (char *)modelpath.c_str() ); ssgTexturePath( (char *)texturepath.c_str() ); + // Scene graph root scene = new ssgRoot; + scene->setName( "Scene" ); + + // Terrain branch terrain = new ssgBranch; terrain->setName( "Terrain" ); + scene->addKid( terrain ); + + // Sky branch + sky = new ssgRoot; + sky->setName( "Sky" ); + current_sky.initialize( sky ); + scene->addKid( sky ); + + // temporary visible aircraft "own ship" penguin_sel = new ssgSelector; penguin_pos = new ssgTransform; - ssgEntity *tux_obj = ssgLoadAC( "glider.ac" ); // ssgEntity *tux_obj = ssgLoadAC( "Tower1x.ac" ); penguin_pos->addKid( tux_obj ); @@ -1319,6 +1351,7 @@ int main( int argc, char **argv ) { ssgFlatten( tux_obj ); ssgStripify( penguin_sel ); penguin_sel->clrTraversalMaskBits( SSGTRAV_HOT ); + scene->addKid( penguin_sel ); #ifdef FG_NETWORK_OLK // Do the network intialization @@ -1327,9 +1360,6 @@ int main( int argc, char **argv ) { } #endif - scene->addKid( terrain ); - scene->addKid( penguin_sel ); - // pass control off to the master GLUT event handler glutMainLoop(); diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 57a9fa257..9ff8a8e9d 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -82,6 +82,7 @@ atoi( const string& str ) #endif } + // Defined the shared options class here fgOPTIONS current_options; diff --git a/src/Time/fg_time.cxx b/src/Time/fg_time.cxx index eebf7b6b3..ccb60e58b 100644 --- a/src/Time/fg_time.cxx +++ b/src/Time/fg_time.cxx @@ -534,7 +534,9 @@ void FGTime::local_update_sky_and_lighting_params( void ) { // fgSunInit(); SolarSystem::theSolarSystem->rebuild(); cur_light_params.Update(); - fgSkyColorsInit(); + current_sky.repaint( cur_light_params.sky_color, + cur_light_params.fog_color, + cur_light_params.sun_angle ); } -- 2.39.5