Track some additional data required for computing vasi/papi colors.
This commit is contained in:
@@ -9,7 +9,8 @@ include_HEADERS = \
|
|||||||
leaf.hxx \
|
leaf.hxx \
|
||||||
obj.hxx \
|
obj.hxx \
|
||||||
pt_lights.hxx \
|
pt_lights.hxx \
|
||||||
userdata.hxx
|
userdata.hxx \
|
||||||
|
vasi.hxx
|
||||||
|
|
||||||
libsgtgdb_a_SOURCES = \
|
libsgtgdb_a_SOURCES = \
|
||||||
apt_signs.cxx \
|
apt_signs.cxx \
|
||||||
|
|||||||
@@ -351,8 +351,8 @@ bool sgBinObjLoad( const string& path, const bool is_base,
|
|||||||
// cout << "pts_v.size() = " << pts_v.size() << endl;
|
// cout << "pts_v.size() = " << pts_v.size() << endl;
|
||||||
if ( pt_materials[i].substr(0, 3) == "RWY" ) {
|
if ( pt_materials[i].substr(0, 3) == "RWY" ) {
|
||||||
// airport environment lighting
|
// airport environment lighting
|
||||||
sgVec3 up;
|
sgdVec3 up;
|
||||||
sgSetVec3( up, center->x(), center->y(), center->z() );
|
sgdSetVec3( up, center->x(), center->y(), center->z() );
|
||||||
// returns a transform -> lod -> leaf structure
|
// returns a transform -> lod -> leaf structure
|
||||||
ssgBranch *branch = sgMakeDirectionalLights( nodes, normals,
|
ssgBranch *branch = sgMakeDirectionalLights( nodes, normals,
|
||||||
pts_v[i], pts_n[i],
|
pts_v[i], pts_n[i],
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include <simgear/scene/material/mat.hxx>
|
#include <simgear/scene/material/mat.hxx>
|
||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
|
|
||||||
|
#include "vasi.hxx"
|
||||||
|
|
||||||
#include "pt_lights.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 &pnt_i,
|
||||||
const int_list &nml_i,
|
const int_list &nml_i,
|
||||||
const SGMaterial *mat,
|
const SGMaterial *mat,
|
||||||
sgVec3 up, bool vertical = false )
|
sgVec3 up, bool vertical )
|
||||||
{
|
{
|
||||||
sgVec3 center;
|
sgVec3 center;
|
||||||
calc_center_point( nodes, pnt_i, 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
|
#if 0 // debugging infrastructure
|
||||||
// Generate a normal line
|
// Generate a normal line
|
||||||
static ssgLeaf *gen_normal_line( SGMaterialLib *matlib,
|
static ssgLeaf *gen_normal_line( SGMaterialLib *matlib,
|
||||||
sgVec3 pt, sgVec3 dir, sgVec3 up ) {
|
sgVec3 pt, sgVec3 dir, sgVec3 up )
|
||||||
|
{
|
||||||
|
|
||||||
ssgVertexArray *vl = new ssgVertexArray( 3 );
|
ssgVertexArray *vl = new ssgVertexArray( 3 );
|
||||||
ssgColourArray *cl = new ssgColourArray( 3 );
|
ssgColourArray *cl = new ssgColourArray( 3 );
|
||||||
@@ -581,8 +584,11 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
|
|||||||
const int_list &nml_i,
|
const int_list &nml_i,
|
||||||
SGMaterialLib *matlib,
|
SGMaterialLib *matlib,
|
||||||
const string &material,
|
const string &material,
|
||||||
sgVec3 up )
|
sgdVec3 dup )
|
||||||
{
|
{
|
||||||
|
sgVec3 up;
|
||||||
|
sgSetVec3( up, dup );
|
||||||
|
|
||||||
sgVec3 nup;
|
sgVec3 nup;
|
||||||
sgNormalizeVec3( nup, up );
|
sgNormalizeVec3( nup, up );
|
||||||
|
|
||||||
@@ -604,6 +610,35 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
|
|||||||
pnt_i, nml_i,
|
pnt_i, nml_i,
|
||||||
matlib, up );
|
matlib, up );
|
||||||
return rabbit;
|
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" ) {
|
} else if ( material == "RWY_BLUE_TAXIWAY_LIGHTS" ) {
|
||||||
ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
|
ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
|
||||||
nml_i, mat, up,
|
nml_i, mat, up,
|
||||||
@@ -611,7 +646,8 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
|
|||||||
return light_group;
|
return light_group;
|
||||||
} else {
|
} else {
|
||||||
ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
|
ssgTransform *light_group = gen_dir_light_group( nodes, normals, pnt_i,
|
||||||
nml_i, mat, up );
|
nml_i, mat, up,
|
||||||
|
false );
|
||||||
return light_group;
|
return light_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ ssgBranch *sgMakeDirectionalLights( const point_list &nodes,
|
|||||||
const int_list &nml_i,
|
const int_list &nml_i,
|
||||||
SGMaterialLib *matlib,
|
SGMaterialLib *matlib,
|
||||||
const string &material,
|
const string &material,
|
||||||
sgVec3 up );
|
sgdVec3 dup );
|
||||||
|
|
||||||
|
|
||||||
#endif // _SG_PT_LIGHTS_HXX
|
#endif // _SG_PT_LIGHTS_HXX
|
||||||
|
|||||||
@@ -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
|
||||||
Reference in New Issue
Block a user