[lights] Maintenance
This commit is contained in:
parent
9a2a4cdb25
commit
7c052d1ed3
1 changed files with 347 additions and 355 deletions
|
@ -25,16 +25,16 @@
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include <simgear/math/SGMath.hxx>
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
#include <simgear/math/SGMath.hxx>
|
||||||
|
|
||||||
#include "runway.hxx"
|
#include "runway.hxx"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
// calculate the runway light direction vector. We take both runway
|
// calculate the runway light direction vector. We take both runway
|
||||||
// ends to get the direction of the runway.
|
// ends to get the direction of the runway.
|
||||||
SGVec3f Runway::gen_runway_light_vector( float angle, bool recip ) {
|
SGVec3f Runway::gen_runway_light_vector(float angle, bool recip)
|
||||||
|
{
|
||||||
SGVec3f cart1, cart2;
|
SGVec3f cart1, cart2;
|
||||||
if (!recip) {
|
if (!recip) {
|
||||||
cart1 = normalize(SGVec3f::fromGeod(GetStart()));
|
cart1 = normalize(SGVec3f::fromGeod(GetStart()));
|
||||||
|
@ -85,8 +85,7 @@ tglightcontour_list Runway::gen_runway_edge_lights( bool recip )
|
||||||
double offset = 2 + rwy.width * 0.5;
|
double offset = 2 + rwy.width * 0.5;
|
||||||
|
|
||||||
//front threshold
|
//front threshold
|
||||||
if (rwy.threshold[get_thresh0(recip)] > step )
|
if (rwy.threshold[get_thresh0(recip)] > step) {
|
||||||
{
|
|
||||||
SGGeod pt0 = pt1;
|
SGGeod pt0 = pt1;
|
||||||
tstep = (int)(rwy.threshold[get_thresh0(recip)] / step);
|
tstep = (int)(rwy.threshold[get_thresh0(recip)] / step);
|
||||||
for (i = 0; i < tstep; ++i) {
|
for (i = 0; i < tstep; ++i) {
|
||||||
|
@ -109,8 +108,7 @@ tglightcontour_list Runway::gen_runway_edge_lights( bool recip )
|
||||||
}
|
}
|
||||||
|
|
||||||
//back threshold
|
//back threshold
|
||||||
if (rwy.threshold[get_thresh1(recip)] > step )
|
if (rwy.threshold[get_thresh1(recip)] > step) {
|
||||||
{
|
|
||||||
tstep = (int)(rwy.threshold[get_thresh1(recip)] / step);
|
tstep = (int)(rwy.threshold[get_thresh1(recip)] / step);
|
||||||
for (i = 0; i < tstep; ++i) {
|
for (i = 0; i < tstep; ++i) {
|
||||||
y_lights.AddLight(SGGeodesy::direct(pt1, left_hdg, offset), normal);
|
y_lights.AddLight(SGGeodesy::direct(pt1, left_hdg, offset), normal);
|
||||||
|
@ -124,13 +122,11 @@ tglightcontour_list Runway::gen_runway_edge_lights( bool recip )
|
||||||
w_lights.SetType("RWY_WHITE_LIGHTS");
|
w_lights.SetType("RWY_WHITE_LIGHTS");
|
||||||
y_lights.SetType("RWY_YELLOW_LIGHTS");
|
y_lights.SetType("RWY_YELLOW_LIGHTS");
|
||||||
r_lights.SetType("RWY_RED_LIGHTS");
|
r_lights.SetType("RWY_RED_LIGHTS");
|
||||||
}
|
} else if (rwy.edge_lights == 2) {
|
||||||
else if (rwy.edge_lights == 2) {
|
|
||||||
w_lights.SetType("RWY_WHITE_MEDIUM_LIGHTS");
|
w_lights.SetType("RWY_WHITE_MEDIUM_LIGHTS");
|
||||||
y_lights.SetType("RWY_YELLOW_MEDIUM_LIGHTS");
|
y_lights.SetType("RWY_YELLOW_MEDIUM_LIGHTS");
|
||||||
r_lights.SetType("RWY_RED_MEDIUM_LIGHTS");
|
r_lights.SetType("RWY_RED_MEDIUM_LIGHTS");
|
||||||
}
|
} else if (rwy.edge_lights == 1) {
|
||||||
else if (rwy.edge_lights == 1) {
|
|
||||||
w_lights.SetType("RWY_WHITE_LOW_LIGHTS");
|
w_lights.SetType("RWY_WHITE_LOW_LIGHTS");
|
||||||
y_lights.SetType("RWY_YELLOW_LOW_LIGHTS");
|
y_lights.SetType("RWY_YELLOW_LOW_LIGHTS");
|
||||||
r_lights.SetType("RWY_RED_LOW_LIGHTS");
|
r_lights.SetType("RWY_RED_LOW_LIGHTS");
|
||||||
|
@ -208,7 +204,6 @@ tglightcontour_list Runway::gen_runway_threshold_lights( const int kind, bool re
|
||||||
|
|
||||||
// Create groups of four lights in front of the displaced threshold
|
// Create groups of four lights in front of the displaced threshold
|
||||||
for (i = 0; i < 4; ++i) {
|
for (i = 0; i < 4; ++i) {
|
||||||
|
|
||||||
if (GetsThreshold(recip)) {
|
if (GetsThreshold(recip)) {
|
||||||
r_lights.AddLight(pt1, normal1);
|
r_lights.AddLight(pt1, normal1);
|
||||||
r_lights.AddLight(pt2, normal1);
|
r_lights.AddLight(pt2, normal1);
|
||||||
|
@ -351,7 +346,7 @@ tgLightContour Runway::gen_touchdown_zone_lights( bool recip )
|
||||||
|
|
||||||
lights.SetType("RWY_WHITE_LIGHTS");
|
lights.SetType("RWY_WHITE_LIGHTS");
|
||||||
|
|
||||||
return lights;;
|
return lights;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -359,7 +354,7 @@ tgLightContour Runway::gen_touchdown_zone_lights( bool recip )
|
||||||
tgLightContour Runway::gen_reil(const int kind, bool recip)
|
tgLightContour Runway::gen_reil(const int kind, bool recip)
|
||||||
{
|
{
|
||||||
tgLightContour lights;
|
tgLightContour lights;
|
||||||
string flag = rwy.rwnum[get_thresh0(recip)];
|
std::string flag = rwy.rwnum[get_thresh0(recip)];
|
||||||
SGVec3f normal;
|
SGVec3f normal;
|
||||||
|
|
||||||
if (kind == 1) {
|
if (kind == 1) {
|
||||||
|
@ -398,11 +393,11 @@ tgLightContour Runway::gen_reil( const int kind, bool recip )
|
||||||
|
|
||||||
|
|
||||||
// generate Calvert-I/II approach lighting schemes
|
// generate Calvert-I/II approach lighting schemes
|
||||||
tglightcontour_list Runway::gen_calvert( const string &kind, bool recip )
|
tglightcontour_list Runway::gen_calvert(const std::string& kind, bool recip)
|
||||||
{
|
{
|
||||||
tgLightContour w_lights;
|
tgLightContour w_lights;
|
||||||
tgLightContour r_lights;
|
tgLightContour r_lights;
|
||||||
string flag;
|
std::string flag;
|
||||||
|
|
||||||
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
||||||
|
|
||||||
|
@ -472,7 +467,6 @@ tglightcontour_list Runway::gen_calvert( const string &kind, bool recip )
|
||||||
crossbar[4] = pt;
|
crossbar[4] = pt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == "2") {
|
if (kind == "2") {
|
||||||
|
@ -571,14 +565,14 @@ tglightcontour_list Runway::gen_calvert( const string &kind, bool recip )
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate ALSF-I/II and SALS/SALSF approach lighting schemes
|
// generate ALSF-I/II and SALS/SALSF approach lighting schemes
|
||||||
tglightcontour_list Runway::gen_alsf( const string &kind, bool recip )
|
tglightcontour_list Runway::gen_alsf(const std::string& kind, bool recip)
|
||||||
{
|
{
|
||||||
tgLightContour g_lights;
|
tgLightContour g_lights;
|
||||||
tgLightContour w_lights;
|
tgLightContour w_lights;
|
||||||
tgLightContour r_lights;
|
tgLightContour r_lights;
|
||||||
tgLightContour s_lights;
|
tgLightContour s_lights;
|
||||||
int i;
|
int i;
|
||||||
string flag;
|
std::string flag;
|
||||||
|
|
||||||
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
||||||
|
|
||||||
|
@ -837,14 +831,14 @@ tglightcontour_list Runway::gen_alsf( const string &kind, bool recip )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// generate ODALS or RAIL lights. Main differende between the two:
|
// generate ODALS or RAIL lights. Main difference between the two:
|
||||||
// ODALS is omnidirectional, RAIL is unidirectional
|
// ODALS is omnidirectional, RAIL is unidirectional
|
||||||
tgLightContour Runway::gen_odals(const int kind, bool recip)
|
tgLightContour Runway::gen_odals(const int kind, bool recip)
|
||||||
{
|
{
|
||||||
tgLightContour lights;
|
tgLightContour lights;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
string material;
|
std::string material;
|
||||||
SGVec3f normal;
|
SGVec3f normal;
|
||||||
|
|
||||||
if (kind == 0) {
|
if (kind == 0) {
|
||||||
|
@ -894,14 +888,14 @@ tgLightContour Runway::gen_odals( const int kind, bool recip )
|
||||||
|
|
||||||
// generate SSALS, SSALF, and SSALR approach lighting scheme (kind =
|
// generate SSALS, SSALF, and SSALR approach lighting scheme (kind =
|
||||||
// S, F, or R)
|
// S, F, or R)
|
||||||
tglightcontour_list Runway::gen_ssalx( const string& kind, bool recip )
|
tglightcontour_list Runway::gen_ssalx(const std::string& kind, bool recip)
|
||||||
{
|
{
|
||||||
tgLightContour g_lights;
|
tgLightContour g_lights;
|
||||||
tgLightContour w_lights;
|
tgLightContour w_lights;
|
||||||
tgLightContour r_lights;
|
tgLightContour r_lights;
|
||||||
tgLightContour s_lights;
|
tgLightContour s_lights;
|
||||||
int i;
|
int i;
|
||||||
string flag;
|
std::string flag;
|
||||||
|
|
||||||
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
||||||
SGGeod ref_save, pt;
|
SGGeod ref_save, pt;
|
||||||
|
@ -1011,14 +1005,14 @@ tglightcontour_list Runway::gen_ssalx( const string& kind, bool recip )
|
||||||
|
|
||||||
// generate MALS, MALSF, and MALSR approach lighting scheme (kind =
|
// generate MALS, MALSF, and MALSR approach lighting scheme (kind =
|
||||||
// ' ', F, or R)
|
// ' ', F, or R)
|
||||||
tglightcontour_list Runway::gen_malsx( const string& kind, bool recip )
|
tglightcontour_list Runway::gen_malsx(const std::string& kind, bool recip)
|
||||||
{
|
{
|
||||||
tgLightContour g_lights;
|
tgLightContour g_lights;
|
||||||
tgLightContour w_lights;
|
tgLightContour w_lights;
|
||||||
tgLightContour r_lights;
|
tgLightContour r_lights;
|
||||||
tgLightContour s_lights;
|
tgLightContour s_lights;
|
||||||
int i;
|
int i;
|
||||||
string flag;
|
std::string flag;
|
||||||
|
|
||||||
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
SGVec3f normal = gen_runway_light_vector(3.0, recip);
|
||||||
|
|
||||||
|
@ -1124,8 +1118,8 @@ tglightcontour_list Runway::gen_malsx( const string& kind, bool recip )
|
||||||
|
|
||||||
|
|
||||||
// top level runway light generator
|
// top level runway light generator
|
||||||
void Runway::gen_runway_lights( tglightcontour_list& lights ) {
|
void Runway::gen_runway_lights(tglightcontour_list& lights)
|
||||||
|
{
|
||||||
unsigned int i, side;
|
unsigned int i, side;
|
||||||
bool recip;
|
bool recip;
|
||||||
|
|
||||||
|
@ -1266,8 +1260,7 @@ void Runway::gen_runway_lights( tglightcontour_list& lights ) {
|
||||||
|
|
||||||
// Approach light systems that have a threshold light bar
|
// Approach light systems that have a threshold light bar
|
||||||
// use a central routine for its creation
|
// use a central routine for its creation
|
||||||
if ( rwy.approach_lights[side] > 0 && rwy.approach_lights[side] < 11)
|
if (rwy.approach_lights[side] > 0 && rwy.approach_lights[side] < 11) {
|
||||||
{
|
|
||||||
tglightcontour_list s = gen_runway_threshold_lights(1, recip);
|
tglightcontour_list s = gen_runway_threshold_lights(1, recip);
|
||||||
for (i = 0; i < s.size(); ++i) {
|
for (i = 0; i < s.size(); ++i) {
|
||||||
lights.push_back(s[i]);
|
lights.push_back(s[i]);
|
||||||
|
@ -1277,8 +1270,7 @@ void Runway::gen_runway_lights( tglightcontour_list& lights ) {
|
||||||
// If the runway has edge lights but no approach lights,
|
// If the runway has edge lights but no approach lights,
|
||||||
// or approach lights without a lights bar,
|
// or approach lights without a lights bar,
|
||||||
// create a simple threshold lighting
|
// create a simple threshold lighting
|
||||||
if ( rwy.edge_lights && (rwy.approach_lights[side] == 0 || rwy.approach_lights[side] > 10))
|
if (rwy.edge_lights && (rwy.approach_lights[side] == 0 || rwy.approach_lights[side] > 10)) {
|
||||||
{
|
|
||||||
tglightcontour_list s = gen_runway_threshold_lights(0, recip);
|
tglightcontour_list s = gen_runway_threshold_lights(0, recip);
|
||||||
for (i = 0; i < s.size(); ++i) {
|
for (i = 0; i < s.size(); ++i) {
|
||||||
lights.push_back(s[i]);
|
lights.push_back(s[i]);
|
||||||
|
|
Loading…
Reference in a new issue