]> git.mxchange.org Git - flightgear.git/commitdiff
Bring lights in in stages as it get's darker.
authorcurt <curt>
Mon, 4 Dec 2000 23:25:05 +0000 (23:25 +0000)
committercurt <curt>
Mon, 4 Dec 2000 23:25:05 +0000 (23:25 +0000)
src/Scenery/newcache.cxx
src/Scenery/tileentry.cxx
src/Scenery/tileentry.hxx
src/Scenery/tilemgr.cxx

index 2f0a489af03aece77a68851ae54bd76532b14092..15ed409d66a7a4c0775f6fb0913238cd2d85d750 100644 (file)
@@ -133,7 +133,7 @@ static void print_refs( ssgSelector *sel, ssgTransform *trans,
 #endif
 
 
-static ssgLeaf *gen_lights( ssgVertexArray *lights ) {
+static ssgLeaf *gen_lights( ssgVertexArray *lights, float bright ) {
     // Allocate ssg structure
     ssgNormalArray   *nl = NULL;
     ssgTexCoordArray *tl = NULL;
@@ -141,7 +141,7 @@ static ssgLeaf *gen_lights( ssgVertexArray *lights ) {
 
     // default to slightly yellow lights for now
     sgVec4 color;
-    sgSetVec4( color, 1.0, 1.0, 0.7, 1.0 );
+    sgSetVec4( color, 1.0 * bright, 1.0 * bright, 0.7 * bright, 1.0 );
     cl->add( color );
 
     // create ssg leaf
@@ -250,12 +250,25 @@ void FGNewCache::fill_in( const FGBucket& b ) {
     terrain->addKid( e->terra_transform );
 
     e->lights_transform = NULL;
+    e->lights_range = NULL;
     /* uncomment this section for testing ground lights */
-    ssgLeaf *lights = gen_lights( light_pts );
-    if ( lights ) {
+    if ( light_pts->getNum() ) {
+       cout << "generating lights" << endl;
        e->lights_transform = new ssgTransform;
        e->lights_range = new ssgRangeSelector;
-       e->lights_range->addKid( lights );
+       e->lights_brightness = new ssgSelector;
+       ssgLeaf *lights;
+
+       lights = gen_lights( light_pts, 0.6 );
+       e->lights_brightness->addKid( lights );
+
+       lights = gen_lights( light_pts, 0.8 );
+       e->lights_brightness->addKid( lights );
+
+       lights = gen_lights( light_pts, 1.0 );
+       e->lights_brightness->addKid( lights );
+
+       e->lights_range->addKid( e->lights_brightness );
        e->lights_transform->addKid( e->lights_range );
        e->lights_transform->setTransform( &sgcoord );
        ground->addKid( e->lights_transform );
index 565d12f9871dbb55dec8ef1c260a14f20516119c..5a94eae4c74e71876d8b608480c86a94e227aa97 100644 (file)
@@ -36,6 +36,7 @@
 #include <Aircraft/aircraft.hxx>
 #include <Main/globals.hxx>
 #include <Scenery/scenery.hxx>
+#include <Time/light.hxx>
 
 #include "tileentry.hxx"
 
@@ -174,8 +175,10 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
     ranges[0] = SG_ZERO;
     ranges[1] = vis + bounding_radius;
     terra_range->setRanges( ranges, 2 );
-    ranges[1] = vis * 1.5 + bounding_radius;
-    lights_range->setRanges( ranges, 2 );
+    if ( lights_range ) {
+       ranges[1] = vis * 1.5 + bounding_radius;
+       lights_range->setRanges( ranges, 2 );
+    }
 #endif
     sgVec3 sgTrans;
     sgSetVec3( sgTrans, offset.x(), offset.y(), offset.z() );
@@ -207,5 +210,17 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
        sgScaleVec3( up, 10.0 + agl / 100.0 + dist / 10000 );
        sgAddVec3( sgTrans, up );
        lights_transform->setTransform( sgTrans );
+
+       // select which set of lights based on sun angle
+       float sun_angle = cur_light_params.sun_angle * RAD_TO_DEG;
+       if ( sun_angle > 100 ) {
+           lights_brightness->select(0x04);
+       } else if ( sun_angle > 95.5 ) {
+           lights_brightness->select(0x02);
+       } else if ( sun_angle > 91 ) {
+           lights_brightness->select(0x01);
+       } else {
+           lights_brightness->select(0x00);
+       }
     }
 }
index 230b1ecdc3735a7491d089d46d4bc13edd8043ab..5bf057daa36820a426041b3e849fa106888e8ca4 100644 (file)
@@ -109,6 +109,10 @@ public:
     ssgRangeSelector *terra_range;
     ssgRangeSelector *lights_range;
 
+    // we create several preset brightness and can choose which one we
+    // want based on lighting conditions.
+    ssgSelector *lights_brightness;
+
 public:
 
     // Constructor
index 1b45d3a466ef36c5a3c50a9ed8ff355d07a296a9..9697a5d1da0295c44a1cfc100c9333c7102a7626 100644 (file)
@@ -130,7 +130,7 @@ void FGTileMgr::load_tile( const FGBucket& b ) {
     if ( t == NULL ) {
        FG_LOG( FG_TERRAIN, FG_DEBUG, "Loading tile " << b );
        global_tile_cache.fill_in( b );
-       FGTileEntry *t = global_tile_cache.get_tile( b );
+       t = global_tile_cache.get_tile( b );
        t->prep_ssg_node( scenery.center, vis);
     } else {
        FG_LOG( FG_TERRAIN, FG_DEBUG, "Tile already in cache " << b );