- remove trailing spaces
- fix many cases of broken indentation (but not all) - unify indendation - ...
This commit is contained in:
parent
4db6e924fe
commit
942561d64c
5 changed files with 258 additions and 253 deletions
|
@ -74,9 +74,9 @@ FGAIBase::~FGAIBase() {
|
|||
globals->get_scenery()->get_scene_graph()->removeKid(aip.getSceneGraph());
|
||||
}
|
||||
if (props) {
|
||||
SGPropertyNode* parent = props->getParent();
|
||||
if (parent)
|
||||
parent->removeChild(props->getName(), props->getIndex(), false);
|
||||
SGPropertyNode* parent = props->getParent();
|
||||
if (parent)
|
||||
parent->removeChild(props->getName(), props->getIndex(), false);
|
||||
}
|
||||
delete fp;
|
||||
fp = 0;
|
||||
|
@ -85,22 +85,24 @@ FGAIBase::~FGAIBase() {
|
|||
|
||||
void FGAIBase::readFromScenario(SGPropertyNode* scFileNode)
|
||||
{
|
||||
if (!scFileNode)
|
||||
return;
|
||||
if (!scFileNode)
|
||||
return;
|
||||
|
||||
setPath(scFileNode->getStringValue("model", "Models/Geometry/glider.ac"));
|
||||
setPath(scFileNode->getStringValue("model", "Models/Geometry/glider.ac"));
|
||||
|
||||
setHeading(scFileNode->getDoubleValue("heading", 0.0));
|
||||
setSpeed(scFileNode->getDoubleValue("speed", 0.0));
|
||||
setAltitude(scFileNode->getDoubleValue("altitude", 0.0));
|
||||
setLongitude(scFileNode->getDoubleValue("longitude", 0.0));
|
||||
setLatitude(scFileNode->getDoubleValue("latitude", 0.0));
|
||||
setBank(scFileNode->getDoubleValue("roll", 0.0));
|
||||
setHeading(scFileNode->getDoubleValue("heading", 0.0));
|
||||
setSpeed(scFileNode->getDoubleValue("speed", 0.0));
|
||||
setAltitude(scFileNode->getDoubleValue("altitude", 0.0));
|
||||
setLongitude(scFileNode->getDoubleValue("longitude", 0.0));
|
||||
setLatitude(scFileNode->getDoubleValue("latitude", 0.0));
|
||||
setBank(scFileNode->getDoubleValue("roll", 0.0));
|
||||
}
|
||||
|
||||
void FGAIBase::update(double dt) {
|
||||
if (_otype == otStatic) return;
|
||||
if (_otype == otBallistic) CalculateMach();
|
||||
if (_otype == otStatic)
|
||||
return;
|
||||
if (_otype == otBallistic)
|
||||
CalculateMach();
|
||||
|
||||
ft_per_deg_lat = 366468.96 - 3717.12 * cos(pos.lat()*SGD_DEGREES_TO_RADIANS);
|
||||
ft_per_deg_lon = 365228.16 * cos(pos.lat()*SGD_DEGREES_TO_RADIANS);
|
||||
|
@ -114,7 +116,7 @@ void FGAIBase::Transform() {
|
|||
} else {
|
||||
aip.setOrientation(roll, pitch, hdg);
|
||||
}
|
||||
aip.update();
|
||||
aip.update();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,10 +139,10 @@ bool FGAIBase::init() {
|
|||
// Register that one at the scenery manager
|
||||
globals->get_scenery()->register_placement_transform(aip.getTransform());
|
||||
} else {
|
||||
if (!model_path.empty()) {
|
||||
if (!model_path.empty()) {
|
||||
SG_LOG(SG_INPUT, SG_WARN, "AIBase: Could not load model " << model_path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setDie(false);
|
||||
|
||||
|
@ -148,30 +150,31 @@ bool FGAIBase::init() {
|
|||
}
|
||||
|
||||
|
||||
ssgBranch * FGAIBase::load3DModel(const string& fg_root,
|
||||
const string &path,
|
||||
SGPropertyNode *prop_root,
|
||||
double sim_time_sec)
|
||||
ssgBranch * FGAIBase::load3DModel(const string& fg_root,
|
||||
const string &path,
|
||||
SGPropertyNode *prop_root,
|
||||
double sim_time_sec)
|
||||
{
|
||||
// some more code here to check whether a model with this name has already been loaded
|
||||
// if not load it, otherwise, get the memory pointer and do something like
|
||||
// if not load it, otherwise, get the memory pointer and do something like
|
||||
// SetModel as in ATC/AIEntity.cxx
|
||||
model = manager->getModel(path);
|
||||
if (!(model))
|
||||
{
|
||||
if (!(model)) {
|
||||
model = sgLoad3DModel(fg_root,
|
||||
path,
|
||||
prop_root,
|
||||
sim_time_sec);
|
||||
path,
|
||||
prop_root,
|
||||
sim_time_sec);
|
||||
manager->setModel(path, model);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
bool FGAIBase::isa( object_type otype ) {
|
||||
if ( otype == _otype ) { return true; }
|
||||
else { return false; }
|
||||
if ( otype == _otype )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -206,7 +209,7 @@ void FGAIBase::bind() {
|
|||
props->tie("radar/elevation-deg", SGRawValuePointer<double>(&elevation));
|
||||
props->tie("radar/range-nm", SGRawValuePointer<double>(&range));
|
||||
props->tie("radar/h-offset", SGRawValuePointer<double>(&horiz_offset));
|
||||
props->tie("radar/v-offset", SGRawValuePointer<double>(&vert_offset));
|
||||
props->tie("radar/v-offset", SGRawValuePointer<double>(&vert_offset));
|
||||
props->tie("radar/x-shift", SGRawValuePointer<double>(&x_shift));
|
||||
props->tie("radar/y-shift", SGRawValuePointer<double>(&y_shift));
|
||||
props->tie("radar/rotation", SGRawValuePointer<double>(&rotation));
|
||||
|
@ -392,43 +395,44 @@ int FGAIBase::getID() const {
|
|||
}
|
||||
|
||||
void FGAIBase::CalculateMach() {
|
||||
// Calculate rho at altitude, using standard atmosphere
|
||||
// For the temperature T and the pressure p,
|
||||
|
||||
if (altitude < 36152) { // curve fits for the troposphere
|
||||
T = 59 - 0.00356 * altitude;
|
||||
p = 2116 * pow( ((T + 459.7) / 518.6) , 5.256);
|
||||
|
||||
} else if ( 36152 < altitude && altitude < 82345 ) { // lower stratosphere
|
||||
T = -70;
|
||||
p = 473.1 * pow( e , 1.73 - (0.000048 * altitude) );
|
||||
|
||||
} else { // upper stratosphere
|
||||
T = -205.05 + (0.00164 * altitude);
|
||||
p = 51.97 * pow( ((T + 459.7) / 389.98) , -11.388);
|
||||
}
|
||||
|
||||
rho = p / (1718 * (T + 459.7));
|
||||
|
||||
// calculate the speed of sound at altitude
|
||||
// a = sqrt ( g * R * (T + 459.7))
|
||||
// where:
|
||||
// a = speed of sound [ft/s]
|
||||
// g = specific heat ratio, which is usually equal to 1.4
|
||||
// R = specific gas constant, which equals 1716 ft-lb/slug/°R
|
||||
|
||||
a = sqrt ( 1.4 * 1716 * (T + 459.7));
|
||||
|
||||
// calculate Mach number
|
||||
|
||||
Mach = speed/a;
|
||||
|
||||
// cout << "Speed(ft/s) "<< speed <<" Altitude(ft) "<< altitude << " Mach " << Mach;
|
||||
// Calculate rho at altitude, using standard atmosphere
|
||||
// For the temperature T and the pressure p,
|
||||
|
||||
if (altitude < 36152) { // curve fits for the troposphere
|
||||
T = 59 - 0.00356 * altitude;
|
||||
p = 2116 * pow( ((T + 459.7) / 518.6) , 5.256);
|
||||
|
||||
} else if ( 36152 < altitude && altitude < 82345 ) { // lower stratosphere
|
||||
T = -70;
|
||||
p = 473.1 * pow( e , 1.73 - (0.000048 * altitude) );
|
||||
|
||||
} else { // upper stratosphere
|
||||
T = -205.05 + (0.00164 * altitude);
|
||||
p = 51.97 * pow( ((T + 459.7) / 389.98) , -11.388);
|
||||
}
|
||||
|
||||
rho = p / (1718 * (T + 459.7));
|
||||
|
||||
// calculate the speed of sound at altitude
|
||||
// a = sqrt ( g * R * (T + 459.7))
|
||||
// where:
|
||||
// a = speed of sound [ft/s]
|
||||
// g = specific heat ratio, which is usually equal to 1.4
|
||||
// R = specific gas constant, which equals 1716 ft-lb/slug/°R
|
||||
|
||||
a = sqrt ( 1.4 * 1716 * (T + 459.7));
|
||||
|
||||
// calculate Mach number
|
||||
|
||||
Mach = speed/a;
|
||||
|
||||
// cout << "Speed(ft/s) "<< speed <<" Altitude(ft) "<< altitude << " Mach " << Mach;
|
||||
}
|
||||
|
||||
int FGAIBase::_newAIModelID() {
|
||||
static int id = 0;
|
||||
if (!++id) id++; // id = 0 is not allowed.
|
||||
static int id = 0;
|
||||
if (!++id)
|
||||
id++; // id = 0 is not allowed.
|
||||
return id;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ protected:
|
|||
double pitch; // degrees, nose-down is negative
|
||||
double speed; // knots true airspeed
|
||||
double altitude; // meters above sea level
|
||||
double vs; // vertical speed, feet per minute
|
||||
double vs; // vertical speed, feet per minute
|
||||
double turn_radius_ft; // turn radius ft at 15 kts rudder angle 15 degrees
|
||||
|
||||
double ft_per_deg_lon;
|
||||
|
@ -167,40 +167,40 @@ public:
|
|||
double rho;
|
||||
double T; // temperature, degs farenheit
|
||||
double p; // pressure lbs/sq ft
|
||||
double a; // speed of sound at altitude (ft/s)
|
||||
double Mach; // Mach number
|
||||
|
||||
double a; // speed of sound at altitude (ft/s)
|
||||
double Mach; // Mach number
|
||||
|
||||
static const double e;
|
||||
static const double lbs_to_slugs;
|
||||
|
||||
inline double _getRange() { return range; };
|
||||
ssgBranch * load3DModel(const string& fg_root,
|
||||
const string &path,
|
||||
SGPropertyNode *prop_root,
|
||||
double sim_time_sec);
|
||||
ssgBranch * load3DModel(const string& fg_root,
|
||||
const string &path,
|
||||
SGPropertyNode *prop_root,
|
||||
double sim_time_sec);
|
||||
|
||||
static bool _isNight();
|
||||
};
|
||||
|
||||
inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) {
|
||||
manager = mgr;
|
||||
props = p;
|
||||
manager = mgr;
|
||||
props = p;
|
||||
}
|
||||
|
||||
inline void FGAIBase::setPath(const char* model ) {
|
||||
model_path.append(model);
|
||||
model_path.append(model);
|
||||
}
|
||||
|
||||
inline void FGAIBase::setSpeed( double speed_KTAS ) {
|
||||
speed = tgt_speed = speed_KTAS;
|
||||
speed = tgt_speed = speed_KTAS;
|
||||
}
|
||||
|
||||
inline void FGAIBase::setRadius( double radius ) {
|
||||
turn_radius_ft = radius;
|
||||
turn_radius_ft = radius;
|
||||
}
|
||||
|
||||
inline void FGAIBase::setHeading( double heading ) {
|
||||
hdg = tgt_heading = heading;
|
||||
hdg = tgt_heading = heading;
|
||||
}
|
||||
|
||||
inline void FGAIBase::setAltitude( double altitude_ft ) {
|
||||
|
@ -209,12 +209,12 @@ inline void FGAIBase::setAltitude( double altitude_ft ) {
|
|||
}
|
||||
|
||||
inline void FGAIBase::setBank( double bank ) {
|
||||
roll = tgt_roll = bank;
|
||||
no_roll = false;
|
||||
roll = tgt_roll = bank;
|
||||
no_roll = false;
|
||||
}
|
||||
|
||||
inline void FGAIBase::setPitch( double newpitch ) {
|
||||
pitch = tgt_pitch = newpitch;
|
||||
pitch = tgt_pitch = newpitch;
|
||||
}
|
||||
|
||||
inline void FGAIBase::setLongitude( double longitude ) {
|
||||
|
|
|
@ -111,7 +111,7 @@ TACAN::init ()
|
|||
_yaw_node = fgGetNode("/orientation/side-slip-deg", true);
|
||||
_serviceable_node = node->getChild("serviceable", 0, true);
|
||||
_electrical_node = fgGetNode("/systems/electrical/outputs/tacan", true);
|
||||
_ident_node = node->getChild("ident", 0, true);
|
||||
_ident_node = node->getChild("ident", 0, true);
|
||||
SGPropertyNode *fnode = node->getChild("frequencies", 0, true);
|
||||
_source_node = fnode->getChild("source", 0, true);
|
||||
_frequency_node = fnode->getChild("selected-mhz", 0, true);
|
||||
|
|
|
@ -68,7 +68,7 @@ private:
|
|||
SGPropertyNode_ptr _x_shift_node;
|
||||
SGPropertyNode_ptr _y_shift_node;
|
||||
SGPropertyNode_ptr _rotation_node;
|
||||
/*SGPropertyNode_ptr _x_shift_calibration_node;
|
||||
/*SGPropertyNode_ptr _x_shift_calibration_node;
|
||||
SGPropertyNode_ptr _y_shift_calibration_node;
|
||||
SGPropertyNode_ptr _distance_calibration_node;*/
|
||||
|
||||
|
|
|
@ -110,8 +110,8 @@ wxRadarBg::init ()
|
|||
void
|
||||
wxRadarBg::update (double delta_time_sec)
|
||||
{
|
||||
if( ! sim_init_done ) {
|
||||
if( ! fgGetBool("sim/sceneryloaded", false) )
|
||||
if ( ! sim_init_done ) {
|
||||
if ( ! fgGetBool("sim/sceneryloaded", false) )
|
||||
return;
|
||||
sim_init_done = true;
|
||||
}
|
||||
|
@ -125,16 +125,16 @@ wxRadarBg::update (double delta_time_sec)
|
|||
float range_nm = _Instrument->getFloatValue("range", 40.0);
|
||||
float range_m = range_nm * SG_NM_TO_METER;
|
||||
|
||||
if( last_switchKnob != switchKnob ) {
|
||||
if ( last_switchKnob != switchKnob ) {
|
||||
// since 3D models don't share textures with the rest of the world
|
||||
// we must locate them and replace their handle by hand
|
||||
// only do that when the instrument is turned on
|
||||
if( last_switchKnob == "off" )
|
||||
if ( last_switchKnob == "off" )
|
||||
odg->set_texture( odgauge_name, resultTexture->getHandle());
|
||||
last_switchKnob = switchKnob;
|
||||
}
|
||||
FGViewer *current__view = globals->get_current_view();
|
||||
if( current__view->getInternal() &&
|
||||
if ( current__view->getInternal() &&
|
||||
(current__view->getHeadingOffset_deg() <= 15.0 || current__view->getHeadingOffset_deg() >= 345.0) &&
|
||||
(current__view->getPitchOffset_deg() <= 15.0 || current__view->getPitchOffset_deg() >= 350.0) ) {
|
||||
|
||||
|
@ -148,191 +148,192 @@ wxRadarBg::update (double delta_time_sec)
|
|||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glPushMatrix();
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
if( switchKnob == "off" ) {
|
||||
_Instrument->setStringValue("status","");
|
||||
} else if( switchKnob == "stby" ) {
|
||||
_Instrument->setStringValue("status","STBY");
|
||||
} else if( switchKnob == "tst" ) {
|
||||
_Instrument->setStringValue("status","TST");
|
||||
// find something interesting to do...
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
if ( switchKnob == "off" ) {
|
||||
_Instrument->setStringValue("status","");
|
||||
} else if ( switchKnob == "stby" ) {
|
||||
_Instrument->setStringValue("status","STBY");
|
||||
} else if ( switchKnob == "tst" ) {
|
||||
_Instrument->setStringValue("status","TST");
|
||||
// find something interesting to do...
|
||||
} else {
|
||||
string display_mode = _Instrument->getStringValue("display-mode", "arc");
|
||||
|
||||
// pretend we have a scan angle bigger then the FOV
|
||||
// TODO:check real fov, enlarge if < nn, and do clipping if > mm
|
||||
const float fovFactor = 1.45f;
|
||||
float view_heading = get_heading() * SG_DEGREES_TO_RADIANS;
|
||||
float range = 200.0f / range_nm;
|
||||
_Instrument->setStringValue("status", modeButton.c_str());
|
||||
if ( display_mode == "arc" ) {
|
||||
glTranslatef(0.0f, -180.0f, 0.0f);
|
||||
range = 2*180.0f / range_nm;
|
||||
} else if ( display_mode == "map" ) {
|
||||
// float view_heading = get_track() * SG_DEGREES_TO_RADIANS;
|
||||
} else if ( display_mode == "plan" ) {
|
||||
// no sense I presume
|
||||
view_heading = 0;
|
||||
} else {
|
||||
string display_mode = _Instrument->getStringValue("display-mode", "arc");
|
||||
// rose
|
||||
}
|
||||
range /= SG_NM_TO_METER;
|
||||
// we will rotate the echo quads, this gives a better rendering
|
||||
const float rot_x = cos ( view_heading );
|
||||
const float rot_y = sin ( view_heading );
|
||||
|
||||
// pretend we have a scan angle bigger then the FOV
|
||||
// TODO:check real fov, enlarge if < nn, and do clipping if > mm
|
||||
const float fovFactor = 1.45f;
|
||||
float view_heading = get_heading() * SG_DEGREES_TO_RADIANS;
|
||||
float range = 200.0f / range_nm;
|
||||
_Instrument->setStringValue("status", modeButton.c_str());
|
||||
if( display_mode == "arc" ) {
|
||||
glTranslatef(0.0f, -180.0f, 0.0f);
|
||||
range = 2*180.0f / range_nm;
|
||||
} else if( display_mode == "map" ) {
|
||||
// float view_heading = get_track() * SG_DEGREES_TO_RADIANS;
|
||||
} else if( display_mode == "plan" ) {
|
||||
// no sense I presume
|
||||
view_heading = 0;
|
||||
} else {
|
||||
// rose
|
||||
}
|
||||
range /= SG_NM_TO_METER;
|
||||
// we will rotate the echo quads, this gives a better rendering
|
||||
const float rot_x = cos ( view_heading );
|
||||
const float rot_y = sin ( view_heading );
|
||||
list_of_SGWxRadarEcho *radarEcho = &radarEchoBuffer;
|
||||
list_of_SGWxRadarEcho::iterator iradarEcho;
|
||||
const float LWClevel[] = { 0.1f, 0.5f, 2.1f };
|
||||
const float symbolSize = 1.0f / 8.0f ;
|
||||
// draw the radar echo, we do that in 3 passes, one for each color level
|
||||
// this is to 'merge' same colors together
|
||||
glBindTexture(GL_TEXTURE_2D, wxEcho->getHandle() );
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glBegin( GL_QUADS );
|
||||
|
||||
list_of_SGWxRadarEcho *radarEcho = &radarEchoBuffer;
|
||||
list_of_SGWxRadarEcho::iterator iradarEcho;
|
||||
const float LWClevel[] = { 0.1f, 0.5f, 2.1f };
|
||||
const float symbolSize = 1.0f / 8.0f ;
|
||||
// draw the radar echo, we do that in 3 passes, one for each color level
|
||||
// this is to 'merge' same colors together
|
||||
glBindTexture(GL_TEXTURE_2D, wxEcho->getHandle() );
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
glBegin( GL_QUADS );
|
||||
|
||||
for(int level = 0; level <= 2 ; level++ ) {
|
||||
float col = level * symbolSize;
|
||||
for(iradarEcho = radarEcho->begin() ; iradarEcho != radarEcho->end() ; iradarEcho++ ) {
|
||||
int cloudId = (iradarEcho->cloudId) ;
|
||||
bool upgrade = ((cloudId >> 5) & 1);
|
||||
float lwc = iradarEcho->LWC + (upgrade ? 1.0f : 0.0f);
|
||||
// skip ns
|
||||
if( iradarEcho->LWC >= 0.5 && iradarEcho->LWC <= 0.6)
|
||||
for (int level = 0; level <= 2 ; level++ ) {
|
||||
float col = level * symbolSize;
|
||||
for (iradarEcho = radarEcho->begin() ; iradarEcho != radarEcho->end() ; iradarEcho++ ) {
|
||||
int cloudId = (iradarEcho->cloudId) ;
|
||||
bool upgrade = ((cloudId >> 5) & 1);
|
||||
float lwc = iradarEcho->LWC + (upgrade ? 1.0f : 0.0f);
|
||||
// skip ns
|
||||
if ( iradarEcho->LWC >= 0.5 && iradarEcho->LWC <= 0.6)
|
||||
continue;
|
||||
if ( (! iradarEcho->lightning) && ( lwc >= LWClevel[level]) ) {
|
||||
float dist = sgSqrt( iradarEcho->dist );
|
||||
float size = iradarEcho->radius * 2.0;
|
||||
if ( dist - size > range_m )
|
||||
continue;
|
||||
if( (! iradarEcho->lightning) && ( lwc >= LWClevel[level]) ) {
|
||||
float dist = sgSqrt( iradarEcho->dist );
|
||||
float size = iradarEcho->radius * 2.0;
|
||||
if( dist - size > range_m )
|
||||
continue;
|
||||
dist = dist * range;
|
||||
size = size * range;
|
||||
// compute the relative angle from the view direction
|
||||
float angle = ( view_heading + iradarEcho->heading );
|
||||
if( angle > SG_PI )
|
||||
angle -= 2.0*SG_PI;
|
||||
if( angle < - SG_PI )
|
||||
angle += 2.0*SG_PI;
|
||||
// and apply a fov factor to simulate a greater scan angle
|
||||
angle = angle * fovFactor + SG_PI / 2.0;
|
||||
float x = cos( angle ) * dist;
|
||||
float y = sin( angle ) * dist;
|
||||
// use different shapes so the display is less boring
|
||||
float row = symbolSize * (float) (4 + (cloudId & 3) );
|
||||
float size_x = rot_x * size;
|
||||
float size_y = rot_y * size;
|
||||
glTexCoord2f( col, row);
|
||||
glVertex2f( x - size_x, y - size_y);
|
||||
glTexCoord2f( col+symbolSize, row);
|
||||
glVertex2f( x + size_y, y - size_x);
|
||||
glTexCoord2f( col+symbolSize, row+symbolSize);
|
||||
glVertex2f( x + size_x, y + size_y);
|
||||
glTexCoord2f( col, row+symbolSize);
|
||||
glVertex2f( x - size_y, y + size_x);
|
||||
}
|
||||
dist = dist * range;
|
||||
size = size * range;
|
||||
// compute the relative angle from the view direction
|
||||
float angle = ( view_heading + iradarEcho->heading );
|
||||
if ( angle > SG_PI )
|
||||
angle -= 2.0*SG_PI;
|
||||
if ( angle < - SG_PI )
|
||||
angle += 2.0*SG_PI;
|
||||
// and apply a fov factor to simulate a greater scan angle
|
||||
angle = angle * fovFactor + SG_PI / 2.0;
|
||||
float x = cos( angle ) * dist;
|
||||
float y = sin( angle ) * dist;
|
||||
// use different shapes so the display is less boring
|
||||
float row = symbolSize * (float) (4 + (cloudId & 3) );
|
||||
float size_x = rot_x * size;
|
||||
float size_y = rot_y * size;
|
||||
glTexCoord2f( col, row);
|
||||
glVertex2f( x - size_x, y - size_y);
|
||||
glTexCoord2f( col+symbolSize, row);
|
||||
glVertex2f( x + size_y, y - size_x);
|
||||
glTexCoord2f( col+symbolSize, row+symbolSize);
|
||||
glVertex2f( x + size_x, y + size_y);
|
||||
glTexCoord2f( col, row+symbolSize);
|
||||
glVertex2f( x - size_y, y + size_x);
|
||||
}
|
||||
}
|
||||
glEnd(); // GL_QUADS
|
||||
}
|
||||
glEnd(); // GL_QUADS
|
||||
|
||||
// draw lightning echos
|
||||
if( drawLightning ) {
|
||||
float col = 3 * symbolSize;
|
||||
float row = 4 * symbolSize;
|
||||
for(iradarEcho = radarEcho->begin() ; iradarEcho != radarEcho->end() ; iradarEcho++ ) {
|
||||
if( iradarEcho->lightning ) {
|
||||
float dist = iradarEcho->dist;
|
||||
dist = dist * range;
|
||||
float angle = (view_heading - iradarEcho->heading);
|
||||
if( angle > SG_PI )
|
||||
angle -= 2.0*SG_PI;
|
||||
if( angle < - SG_PI )
|
||||
angle += 2.0*SG_PI;
|
||||
angle = angle * fovFactor - SG_PI / 2.0;
|
||||
float x = cos( angle ) * dist;
|
||||
float y = sin( angle ) * dist;
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
float size = symbolSize * 0.5f;
|
||||
glBegin( GL_QUADS );
|
||||
glTexCoord2f( col, row);
|
||||
glVertex2f( x - size, y - size);
|
||||
glTexCoord2f( col+symbolSize, row);
|
||||
glVertex2f( x + size, y - size);
|
||||
glTexCoord2f( col+symbolSize, row+symbolSize);
|
||||
glVertex2f( x + size, y + size);
|
||||
glTexCoord2f( col, row+symbolSize);
|
||||
glVertex2f( x - size, y + size);
|
||||
glEnd();
|
||||
}
|
||||
// draw lightning echos
|
||||
if ( drawLightning ) {
|
||||
float col = 3 * symbolSize;
|
||||
float row = 4 * symbolSize;
|
||||
for (iradarEcho = radarEcho->begin() ; iradarEcho != radarEcho->end() ; iradarEcho++ ) {
|
||||
if ( iradarEcho->lightning ) {
|
||||
float dist = iradarEcho->dist;
|
||||
dist = dist * range;
|
||||
float angle = (view_heading - iradarEcho->heading);
|
||||
if ( angle > SG_PI )
|
||||
angle -= 2.0*SG_PI;
|
||||
if ( angle < - SG_PI )
|
||||
angle += 2.0*SG_PI;
|
||||
angle = angle * fovFactor - SG_PI / 2.0;
|
||||
float x = cos( angle ) * dist;
|
||||
float y = sin( angle ) * dist;
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
float size = symbolSize * 0.5f;
|
||||
glBegin( GL_QUADS );
|
||||
glTexCoord2f( col, row);
|
||||
glVertex2f( x - size, y - size);
|
||||
glTexCoord2f( col+symbolSize, row);
|
||||
glVertex2f( x + size, y - size);
|
||||
glTexCoord2f( col+symbolSize, row+symbolSize);
|
||||
glVertex2f( x + size, y + size);
|
||||
glTexCoord2f( col, row+symbolSize);
|
||||
glVertex2f( x - size, y + size);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
// erase what is out of sight of antenna
|
||||
/*
|
||||
|\ /|
|
||||
| \ / |
|
||||
| \ / |
|
||||
---------
|
||||
| |
|
||||
| |
|
||||
---------
|
||||
*/
|
||||
float yOffset = 180.0f, xOffset = 256.0f;
|
||||
|
||||
if( display_mode != "arc" ) {
|
||||
yOffset = 40.0f;
|
||||
xOffset = 240.0f;
|
||||
}
|
||||
|
||||
if ( display_mode != "plan" ) {
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1.0f, 0.0f, 0.0f, 0.01f);
|
||||
}
|
||||
// erase what is out of sight of antenna
|
||||
/*
|
||||
|\ /|
|
||||
| \ / |
|
||||
| \ / |
|
||||
---------
|
||||
| |
|
||||
| |
|
||||
---------
|
||||
*/
|
||||
float yOffset = 180.0f, xOffset = 256.0f;
|
||||
|
||||
if ( display_mode != "arc" ) {
|
||||
yOffset = 40.0f;
|
||||
xOffset = 240.0f;
|
||||
}
|
||||
|
||||
if ( display_mode != "plan" ) {
|
||||
glDisable(GL_BLEND);
|
||||
glColor4f(1.0f, 0.0f, 0.0f, 0.01f);
|
||||
glBegin( GL_QUADS );
|
||||
glTexCoord2f( 0.5f, 0.25f);
|
||||
glVertex2f(-xOffset, 0.0 + yOffset);
|
||||
glTexCoord2f( 1.0f, 0.25f);
|
||||
glVertex2f(xOffset, 0.0 + yOffset);
|
||||
glTexCoord2f( 1.0f, 0.5f);
|
||||
glVertex2f(xOffset, 256.0 + yOffset);
|
||||
glTexCoord2f( 0.5f, 0.5f);
|
||||
glVertex2f(-xOffset, 256.0 + yOffset);
|
||||
glTexCoord2f( 0.5f, 0.25f);
|
||||
glVertex2f(-xOffset, 0.0 + yOffset);
|
||||
glTexCoord2f( 1.0f, 0.25f);
|
||||
glVertex2f(xOffset, 0.0 + yOffset);
|
||||
glTexCoord2f( 1.0f, 0.5f);
|
||||
glVertex2f(xOffset, 256.0 + yOffset);
|
||||
glTexCoord2f( 0.5f, 0.5f);
|
||||
glVertex2f(-xOffset, 256.0 + yOffset);
|
||||
glEnd();
|
||||
|
||||
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
// glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
// glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glBegin( GL_TRIANGLES );
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(-256.0, 0.0);
|
||||
glVertex2f(-256.0, 256.0 * tan(30*SG_DEGREES_TO_RADIANS));
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(-256.0, 0.0);
|
||||
glVertex2f(-256.0, 256.0 * tan(30*SG_DEGREES_TO_RADIANS));
|
||||
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(256.0, 0.0);
|
||||
glVertex2f(256.0, 256.0 * tan(30*SG_DEGREES_TO_RADIANS));
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(256.0, 0.0);
|
||||
glVertex2f(256.0, 256.0 * tan(30*SG_DEGREES_TO_RADIANS));
|
||||
|
||||
glVertex2f(-256, 0.0);
|
||||
glVertex2f(256.0, 0.0);
|
||||
glVertex2f(-256.0, -256.0);
|
||||
glVertex2f(-256, 0.0);
|
||||
glVertex2f(256.0, 0.0);
|
||||
glVertex2f(-256.0, -256.0);
|
||||
|
||||
glVertex2f(256, 0.0);
|
||||
glVertex2f(256.0, -256.0);
|
||||
glVertex2f(-256.0, -256.0);
|
||||
glVertex2f(256, 0.0);
|
||||
glVertex2f(256.0, -256.0);
|
||||
glVertex2f(-256.0, -256.0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
// DEBUG only
|
||||
/* glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
glBegin( GL_LINES );
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(-256.0, 256.0);
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(256.0, 256.0);
|
||||
glEnd();*/
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
}
|
||||
|
||||
// DEBUG only
|
||||
/* glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
|
||||
glBegin( GL_LINES );
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(-256.0, 256.0);
|
||||
glVertex2f(0.0, 0.0);
|
||||
glVertex2f(256.0, 256.0);
|
||||
glEnd();*/
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
}
|
||||
glPopMatrix();
|
||||
odg->endCapture( resultTexture->getHandle() );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue