1
0
Fork 0

infrastructure for lights

This commit is contained in:
PSadrozinski 2011-10-02 15:51:03 -04:00 committed by Christian Schmitt
parent 5e1ed20e4d
commit 6f7df8da5e
9 changed files with 128 additions and 98 deletions

View file

@ -353,65 +353,60 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
SGBucket b( apt_lon, apt_lat ); SGBucket b( apt_lon, apt_lat );
SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str()); SG_LOG(SG_GENERAL, SG_INFO, b.gen_base_path() << "/" << b.gen_index_str());
// Build precision runways first superpoly_list rwy_lights;
for (i=0; i<runways.size(); i++ ) rwy_lights.clear();
{
if ( runways[i]->IsPrecision() )
{
runways[i]->BuildBtg( altitude, &rwy_polys, &rwy_tps, &accum, &apt_base, &apt_clearing );
}
}
// Now generate pavements, and gather the linear features and lights from them
SG_LOG(SG_GENERAL, SG_ALERT, "Features before pavement add " << features.size() );
// If we are cutting in the linear features, add them first
if (pavements.size()) if (pavements.size())
{ {
for ( i=0; i<pavements.size(); i++ ) for ( i=0; i<pavements.size(); i++ )
{ {
AddFeatures( pavements[i]->GetMarkings() ); AddFeatures( pavements[i]->GetFeatures() );
} }
} }
SG_LOG(SG_GENERAL, SG_ALERT, "Features after pavement add " << features.size() ); // Add the linear features
// Then the linear features
if (features.size()) if (features.size())
{ {
for ( i=0; i<features.size(); i++ ) for ( i=0; i<features.size(); i++ )
{ {
SG_LOG(SG_GENERAL, SG_ALERT, "Build feature Poly " << i << ": " << features[i]->GetDescription() ); SG_LOG(SG_GENERAL, SG_ALERT, "Build Feature Poly " << i << ": " << features[i]->GetDescription() );
// cut the linear feature in until we get the geometry right... // cut the linear feature in until we get the geometry right...
// features[i]->BuildBtg( altitude, &line_polys, &line_tps, &line_accum ); // features[i]->BuildBtg( altitude, &line_polys, &line_tps, &line_accum );
features[i]->BuildBtg( altitude, &pvmt_polys, &pvmt_tps, &accum ); features[i]->BuildBtg( altitude, &pvmt_polys, &pvmt_tps, &accum, &rwy_lights );
} }
} }
else else
{ {
SG_LOG(SG_GENERAL, SG_ALERT, "no pavements"); SG_LOG(SG_GENERAL, SG_ALERT, "no markings");
} }
// wipe out the pavements to save memory
features.clear();
// Now generate pavements, and gather the linear features and lights from them // Build runways next
for (i=0; i<runways.size(); i++ )
{
if ( runways[i]->IsPrecision() )
{
runways[i]->BuildBtg( altitude, &rwy_polys, &rwy_tps, &rwy_lights, &accum, &apt_base, &apt_clearing );
}
}
// Build the pavements
if (pavements.size()) if (pavements.size())
{ {
for ( i=0; i<pavements.size(); i++ ) for ( i=0; i<pavements.size(); i++ )
{ {
SG_LOG(SG_GENERAL, SG_ALERT, "Build Pavement Poly " << i << ": " << pavements[i]->GetDescription()); SG_LOG(SG_GENERAL, SG_ALERT, "Build Pavement Poly " << i << ": " << pavements[i]->GetDescription());
pavements[i]->BuildBtg( altitude, &pvmt_polys, &pvmt_tps, &accum, &apt_base, &apt_clearing ); pavements[i]->BuildBtg( altitude, &pvmt_polys, &pvmt_tps, &accum, &apt_base, &apt_clearing );
AddFeatures( pavements[i]->GetMarkings() ); // AddFeatures( pavements[i]->GetMarkings() );
} }
} }
else else
{ {
SG_LOG(SG_GENERAL, SG_ALERT, "no pavements"); SG_LOG(SG_GENERAL, SG_ALERT, "no pavements");
} }
// wipe out the pavements to save memory
pavements.clear();
if ( apt_base.total_size() == 0 ) if ( apt_base.total_size() == 0 )
{ {
SG_LOG(SG_GENERAL, SG_ALERT, "no airport points generated"); SG_LOG(SG_GENERAL, SG_ALERT, "no airport points generated");
return; return;
@ -894,14 +889,11 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
} }
} }
#if 0
// extend the min/max coordinates of airport area to cover all // extend the min/max coordinates of airport area to cover all
// lights as well // lights as well
for ( i = 0; i < (int)rwy_lights.size(); ++i ) for ( i = 0; i < (int)rwy_lights.size(); ++i )
{ {
for ( j = 0; for ( j = 0; j < (int)rwy_lights[i].get_poly().get_contour(0).size(); ++j )
j < (int)rwy_lights[i].get_poly().get_contour(0).size();
++j )
{ {
Point3D p = rwy_lights[i].get_poly().get_contour(0)[j]; Point3D p = rwy_lights[i].get_poly().get_contour(0)[j];
if ( p.lon() < min_deg.lon() ) if ( p.lon() < min_deg.lon() )
@ -922,7 +914,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
} }
} }
} }
#endif
// need newmat.... // need newmat....
@ -1070,11 +1061,9 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
strips_tc.push_back( base_tc ); strips_tc.push_back( base_tc );
} }
#if 0
// add light points // add light points
superpoly_list tmp_light_list;
superpoly_list tmp_light_list; tmp_light_list.clear(); tmp_light_list.clear();
typedef map < string, double, less<string> > elev_map_type; typedef map < string, double, less<string> > elev_map_type;
typedef elev_map_type::const_iterator const_elev_map_iterator; typedef elev_map_type::const_iterator const_elev_map_iterator;
elev_map_type elevation_map; elev_map_type elevation_map;
@ -1082,7 +1071,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
SG_LOG(SG_GENERAL, SG_INFO, "Computing runway/approach lighting elevations"); SG_LOG(SG_GENERAL, SG_INFO, "Computing runway/approach lighting elevations");
// pass one, calculate raw elevations from Array // pass one, calculate raw elevations from Array
for ( i = 0; i < (int)rwy_lights.size(); ++i ) for ( i = 0; i < (int)rwy_lights.size(); ++i )
{ {
TGTriNodes light_nodes; TGTriNodes light_nodes;
@ -1095,7 +1083,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
} }
// calculate light node elevations // calculate light node elevations
point_list geod_light_nodes = calc_elevations( apt_surf, light_nodes.get_node_list(), 0.5 ); point_list geod_light_nodes = calc_elevations( apt_surf, light_nodes.get_node_list(), 0.5 );
TGPolygon p; TGPolygon p;
p.add_contour( geod_light_nodes, 0 ); p.add_contour( geod_light_nodes, 0 );
@ -1155,7 +1142,6 @@ void Airport::BuildBtg(const string& root, const string_list& elev_src )
pts_n.push_back( pt_n ); pts_n.push_back( pt_n );
pt_materials.push_back( rwy_lights[i].get_material() ); pt_materials.push_back( rwy_lights[i].get_material() );
} }
#endif
// calculate wgs84 mapping of nodes // calculate wgs84 mapping of nodes
std::vector< SGVec3d > wgs84_nodes; std::vector< SGVec3d > wgs84_nodes;

View file

@ -31,7 +31,7 @@ ClosedPoly::ClosedPoly( int st, float s, float th, char* desc )
boundary = NULL; boundary = NULL;
cur_contour = NULL; cur_contour = NULL;
cur_marking = NULL; cur_feature = NULL;
} }
void ClosedPoly::AddNode( BezNode* node ) void ClosedPoly::AddNode( BezNode* node )
@ -52,22 +52,22 @@ void ClosedPoly::AddNode( BezNode* node )
// if recording a linear feature on the pavement, add this node // if recording a linear feature on the pavement, add this node
// to it as well // to it as well
// TODO: just doing marking now, need lighting as well // TODO: just doing marking now, need lighting as well
if (!cur_marking) if (!cur_feature)
{ {
string marking_desc = description + ":"; string feature_desc = description + ":";
if (boundary) if (boundary)
{ {
marking_desc += "hole"; feature_desc += "hole";
} }
else else
{ {
marking_desc += "boundary"; feature_desc += "boundary";
} }
SG_LOG(SG_GENERAL, SG_DEBUG, " Adding node (" << node->GetLoc().x() << "," << node->GetLoc().y() << ") to current linear feature " << cur_marking); SG_LOG(SG_GENERAL, SG_DEBUG, " Adding node (" << node->GetLoc().x() << "," << node->GetLoc().y() << ") to current linear feature " << cur_feature);
cur_marking = new LinearFeature(marking_desc, 1.0f ); cur_feature = new LinearFeature(feature_desc, 1.0f );
} }
cur_marking->AddNode( node ); cur_feature->AddNode( node );
} }
void ClosedPoly::CreateConvexHull( void ) void ClosedPoly::CreateConvexHull( void )
@ -93,14 +93,13 @@ int ClosedPoly::CloseCurContour()
// if we are recording a pavement marking - it must be closed - // if we are recording a pavement marking - it must be closed -
// add the first node of the poly // add the first node of the poly
if (cur_marking) if (cur_feature)
{ {
SG_LOG(SG_GENERAL, SG_DEBUG, "We still have an active linear feature - add the first node to close it"); SG_LOG(SG_GENERAL, SG_DEBUG, "We still have an active linear feature - add the first node to close it");
// cur_marking->Close(); cur_feature->Finish();
cur_marking->Finish();
markings.push_back(cur_marking); features.push_back(cur_feature);
cur_marking = NULL; cur_feature = NULL;
} }
// add the contour to the poly - first one is the outer boundary // add the contour to the poly - first one is the outer boundary
@ -596,7 +595,7 @@ int ClosedPoly::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list
break; break;
default: default:
SG_LOG(SG_GENERAL, SG_ALERT, "ClosedPoly::BuildBtg: unknown material " << surface_type ); SG_LOG(SG_GENERAL, SG_ALERT, "ClosedPoly::BuildBtg: unknown surface type " << surface_type );
exit(1); exit(1);
} }

View file

@ -27,10 +27,10 @@ public:
int BuildOsg( osg::Group* airport ); int BuildOsg( osg::Group* airport );
int BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ); int BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing );
FeatureList* GetMarkings() FeatureList* GetFeatures()
{ {
return &markings; return &features;
} }
private: private:
//osg::DrawArrays* CreatePrimitive( BezContour* contour, osg::Vec3Array* v_pave ); //osg::DrawArrays* CreatePrimitive( BezContour* contour, osg::Vec3Array* v_pave );
@ -61,8 +61,8 @@ private:
TGPolygon pre_tess; TGPolygon pre_tess;
// pavement definitions have multiple linear features (markings and lights for each contour) // pavement definitions have multiple linear features (markings and lights for each contour)
LinearFeature* cur_marking; LinearFeature* cur_feature;
FeatureList markings; FeatureList features;
}; };
typedef std::vector <ClosedPoly *> PavementList; typedef std::vector <ClosedPoly *> PavementList;

View file

@ -405,10 +405,10 @@ int LinearFeature::Finish()
// create the inner and outer boundaries to generate polys // create the inner and outer boundaries to generate polys
// this generates 2 point lists for the contours, and remembers // this generates 2 point lists for the contours, and remembers
// the start stop points for markings // the start stop points for markings and lights
ConvertContour( &contour ); ConvertContour( &contour );
// now generate the supoerpoly and texparams list // now generate the supoerpoly and texparams lists for markings
for (i=0; i<marks.size(); i++) for (i=0; i<marks.size(); i++)
{ {
prev_inner = Point3D(0.0f, 0.0f, 0.0f); prev_inner = Point3D(0.0f, 0.0f, 0.0f);
@ -524,18 +524,9 @@ int LinearFeature::Finish()
material = "lf_broken_white"; material = "lf_broken_white";
width = 0.25f; width = 0.25f;
break; break;
case 101:
case 102:
case 103:
case 104:
case 105:
case 106:
// don't generate lights yet...
break;
default: default:
SG_LOG(SG_GENERAL, SG_ALERT, "ClosedPoly::BuildBtg: unknown material " << marks[i]->type ); SG_LOG(SG_GENERAL, SG_ALERT, "LinearFeature::Finish: unknown marking " << marks[i]->type );
exit(1); exit(1);
} }
@ -580,11 +571,11 @@ int LinearFeature::Finish()
sp.set_poly( poly ); sp.set_poly( poly );
sp.set_material( material ); sp.set_material( material );
sp.set_flag("lf"); sp.set_flag("lf");
feature_polys.push_back(sp); marking_polys.push_back(sp);
tp = TGTexParams( prev_inner, width, 1.0f, heading ); tp = TGTexParams( prev_inner, width, 1.0f, heading );
tp.set_minv(last_end_v); tp.set_minv(last_end_v);
feature_tps.push_back(tp); marking_tps.push_back(tp);
last_end_v = 1.0f - (fmod( (dist - last_end_v), 1.0f )); last_end_v = 1.0f - (fmod( (dist - last_end_v), 1.0f ));
} }
@ -593,18 +584,44 @@ int LinearFeature::Finish()
prev_inner = cur_inner; prev_inner = cur_inner;
} }
} }
// now generate the supoerpoly list for lights
for (i=0; i<lights.size(); i++)
{
// which material for this light
switch( lights[i]->type )
{
case LF_BIDIR_GREEN:
break;
case LF_OMNIDIR_BLUE:
break;
case LF_UNIDIR_CLOSE_AMBER:
break;
case LF_UNIDIR_CLOSE_AMBER_PULSE:
break;
case LF_BIDIR_GREEN_AMBER:
break;
case LF_OMNIDIR_RED:
break;
}
}
} }
int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum ) int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum, superpoly_list* lights )
{ {
TGPolygon poly; TGPolygon poly;
TGPolygon clipped; TGPolygon clipped;
TGPolygon split; TGPolygon split;
int i; int i;
for (i=0; i<feature_polys.size(); i++) for (i=0; i<marking_polys.size(); i++)
{ {
poly = feature_polys[i].get_poly(); poly = marking_polys[i].get_poly();
clipped = tgPolygonDiff( poly, *line_accum ); clipped = tgPolygonDiff( poly, *line_accum );
SG_LOG(SG_GENERAL, SG_DEBUG, "BuildBtg: clipped poly has " << clipped.contours() << " contours"); SG_LOG(SG_GENERAL, SG_DEBUG, "BuildBtg: clipped poly has " << clipped.contours() << " contours");
@ -612,11 +629,11 @@ int LinearFeature::BuildBtg(float alt_m, superpoly_list* line_polys, texparams_l
TGPolygon split = tgPolygonSplitLongEdges( clipped, 400.0 ); TGPolygon split = tgPolygonSplitLongEdges( clipped, 400.0 );
SG_LOG(SG_GENERAL, SG_DEBUG, "BuildBtg: split poly has " << split.contours() << " contours"); SG_LOG(SG_GENERAL, SG_DEBUG, "BuildBtg: split poly has " << split.contours() << " contours");
feature_polys[i].set_poly( split ); marking_polys[i].set_poly( split );
line_polys->push_back( feature_polys[i] ); line_polys->push_back( marking_polys[i] );
*line_accum = tgPolygonUnion( poly, *line_accum ); *line_accum = tgPolygonUnion( poly, *line_accum );
line_tps->push_back( feature_tps[i] ); line_tps->push_back( marking_tps[i] );
} }
return 1; return 1;

View file

@ -53,6 +53,14 @@ public:
}; };
typedef std::vector <Marking*> MarkingList; typedef std::vector <Marking*> MarkingList;
struct Lighting
{
public:
int type;
int start_idx;
int end_idx;
};
typedef std::vector <Lighting*> LightingList;
class LinearFeature class LinearFeature
{ {
@ -85,7 +93,7 @@ public:
int Finish(); int Finish();
int BuildOsg( osg::Group* airport ); int BuildOsg( osg::Group* airport );
int BuildBtg( float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum ); int BuildBtg( float alt_m, superpoly_list* line_polys, texparams_list* line_tps, TGPolygon* line_accum, superpoly_list* lights );
private: private:
Point3D OffsetPointFirst( Point3D *cur, Point3D *next, double offset_by ); Point3D OffsetPointFirst( Point3D *cur, Point3D *next, double offset_by );
@ -94,8 +102,12 @@ private:
double offset; double offset;
double width; double width;
MarkingList marks;
Marking* cur_mark; MarkingList marks;
Marking* cur_mark;
LightingList lights;
Lighting* cur_light;
void ConvertContour( BezContour* src ); void ConvertContour( BezContour* src );
@ -108,8 +120,10 @@ private:
// contour definition after bezier interpolation // contour definition after bezier interpolation
point_list points; point_list points;
superpoly_list feature_polys; superpoly_list marking_polys;
texparams_list feature_tps; texparams_list marking_tps;
superpoly_list lighting_polys;
}; };
typedef std::vector <LinearFeature *> FeatureList; typedef std::vector <LinearFeature *> FeatureList;

View file

@ -293,7 +293,7 @@ int main(int argc, char **argv)
Parser* parser = new Parser(input_file); Parser* parser = new Parser(input_file);
SG_LOG(SG_GENERAL, SG_INFO, "Parse katl"); SG_LOG(SG_GENERAL, SG_INFO, "Parse katl");
parser->Parse((char*)"katl"); parser->Parse((char*)"edfe");
if (view_osg) if (view_osg)
{ {

View file

@ -38,14 +38,14 @@ BezNode* Parser::ParseNode( int type, char* line, BezNode* prevNode )
{ {
double lat, lon; double lat, lon;
double ctrl_lat, ctrl_lon; double ctrl_lat, ctrl_lon;
int mark_type, light_type; int feat_type1, feat_type2;
BezNode *curNode = NULL; BezNode *curNode = NULL;
bool hasCtrl; bool hasCtrl;
bool close; bool close;
bool term; bool term;
bool hasMarking = false; bool hasFeat1 = false;
bool hasLighting = false; bool hasFeat2 = false;
int numParams; int numParams;
switch(type) switch(type)
@ -90,26 +90,26 @@ BezNode* Parser::ParseNode( int type, char* line, BezNode* prevNode )
// parse the line // parse the line
if (hasCtrl) if (hasCtrl)
{ {
numParams = sscanf(line, "%lf %lf %lf %lf %d %d", &lat, &lon, &ctrl_lat, &ctrl_lon, &mark_type, &light_type); numParams = sscanf(line, "%lf %lf %lf %lf %d %d", &lat, &lon, &ctrl_lat, &ctrl_lon, &feat_type1, &feat_type2);
if (numParams > 4) if (numParams > 4)
{ {
hasMarking = true; hasFeat1 = true;
} }
if (numParams > 5) if (numParams > 5)
{ {
hasLighting = true; hasFeat2 = true;
} }
} }
else else
{ {
numParams = sscanf(line, "%lf %lf %d %d", &lat, &lon, &mark_type, &light_type); numParams = sscanf(line, "%lf %lf %d %d", &lat, &lon, &feat_type1, &feat_type2);
if (numParams > 2) if (numParams > 2)
{ {
hasMarking = true; hasFeat1 = true;
} }
if (numParams > 3) if (numParams > 3)
{ {
hasLighting = true; hasFeat2 = true;
} }
} }
@ -143,14 +143,28 @@ BezNode* Parser::ParseNode( int type, char* line, BezNode* prevNode )
} }
} }
if (hasMarking) if (hasFeat1)
{ {
curNode->SetMarking( mark_type ); if (feat_type1 < 100)
{
curNode->SetMarking( feat_type1 );
}
else
{
curNode->SetLighting( feat_type1 );
}
} }
if (hasLighting) if (hasFeat2)
{ {
curNode->SetLighting( light_type ); if (feat_type2 < 100)
{
curNode->SetMarking( feat_type2 );
}
else
{
curNode->SetLighting( feat_type2 );
}
} }
return curNode; return curNode;

View file

@ -370,7 +370,7 @@ void Runway::gen_marked_rwy( double alt_m, const string& material, superpoly_lis
} }
#endif #endif
int Runway::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ) int Runway::BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, superpoly_list* rwy_lights, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing )
{ {
TGPolygon base, safe_base; TGPolygon base, safe_base;
string material; string material;

View file

@ -69,7 +69,7 @@ TGRunway rwy;
} }
int BuildOsg( osg::Group* airport ); int BuildOsg( osg::Group* airport );
int BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing ); int BuildBtg( float alt_m, superpoly_list* rwy_polys, texparams_list* texparams, superpoly_list* rwy_lights, TGPolygon* accum, TGPolygon* apt_base, TGPolygon* apt_clearing );
private: private: