static const double sqrt_m_log01 = sqrt( m_log01 );
static GLfloat fog_exp_density;
static GLfloat fog_exp2_density;
-static GLfloat fog_exp2_punch_through;
+static GLfloat rwy_exp2_punch_through;
+static GLfloat taxi_exp2_punch_through;
#ifdef FG_NETWORK_OLK
ssgSelector *fgd_sel = NULL;
ssgCullAndDraw( globals->get_scenery()->get_scene_graph() );
// draw the lights
- glFogf (GL_FOG_DENSITY, fog_exp2_punch_through);
+ glFogf (GL_FOG_DENSITY, rwy_exp2_punch_through);
ssgSetNearFar( scene_nearplane, scene_farplane );
- ssgCullAndDraw( globals->get_scenery()->get_gnd_lights_root() );
ssgCullAndDraw( globals->get_scenery()->get_rwy_lights_root() );
+ ssgCullAndDraw( globals->get_scenery()->get_gnd_lights_root() );
+
if (fgGetBool("/environment/clouds/status"))
thesky->postDraw( cur_fdm_state->get_Altitude() * SG_FEET_TO_METER );
fog_exp_density = m_log01 / actual_visibility;
fog_exp2_density = sqrt_m_log01 / actual_visibility;
- fog_exp2_punch_through = sqrt_m_log01 / ( actual_visibility * 2.5 );
+ rwy_exp2_punch_through = sqrt_m_log01 / ( actual_visibility * 2.5 );
+ taxi_exp2_punch_through = sqrt_m_log01 / ( actual_visibility * 1.5 );
}
// double angle;
// change state for lighting here
- // draw lighting
- // Set punch through fog density
- glFogf (GL_FOG_DENSITY, fog_exp2_punch_through);
-
+ // draw runway lighting
+ glFogf (GL_FOG_DENSITY, rwy_exp2_punch_through);
ssgSetNearFar( scene_nearplane, scene_farplane );
- ssgCullAndDraw( globals->get_scenery()->get_gnd_lights_root() );
#ifdef FG_EXPERIMENTAL_LIGHTING
// Enable states for drawing points with GL_extension
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glPolygonMode(GL_FRONT, GL_POINT);
+
+ // draw runway lighting
ssgCullAndDraw( globals->get_scenery()->get_rwy_lights_root() );
+
+ // change punch through and then draw taxi lighting
+ glFogf (GL_FOG_DENSITY, taxi_exp2_punch_through);
+ ssgCullAndDraw( globals->get_scenery()->get_taxi_lights_root() );
+
+ // clean up lighting
glPolygonMode(GL_FRONT, GL_FILL);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_POINT_SMOOTH);
#endif
+ // draw ground lighting
+ ssgCullAndDraw( globals->get_scenery()->get_gnd_lights_root() );
+
if ( fgGetBool("/sim/rendering/skyblend") ) {
// draw the sky cloud layers
if (fgGetBool("/environment/clouds/status")) {
tile_bucket( b ),
terra_transform( new ssgTransform ),
rwy_lights_transform( new ssgTransform ),
+ taxi_lights_transform( new ssgTransform ),
terra_range( new ssgRangeSelector ),
loaded(false),
pending_models(0),
free_tracker |= GROUND_LIGHTS;
}
} else if ( !(free_tracker & RWY_LIGHTS) && rwy_lights_transform ) {
- // delete the terrain lighting branch (this should already have been
- // disconnected from the scene graph)
+ // 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 );
free_tracker |= RWY_LIGHTS;
}
+ } else if ( !(free_tracker & TAXI_LIGHTS) && taxi_lights_transform ) {
+ // 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 );
+ free_tracker |= TAXI_LIGHTS;
+ }
} else if ( !(free_tracker & LIGHTMAPS) && lightmaps_transform ) {
// ADA
// delete the terrain lighting branch (this should already have been
// }
}
+ if ( taxi_lights_transform ) {
+ // we need to lift the lights above the terrain to avoid
+ // z-buffer fighting. We do this based on our altitude and
+ // the distance this tile is away from scenery center.
+
+ sgVec3 lift_vec;
+ sgCopyVec3( lift_vec, up );
+
+ // we fudge agl by 30 meters so that the lifting function
+ // doesn't phase in until we are > 30m agl.
+ double agl;
+ agl = globals->get_current_view()->getAltitudeASL_ft()
+ * SG_FEET_TO_METER - globals->get_scenery()->get_cur_elev()
+ - 30.0;
+ if ( agl < 0.0 ) {
+ agl = 0.0;
+ }
+
+ if ( general.get_glDepthBits() > 16 ) {
+ sgScaleVec3( lift_vec, 0.0 + agl / 500.0 );
+ } else {
+ sgScaleVec3( lift_vec, 0.0 + agl / 20.0 );
+ }
+
+ sgVec3 lt_trans;
+ sgCopyVec3( lt_trans, sgTrans );
+
+ 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);
+ // }
+ }
+
// ADA
// Transform & Render runway lights - 23 Mar 2001
sgSetVec3( sgTrans, offset.x(), offset.y(), offset.z() );
bool FGTileEntry::obj_load( const std::string& path,
- ssgBranch* geometry,
- ssgBranch* rwy_lights,
- ssgVertexArray* ground_lights, bool is_base )
+ ssgBranch* geometry,
+ ssgBranch* rwy_lights,
+ ssgBranch* taxi_lights,
+ ssgVertexArray* ground_lights, bool is_base )
{
Point3D c; // returned center point
double br; // returned bounding radius
// try loading binary format
if ( fgBinObjLoad( path, is_base,
- &c, &br, geometry, rwy_lights, ground_lights ) )
+ &c, &br, geometry,
+ rwy_lights, taxi_lights, ground_lights ) )
{
if ( is_base ) {
center = c;
ssgBranch *geometry = new ssgBranch;
if ( obj_load( custom_path.str(),
- geometry, NULL, light_pts, true ) )
+ geometry, NULL, NULL, light_pts, true ) )
{
new_tile -> addKid( geometry );
} else {
ssgBranch *geometry = new ssgBranch;
ssgBranch *rwy_lights = new ssgBranch;
+ ssgBranch *taxi_lights = new ssgBranch;
if ( obj_load( custom_path.str(),
- geometry, rwy_lights, NULL, false ) )
+ geometry, rwy_lights, taxi_lights,
+ NULL, false ) )
{
if ( geometry -> getNumKids() > 0 ) {
new_tile -> addKid( geometry );
} else {
delete rwy_lights;
}
+ if ( taxi_lights -> getNumKids() > 0 ) {
+ taxi_lights_transform -> addKid( taxi_lights );
+ } else {
+ delete taxi_lights;
+ }
} else {
delete geometry;
delete rwy_lights;
+ delete taxi_lights;
}
} else if ( token == "OBJECT_STATIC" ||
rwy_lights_transform->setTransform( &sgcoord );
}
+ // Add taxi lights to scene graph if any exist
+ if ( taxi_lights_transform->getNumKids() > 0 ) {
+ SG_LOG( SG_TERRAIN, SG_DEBUG, "adding taxi lights" );
+ taxi_lights_transform->setTransform( &sgcoord );
+ }
+
// ADA
// Create runway lights - 23 Mar 2001
lightmaps_transform = NULL;
void
FGTileEntry::add_ssg_nodes( ssgBranch* terrain_branch,
ssgBranch* gnd_lights_branch,
- ssgBranch* rwy_lights_branch )
+ ssgBranch* rwy_lights_branch,
+ ssgBranch* taxi_lights_branch )
{
// bump up the ref count so we can remove this later without
// having ssg try to free the memory.
rwy_lights_branch->addKid( rwy_lights_transform );
}
+ 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 );
+ }
+
// ADA
if ( lightmaps_transform != 0 ) {
// bump up the ref count so we can remove this later without
}
}
+ // find the taxi lighting branch
+ if ( taxi_lights_transform ) {
+ pcount = taxi_lights_transform->getNumParents();
+ if ( pcount > 0 ) {
+ // find the first parent (should only be one)
+ ssgBranch *parent = taxi_lights_transform->getParent( 0 ) ;
+ if( parent ) {
+ // disconnect the light branch (we previously ref()'d
+ // it so it won't get freed now)
+ parent->removeKid( taxi_lights_transform );
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "parent pointer is NULL! Dying" );
+ exit(-1);
+ }
+ } else {
+ SG_LOG( SG_TERRAIN, SG_ALERT,
+ "Parent count is zero for an ssg light tile! Dying" );
+ exit(-1);
+ }
+ }
+
// ADA
//runway lights - 23 Mar 2001
// Delete runway lights and free memory