]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/HUD/HUD_ladder.cxx
Add support for drawing target markers (circles on top of any AI/MP aircraft)
[flightgear.git] / src / Instrumentation / HUD / HUD_ladder.cxx
1 // HUD_ladder.cxx -- HUD Ladder Instrument
2 //
3 // Written by Michele America, started September 1997.
4 //
5 // Copyright (C) 1997  Michele F. America  [micheleamerica#geocities:com]
6 // Copyright (C) 2006  Melchior FRANZ  [mfranz#aon:at]
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22 #ifdef HAVE_CONFIG_H
23 #  include <config.h>
24 #endif
25
26 #include <Main/viewer.hxx>
27 #include "HUD.hxx"
28
29
30 // FIXME
31 float get__heading() { return fgGetFloat("/orientation/heading-deg") * M_PI / 180.0; }
32 float get__throttleval() { return fgGetFloat("/controls/engines/engine/throttle"); }
33 float get__Vx() { return fgGetFloat("/velocities/uBody-fps"); }
34 float get__Vy() { return fgGetFloat("/velocities/vBody-fps"); }
35 float get__Vz() { return fgGetFloat("/velocities/wBody-fps"); }
36 float get__Ax() { return fgGetFloat("/acclerations/pilot/x-accel-fps_sec"); }
37 float get__Ay() { return fgGetFloat("/acclerations/pilot/y-accel-fps_sec"); }
38 float get__Az() { return fgGetFloat("/acclerations/pilot/z-accel-fps_sec"); }
39 float get__alpha() { return fgGetFloat("/orientation/alpha-deg"); }
40 float get__beta() { return fgGetFloat("/orientation/side-slip-deg"); }
41 #undef ENABLE_SP_FDM
42
43
44 HUD::Ladder::Ladder(HUD *hud, const SGPropertyNode *n, float x, float y) :
45     Item(hud, n, x, y),
46     _pitch(n->getNode("pitch-input", false)),
47     _roll(n->getNode("roll-input", false)),
48     _width_units(int(n->getFloatValue("display-span"))),
49     _div_units(int(fabs(n->getFloatValue("divisions")))),
50     _scr_hole(n->getIntValue("screen-hole")),
51     _compression(n->getFloatValue("compression-factor")),
52     _frl(n->getBoolValue("enable-fuselage-ref-line")),
53     _target_spot(n->getBoolValue("enable-target-spot")),
54     _target_markers(n->getBoolValue("enable-target-markers")),
55     _velocity_vector(n->getBoolValue("enable-velocity-vector")),
56     _drift_marker(n->getBoolValue("enable-drift-marker")),
57     _alpha_bracket(n->getBoolValue("enable-alpha-bracket")),
58     _energy_marker(n->getBoolValue("enable-energy-marker")),
59     _climb_dive_marker(n->getBoolValue("enable-climb-dive-marker")),
60     _glide_slope_marker(n->getBoolValue("enable-glide-slope-marker")),
61     _glide_slope(n->getFloatValue("glide-slope", -4.0)),
62     _energy_worm(n->getBoolValue("enable-energy-marker")),
63     _waypoint_marker(n->getBoolValue("enable-waypoint-marker")),
64     _zenith(n->getBoolValue("enable-zenith")),
65     _nadir(n->getBoolValue("enable-nadir")),
66     _hat(n->getBoolValue("enable-hat"))
67 {
68     const char *t = n->getStringValue("type");
69     _type = strcmp(t, "climb-dive") ? PITCH : CLIMB_DIVE;
70
71     if (!_width_units)
72         _width_units = 45;
73
74     _vmax = _width_units / 2;
75     _vmin = -_vmax;
76 }
77
78
79 void HUD::Ladder::draw(void)
80 {
81     if (!_pitch.isValid() || !_roll.isValid())
82         return;
83
84     float roll_value = _roll.getFloatValue() * SGD_DEGREES_TO_RADIANS;
85     float pitch_value = _pitch.getFloatValue();
86     float alpha;
87
88     bool pitch_ladder;
89     bool climb_dive_ladder;
90     bool clip_plane;
91
92     if (_type == CLIMB_DIVE) {
93         pitch_ladder = false;
94         climb_dive_ladder = true;
95         clip_plane = true;
96
97     } else { // _type == PITCH
98         pitch_ladder = true;
99         climb_dive_ladder = false;
100         clip_plane = false;
101     }
102
103     //**************************************************************
104     glPushMatrix();
105     glTranslatef(_center_x, _center_y, 0);
106
107     // OBJECT STATIC RETICLE
108     // TYPE FRL (FUSELAGE REFERENCE LINE)
109     // ATTRIB - ALWAYS
110     // Draw the FRL spot and line
111     if (_frl) {
112 #define FRL_DIAMOND_SIZE 2.0
113         glBegin(GL_LINE_LOOP);
114         glVertex2f(-FRL_DIAMOND_SIZE, 0.0);
115         glVertex2f(0.0, FRL_DIAMOND_SIZE);
116         glVertex2f(FRL_DIAMOND_SIZE, 0.0);
117         glVertex2f(0.0, -FRL_DIAMOND_SIZE);
118         glEnd();
119
120         glBegin(GL_LINE_STRIP);
121         glVertex2f(0, FRL_DIAMOND_SIZE);
122         glVertex2f(0, 8.0);
123         glEnd();
124 #undef FRL_DIAMOND_SIZE
125     }
126     // TYPE WATERLINE_MARK (W shaped _    _ )           // TODO (-> HUD_misc.cxx)
127     //                                \/\/
128
129     //****************************************************************
130     // TYPE TARGET_SPOT
131     // Draw the target spot.
132     if (_target_spot) {
133 #define CENTER_DIAMOND_SIZE 6.0
134         glBegin(GL_LINE_LOOP);
135         glVertex2f(-CENTER_DIAMOND_SIZE, 0.0);
136         glVertex2f(0.0, CENTER_DIAMOND_SIZE);
137         glVertex2f(CENTER_DIAMOND_SIZE, 0.0);
138         glVertex2f(0.0, -CENTER_DIAMOND_SIZE);
139         glEnd();
140 #undef CENTER_DIAMOND_SIZE
141     }
142
143     //****************************************************************
144     //velocity vector reticle - computations
145     float xvvr, /* yvvr, */ Vxx = 0.0, Vyy = 0.0, Vzz = 0.0;
146     float Axx = 0.0, Ayy = 0.0, Azz = 0.0, total_vel = 0.0, pot_slope, t1;
147     float up_vel, ground_vel, actslope = 0.0, psi = 0.0;
148     float vel_x = 0.0, vel_y = 0.0, drift;
149
150     if (_velocity_vector) {
151         drift = get__beta();
152         alpha = get__alpha();
153
154         Vxx = get__Vx();
155         Vyy = get__Vy();
156         Vzz = get__Vz();
157         Axx = get__Ax();
158         Ayy = get__Ay();
159         Azz = get__Az();
160         psi = get__heading();
161
162         if (psi > 180.0)
163             psi = psi - 360;
164
165         total_vel = sqrt(Vxx * Vxx + Vyy * Vyy + Vzz * Vzz);
166         ground_vel = sqrt(Vxx * Vxx + Vyy * Vyy);
167         up_vel = Vzz;
168
169         if (ground_vel < 2.0) {
170             if (fabs(up_vel) < 2.0)
171                 actslope = 0.0;
172             else
173                 actslope = (up_vel / fabs(up_vel)) * 90.0;
174
175         } else {
176             actslope = atan(up_vel / ground_vel) * SGD_RADIANS_TO_DEGREES;
177         }
178
179         xvvr = (-drift * (_compression / globals->get_current_view()->get_aspect_ratio()));
180         // drift = ((atan2(Vyy, Vxx) * SGD_RADIANS_TO_DEGREES) - psi);
181         // yvvr = (-alpha * _compression);
182         // vel_y = (-alpha * cos(roll_value) + drift * sin(roll_value)) * _compression;
183         // vel_x = (alpha * sin(roll_value) + drift * cos(roll_value))
184         //         * (_compression / globals->get_current_view()->get_aspect_ratio());
185         vel_y = -alpha * _compression;
186         vel_x = -drift * (_compression / globals->get_current_view()->get_aspect_ratio());
187         //  printf("%f %f %f %f\n",vel_x, vel_y, drift, psi);
188
189         //****************************************************************
190         // OBJECT MOVING RETICLE
191         // TYPE - DRIFT MARKER
192         // ATTRIB - ALWAYS
193         // drift marker
194         if (_drift_marker) {
195             glBegin(GL_LINE_STRIP);
196             glVertex2f((xvvr * 25 / 120) - 6, -4);
197             glVertex2f(xvvr * 25 / 120, 8);
198             glVertex2f((xvvr * 25 / 120) + 6, -4);
199             glEnd();
200         }
201
202         //****************************************************************
203         // Clipping coordinates for ladder to be input from xml file
204         // Clip hud ladder
205         if (clip_plane) {
206             GLdouble eqn_top[4] = {0.0, -1.0, 0.0, 0.0};
207             GLdouble eqn_left[4] = {-1.0, 0.0, 0.0, 100.0};
208             GLdouble eqn_right[4] = {1.0, 0.0, 0.0, 100.0};
209
210             glClipPlane(GL_CLIP_PLANE0, eqn_top);
211             glEnable(GL_CLIP_PLANE0);
212             glClipPlane(GL_CLIP_PLANE1, eqn_left);
213             glEnable(GL_CLIP_PLANE1);
214             glClipPlane(GL_CLIP_PLANE2, eqn_right);
215             glEnable(GL_CLIP_PLANE2);
216             // glScissor(-100,-240, 200, 240);
217             // glEnable(GL_SCISSOR_TEST);
218         }
219
220         //****************************************************************
221         // OBJECT MOVING RETICLE
222         // TYPE VELOCITY VECTOR
223         // ATTRIB - ALWAYS
224         // velocity vector
225         draw_circle(vel_x, vel_y, 6);
226
227         //velocity vector reticle orientation lines
228         glBegin(GL_LINE_STRIP);
229         glVertex2f(vel_x - 12, vel_y);
230         glVertex2f(vel_x - 6, vel_y);
231         glEnd();
232         glBegin(GL_LINE_STRIP);
233         glVertex2f(vel_x + 12, vel_y);
234         glVertex2f(vel_x + 6, vel_y);
235         glEnd();
236         glBegin(GL_LINE_STRIP);
237         glVertex2f(vel_x, vel_y + 12);
238         glVertex2f(vel_x, vel_y + 6);
239         glEnd();
240
241 #ifdef ENABLE_SP_FDM
242         int lgear = get__iaux3();
243         int ihook = get__iaux6();
244
245         // OBJECT MOVING RETICLE
246         // TYPE LINE
247         // ATTRIB - ON CONDITION
248         if (lgear == 1) {
249             // undercarriage status
250             glBegin(GL_LINE_STRIP);
251             glVertex2f(vel_x + 8, vel_y);
252             glVertex2f(vel_x + 8, vel_y - 4);
253             glEnd();
254
255             // OBJECT MOVING RETICLE
256             // TYPE LINE
257             // ATTRIB - ON CONDITION
258             glBegin(GL_LINE_STRIP);
259             glVertex2f(vel_x - 8, vel_y);
260             glVertex2f(vel_x - 8, vel_y - 4);
261             glEnd();
262
263             // OBJECT MOVING RETICLE
264             // TYPE LINE
265             // ATTRIB - ON CONDITION
266             glBegin(GL_LINE_STRIP);
267             glVertex2f(vel_x, vel_y - 6);
268             glVertex2f(vel_x, vel_y - 10);
269             glEnd();
270         }
271
272         // OBJECT MOVING RETICLE
273         // TYPE V
274         // ATTRIB - ON CONDITION
275         if (ihook == 1) {
276             // arrestor hook status
277             glBegin(GL_LINE_STRIP);
278             glVertex2f(vel_x - 4, vel_y - 8);
279             glVertex2f(vel_x, vel_y - 10);
280             glVertex2f(vel_x + 4, vel_y - 8);
281             glEnd();
282         }
283 #endif
284     } // if _velocity_vector
285
286     // draw hud markers on top of each AI/MP target
287     if ( _target_markers ) {
288         SGPropertyNode *models
289             = globals->get_props()->getNode("/ai/models", true);
290         for ( int i = 0; i < models->nChildren(); i++ ) {
291             SGPropertyNode *chld = models->getChild(i);
292             string name;
293             name = chld->getName();
294             if ( name == "aircraft" || name == "multiplayer" ) {
295                 string callsign = chld->getStringValue("callsign");
296                 if ( callsign != "" ) {
297                     float h_deg = chld->getFloatValue("radar/h-offset");
298                     float v_deg = chld->getFloatValue("radar/v-offset");
299                     float pos_x = (h_deg * cos(roll_value) -
300                                    v_deg * sin(roll_value)) * _compression;
301                     float pos_y = (v_deg * cos(roll_value) +
302                                    h_deg * sin(roll_value)) * _compression;
303                     draw_circle(pos_x, pos_y, 8);
304                 }
305             }
306         }
307     }
308
309     //***************************************************************
310     // OBJECT MOVING RETICLE
311     // TYPE - SQUARE_BRACKET
312     // ATTRIB - ON CONDITION
313     // alpha bracket
314 #ifdef ENABLE_SP_FDM
315     alpha = get__alpha();
316
317     if (_alpha_bracket && ihook == 1) {
318         glBegin(GL_LINE_STRIP);
319         glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
320         glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
321         glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
322         glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
323         glEnd();
324
325         glBegin(GL_LINE_STRIP);
326         glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
327         glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
328         glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
329         glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
330         glEnd();
331     }
332 #endif
333     //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
334     //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
335
336     //****************************************************************
337     // OBJECT MOVING RETICLE
338     // TYPE ENERGY_MARKERS
339     // ATTRIB - ALWAYS
340     //energy markers - compute potential slope
341     float pla = get__throttleval();
342     float t2 = 0.0;
343
344     if (_energy_marker) {
345         if (total_vel < 5.0) {
346             t1 = 0;
347             t2 = 0;
348         } else {
349             t1 = up_vel / total_vel;
350             t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
351         }
352         pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
353         // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
354         // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
355
356         //energy markers
357         glBegin(GL_LINE_STRIP);
358         glVertex2f(vel_x - 20, pot_slope - 5);
359         glVertex2f(vel_x - 15, pot_slope);
360         glVertex2f(vel_x - 20, pot_slope + 5);
361         glEnd();
362
363         glBegin(GL_LINE_STRIP);
364         glVertex2f(vel_x + 20, pot_slope - 5);
365         glVertex2f(vel_x + 15, pot_slope);
366         glVertex2f(vel_x + 20, pot_slope + 5);
367         glEnd();
368
369         if (pla > (105.0 / 131.0)) {
370             glBegin(GL_LINE_STRIP);
371             glVertex2f(vel_x - 24, pot_slope - 5);
372             glVertex2f(vel_x - 19, pot_slope);
373             glVertex2f(vel_x - 24, pot_slope + 5);
374             glEnd();
375
376             glBegin(GL_LINE_STRIP);
377             glVertex2f(vel_x + 24, pot_slope - 5);
378             glVertex2f(vel_x + 19, pot_slope);
379             glVertex2f(vel_x + 24, pot_slope + 5);
380             glEnd();
381         }
382     }
383
384     //**********************************************************
385     // ramp reticle
386     // OBJECT STATIC RETICLE
387     // TYPE LINE
388     // ATTRIB - ON CONDITION
389 #ifdef ENABLE_SP_FDM
390     int ilcanclaw = get__iaux2();
391
392     if (_energy_worm && ilcanclaw == 1) {
393         glBegin(GL_LINE_STRIP);
394         glVertex2f(-15, -134);
395         glVertex2f(15, -134);
396         glEnd();
397
398         // OBJECT MOVING RETICLE
399         // TYPE BOX
400         // ATTRIB - ON CONDITION
401         glBegin(GL_LINE_STRIP);
402         glVertex2f(-6, -134);
403         glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
404         glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
405         glVertex2f(6, -134);
406         glEnd();
407
408         // OBJECT MOVING RETICLE
409         // TYPE DIAMOND
410         // ATTRIB - ON CONDITION
411         glBegin(GL_LINE_LOOP);
412         glVertex2f(-6, actslope * 4.0 - 134);
413         glVertex2f(0, actslope * 4.0 -134 + 3);
414         glVertex2f(6, actslope * 4.0 - 134);
415         glVertex2f(0, actslope * 4.0 -134 -3);
416         glEnd();
417     }
418 #endif
419
420     //*************************************************************
421     // OBJECT MOVING RETICLE
422     // TYPE DIAMOND
423     // ATTRIB - ALWAYS
424     // Draw the locked velocity vector.
425     if (_climb_dive_marker) {
426         glBegin(GL_LINE_LOOP);
427         glVertex2f(-3.0, 0.0 + vel_y);
428         glVertex2f(0.0, 6.0 + vel_y);
429         glVertex2f(3.0, 0.0 + vel_y);
430         glVertex2f(0.0, -6.0 + vel_y);
431         glEnd();
432     }
433
434     //****************************************************************
435
436     if (climb_dive_ladder) { // CONFORMAL_HUD
437         _vmin = pitch_value - _width_units;
438         _vmax = pitch_value + _width_units;
439         glTranslatef(vel_x, vel_y, 0);
440
441     } else { // pitch_ladder - Default Hud
442         _vmin = pitch_value - _width_units * 0.5f;
443         _vmax = pitch_value + _width_units * 0.5f;
444     }
445
446     glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
447     // FRL marker not rotated - this line shifted below
448     float half_span = _w / 2.0;
449     float y = 0;
450     float x_ini, x_ini2;
451     float x_end, x_end2;
452
453     if (_div_units) {
454         const int BUFSIZE = 8;
455         char buf[BUFSIZE];
456         float label_length;
457         float label_height;
458         float left;
459         float right;
460         float bot;
461         float top;
462         float text_offset = 4.0f;
463         float zero_offset = 0.0;
464
465         if (climb_dive_ladder)
466             zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
467         else
468             zero_offset = 10.0f;
469
470         fntFont *font = _hud->_font_renderer->getFont();                        // FIXME
471         float pointsize = _hud->_font_renderer->getPointSize();
472         float italic = _hud->_font_renderer->getSlant();
473
474         _locTextList.setFont(_hud->_font_renderer);
475         _locTextList.erase();
476         _locLineList.erase();
477         _locStippleLineList.erase();
478
479         int last = int(_vmax) + 1;
480         int i = int(_vmin);
481
482         if (!_scr_hole) {
483             x_end = half_span;
484
485             for (; i < last; i++) {
486                 y = (i - pitch_value) * _compression + .5f;
487
488                 if (!(i % _div_units)) {           //  At integral multiple of div
489                     snprintf(buf, BUFSIZE, "%d", i);
490                     font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
491                     label_length = right + left;
492                     label_height = (top + bot) / 2.0f;
493
494                     x_ini = -half_span;
495
496                     if (i >= 0) {
497                         // Make zero point wider on left
498                         if (i == 0)
499                             x_ini -= zero_offset;
500
501                         // Zero or above draw solid lines
502                         draw_line(x_ini, y, x_end, y);
503
504                         if (i == 90 && _zenith)
505                             draw_zenith(0.0, y);
506                     } else {
507                         // Below zero draw dashed lines.
508                         draw_stipple_line(x_ini, y, x_end, y);
509
510                         if (i == -90 && _nadir)
511                             draw_nadir(0.0, y);
512                     }
513
514                     // Calculate the position of the left text and write it.
515                     draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
516                     draw_text(x_end + text_offset, y - label_height, buf);
517                 }
518             }
519
520         } else { // if (_scr_hole)
521             // Draw ladder with space in the middle of the lines
522             float hole = _scr_hole / 2.0f;
523
524             x_end = -half_span + hole;
525             x_ini2 = half_span - hole;
526
527             for (; i < last; i++) {
528                 if (_type == PITCH)
529                     y = float(i - pitch_value) * _compression + .5;
530                 else // _type == CLIMB_DIVE
531                     y = float(i - actslope) * _compression + .5;
532
533                 if (!(i % _div_units)) {  //  At integral multiple of div
534                     snprintf(buf, BUFSIZE, "%d", i);
535                     font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
536                     label_length = right + left;
537                     label_height = (top + bot) / 2.0f;
538                     //printf("%s -- l %f r %f b %f t %f\n", buf, left, right, bot, top);
539
540                     // Start by calculating the points and drawing the
541                     // left side lines.
542                     x_ini = -half_span;
543                     x_end2 = half_span;
544
545                     if (i >= 0) {
546                         // Make zero point wider on left
547                         if (i == 0) {
548                             x_ini -= zero_offset;
549                             x_end2 += zero_offset;
550                         }
551                         //draw climb bar vertical lines
552                         if (climb_dive_ladder) {
553                             // Zero or above draw solid lines
554                             draw_line(x_end, y - 5.0, x_end, y);
555                             draw_line(x_ini2, y - 5.0, x_ini2, y);
556                         }
557                         // draw pitch / climb bar
558                         draw_line(x_ini, y, x_end, y);
559                         draw_line(x_ini2, y, x_end2, y);
560
561                         if (i == 90 && _zenith)
562                             draw_zenith(0.0, y);
563
564                     } else { // i < 0
565                         // draw dive bar vertical lines
566                         if (climb_dive_ladder) {
567                             draw_line(x_end, y + 5.0, x_end, y);
568                             draw_line(x_ini2, y + 5.0, x_ini2, y);
569                         }
570
571                         // draw pitch / dive bars
572                         draw_stipple_line(x_ini, y, x_end, y);
573                         draw_stipple_line(x_ini2, y, x_end2, y);
574
575                         if (i == -90 && _nadir)
576                             draw_nadir(0.0, y);
577                     }
578
579                     // Now calculate the location of the left side label using
580                     draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
581                     draw_text(x_end2 + text_offset, y - label_height, buf);
582                 }
583             }
584
585             // OBJECT LADDER MARK
586             // TYPE LINE
587             // ATTRIB - ON CONDITION
588             // draw appraoch glide slope marker
589 #ifdef ENABLE_SP_FDM
590             if (_glide_slope_marker && ihook) {
591                 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
592                         -half_span + hole, (_glide_slope - actslope) * _compression);
593                 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
594                         half_span - hole, (_glide_slope - actslope) * _compression);
595             }
596 #endif
597         }
598         _locTextList.draw();
599
600         glLineWidth(0.2);
601
602         _locLineList.draw();
603
604         glEnable(GL_LINE_STIPPLE);
605         glLineStipple(1, 0x00FF);
606         _locStippleLineList.draw();
607         glDisable(GL_LINE_STIPPLE);
608     }
609     glDisable(GL_CLIP_PLANE0);
610     glDisable(GL_CLIP_PLANE1);
611     glDisable(GL_CLIP_PLANE2);
612     //  glDisable(GL_SCISSOR_TEST);
613     glPopMatrix();
614     //*************************************************************
615
616     //*************************************************************
617 #ifdef ENABLE_SP_FDM
618     if (_waypoint_marker) {
619         //waypoint marker computation
620         float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
621
622         fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
623         fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
624         towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
625         towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
626
627         dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
628                 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
629         delx= towp_lat - fromwp_lat;
630         dely = towp_lon - fromwp_lon;
631         hyp = sqrt(pow(delx, 2) + pow(dely, 2));
632
633         if (hyp != 0)
634             theta = asin(dely / hyp);
635         else
636             theta = 0.0;
637
638         brg = theta * SGD_RADIANS_TO_DEGREES;
639         if (brg > 360.0)
640             brg = 0.0;
641         if (delx < 0)
642             brg = 180 - brg;
643
644         // {Brg  = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
645         // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
646
647         dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
648         // end waypoint marker computation
649
650         //*********************************************************
651         // OBJECT MOVING RETICLE
652         // TYPE ARROW
653         // waypoint marker
654         if (fabs(brg - psi) > 10.0) {
655             glPushMatrix();
656             glTranslatef(_center_x, _center_y, 0);
657             glTranslatef(vel_x, vel_y, 0);
658             glRotatef(brg - psi, 0.0, 0.0, -1.0);
659             glBegin(GL_LINE_LOOP);
660             glVertex2f(-2.5, 20.0);
661             glVertex2f(-2.5, 30.0);
662             glVertex2f(-5.0, 30.0);
663             glVertex2f(0.0, 35.0);
664             glVertex2f(5.0, 30.0);
665             glVertex2f(2.5, 30.0);
666             glVertex2f(2.5, 20.0);
667             glEnd();
668             glPopMatrix();
669         }
670
671         // waypoint marker on heading scale
672         if (fabs(brg - psi) < 12.0) {
673             if (!_hat) {
674                 glBegin(GL_LINE_LOOP);
675                 GLfloat x = (brg - psi) * 60 / 25;
676                 glVertex2f(x + 320, 240.0);
677                 glVertex2f(x + 326, 240.0 - 4);
678                 glVertex2f(x + 323, 240.0 - 4);
679                 glVertex2f(x + 323, 240.0 - 8);
680                 glVertex2f(x + 317, 240.0 - 8);
681                 glVertex2f(x + 317, 240.0 - 4);
682                 glVertex2f(x + 314, 240.0 - 4);
683                 glEnd();
684
685             } else { // if (_hat)
686                 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
687                 float x1, y1;
688
689                 glEnable(GL_POINT_SMOOTH);
690                 glBegin(GL_POINTS);
691
692                 for (int count = 0; count <= 200; count++) {
693                     float temp = count * SG_PI * 3 / (200.0 * 2.0);
694                     float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
695                     x1 = x + r * cos(temp1);
696                     y1 = y + r * sin(temp1);
697                     glVertex2f(x1, y1);
698                 }
699
700                 glEnd();
701                 glDisable(GL_POINT_SMOOTH);
702             }
703
704          } //brg<12
705      } // if _waypoint_marker
706 #endif
707 }//draw
708
709
710 /******************************************************************/
711 //  draws the zenith symbol (highest possible climb angle i.e. 90 degree climb angle)
712 //
713 void HUD::Ladder::draw_zenith(float x, float y)
714 {
715     draw_line(x - 9.0, y, x - 3.0, y + 1.3);
716     draw_line(x - 9.0, y, x - 3.0, y - 1.3);
717
718     draw_line(x + 9.0, y, x + 3.0, y + 1.3);
719     draw_line(x + 9.0, y, x + 3.0, y - 1.3);
720
721     draw_line(x, y + 9.0, x - 1.3, y + 3.0);
722     draw_line(x, y + 9.0, x + 1.3, y + 3.0);
723
724     draw_line(x - 3.9, y + 3.9, x - 3.0, y + 1.3);
725     draw_line(x - 3.9, y + 3.9, x - 1.3, y + 3.0);
726
727     draw_line(x + 3.9, y + 3.9, x + 1.3, y + 3.0);
728     draw_line(x + 3.9, y + 3.9, x + 3.0, y + 1.3);
729
730     draw_line(x - 3.9, y - 3.9, x - 3.0, y - 1.3);
731     draw_line(x - 3.9, y - 3.9, x - 1.3, y - 2.6);
732
733     draw_line(x + 3.9, y - 3.9, x + 3.0, y - 1.3);
734     draw_line(x + 3.9, y - 3.9, x + 1.3, y - 2.6);
735
736     draw_line(x - 1.3, y - 2.6, x, y - 27.0);
737     draw_line(x + 1.3, y - 2.6, x, y - 27.0);
738 }
739
740
741 //  draws the nadir symbol (lowest possible dive angle i.e. 90 degree dive angle))
742 //
743 void HUD::Ladder::draw_nadir(float x, float y)
744 {
745     const float R = 7.5;
746
747     draw_circle(x, y, R);
748     draw_line(x, y + R, x, y + 22.5); // line above the circle
749     draw_line(x - R, y, x + R, y);    // line at middle of circle
750
751     float theta = asin(2.5 / R);
752     float theta1 = asin(5.0 / R);
753     float x1, y1, x2, y2;
754
755     x1 = x + R * cos(theta);
756     y1 = y + 2.5;
757     x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
758     y2 = y + 2.5;
759     draw_line(x1, y1, x2, y2);
760
761     x1 = x + R * cos(theta1);
762     y1 = y + 5.0;
763     x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
764     y2 = y + 5.0;
765     draw_line(x1, y1, x2, y2);
766
767     x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
768     y1 = y - 2.5;
769     x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
770     y2 = y - 2.5;
771     draw_line(x1, y1, x2, y2);
772
773     x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
774     y1 = y - 5.0;
775     x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
776     y2 = y - 5.0;
777     draw_line(x1, y1, x2, y2);
778 }
779
780