1 // vasi.hxx -- a class to hold some critical vasi data
3 // Written by Curtis Olson, started December 2003.
5 // Copyright (C) 2003 Curtis L. Olson - curt@flightgear.org
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 # error This library requires C++
33 #include <simgear/compiler.h>
38 #include <plib/ssg.h> // plib include
40 #include <simgear/math/sg_geodesy.hxx>
43 class SGVASIUserData : public ssgBase
54 SGVASIUserData( sgdVec3 pos_cart, ssgLeaf *l ) {
55 sgdCopyVec3( abs_pos, pos_cart );
58 sgCartToGeod( abs_pos, &lat, &lon, &alt_m );
65 double get_alt_m() { return alt_m; }
66 double *get_abs_pos() { return abs_pos; }
69 // color the vasi/papi correctly based on angle
70 void set_color( float angle_deg ) {
71 int count = leaf->getNumColours();
82 if ( angle_deg < ref - trans ) {
84 } else if ( angle_deg < ref + trans ) {
85 color = 1.0 - (ref + trans - angle_deg) * (1 / (2 * trans) );
89 for ( i = 0; i < 3; ++i ) {
90 entry = leaf->getColour( i );
97 if ( angle_deg < ref - trans ) {
99 } else if ( angle_deg < ref + trans ) {
100 color = 1.0 - (ref + trans - angle_deg) * (1 / (2 * trans) );
104 for ( i = 3; i < 6; ++i ) {
105 entry = leaf->getColour( i );
112 if ( angle_deg < ref - trans ) {
114 } else if ( angle_deg < ref + trans ) {
115 color = 1.0 - (ref + trans - angle_deg) * (1 / (2 * trans) );
119 for ( i = 6; i < 9; ++i ) {
120 entry = leaf->getColour( i );
127 if ( angle_deg < ref - trans ) {
129 } else if ( angle_deg < ref + trans ) {
130 color = 1.0 - (ref + trans - angle_deg) * (1 / (2 * trans) );
134 for ( i = 9; i < 12; ++i ) {
135 entry = leaf->getColour( i );
139 } else if ( count == 36 ) {
140 // probably vasi, first 18 are downwind bar (2.5 deg)
142 if ( angle_deg < ref - trans ) {
144 } else if ( angle_deg < ref + trans ) {
145 color = 1.0 - (ref + trans - angle_deg) * (1 / (2 * trans) );
149 for ( int i = 0; i < 18; ++i ) {
150 entry = leaf->getColour( i );
155 // last 6 are upwind bar (3.0 deg)
157 if ( angle_deg < ref - trans ) {
159 } else if ( angle_deg < ref + trans ) {
160 color = 1.0 - (ref + trans - angle_deg) * (1 / (2 * trans) );
164 for ( int i = 18; i < 36; ++i ) {
165 entry = leaf->getColour( i );
171 cout << "unknown vasi/papi configuration, count = " << count << endl;
172 for ( int i = 0; i < count; ++i ) {
173 entry = leaf->getColour( i );
182 #endif // _SG_VASI_HXX