#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
-#include <Time/light.hxx>
-
#include "obj.hxx"
typedef int_list::const_iterator int_point_list_iterator;
-// not used because plib branches don't honor call backs.
-static int
-runway_lights_pretrav (ssgEntity * e, int mask)
-{
- // Turn on lights only at night
- float sun_angle = cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES;
- return int((sun_angle > 85.0) ||
- (fgGetDouble("/environment/visibility-m") < 5000.0));
-}
-
-
// Generate an ocean tile
bool fgGenTile( const string& path, SGBucket b,
Point3D *center, double *bounding_radius,
Point3D *center,
double *bounding_radius,
SGMaterialLib *matlib,
+ bool use_random_objects,
ssgBranch* geometry,
ssgBranch* rwy_lights,
ssgBranch* taxi_lights,
ssgVertexArray *ground_lights )
{
SGBinObject obj;
- bool use_random_objects =
- fgGetBool("/sim/rendering/random-objects", true);
if ( ! obj.read_bin( path ) ) {
return false;
pts_v[i], pts_n[i],
matlib,
pt_materials[i], up );
- // branches don't honor callbacks as far as I know so I'm
- // commenting this out to avoid a plib runtime warning.
- branch->setTravCallback( SSG_CALLBACK_PRETRAV,
- runway_lights_pretrav );
if ( pt_materials[i].substr(0, 16) == "RWY_BLUE_TAXIWAY" ) {
taxi_lights->addKid( branch );
} else {
#include <Aircraft/aircraft.hxx>
#include <Include/general.hxx>
+#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
#include <Main/viewer.hxx>
#include <Scenery/scenery.hxx>
// Constructor
FGTileEntry::FGTileEntry ( const SGBucket& b )
- : /* ncount( 0 ), */
- center( Point3D( 0.0 ) ),
+ : center( Point3D( 0.0 ) ),
tile_bucket( b ),
terra_transform( new ssgTransform ),
rwy_lights_transform( new ssgTransform ),
taxi_lights_transform( new ssgTransform ),
terra_range( new ssgRangeSelector ),
+ rwy_lights_selector( new ssgSelector ),
+ taxi_lights_selector( new ssgSelector ),
loaded(false),
pending_models(0),
free_tracker(0)
ssgDeRefDelete( gnd_lights_transform );
free_tracker |= GROUND_LIGHTS;
}
- } else if ( !(free_tracker & RWY_LIGHTS) && rwy_lights_transform ) {
+ } else if ( !(free_tracker & RWY_LIGHTS) && rwy_lights_selector ) {
// delete the runway lighting branch (this should already have
// been disconnected from the scene graph)
- SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING rwy_lights_transform" );
- if ( fgPartialFreeSSGtree( rwy_lights_transform, delete_size ) == 0 ) {
- ssgDeRefDelete( rwy_lights_transform );
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING rwy_lights_selector" );
+ if ( fgPartialFreeSSGtree( rwy_lights_selector, delete_size ) == 0 ) {
+ ssgDeRefDelete( rwy_lights_selector );
free_tracker |= RWY_LIGHTS;
}
- } else if ( !(free_tracker & TAXI_LIGHTS) && taxi_lights_transform ) {
+ } else if ( !(free_tracker & TAXI_LIGHTS) && taxi_lights_selector ) {
// delete the taxi lighting branch (this should already have been
// disconnected from the scene graph)
- SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING taxi_lights_transform" );
- if ( fgPartialFreeSSGtree( taxi_lights_transform, delete_size ) == 0 ) {
- ssgDeRefDelete( taxi_lights_transform );
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "FREEING taxi_lights_selector" );
+ if ( fgPartialFreeSSGtree( taxi_lights_selector, delete_size ) == 0 ) {
+ ssgDeRefDelete( taxi_lights_selector );
free_tracker |= TAXI_LIGHTS;
}
} else if ( !(free_tracker & LIGHTMAPS) ) {
sgAddVec3( lt_trans, lift_vec );
rwy_lights_transform->setTransform( lt_trans );
- // select which set of lights based on sun angle
- // float sun_angle = cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES;
- // if ( sun_angle > 95 ) {
- // gnd_lights_brightness->select(0x04);
- // } else if ( sun_angle > 92 ) {
- // gnd_lights_brightness->select(0x02);
- // } else if ( sun_angle > 89 ) {
- // gnd_lights_brightness->select(0x01);
- // } else {
- // gnd_lights_brightness->select(0x00);
- // }
+ // turn runway lights on/off based on sun angle and visibility
+ float sun_angle = cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES;
+ if ( sun_angle > 85 ||
+ (fgGetDouble("/environment/visibility-m") < 5000.0) ) {
+ rwy_lights_selector->select(0x01);
+ } else {
+ rwy_lights_selector->select(0x00);
+ }
}
if ( taxi_lights_transform ) {
sgAddVec3( lt_trans, lift_vec );
taxi_lights_transform->setTransform( lt_trans );
- // select which set of lights based on sun angle
- // float sun_angle = cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES;
- // if ( sun_angle > 95 ) {
- // gnd_lights_brightness->select(0x04);
- // } else if ( sun_angle > 92 ) {
- // gnd_lights_brightness->select(0x02);
- // } else if ( sun_angle > 89 ) {
- // gnd_lights_brightness->select(0x01);
- // } else {
- // gnd_lights_brightness->select(0x00);
- // }
+ // turn taxi lights on/off based on sun angle and visibility
+ float sun_angle = cur_light_params.sun_angle * SGD_RADIANS_TO_DEGREES;
+ if ( sun_angle > 85 ||
+ (fgGetDouble("/environment/visibility-m") < 5000.0) ) {
+ taxi_lights_selector->select(0x01);
+ } else {
+ taxi_lights_selector->select(0x00);
+ }
}
}
Point3D c; // returned center point
double br; // returned bounding radius
+ bool use_random_objects =
+ fgGetBool("/sim/rendering/random-objects", true);
+
// try loading binary format
if ( fgBinObjLoad( path, is_base,
- &c, &br, globals->get_matlib(), geometry,
- rwy_lights, taxi_lights, ground_lights ) )
+ &c, &br, globals->get_matlib(), use_random_objects,
+ geometry, rwy_lights, taxi_lights, ground_lights ) )
{
if ( is_base ) {
center = c;
gnd_lights_transform->setTransform( &sgcoord );
}
- // Add runway lights to scene graph if any exist
+ // Update runway lights transform
if ( rwy_lights_transform->getNumKids() > 0 ) {
- SG_LOG( SG_TERRAIN, SG_DEBUG, "adding runway lights" );
rwy_lights_transform->setTransform( &sgcoord );
}
- // Add taxi lights to scene graph if any exist
+ // Update taxi lights transform
if ( taxi_lights_transform->getNumKids() > 0 ) {
- SG_LOG( SG_TERRAIN, SG_DEBUG, "adding taxi lights" );
taxi_lights_transform->setTransform( &sgcoord );
}
}
if ( rwy_lights_transform != NULL ) {
// bump up the ref count so we can remove this later without
// having ssg try to free the memory.
- rwy_lights_transform->ref();
- rwy_lights_branch->addKid( rwy_lights_transform );
+ rwy_lights_selector->ref();
+ rwy_lights_selector->addKid( rwy_lights_transform );
+ rwy_lights_branch->addKid( rwy_lights_selector );
}
if ( taxi_lights_transform != NULL ) {
// bump up the ref count so we can remove this later without
// having ssg try to free the memory.
- taxi_lights_transform->ref();
- taxi_lights_branch->addKid( taxi_lights_transform );
+ taxi_lights_selector->ref();
+ taxi_lights_selector->addKid( taxi_lights_transform );
+ taxi_lights_branch->addKid( taxi_lights_selector );
}
loaded = true;