X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FInstrumentation%2Fgroundradar.cxx;h=3b74bea9e744b7dce69f198491d17b33717b5944;hb=73fbc05a6b6af52825c792902d7738f9cad7ec2f;hp=02f8ca1a461f2169827b43e12c8233fcac17455a;hpb=e0aeda5a5197743b97c5d8e2eae2bfafeebf9c6e;p=flightgear.git diff --git a/src/Instrumentation/groundradar.cxx b/src/Instrumentation/groundradar.cxx index 02f8ca1a4..3b74bea9e 100644 --- a/src/Instrumentation/groundradar.cxx +++ b/src/Instrumentation/groundradar.cxx @@ -112,13 +112,30 @@ void GroundRadar::createTexture(const char* texture_name) FGTextureManager::addTexture(texture_name, getTexture()); } +void GroundRadar::addRunwayVertices(const FGRunwayBase* aRunway, double aTowerLat, double aTowerLon, double aScale, osg::Vec3Array* aVertices) +{ + double az1, az2, dist_m; + geo_inverse_wgs_84(aTowerLat, aTowerLon, aRunway->latitude(), aRunway->longitude(), &az1, &az2, &dist_m); + + osg::Vec3 center = fromPolar(az1, dist_m * aScale) + osg::Vec3(256, 256, 0); + osg::Vec3 leftcenter = fromPolar(aRunway->headingDeg(), aRunway->lengthM() * aScale / 2) + center; + osg::Vec3 lefttop = fromPolar(aRunway->headingDeg() - 90, aRunway->widthM() * aScale / 2) + leftcenter; + osg::Vec3 leftbottom = leftcenter * 2 - lefttop; + osg::Vec3 rightbottom = center * 2 - lefttop; + osg::Vec3 righttop = center * 2 - leftbottom; + + aVertices->push_back(lefttop); + aVertices->push_back(leftbottom); + aVertices->push_back(rightbottom); + aVertices->push_back(righttop); +} + void GroundRadar::updateTexture() { osg::ref_ptr rwy_vertices = new osg::Vec3Array; osg::ref_ptr taxi_vertices = new osg::Vec3Array; const string airport_name = _airport_node->getStringValue(); - FGRunwayList* runways = globals->get_runways(); const FGAirport* airport = fgFindAirportID(airport_name); if (airport == 0) @@ -128,26 +145,24 @@ void GroundRadar::updateTexture() const double tower_lat = tower_location.getLatitudeDeg(); const double tower_lon = tower_location.getLongitudeDeg(); double scale = SG_METER_TO_NM * 200 / _range_node->getDoubleValue(); + + const FGAirport* apt = fgFindAirportID(airport_name); + assert(apt); - for (FGRunway runway = runways->search(airport_name); runway._id == airport_name; runway = runways->next()) + for (unsigned int i=0; inumRunways(); ++i) { - double az1, az2, dist_m; - geo_inverse_wgs_84(tower_lat, tower_lon, runway._lat, runway._lon, &az1, &az2, &dist_m); - - osg::Vec3 center = fromPolar(az1, dist_m * scale) + osg::Vec3(256, 256, 0); - osg::Vec3 leftcenter = fromPolar(runway._heading, runway._length * SG_FEET_TO_METER * scale / 2) + center; - osg::Vec3 lefttop = fromPolar(runway._heading - 90, runway._width * SG_FEET_TO_METER * scale / 2) + leftcenter; - osg::Vec3 leftbottom = leftcenter * 2 - lefttop; - osg::Vec3 rightbottom = center * 2 - lefttop; - osg::Vec3 righttop = center * 2 - leftbottom; - - osg::Vec3Array* vertices = runway._rwy_no[0] == 'x' ? taxi_vertices.get() : rwy_vertices.get(); - vertices->push_back(lefttop); - vertices->push_back(leftbottom); - vertices->push_back(rightbottom); - vertices->push_back(righttop); + FGRunway* runway(apt->getRunwayByIndex(i)); + if (runway->isReciprocal()) continue; + + addRunwayVertices(runway, tower_lat, tower_lon, scale, rwy_vertices.get()); } - + + for (unsigned int i=0; inumTaxiways(); ++i) + { + FGTaxiway* txwy(apt->getTaxiwayByIndex(i)); + addRunwayVertices(txwy, tower_lat, tower_lon, scale, taxi_vertices.get()); + } + osg::Vec3Array* vertices = new osg::Vec3Array(*taxi_vertices.get()); vertices->insert(vertices->end(), rwy_vertices->begin(), rwy_vertices->end()); _geom->setVertexArray(vertices);