Bring lights in in stages as it get's darker.
This commit is contained in:
parent
f14e155533
commit
a775392e31
4 changed files with 40 additions and 8 deletions
|
@ -133,7 +133,7 @@ static void print_refs( ssgSelector *sel, ssgTransform *trans,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static ssgLeaf *gen_lights( ssgVertexArray *lights ) {
|
static ssgLeaf *gen_lights( ssgVertexArray *lights, float bright ) {
|
||||||
// Allocate ssg structure
|
// Allocate ssg structure
|
||||||
ssgNormalArray *nl = NULL;
|
ssgNormalArray *nl = NULL;
|
||||||
ssgTexCoordArray *tl = NULL;
|
ssgTexCoordArray *tl = NULL;
|
||||||
|
@ -141,7 +141,7 @@ static ssgLeaf *gen_lights( ssgVertexArray *lights ) {
|
||||||
|
|
||||||
// default to slightly yellow lights for now
|
// default to slightly yellow lights for now
|
||||||
sgVec4 color;
|
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 );
|
cl->add( color );
|
||||||
|
|
||||||
// create ssg leaf
|
// create ssg leaf
|
||||||
|
@ -250,12 +250,25 @@ void FGNewCache::fill_in( const FGBucket& b ) {
|
||||||
terrain->addKid( e->terra_transform );
|
terrain->addKid( e->terra_transform );
|
||||||
|
|
||||||
e->lights_transform = NULL;
|
e->lights_transform = NULL;
|
||||||
|
e->lights_range = NULL;
|
||||||
/* uncomment this section for testing ground lights */
|
/* uncomment this section for testing ground lights */
|
||||||
ssgLeaf *lights = gen_lights( light_pts );
|
if ( light_pts->getNum() ) {
|
||||||
if ( lights ) {
|
cout << "generating lights" << endl;
|
||||||
e->lights_transform = new ssgTransform;
|
e->lights_transform = new ssgTransform;
|
||||||
e->lights_range = new ssgRangeSelector;
|
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->addKid( e->lights_range );
|
||||||
e->lights_transform->setTransform( &sgcoord );
|
e->lights_transform->setTransform( &sgcoord );
|
||||||
ground->addKid( e->lights_transform );
|
ground->addKid( e->lights_transform );
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Main/globals.hxx>
|
#include <Main/globals.hxx>
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
|
#include <Time/light.hxx>
|
||||||
|
|
||||||
#include "tileentry.hxx"
|
#include "tileentry.hxx"
|
||||||
|
|
||||||
|
@ -174,8 +175,10 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, float vis) {
|
||||||
ranges[0] = SG_ZERO;
|
ranges[0] = SG_ZERO;
|
||||||
ranges[1] = vis + bounding_radius;
|
ranges[1] = vis + bounding_radius;
|
||||||
terra_range->setRanges( ranges, 2 );
|
terra_range->setRanges( ranges, 2 );
|
||||||
|
if ( lights_range ) {
|
||||||
ranges[1] = vis * 1.5 + bounding_radius;
|
ranges[1] = vis * 1.5 + bounding_radius;
|
||||||
lights_range->setRanges( ranges, 2 );
|
lights_range->setRanges( ranges, 2 );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
sgVec3 sgTrans;
|
sgVec3 sgTrans;
|
||||||
sgSetVec3( sgTrans, offset.x(), offset.y(), offset.z() );
|
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 );
|
sgScaleVec3( up, 10.0 + agl / 100.0 + dist / 10000 );
|
||||||
sgAddVec3( sgTrans, up );
|
sgAddVec3( sgTrans, up );
|
||||||
lights_transform->setTransform( sgTrans );
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,10 @@ public:
|
||||||
ssgRangeSelector *terra_range;
|
ssgRangeSelector *terra_range;
|
||||||
ssgRangeSelector *lights_range;
|
ssgRangeSelector *lights_range;
|
||||||
|
|
||||||
|
// we create several preset brightness and can choose which one we
|
||||||
|
// want based on lighting conditions.
|
||||||
|
ssgSelector *lights_brightness;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
|
|
|
@ -130,7 +130,7 @@ void FGTileMgr::load_tile( const FGBucket& b ) {
|
||||||
if ( t == NULL ) {
|
if ( t == NULL ) {
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG, "Loading tile " << b );
|
FG_LOG( FG_TERRAIN, FG_DEBUG, "Loading tile " << b );
|
||||||
global_tile_cache.fill_in( 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);
|
t->prep_ssg_node( scenery.center, vis);
|
||||||
} else {
|
} else {
|
||||||
FG_LOG( FG_TERRAIN, FG_DEBUG, "Tile already in cache " << b );
|
FG_LOG( FG_TERRAIN, FG_DEBUG, "Tile already in cache " << b );
|
||||||
|
|
Loading…
Reference in a new issue