]> git.mxchange.org Git - simgear.git/commitdiff
Track some additional data required for computing vasi/papi colors.
authorcurt <curt>
Tue, 30 Dec 2003 05:53:50 +0000 (05:53 +0000)
committercurt <curt>
Tue, 30 Dec 2003 05:53:50 +0000 (05:53 +0000)
simgear/scene/tgdb/Makefile.am
simgear/scene/tgdb/obj.cxx
simgear/scene/tgdb/pt_lights.cxx
simgear/scene/tgdb/pt_lights.hxx
simgear/scene/tgdb/vasi.hxx [new file with mode: 0644]

index 91a6285369a28b9dd44a5744112104a53363d317..bdc8cf5378e83f8bbf3dfea6f941f4e3b843a6c7 100644 (file)
@@ -9,7 +9,8 @@ include_HEADERS = \
        leaf.hxx \
        obj.hxx \
        pt_lights.hxx \
-       userdata.hxx
+       userdata.hxx \
+       vasi.hxx
 
 libsgtgdb_a_SOURCES = \
        apt_signs.cxx \
index d8084de05828b84737c4223e2568a8a36094f586..7ec6504177534ba672a67c29b26d13e6ae3b622b 100644 (file)
@@ -351,8 +351,8 @@ bool sgBinObjLoad( const string& path, const bool is_base,
         // cout << "pts_v.size() = " << pts_v.size() << endl;
         if ( pt_materials[i].substr(0, 3) == "RWY" ) {
             // airport environment lighting
-            sgVec3 up;
-            sgSetVec3( up, center->x(), center->y(), center->z() );
+            sgdVec3 up;
+            sgdSetVec3( up, center->x(), center->y(), center->z() );
             // returns a transform -> lod -> leaf structure
             ssgBranch *branch = sgMakeDirectionalLights( nodes, normals,
                                                          pts_v[i], pts_n[i],
index 539c99e0df37dc87738037257ad8d56c72b79944..6512a9e063892f313a7cf334120f92828f51d8ee 100644 (file)
@@ -26,6 +26,8 @@
 #include <simgear/scene/material/mat.hxx>
 #include <simgear/scene/material/matlib.hxx>
 
+#include "vasi.hxx"
+
 #include "pt_lights.hxx"
 
 
@@ -161,7 +163,7 @@ static ssgTransform *gen_dir_light_group( const point_list &nodes,
                                           const int_list &pnt_i,
                                           const int_list &nml_i,
                                           const SGMaterial *mat,
-                                          sgVec3 up, bool vertical = false )
+                                          sgVec3 up, bool vertical )
 {
     sgVec3 center;
     calc_center_point( nodes, pnt_i, center );
@@ -548,7 +550,8 @@ static ssgTransform *gen_rabbit_lights( const point_list &nodes,
 #if 0 // debugging infrastructure
 // Generate a normal line 
 static ssgLeaf *gen_normal_line( SGMaterialLib *matlib,
-                                 sgVec3 pt, sgVec3 dir, sgVec3 up ) {
+                                 sgVec3 pt, sgVec3 dir, sgVec3 up )
+{
 
     ssgVertexArray *vl = new ssgVertexArray( 3 );
     ssgColourArray *cl = new ssgColourArray( 3 );
@@ -581,8 +584,11 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
                                     const int_list &nml_i,
                                     SGMaterialLib *matlib,
                                     const string &material,
-                                    sgVec3 up )
+                                    sgdVec3 dup )
 {
+    sgVec3 up;
+    sgSetVec3( up, dup );
+
     sgVec3 nup;
     sgNormalizeVec3( nup, up );
 
@@ -604,6 +610,35 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
                                                   pnt_i, nml_i,
                                                   matlib, up );
         return rabbit;
+    } else if ( material == "RWY_VASI_LIGHTS" ) {
+        ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
+                                                         nml_i, mat, up,
+                                                         false );
+
+        // calculate the geocentric position of this vasi and use it
+        // to init the vasi structure and save it in the userdata slot
+        sgdVec3 pos;
+        sgdSetVec3( pos, nodes[pnt_i[0]][0], nodes[pnt_i[0]][1],
+                    nodes[pnt_i[0]][2] );
+        // dup is the double version of the "up" vector which is also
+        // the reference center point of this tile.  The reference
+        // center + the coordinate of the first light gives the actual
+        // location of the first light.
+        sgdAddVec3( pos, dup );
+
+        // extract a pointer to the leaf node so a) we can set the
+        // phat light call back and b) we can pass this to the vasi
+        // structure.
+        ssgRangeSelector *lod = (ssgRangeSelector *)light_group->getKid(0);
+        ssgLeaf *leaf = (ssgLeaf *)lod->getKid(0);
+        leaf->setCallback( SSG_CALLBACK_PREDRAW, StrobePreDraw );
+        leaf->setCallback( SSG_CALLBACK_POSTDRAW, StrobePostDraw );
+
+        SGVASIUserData *vasi = new SGVASIUserData( pos, leaf );
+
+        light_group->setUserData( vasi );
+
+        return light_group;
     } else if ( material == "RWY_BLUE_TAXIWAY_LIGHTS" ) {
         ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
                                                          nml_i, mat, up,
@@ -611,7 +646,8 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
         return light_group;
     } else {
         ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
-                                                         nml_i, mat, up );
+                                                         nml_i, mat, up,
+                                                         false );
         return light_group;
     }
 
index 9bf2606ed42562900c4c655ac88ed64702bdba55..6cce587363a05858adb70cdf6fa7f4cc5f76b7b5 100644 (file)
@@ -87,7 +87,7 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
                                     const int_list &nml_i,
                                     SGMaterialLib *matlib,
                                     const string &material,
-                                    sgVec3 up );
+                                    sgdVec3 dup );
 
 
 #endif // _SG_PT_LIGHTS_HXX
diff --git a/simgear/scene/tgdb/vasi.hxx b/simgear/scene/tgdb/vasi.hxx
new file mode 100644 (file)
index 0000000..388aecf
--- /dev/null
@@ -0,0 +1,80 @@
+// vasi.hxx -- a class to hold some critical vasi data
+//
+// Written by Curtis Olson, started December 2003.
+//
+// Copyright (C) 2003  Curtis L. Olson  - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+
+#ifndef _SG_VASI_HXX
+#define _SG_VASI_HXX
+
+
+#ifndef __cplusplus                                                          
+# error This library requires C++
+#endif                                   
+
+
+#include <simgear/compiler.h>
+
+#include STL_STRING
+SG_USING_STD(string);
+
+#include <plib/ssg.h>          // plib include
+
+#include <simgear/math/sg_geodesy.hxx>
+
+
+class SGVASIUserData : public ssgBase
+{
+
+private:
+
+    sgdVec3 abs_pos;
+    double alt_m;
+    ssgLeaf *leaf;
+
+public:
+
+    SGVASIUserData( sgdVec3 pos_cart, ssgLeaf *l ) {
+        sgdCopyVec3( abs_pos, pos_cart );
+
+        double lat, lon;
+        sgCartToGeod( abs_pos, &lat, &lon, &alt_m );
+
+        leaf = l;
+    }
+
+    ~SGVASIUserData() {}
+
+    double get_alt_m() { return alt_m; }
+    double *get_abs_pos() { return abs_pos; }
+
+    // color is a number in the range of 0.0 = full red, 1.0 = full white
+    void set_color( float color ) {
+        int count = leaf->getNumColours();
+        for ( int i = 0; i < count; ++i ) {
+            float *entry = leaf->getColour( i );
+            entry[1] = color;
+            entry[2] = color;
+        }
+    }
+};
+
+
+#endif // _SG_VASI_HXX