From 3d7f467c61873b624bdcc0389273415791852f73 Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 30 Dec 2003 05:57:25 +0000 Subject: [PATCH] First stab at correct vasi/papi coloring. This is still rough and doesn't account for variation in lighting alignment, but it's more useful than the previous attempt which was based on a misunderstanding of how environment mapping worked. --- src/Scenery/tileentry.cxx | 49 +++++++++++++++++++++++++++++++++++++++ src/Scenery/tilemgr.cxx | 13 ++--------- src/Scenery/tilemgr.hxx | 2 -- 3 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/Scenery/tileentry.cxx b/src/Scenery/tileentry.cxx index 7e71d5da5..844cd4311 100644 --- a/src/Scenery/tileentry.cxx +++ b/src/Scenery/tileentry.cxx @@ -34,6 +34,7 @@ #include #include +#include #include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include #include #include @@ -490,6 +492,53 @@ void FGTileEntry::prep_ssg_node( const Point3D& p, sgVec3 up, float vis) { taxi_lights_selector->select(0x00); } } + + if ( vasi_lights_transform ) { + // now we need to traverse the list of vasi lights and update + // their coloring + for ( int i = 0; i < vasi_lights_transform->getNumKids(); ++i ) { + // cout << "vasi root = " << i << endl; + ssgBranch *v = (ssgBranch *)vasi_lights_transform->getKid(i); + for ( int j = 0; j < v->getNumKids(); ++j ) { + // cout << " vasi branch = " << j << endl; + ssgTransform *kid = (ssgTransform *)v->getKid(j); + SGVASIUserData *vasi = (SGVASIUserData *)kid->getUserData(); + + if ( vasi != NULL ) { + sgdVec3 s; + sgdCopyVec3( s, vasi->get_abs_pos() ); + Point3D start(s[0], s[1], s[2]); + + sgdVec3 d; + sgdCopyVec3( d, globals->get_current_view()->get_absolute_view_pos() ); + + double dist = sgdDistanceVec3( s, d ); + + double cur_alt = globals->get_current_view()->getAltitudeASL_ft() * SG_FEET_TO_METER; + + double y = cur_alt - vasi->get_alt_m(); + + double angle; + if ( dist != 0 ) { + angle = asin( y / dist ); + } else { + angle = 0.0; + } + + if ( angle * SG_RADIANS_TO_DEGREES < 3.0 ) { + vasi->set_color(0.0); + } else { + vasi->set_color(1.0); + } + // cout << " dist = " << dist + // << " angle = " << angle * SG_RADIANS_TO_DEGREES + // << endl; + } else { + SG_LOG( SG_TERRAIN, SG_ALERT, "no vasi data!" ); + } + } + } + } } diff --git a/src/Scenery/tilemgr.cxx b/src/Scenery/tilemgr.cxx index 2b16af018..0747c4ea6 100644 --- a/src/Scenery/tilemgr.cxx +++ b/src/Scenery/tilemgr.cxx @@ -108,7 +108,6 @@ int FGTileMgr::init() { current_bucket.make_bad(); longitude = latitude = -1000.0; - last_longitude = last_latitude = -1000.0; return 1; } @@ -417,16 +416,8 @@ int FGTileMgr::update( SGLocation *location, double visibility_meters, // save bucket... previous_bucket = current_bucket; - // no reason to update this if we haven't moved... - if ( longitude != last_longitude || latitude != last_latitude ) { - // update current elevation... - if ( updateCurrentElevAtPos( abs_pos_vector, altitude_m, - location->get_tile_center() ) ) - { - last_longitude = longitude; - last_latitude = latitude; - } - } + updateCurrentElevAtPos( abs_pos_vector, altitude_m, + location->get_tile_center() ); return 1; } diff --git a/src/Scenery/tilemgr.hxx b/src/Scenery/tilemgr.hxx index 686ab4514..ab4c422a9 100644 --- a/src/Scenery/tilemgr.hxx +++ b/src/Scenery/tilemgr.hxx @@ -101,8 +101,6 @@ private: double longitude; double latitude; double altitude_m; - double last_longitude; - double last_latitude; /** * tile cache