1
0
Fork 0

Bring lights in in stages as it get's darker.

This commit is contained in:
curt 2000-12-04 23:25:05 +00:00
parent f14e155533
commit a775392e31
4 changed files with 40 additions and 8 deletions

View 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 );

View 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);
}
}
}

View 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

View 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 );