- // no .stg file so this must be old scenery
-
- new_tile = obj_load( basename.str(), light_pts, true );
-
- // load custom objects
- SG_LOG( SG_TERRAIN, SG_DEBUG, "Checking for custom objects ..." );
-
- SGPath index_path = tile_path;
- index_path.append( index_str );
- index_path.concat( ".ind" );
-
- SG_LOG( SG_TERRAIN, SG_DEBUG, "Looking in " << index_path.str() );
-
- sg_gzifstream in( index_path.str() );
-
- if ( in.is_open() ) {
- string token, name;
-
- while ( ! in.eof() ) {
- in >> token;
-
- if ( token == "OBJECT" ) {
- in >> name >> ::skipws;
- SG_LOG( SG_TERRAIN, SG_DEBUG, "token = " << token
- << " name = " << name );
-
- SGPath custom_path = tile_path;
- custom_path.append( name );
- ssgBranch *custom_obj
- = obj_load( custom_path.str(), NULL, false );
- if ( (new_tile != NULL) && (custom_obj != NULL) ) {
- new_tile -> addKid( custom_obj );
- }
- } else if ( token == "OBJECT_STATIC" ) {
- // load object info
- double lon, lat, elev, hdg;
- in >> name >> lon >> lat >> elev >> hdg >> ::skipws;
- SG_LOG( SG_TERRAIN, SG_INFO, "token = " << token
- << " name = " << name
- << " pos = " << lon << ", " << lat
- << " elevation = " << elev
- << " heading = " << hdg );
-
- // object loading is deferred to main render thread,
- // but lets figure out the paths right now.
- SGPath custom_path = tile_path;
- custom_path.append( name );
-
- sgCoord obj_pos;
- WorldCoordinate( &obj_pos, center, lat, lon, elev, hdg );
-
- ssgTransform *obj_trans = new ssgTransform;
- obj_trans->setTransform( &obj_pos );
-
- // wire as much of the scene graph together as we can
- new_tile->addKid( obj_trans );
-
- // bump up the pending models count
- pending_models++;
-
- // push an entry onto the model load queue
- FGDeferredModel *dm
- = new FGDeferredModel( custom_path.str(),
- tile_path.str(),
- this, obj_trans );
- FGTileMgr::model_ready( dm );
- } else if ( token == "OBJECT_TAXI_SIGN" ) {
- // load object info
- double lon, lat, elev, hdg;
- in >> name >> lon >> lat >> elev >> hdg >> ::skipws;
- SG_LOG( SG_TERRAIN, SG_INFO, "token = " << token
- << " name = " << name
- << " pos = " << lon << ", " << lat
- << " elevation = " << elev
- << " heading = " << hdg );
-
- // load the object itself
- SGPath custom_path = tile_path;
- custom_path.append( name );
-
- sgCoord obj_pos;
- WorldCoordinate( &obj_pos, center, lat, lon, elev, hdg );
-
- ssgTransform *obj_trans = new ssgTransform;
- obj_trans->setTransform( &obj_pos );
-
- ssgBranch *custom_obj
- = gen_taxi_sign( custom_path.str(), name );
-
- // wire the pieces together
- if ( (new_tile != NULL) && (custom_obj != NULL) ) {
- obj_trans -> addKid( custom_obj );
- }
- new_tile->addKid( obj_trans );
- } else if ( token == "OBJECT_RUNWAY_SIGN" ) {
- // load object info
- double lon, lat, elev, hdg;
- in >> name >> lon >> lat >> elev >> hdg >> ::skipws;
- SG_LOG( SG_TERRAIN, SG_INFO, "token = " << token
- << " name = " << name
- << " pos = " << lon << ", " << lat
- << " elevation = " << elev
- << " heading = " << hdg );
-
- // load the object itself
- SGPath custom_path = tile_path;
- custom_path.append( name );
-
- sgCoord obj_pos;
- WorldCoordinate( &obj_pos, center, lat, lon, elev, hdg );
-
- ssgTransform *obj_trans = new ssgTransform;
- obj_trans->setTransform( &obj_pos );
-
- ssgBranch *custom_obj
- = gen_runway_sign( custom_path.str(), name );
-
- // wire the pieces together
- if ( (new_tile != NULL) && (custom_obj != NULL) ) {
- obj_trans -> addKid( custom_obj );
- }
- new_tile->addKid( obj_trans );
- } else {
- SG_LOG( SG_TERRAIN, SG_ALERT,
- "Unknown token " << token << " in "
- << index_path.str() );
- in >> ::skipws;
- }
- }
- }
- }
-
- if ( new_tile != NULL ) {
- terra_range->addKid( new_tile );
- }
-
- terra_transform->addKid( terra_range );
-
- // calculate initial tile offset
- SetOffset( scenery.center );
- sgCoord sgcoord;
- sgSetCoord( &sgcoord,
- offset.x(), offset.y(), offset.z(),
- 0.0, 0.0, 0.0 );
- terra_transform->setTransform( &sgcoord );
- // terrain->addKid( terra_transform );
-
- lights_transform = NULL;
- lights_range = NULL;
- /* uncomment this section for testing ground lights */
- if ( light_pts->getNum() ) {
- SG_LOG( SG_TERRAIN, SG_DEBUG, "generating lights" );
- lights_transform = new ssgTransform;
- lights_range = new ssgRangeSelector;
- lights_brightness = new ssgSelector;
- ssgLeaf *lights;
-
- lights = gen_lights( light_pts, 4, 0.7 );
- lights_brightness->addKid( lights );
-
- lights = gen_lights( light_pts, 2, 0.85 );
- lights_brightness->addKid( lights );
-
- lights = gen_lights( light_pts, 1, 1.0 );
- lights_brightness->addKid( lights );
-
- lights_range->addKid( lights_brightness );
- lights_transform->addKid( lights_range );
- lights_transform->setTransform( &sgcoord );
- // ground->addKid( lights_transform );