# include <config.h>
#endif
+#include <sstream>
+#include <simgear/math/SGGeometry.hxx>
#include <Main/viewer.hxx>
#include "HUD.hxx"
-
// FIXME
-float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
-float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
-float get__aoa() { return fgGetFloat("/sim/frame-rate"); } // FIXME
-float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
-float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
-float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
-float get__Ax() { return fgGetFloat("/acclerations/pilot/x-accel-fps_sec"); }
-float get__Ay() { return fgGetFloat("/acclerations/pilot/y-accel-fps_sec"); }
-float get__Az() { return fgGetFloat("/acclerations/pilot/z-accel-fps_sec"); }
+static float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
+static float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
+static float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
+static float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
+static float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
+static float get__Ax() { return fgGetFloat("/accelerations/pilot/x-accel-fps_sec"); }
+static float get__Ay() { return fgGetFloat("/accelerations/pilot/y-accel-fps_sec"); }
+static float get__Az() { return fgGetFloat("/accelerations/pilot/z-accel-fps_sec"); }
+static float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
+static float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
#undef ENABLE_SP_FDM
_roll(n->getNode("roll-input", false)),
_width_units(int(n->getFloatValue("display-span"))),
_div_units(int(fabs(n->getFloatValue("divisions")))),
- _scr_hole(n->getIntValue("screen-hole")),
+ _scr_hole(fabsf(n->getFloatValue("screen-hole")) * 0.5f),
+ _zero_bar_overlength(n->getFloatValue("zero-bar-overlength", 10)),
+ _dive_bar_angle(n->getBoolValue("enable-dive-bar-angle")),
+ _tick_length(n->getFloatValue("tick-length")),
_compression(n->getFloatValue("compression-factor")),
- _frl(n->getBoolValue("enable-fuselage-ref-line", false)),
- _target_spot(n->getBoolValue("enable-target-spot", false)),
- _velocity_vector(n->getBoolValue("enable-velocity-vector", false)),
- _drift_marker(n->getBoolValue("enable-drift-marker", false)),
- _alpha_bracket(n->getBoolValue("enable-alpha-bracket", false)),
- _energy_marker(n->getBoolValue("enable-energy-marker", false)),
- _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker", false)),
- _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker",false)),
+ _dynamic_origin(n->getBoolValue("enable-dynamic-origin")),
+ _frl(n->getBoolValue("enable-fuselage-ref-line")),
+ _target_spot(n->getBoolValue("enable-target-spot")),
+ _target_markers(n->getBoolValue("enable-target-markers")),
+ _velocity_vector(n->getBoolValue("enable-velocity-vector")),
+ _drift_marker(n->getBoolValue("enable-drift-marker")),
+ _alpha_bracket(n->getBoolValue("enable-alpha-bracket")),
+ _energy_marker(n->getBoolValue("enable-energy-marker")),
+ _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker")),
+ _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker")),
_glide_slope(n->getFloatValue("glide-slope", -4.0)),
- _energy_worm(n->getBoolValue("enable-energy-marker", false)),
- _waypoint_marker(n->getBoolValue("enable-waypoint-marker", false)),
- _zenith(n->getIntValue("zenith")),
- _nadir(n->getIntValue("nadir")),
- _hat(n->getIntValue("hat"))
+ _energy_worm(n->getBoolValue("enable-energy-marker")),
+ _waypoint_marker(n->getBoolValue("enable-waypoint-marker")),
+ _zenith(n->getBoolValue("enable-zenith")),
+ _nadir(n->getBoolValue("enable-nadir")),
+ _hat(n->getBoolValue("enable-hat")),
+ _clip_box(new ClipBox(n->getNode("clipping")))
{
const char *t = n->getStringValue("type");
_type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
}
+HUD::Ladder::~Ladder()
+{
+ delete _clip_box;
+}
+
void HUD::Ladder::draw(void)
{
if (!_pitch.isValid() || !_roll.isValid())
return;
- float x_ini, x_ini2;
- float x_end, x_end2;
- float y = 0;
- int count;
- float cosine, sine, xvvr, yvvr, Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
- float up_vel, ground_vel, actslope = 0.0;
- float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
- float t2 = 0.0, psi = 0.0, alpha, pla;
- float vel_x = 0.0, vel_y = 0.0, drift;
- bool pitch_ladder = false;
- bool climb_dive_ladder = false;
- bool clip_plane = false;
-
- GLdouble eqn_top[4] = {0.0, -1.0, 0.0, 0.0};
- GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
- GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
-
- Point centroid = get_centroid();
-
- float half_span = _w / 2.0;
- float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS; // FIXME rad/deg conversion
- alpha = get__aoa();
- pla = get__throttleval();
-
-#ifdef ENABLE_SP_FDM
- int lgear, wown, wowm, ilcanclaw, ihook;
- ilcanclaw = get__iaux2();
- lgear = get__iaux3();
- wown = get__iaux4();
- wowm = get__iaux5();
- ihook = get__iaux6();
-#endif
+ float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS;
float pitch_value = _pitch.getFloatValue();
- if (_type == CLIMB_DIVE) {
- pitch_ladder = false;
- climb_dive_ladder = true;
- clip_plane = true;
-
- } else { // _type == PITCH
- pitch_ladder = true;
- climb_dive_ladder = false;
- clip_plane = false;
- }
-
//**************************************************************
glPushMatrix();
- // define (0, 0) as center of screen
- glTranslatef(centroid.x, centroid.y, 0);
+ glTranslatef(_center_x, _center_y, 0);
// OBJECT STATIC RETICLE
// TYPE FRL (FUSELAGE REFERENCE LINE)
glEnd();
#undef FRL_DIAMOND_SIZE
}
- // TYPE WATERLINE_MARK (W shaped _ _ )
+ // TYPE WATERLINE_MARK (W shaped _ _ ) // TODO (-> HUD_misc.cxx)
// \/\/
//****************************************************************
//****************************************************************
//velocity vector reticle - computations
+ float xvvr, /* yvvr, */ Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
+ float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
+ float up_vel, ground_vel, actslope = 0.0, psi = 0.0;
+ float vel_x = 0.0, vel_y = 0.0, drift;
+ float alpha;
+
if (_velocity_vector) {
+ drift = get__beta();
+ alpha = get__alpha();
+
Vxx = get__Vx();
Vyy = get__Vy();
Vzz = get__Vz();
actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
}
- xvvr = (((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi)
- * (_compression / globals->get_current_view()->get_aspect_ratio()));
- drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
- yvvr = ((actslope - pitch_value) * _compression);
- vel_y = ((actslope - pitch_value) * cos(roll_value) + drift * sin(roll_value)) * _compression;
- vel_x = (-(actslope - pitch_value) * sin(roll_value) + drift * cos(roll_value))
- * (_compression / globals->get_current_view()->get_aspect_ratio());
+ xvvr = (-drift * (_compression / globals->get_current_view()->get_aspect_ratio()));
+ // drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
+ // yvvr = (-alpha * _compression);
+ // vel_y = (-alpha * cos(roll_value) + drift * sin(roll_value)) * _compression;
+ // vel_x = (alpha * sin(roll_value) + drift * cos(roll_value))
+ // * (_compression / globals->get_current_view()->get_aspect_ratio());
+ vel_y = -alpha * _compression;
+ vel_x = -drift * (_compression / globals->get_current_view()->get_aspect_ratio());
// printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
//****************************************************************
glEnd();
}
- //****************************************************************
- // Clipping coordinates for ladder to be input from xml file
- // Clip hud ladder
- if (clip_plane) {
- glClipPlane(GL_CLIP_PLANE0, eqn_top);
- glEnable(GL_CLIP_PLANE0);
- glClipPlane(GL_CLIP_PLANE1, eqn_left);
- glEnable(GL_CLIP_PLANE1);
- glClipPlane(GL_CLIP_PLANE2, eqn_right);
- glEnable(GL_CLIP_PLANE2);
- // glScissor(-100,-240, 200, 240);
- // glEnable(GL_SCISSOR_TEST);
- }
-
//****************************************************************
// OBJECT MOVING RETICLE
// TYPE VELOCITY VECTOR
// ATTRIB - ALWAYS
// velocity vector
- glBegin(GL_LINE_LOOP); // Use polygon to approximate a circle
- for (count = 0; count < 50; count++) {
- cosine = 6 * cos(count * SGD_2PI / 50.0);
- sine = 6 * sin(count * SGD_2PI / 50.0);
- glVertex2f(cosine + vel_x, sine + vel_y);
- }
- glEnd();
+ draw_circle(vel_x, vel_y, 6);
//velocity vector reticle orientation lines
glBegin(GL_LINE_STRIP);
glEnd();
#ifdef ENABLE_SP_FDM
+ int lgear = get__iaux3();
+ int ihook = get__iaux6();
+
// OBJECT MOVING RETICLE
// TYPE LINE
// ATTRIB - ON CONDITION
#endif
} // if _velocity_vector
+ // draw hud markers on top of each AI/MP target
+ if (_target_markers) {
+ SGPropertyNode *models = globals->get_props()->getNode("/ai/models", true);
+ for (int i = 0; i < models->nChildren(); i++) {
+ SGPropertyNode *chld = models->getChild(i);
+ string name;
+ name = chld->getName();
+ if (name == "aircraft" || name == "multiplayer") {
+ string callsign = chld->getStringValue("callsign");
+ if (callsign != "") {
+ float h_deg = chld->getFloatValue("radar/h-offset");
+ float v_deg = chld->getFloatValue("radar/v-offset");
+ float pos_x = (h_deg * cos(roll_value) -
+ v_deg * sin(roll_value)) * _compression;
+ float pos_y = (v_deg * cos(roll_value) +
+ h_deg * sin(roll_value)) * _compression;
+ draw_circle(pos_x, pos_y, 8);
+ }
+ }
+ }
+ }
//***************************************************************
// OBJECT MOVING RETICLE
// ATTRIB - ON CONDITION
// alpha bracket
#ifdef ENABLE_SP_FDM
+ alpha = get__alpha();
+
if (_alpha_bracket && ihook == 1) {
glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x - 20 , vel_y - (16 - alpha) * _compression);
+ glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
glEnd();
glBegin(GL_LINE_STRIP);
- glVertex2f(vel_x + 20 , vel_y - (16 - alpha) * _compression);
+ glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
// TYPE ENERGY_MARKERS
// ATTRIB - ALWAYS
//energy markers - compute potential slope
+ float pla = get__throttleval();
+ float t2 = 0.0;
+
if (_energy_marker) {
if (total_vel < 5.0) {
t1 = 0;
// TYPE LINE
// ATTRIB - ON CONDITION
#ifdef ENABLE_SP_FDM
+ int ilcanclaw = get__iaux2();
+
if (_energy_worm && ilcanclaw == 1) {
glBegin(GL_LINE_STRIP);
glVertex2f(-15, -134);
//****************************************************************
- if (climb_dive_ladder) { // CONFORMAL_HUD
- _vmin = pitch_value - _width_units;
- _vmax = pitch_value + _width_units;
- glTranslatef(vel_x, vel_y, 0);
+ _clip_box->set();
- } else { // pitch_ladder - Default Hud
+ if (_dynamic_origin) {
+ // ladder moves with alpha/beta offset projected onto horizon
+ // line (so that the horizon line always aligns with the
+ // actual horizon.
+ _vmin = pitch_value - _width_units * 0.5f;
+ _vmax = pitch_value + _width_units * 0.5f;
+ {
+ // the hud ladder center point should move relative to alpha/beta
+ // however the horizon line should always stay on the horizon. We
+ // project the alpha/beta offset onto the horizon line to get the
+ // result we want.
+
+ SGVec3d d(cos(roll_value), sin(roll_value), 0.0);
+ SGRayd r(SGVec3d::zeros(), d);
+ SGVec3d p = r.getClosestPointTo(SGVec3d(vel_x, vel_y, 0.0));
+ glTranslatef(p[0], p[1], 0);
+ }
+ } else {
+ // ladder position is fixed relative to the center of the screen.
_vmin = pitch_value - _width_units * 0.5f;
_vmax = pitch_value + _width_units * 0.5f;
}
glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
+
// FRL marker not rotated - this line shifted below
+ float half_span = _w * 0.5f;
+ float y = 0;
+ struct { float x, y; } lo, li, ri, ro, numoffs; // left/right inner/outer
if (_div_units) {
- const int BUFSIZE = 8;
- char buf[BUFSIZE];
- float label_length;
- float label_height;
- float left;
- float right;
- float bot;
- float top;
- float text_offset = 4.0f;
- float zero_offset = 0.0;
-
- if (climb_dive_ladder)
- zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
- else
- zero_offset = 10.0f;
-
- fntFont *font = _hud->_font_renderer->getFont(); // FIXME
- float pointsize = _hud->_font_renderer->getPointSize();
- float italic = _hud->_font_renderer->getSlant();
-
_locTextList.setFont(_hud->_font_renderer);
_locTextList.erase();
_locLineList.erase();
_locStippleLineList.erase();
- int last = int(_vmax) + 1;
- int i = int(_vmin);
-
- if (!_scr_hole) {
- x_end = half_span;
-
- for (; i < last; i++) {
- y = (i - pitch_value) * _compression + .5f;
+ for (int i = int(_vmin); i < int(_vmax) + 1; i++) {
+ if (i % _div_units)
+ continue;
- if (!(i % _div_units)) { // At integral multiple of div
- snprintf(buf, BUFSIZE, "%d", i);
- font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
- label_length = right + left;
- label_height = (top + bot) / 2.0f;
-
- x_ini = -half_span;
-
- if (i >= 0) {
- // Make zero point wider on left
- if (i == 0)
- x_ini -= zero_offset;
-
- // Zero or above draw solid lines
- draw_line(x_ini, y, x_end, y);
-
- if (i == 90 && _zenith == 1)
- draw_zenith(x_ini, x_end, y);
- } else {
- // Below zero draw dashed lines.
- draw_stipple_line(x_ini, y, x_end, y);
-
- if (i == -90 && _nadir ==1)
- draw_nadir(x_ini, x_end, y);
- }
-
- // Calculate the position of the left text and write it.
- draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
- draw_text(x_end + text_offset, y - label_height, buf);
- }
- }
-
- } else { // if (_scr_hole)
- // Draw ladder with space in the middle of the lines
- float hole = _scr_hole / 2.0f;
-
- x_end = -half_span + hole;
- x_ini2 = half_span - hole;
-
- for (; i < last; i++) {
- if (_type == PITCH)
- y = float(i - pitch_value) * _compression + .5;
- else // _type == CLIMB_DIVE
- y = float(i - actslope) * _compression + .5;
-
- if (!(i % _div_units)) { // At integral multiple of div
- snprintf(buf, BUFSIZE, "%d", i);
- font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
- label_length = right + left;
- label_height = (top + bot) / 2.0f;
- //printf("%s -- l %f r %f b %f t %f\n", buf, left, right, bot, top);
-
- // Start by calculating the points and drawing the
- // left side lines.
- x_ini = -half_span;
- x_end2 = half_span;
-
- if (i >= 0) {
- // Make zero point wider on left
- if (i == 0) {
- x_ini -= zero_offset;
- x_end2 += zero_offset;
- }
- //draw climb bar vertical lines
- if (climb_dive_ladder) {
- // Zero or above draw solid lines
- draw_line(x_end, y - 5.0, x_end, y);
- draw_line(x_ini2, y - 5.0, x_ini2, y);
- }
- // draw pitch / climb bar
- draw_line(x_ini, y, x_end, y);
- draw_line(x_ini2, y, x_end2, y);
-
- if (i == 90 && _zenith == 1)
- draw_zenith(x_ini2, x_end, y);
-
- } else { // i < 0
- // draw dive bar vertical lines
- if (climb_dive_ladder) {
- draw_line(x_end, y + 5.0, x_end, y);
- draw_line(x_ini2, y + 5.0, x_ini2, y);
- }
-
- // draw pitch / dive bars
- draw_stipple_line(x_ini, y, x_end, y);
- draw_stipple_line(x_ini2, y, x_end2, y);
-
- if (i == -90 && _nadir == 1)
- draw_nadir(x_ini2, x_end, y);
- }
-
- // Now calculate the location of the left side label using
- draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
- draw_text(x_end2 + text_offset, y - label_height, buf);
- }
- }
+ if (_type == PITCH)
+ y = float(i - pitch_value) * _compression + .5;
+ else // _type == CLIMB_DIVE
+ y = float(i - actslope) * _compression + .5;
// OBJECT LADDER MARK
// TYPE LINE
// ATTRIB - ON CONDITION
- // draw appraoch glide slope marker
+ // draw approach glide slope marker
#ifdef ENABLE_SP_FDM
if (_glide_slope_marker && ihook) {
draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
half_span - hole, (_glide_slope - actslope) * _compression);
}
#endif
+
+ // draw symbols
+ if (i == 90 && _zenith)
+ draw_zenith(0.0, y);
+ else if (i == -90 && _nadir)
+ draw_nadir(0.0, y);
+
+ if ((_zenith && i > 85) || i > 90)
+ continue;
+ if ((_nadir && i < -85) || i < -90)
+ continue;
+
+ lo.x = -half_span;
+ ro.x = half_span;
+ li.x = ri.x = 0;
+ lo.y = ro.y = li.y = ri.y = y;
+ numoffs.x = 4;
+ numoffs.y = 0;
+
+ if (i == 0) {
+ lo.x -= _zero_bar_overlength;
+ ro.x += _zero_bar_overlength;
+ }
+
+ if (_scr_hole > 0.0f) {
+ li.x = -_scr_hole;
+ ri.x = _scr_hole;
+
+ if (_dive_bar_angle && i < 0) {
+ float alpha = i * SG_DEGREES_TO_RADIANS * 0.5;
+ float xoffs = (ro.x - ri.x) * cos(alpha);
+ float yoffs = (ro.x - ri.x) * sin(alpha);
+ lo.x = li.x - xoffs;
+ ro.x = ri.x + xoffs;
+ lo.y = ro.y = li.y + yoffs;
+ numoffs.x = 0;
+ numoffs.y = 4 - yoffs * 0.3;
+ }
+ }
+
+ // draw bars
+ if (_scr_hole) {
+ draw_line(li.x, li.y, lo.x, lo.y, i < 0);
+ draw_line(ri.x, ri.y, ro.x, ro.y, i < 0);
+ } else {
+ draw_line(lo.x, lo.y, ro.x, ro.y, i < 0);
+ }
+
+ // draw ticks
+ if (_tick_length) {
+ if (i < 0) {
+ draw_line(li.x, li.y, li.x, li.y + _tick_length);
+ draw_line(ri.x, ri.y, ri.x, ri.y + _tick_length);
+ } else if (i > 0 || _zero_bar_overlength == 0) {
+ if (_tick_length > 0) {
+ numoffs.x = -0.3;
+ numoffs.y = -0.3;
+ draw_line(lo.x, lo.y, lo.x, lo.y - _tick_length);
+ draw_line(ro.x, ro.y, ro.x, ro.y - _tick_length);
+ } else {
+ draw_line(li.x, li.y, li.x, li.y - _tick_length);
+ draw_line(ri.x, ri.y, ri.x, ri.y - _tick_length);
+ }
+ }
+ }
+
+ // draw numbers
+ std::ostringstream str;
+ str << i;
+ // must keep this string, otherwise it will free the c_str!
+ string num_str = str.str();
+ const char *num = num_str.c_str();
+ int valign = numoffs.y > 0 ? BOTTOM : numoffs.y < 0 ? TOP : VCENTER;
+ draw_text(lo.x - numoffs.x, lo.y + numoffs.y, num,
+ valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? RIGHT : LEFT));
+ draw_text(ro.x + numoffs.x, lo.y + numoffs.y, num,
+ valign | (numoffs.x == 0 ? CENTER : numoffs.x > 0 ? LEFT : RIGHT));
+
}
_locTextList.draw();
_locStippleLineList.draw();
glDisable(GL_LINE_STIPPLE);
}
- glDisable(GL_CLIP_PLANE0);
- glDisable(GL_CLIP_PLANE1);
- glDisable(GL_CLIP_PLANE2);
- // glDisable(GL_SCISSOR_TEST);
+ _clip_box->unset();
glPopMatrix();
//*************************************************************
// OBJECT MOVING RETICLE
// TYPE ARROW
// waypoint marker
- if (fabs(brg-psi) > 10.0) {
+ if (fabs(brg - psi) > 10.0) {
glPushMatrix();
- glTranslatef(centroid.x, centroid.y, 0);
+ glTranslatef(_center_x, _center_y, 0);
glTranslatef(vel_x, vel_y, 0);
glRotatef(brg - psi, 0.0, 0.0, -1.0);
glBegin(GL_LINE_LOOP);
}
// waypoint marker on heading scale
- if (fabs(brg-psi) < 12.0) {
- if (_hat == 0) {
+ if (fabs(brg - psi) < 12.0) {
+ if (!_hat) {
glBegin(GL_LINE_LOOP);
- glVertex2f(((brg - psi) * 60 / 25) + 320, 240.0);
- glVertex2f(((brg - psi) * 60 / 25) + 326, 240.0 - 4);
- glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 4);
- glVertex2f(((brg - psi) * 60 / 25) + 323, 240.0 - 8);
- glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 8);
- glVertex2f(((brg - psi) * 60 / 25) + 317, 240.0 - 4);
- glVertex2f(((brg - psi) * 60 / 25) + 314, 240.0 - 4);
+ GLfloat x = (brg - psi) * 60 / 25;
+ glVertex2f(x + 320, 240.0);
+ glVertex2f(x + 326, 240.0 - 4);
+ glVertex2f(x + 323, 240.0 - 4);
+ glVertex2f(x + 323, 240.0 - 8);
+ glVertex2f(x + 317, 240.0 - 8);
+ glVertex2f(x + 317, 240.0 - 4);
+ glVertex2f(x + 314, 240.0 - 4);
glEnd();
- } else { //if _hat=0
+ } else { // if (_hat)
float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
float x1, y1;
glEnd();
glDisable(GL_POINT_SMOOTH);
- } //_hat=0
+ }
} //brg<12
} // if _waypoint_marker
/******************************************************************/
-// draws the zenith symbol for highest possible climb angle (i.e. 90 degree climb angle)
+// draws the zenith symbol (highest possible climb angle i.e. 90 degree climb angle)
//
-void HUD::Ladder::draw_zenith(float xfirst, float xlast, float yvalue)
+void HUD::Ladder::draw_zenith(float x, float y)
{
- float xcentre = (xfirst + xlast) / 2.0;
- float ycentre = yvalue;
+ draw_line(x - 9.0, y, x - 3.0, y + 1.3);
+ draw_line(x - 9.0, y, x - 3.0, y - 1.3);
- draw_line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre + 1.3);
- draw_line(xcentre - 9.0, ycentre, xcentre - 3.0, ycentre - 1.3);
+ draw_line(x + 9.0, y, x + 3.0, y + 1.3);
+ draw_line(x + 9.0, y, x + 3.0, y - 1.3);
- draw_line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre + 1.3);
- draw_line(xcentre + 9.0, ycentre, xcentre + 3.0, ycentre - 1.3);
+ draw_line(x, y + 9.0, x - 1.3, y + 3.0);
+ draw_line(x, y + 9.0, x + 1.3, y + 3.0);
- draw_line(xcentre, ycentre + 9.0, xcentre - 1.3, ycentre + 3.0);
- draw_line(xcentre, ycentre + 9.0, xcentre + 1.3, ycentre + 3.0);
+ draw_line(x - 3.9, y + 3.9, x - 3.0, y + 1.3);
+ draw_line(x - 3.9, y + 3.9, x - 1.3, y + 3.0);
- draw_line(xcentre - 3.9, ycentre + 3.9, xcentre - 3.0, ycentre + 1.3);
- draw_line(xcentre - 3.9, ycentre + 3.9, xcentre - 1.3, ycentre + 3.0);
+ draw_line(x + 3.9, y + 3.9, x + 1.3, y + 3.0);
+ draw_line(x + 3.9, y + 3.9, x + 3.0, y + 1.3);
- draw_line(xcentre + 3.9, ycentre + 3.9, xcentre + 1.3, ycentre+3.0);
- draw_line(xcentre + 3.9, ycentre + 3.9, xcentre + 3.0, ycentre+1.3);
+ draw_line(x - 3.9, y - 3.9, x - 3.0, y - 1.3);
+ draw_line(x - 3.9, y - 3.9, x - 1.3, y - 2.6);
- draw_line(xcentre - 3.9, ycentre - 3.9, xcentre - 3.0, ycentre-1.3);
- draw_line(xcentre - 3.9, ycentre - 3.9, xcentre - 1.3, ycentre-2.6);
+ draw_line(x + 3.9, y - 3.9, x + 3.0, y - 1.3);
+ draw_line(x + 3.9, y - 3.9, x + 1.3, y - 2.6);
- draw_line(xcentre + 3.9, ycentre - 3.9, xcentre + 3.0, ycentre-1.3);
- draw_line(xcentre + 3.9, ycentre - 3.9, xcentre + 1.3, ycentre-2.6);
-
- draw_line(xcentre - 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
- draw_line(xcentre + 1.3, ycentre - 2.6, xcentre, ycentre - 27.0);
+ draw_line(x - 1.3, y - 2.6, x, y - 27.0);
+ draw_line(x + 1.3, y - 2.6, x, y - 27.0);
}
-// draws the nadir symbol for lowest possible dive angle (i.e. 90 degree dive angle)
+// draws the nadir symbol (lowest possible dive angle i.e. 90 degree dive angle))
//
-void HUD::Ladder::draw_nadir(float xfirst, float xlast, float yvalue)
+void HUD::Ladder::draw_nadir(float x, float y)
{
- float xcentre = (xfirst + xlast) / 2.0;
- float ycentre = yvalue;
+ const float R = 7.5;
- float r = 7.5;
- float x1, y1, x2, y2;
+ draw_circle(x, y, R);
+ draw_line(x, y + R, x, y + 22.5); // line above the circle
+ draw_line(x - R, y, x + R, y); // line at middle of circle
- // to draw a circle
- float xcent1, xcent2, ycent1, ycent2;
- xcent1 = xcentre + r;
- ycent1 = ycentre;
-
- for (int count = 1; count <= 400; count++) {
- float temp = count * 2 * SG_PI / 400.0;
- xcent2 = xcentre + r * cos(temp);
- ycent2 = ycentre + r * sin(temp);
-
- draw_line(xcent1, ycent1, xcent2, ycent2);
-
- xcent1 = xcent2;
- ycent1 = ycent2;
- }
-
- xcent2 = xcentre + r;
- ycent2 = ycentre;
-
- Item::draw_line(xcent1, ycent1, xcent2, ycent2); //to connect last point to first point
- //end circle
-
- //to draw a line above the circle
- draw_line(xcentre, ycentre + 7.5, xcentre, ycentre + 22.5);
-
- //line in the middle of circle
- draw_line(xcentre - 7.5, ycentre, xcentre + 7.5, ycentre);
-
- float theta = asin(2.5 / 7.5);
- float theta1 = asin(5.0 / 7.5);
+ float theta = asin(2.5 / R);
+ float theta1 = asin(5.0 / R);
+ float x1, y1, x2, y2;
- x1 = xcentre + r * cos(theta);
- y1 = ycentre + 2.5;
- x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
- y2 = ycentre + 2.5;
+ x1 = x + R * cos(theta);
+ y1 = y + 2.5;
+ x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
+ y2 = y + 2.5;
draw_line(x1, y1, x2, y2);
- x1 = xcentre + r * cos(theta1);
- y1 = ycentre + 5.0;
- x2 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
- y2 = ycentre + 5.0;
+ x1 = x + R * cos(theta1);
+ y1 = y + 5.0;
+ x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
+ y2 = y + 5.0;
draw_line(x1, y1, x2, y2);
- x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
- y1 = ycentre - 2.5;
- x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
- y2 = ycentre - 2.5;
+ x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
+ y1 = y - 2.5;
+ x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
+ y2 = y - 2.5;
draw_line(x1, y1, x2, y2);
- x1 = xcentre + r * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
- y1 = ycentre - 5.0;
- x2 = xcentre + r * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
- y2 = ycentre - 5.0;
+ x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
+ y1 = y - 5.0;
+ x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
+ y2 = y - 5.0;
draw_line(x1, y1, x2, y2);
}