From 3f32f2680d1ebbc28fca60886ff9199d0a3aa3f8 Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 4 Dec 2000 05:26:40 +0000 Subject: [PATCH] Started laying out infrastructure for ground lighting. Renamed fg_random -> sg_random. --- src/Main/main.cxx | 45 ++++++++++++++++++++++++++++++++++++--------- src/Main/splash.cxx | 4 ++-- 2 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 54c42190e..03d88904a 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -64,7 +64,7 @@ #include // for VERSION #include #include -#include +#include #include #include #include @@ -162,6 +162,10 @@ ssgBranch *terrain = NULL; ssgSelector *penguin_sel = NULL; ssgTransform *penguin_pos = NULL; +ssgRoot *lighting = NULL; +ssgBranch *ground = NULL; +ssgBranch *airport = NULL; + #ifdef FG_NETWORK_OLK ssgSelector *fgd_sel = NULL; ssgTransform *fgd_pos = NULL; @@ -293,6 +297,10 @@ void fgRenderFrame( void ) { fgLIGHT *l = &cur_light_params; static double last_visibility = -9999; + static GLfloat fog_exp_density; + static GLfloat fog_exp2_density; + static GLfloat fog_exp2_punch_through; + // double angle; // GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 }; // GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 }; @@ -465,19 +473,18 @@ void fgRenderFrame( void ) { // cout << "----> updating fog params" << endl; - GLfloat fog_exp_density; - GLfloat fog_exp2_density; - // for GL_FOG_EXP fog_exp_density = -log(0.01 / actual_visibility); // for GL_FOG_EXP2 fog_exp2_density = sqrt( -log(0.01) ) / actual_visibility; - - // Set correct opengl fog density - glFogf (GL_FOG_DENSITY, fog_exp2_density); + fog_exp2_punch_through = sqrt( -log(0.01) ) / + ( actual_visibility * 1.5 ); } - + + // Set correct opengl fog density + glFogf (GL_FOG_DENSITY, fog_exp2_density); + // update the sky dome if ( globals->get_options()->get_skyblend() ) { /* cout << "thesky->repaint() sky_color = " @@ -646,6 +653,14 @@ void fgRenderFrame( void ) { glEnable( GL_DEPTH_TEST ); ssgCullAndDraw( scene ); + // change state for lighting here + + // draw lighting + // Set punch through fog density + glFogf (GL_FOG_DENSITY, fog_exp2_density); + + ssgCullAndDraw( lighting ); + // draw the sky cloud layers thesky->postDraw( cur_fdm_state->get_Altitude() * FEET_TO_METER ); @@ -1344,7 +1359,7 @@ int main( int argc, char **argv ) { << FLIGHTGEAR_VERSION << endl ); // seed the random number generater - fg_srandom(); + sg_srandom(); // Allocate global data structures. This needs to happen before // we parse command line options @@ -1508,6 +1523,9 @@ int main( int argc, char **argv ) { scene = new ssgRoot; scene->setName( "Scene" ); + lighting = new ssgRoot; + lighting->setName( "Lighting" ); + // Initialize the sky FGPath ephem_data_path( globals->get_options()->get_fg_root() ); ephem_data_path.append( "Astro" ); @@ -1549,6 +1567,15 @@ int main( int argc, char **argv ) { terrain->setName( "Terrain" ); scene->addKid( terrain ); + // Lighting + ground = new ssgBranch; + ground->setName( "Ground Lighting" ); + lighting->addKid( ground ); + + airport = new ssgBranch; + airport->setName( "Airport Lighting" ); + lighting->addKid( airport ); + // temporary visible aircraft "own ship" penguin_sel = new ssgSelector; penguin_pos = new ssgTransform; diff --git a/src/Main/splash.cxx b/src/Main/splash.cxx index 712847eb8..b9444f528 100644 --- a/src/Main/splash.cxx +++ b/src/Main/splash.cxx @@ -40,7 +40,7 @@ #include #include -#include +#include #include #include @@ -74,7 +74,7 @@ void fgSplashInit ( void ) { xglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // load in the texture data - int num = (int)(fg_random() * 4.0 + 1.0); + int num = (int)(sg_random() * 4.0 + 1.0); char num_str[256]; sprintf(num_str, "%d", num);