// 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],
#include <simgear/scene/material/mat.hxx>
#include <simgear/scene/material/matlib.hxx>
+#include "vasi.hxx"
+
#include "pt_lights.hxx"
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 );
#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 );
const int_list &nml_i,
SGMaterialLib *matlib,
const string &material,
- sgVec3 up )
+ sgdVec3 dup )
{
+ sgVec3 up;
+ sgSetVec3( up, dup );
+
sgVec3 nup;
sgNormalizeVec3( nup, up );
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,
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;
}
--- /dev/null
+// 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