From 40d68c5627c91b4445fa0e6d7379fc5648daa51c Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 6 Dec 2000 13:57:29 +0000 Subject: [PATCH] Tweaks to get lights to fade in quantity-wise as well as brightness-wise. --- src/Objects/matlib.cxx | 2 +- src/Scenery/newcache.cxx | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/src/Objects/matlib.cxx b/src/Objects/matlib.cxx index ffb5422ce..3f6dfa280 100644 --- a/src/Objects/matlib.cxx +++ b/src/Objects/matlib.cxx @@ -170,7 +170,7 @@ bool FGMaterialLib::load( const string& mpath ) { lights->setColourMaterial( GL_AMBIENT_AND_DIFFUSE ); lights->setMaterial( GL_EMISSION, 0, 0, 0, 1 ); lights->setMaterial( GL_SPECULAR, 0, 0, 0, 1 ); - lights->disable( GL_BLEND ); + lights->enable( GL_BLEND ); lights->disable( GL_ALPHA_TEST ); lights->disable( GL_LIGHTING ); diff --git a/src/Scenery/newcache.cxx b/src/Scenery/newcache.cxx index 15ed409d6..8ec1e841a 100644 --- a/src/Scenery/newcache.cxx +++ b/src/Scenery/newcache.cxx @@ -133,20 +133,40 @@ static void print_refs( ssgSelector *sel, ssgTransform *trans, #endif -static ssgLeaf *gen_lights( ssgVertexArray *lights, float bright ) { +static ssgLeaf *gen_lights( ssgVertexArray *lights, int inc, float bright ) { + int size = lights->getNum() / inc; + // Allocate ssg structure + ssgVertexArray *vl = new ssgVertexArray( size + 1 ); ssgNormalArray *nl = NULL; ssgTexCoordArray *tl = NULL; - ssgColourArray *cl = new ssgColourArray( 1 ); + ssgColourArray *cl = new ssgColourArray( size + 1 ); - // default to slightly yellow lights for now sgVec4 color; - sgSetVec4( color, 1.0 * bright, 1.0 * bright, 0.7 * bright, 1.0 ); - cl->add( color ); + for ( int i = 0; i < lights->getNum(); i += inc ) { + vl->add( lights->get(i) ); + + // yellow = 1,1,0 + float zombie = sg_random(); + if ( zombie > 0.5 ) { + // 50% chance of yellowish + sgSetVec4( color, 0.9, 0.9, 0.3, bright ); + } else if ( zombie > 0.15 ) { + // 35% chance of whitish + sgSetVec4( color, 0.9, 0.9, 0.6, bright ); + } else if ( zombie > 0.05 ) { + // 10% chance of orangish + sgSetVec4( color, 0.9, 0.6, 0.2, bright ); + } else { + // 5% chance of redish + sgSetVec4( color, 0.9, 0.2, 0.2, bright ); + } + cl->add( color ); + } // create ssg leaf ssgLeaf *leaf = - new ssgVtxTable ( GL_POINTS, lights, nl, tl, cl ); + new ssgVtxTable ( GL_POINTS, vl, nl, tl, cl ); // assign state FGNewMat *newmat = material_lib.find( "LIGHTS" ); @@ -259,13 +279,13 @@ void FGNewCache::fill_in( const FGBucket& b ) { e->lights_brightness = new ssgSelector; ssgLeaf *lights; - lights = gen_lights( light_pts, 0.6 ); + lights = gen_lights( light_pts, 4, 0.7 ); e->lights_brightness->addKid( lights ); - lights = gen_lights( light_pts, 0.8 ); + lights = gen_lights( light_pts, 2, 0.85 ); e->lights_brightness->addKid( lights ); - lights = gen_lights( light_pts, 1.0 ); + lights = gen_lights( light_pts, 1, 1.0 ); e->lights_brightness->addKid( lights ); e->lights_range->addKid( e->lights_brightness ); -- 2.39.5