]> git.mxchange.org Git - flightgear.git/commitdiff
First stab at correct vasi/papi coloring. This is still rough and doesn't
authorcurt <curt>
Tue, 30 Dec 2003 05:57:25 +0000 (05:57 +0000)
committercurt <curt>
Tue, 30 Dec 2003 05:57:25 +0000 (05:57 +0000)
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
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx

index 7e71d5da5a594ae7f9286184ef02e3beb215788b..844cd4311c0f1ecf76051f4fb1f469fc2bdafde2 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <simgear/bucket/newbucket.hxx>
 #include <simgear/debug/logstream.hxx>
+#include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/sg_random.h>
 #include <simgear/misc/sgstream.hxx>
@@ -41,6 +42,7 @@
 #include <simgear/scene/material/matlib.hxx>
 #include <simgear/scene/tgdb/apt_signs.hxx>
 #include <simgear/scene/tgdb/obj.hxx>
+#include <simgear/scene/tgdb/vasi.hxx>
 
 #include <Aircraft/aircraft.hxx>
 #include <Include/general.hxx>
@@ -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!" );
+                }
+            }
+        }
+    }
 }
 
 
index 2b16af01838cb629a7c5d9c1744931f5a14e9730..0747c4ea663147947215cf72d789d0950b819f89 100644 (file)
@@ -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;
 }
index 686ab45140b7ca603b70353f14606c775cd49e0f..ab4c422a9744dec9d78afa15c34c6d47f9963a6b 100644 (file)
@@ -101,8 +101,6 @@ private:
     double longitude;
     double latitude;
     double altitude_m;
-    double last_longitude;
-    double last_latitude;
 
     /**
      * tile cache