]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/HUD/HUD_ladder.cxx
- fix turn bank indicator (bank scale type)
[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         }
217
218         //****************************************************************
219         // OBJECT MOVING RETICLE
220         // TYPE VELOCITY VECTOR
221         // ATTRIB - ALWAYS
222         // velocity vector
223         draw_circle(vel_x, vel_y, 6);
224
225         //velocity vector reticle orientation lines
226         glBegin(GL_LINE_STRIP);
227         glVertex2f(vel_x - 12, vel_y);
228         glVertex2f(vel_x - 6, vel_y);
229         glEnd();
230         glBegin(GL_LINE_STRIP);
231         glVertex2f(vel_x + 12, vel_y);
232         glVertex2f(vel_x + 6, vel_y);
233         glEnd();
234         glBegin(GL_LINE_STRIP);
235         glVertex2f(vel_x, vel_y + 12);
236         glVertex2f(vel_x, vel_y + 6);
237         glEnd();
238
239 #ifdef ENABLE_SP_FDM
240         int lgear = get__iaux3();
241         int ihook = get__iaux6();
242
243         // OBJECT MOVING RETICLE
244         // TYPE LINE
245         // ATTRIB - ON CONDITION
246         if (lgear == 1) {
247             // undercarriage status
248             glBegin(GL_LINE_STRIP);
249             glVertex2f(vel_x + 8, vel_y);
250             glVertex2f(vel_x + 8, vel_y - 4);
251             glEnd();
252
253             // OBJECT MOVING RETICLE
254             // TYPE LINE
255             // ATTRIB - ON CONDITION
256             glBegin(GL_LINE_STRIP);
257             glVertex2f(vel_x - 8, vel_y);
258             glVertex2f(vel_x - 8, vel_y - 4);
259             glEnd();
260
261             // OBJECT MOVING RETICLE
262             // TYPE LINE
263             // ATTRIB - ON CONDITION
264             glBegin(GL_LINE_STRIP);
265             glVertex2f(vel_x, vel_y - 6);
266             glVertex2f(vel_x, vel_y - 10);
267             glEnd();
268         }
269
270         // OBJECT MOVING RETICLE
271         // TYPE V
272         // ATTRIB - ON CONDITION
273         if (ihook == 1) {
274             // arrestor hook status
275             glBegin(GL_LINE_STRIP);
276             glVertex2f(vel_x - 4, vel_y - 8);
277             glVertex2f(vel_x, vel_y - 10);
278             glVertex2f(vel_x + 4, vel_y - 8);
279             glEnd();
280         }
281 #endif
282     } // if _velocity_vector
283
284     // draw hud markers on top of each AI/MP target
285     if (_target_markers) {
286         SGPropertyNode *models = globals->get_props()->getNode("/ai/models", true);
287         for (int i = 0; i < models->nChildren(); i++) {
288             SGPropertyNode *chld = models->getChild(i);
289             string name;
290             name = chld->getName();
291             if (name == "aircraft" || name == "multiplayer") {
292                 string callsign = chld->getStringValue("callsign");
293                 if (callsign != "") {
294                     float h_deg = chld->getFloatValue("radar/h-offset");
295                     float v_deg = chld->getFloatValue("radar/v-offset");
296                     float pos_x = (h_deg * cos(roll_value) -
297                                    v_deg * sin(roll_value)) * _compression;
298                     float pos_y = (v_deg * cos(roll_value) +
299                                    h_deg * sin(roll_value)) * _compression;
300                     draw_circle(pos_x, pos_y, 8);
301                 }
302             }
303         }
304     }
305
306     //***************************************************************
307     // OBJECT MOVING RETICLE
308     // TYPE - SQUARE_BRACKET
309     // ATTRIB - ON CONDITION
310     // alpha bracket
311 #ifdef ENABLE_SP_FDM
312     alpha = get__alpha();
313
314     if (_alpha_bracket && ihook == 1) {
315         glBegin(GL_LINE_STRIP);
316         glVertex2f(vel_x - 20, vel_y - (16 - alpha) * _compression);
317         glVertex2f(vel_x - 17, vel_y - (16 - alpha) * _compression);
318         glVertex2f(vel_x - 17, vel_y - (14 - alpha) * _compression);
319         glVertex2f(vel_x - 20, vel_y - (14 - alpha) * _compression);
320         glEnd();
321
322         glBegin(GL_LINE_STRIP);
323         glVertex2f(vel_x + 20, vel_y - (16 - alpha) * _compression);
324         glVertex2f(vel_x + 17, vel_y - (16 - alpha) * _compression);
325         glVertex2f(vel_x + 17, vel_y - (14 - alpha) * _compression);
326         glVertex2f(vel_x + 20, vel_y - (14 - alpha) * _compression);
327         glEnd();
328     }
329 #endif
330     //printf("xvr=%f, yvr=%f, Vx=%f, Vy=%f, Vz=%f\n",xvvr, yvvr, Vx, Vy, Vz);
331     //printf("Ax=%f, Ay=%f, Az=%f\n",Ax, Ay, Az);
332
333     //****************************************************************
334     // OBJECT MOVING RETICLE
335     // TYPE ENERGY_MARKERS
336     // ATTRIB - ALWAYS
337     //energy markers - compute potential slope
338     float pla = get__throttleval();
339     float t2 = 0.0;
340
341     if (_energy_marker) {
342         if (total_vel < 5.0) {
343             t1 = 0;
344             t2 = 0;
345         } else {
346             t1 = up_vel / total_vel;
347             t2 = asin((Vxx * Axx + Vyy * Ayy + Vzz * Azz) / (9.81 * total_vel));
348         }
349         pot_slope = ((t2 / 3) * SGD_RADIANS_TO_DEGREES) * _compression + vel_y;
350         // if (pot_slope < (vel_y - 45)) pot_slope = vel_y - 45;
351         // if (pot_slope > (vel_y + 45)) pot_slope = vel_y + 45;
352
353         //energy markers
354         glBegin(GL_LINE_STRIP);
355         glVertex2f(vel_x - 20, pot_slope - 5);
356         glVertex2f(vel_x - 15, pot_slope);
357         glVertex2f(vel_x - 20, pot_slope + 5);
358         glEnd();
359
360         glBegin(GL_LINE_STRIP);
361         glVertex2f(vel_x + 20, pot_slope - 5);
362         glVertex2f(vel_x + 15, pot_slope);
363         glVertex2f(vel_x + 20, pot_slope + 5);
364         glEnd();
365
366         if (pla > (105.0 / 131.0)) {
367             glBegin(GL_LINE_STRIP);
368             glVertex2f(vel_x - 24, pot_slope - 5);
369             glVertex2f(vel_x - 19, pot_slope);
370             glVertex2f(vel_x - 24, pot_slope + 5);
371             glEnd();
372
373             glBegin(GL_LINE_STRIP);
374             glVertex2f(vel_x + 24, pot_slope - 5);
375             glVertex2f(vel_x + 19, pot_slope);
376             glVertex2f(vel_x + 24, pot_slope + 5);
377             glEnd();
378         }
379     }
380
381     //**********************************************************
382     // ramp reticle
383     // OBJECT STATIC RETICLE
384     // TYPE LINE
385     // ATTRIB - ON CONDITION
386 #ifdef ENABLE_SP_FDM
387     int ilcanclaw = get__iaux2();
388
389     if (_energy_worm && ilcanclaw == 1) {
390         glBegin(GL_LINE_STRIP);
391         glVertex2f(-15, -134);
392         glVertex2f(15, -134);
393         glEnd();
394
395         // OBJECT MOVING RETICLE
396         // TYPE BOX
397         // ATTRIB - ON CONDITION
398         glBegin(GL_LINE_STRIP);
399         glVertex2f(-6, -134);
400         glVertex2f(-6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
401         glVertex2f(+6, t2 * SGD_RADIANS_TO_DEGREES * 4.0 - 134);
402         glVertex2f(6, -134);
403         glEnd();
404
405         // OBJECT MOVING RETICLE
406         // TYPE DIAMOND
407         // ATTRIB - ON CONDITION
408         glBegin(GL_LINE_LOOP);
409         glVertex2f(-6, actslope * 4.0 - 134);
410         glVertex2f(0, actslope * 4.0 -134 + 3);
411         glVertex2f(6, actslope * 4.0 - 134);
412         glVertex2f(0, actslope * 4.0 -134 -3);
413         glEnd();
414     }
415 #endif
416
417     //*************************************************************
418     // OBJECT MOVING RETICLE
419     // TYPE DIAMOND
420     // ATTRIB - ALWAYS
421     // Draw the locked velocity vector.
422     if (_climb_dive_marker) {
423         glBegin(GL_LINE_LOOP);
424         glVertex2f(-3.0, 0.0 + vel_y);
425         glVertex2f(0.0, 6.0 + vel_y);
426         glVertex2f(3.0, 0.0 + vel_y);
427         glVertex2f(0.0, -6.0 + vel_y);
428         glEnd();
429     }
430
431     //****************************************************************
432
433     if (climb_dive_ladder) { // CONFORMAL_HUD
434         _vmin = pitch_value - _width_units;
435         _vmax = pitch_value + _width_units;
436         glTranslatef(vel_x, vel_y, 0);
437
438     } else { // pitch_ladder - Default Hud
439         _vmin = pitch_value - _width_units * 0.5f;
440         _vmax = pitch_value + _width_units * 0.5f;
441     }
442
443     glRotatef(roll_value * SGD_RADIANS_TO_DEGREES, 0.0, 0.0, 1.0);
444     // FRL marker not rotated - this line shifted below
445     float half_span = _w / 2.0;
446     float y = 0;
447     float x_ini, x_ini2;
448     float x_end, x_end2;
449
450     if (_div_units) {
451         const int BUFSIZE = 8;
452         char buf[BUFSIZE];
453         float label_length;
454         float label_height;
455         float left;
456         float right;
457         float bot;
458         float top;
459         float text_offset = 4.0f;
460         float zero_offset = 0.0;
461
462         if (climb_dive_ladder)
463             zero_offset = 50.0f; // horizon line is wider by this much (hard coded ??)
464         else
465             zero_offset = 10.0f;
466
467         fntFont *font = _hud->_font_renderer->getFont();                        // FIXME
468         float pointsize = _hud->_font_renderer->getPointSize();
469         float italic = _hud->_font_renderer->getSlant();
470
471         _locTextList.setFont(_hud->_font_renderer);
472         _locTextList.erase();
473         _locLineList.erase();
474         _locStippleLineList.erase();
475
476         int last = int(_vmax) + 1;
477         int i = int(_vmin);
478
479         if (!_scr_hole) {
480             x_end = half_span;
481
482             for (; i < last; i++) {
483                 y = (i - pitch_value) * _compression + .5f;
484
485                 if (!(i % _div_units)) {           //  At integral multiple of div
486                     snprintf(buf, BUFSIZE, "%d", i);
487                     font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
488                     label_length = right + left;
489                     label_height = (top + bot) / 2.0f;
490
491                     x_ini = -half_span;
492
493                     if (i >= 0) {
494                         // Make zero point wider on left
495                         if (i == 0)
496                             x_ini -= zero_offset;
497
498                         // Zero or above draw solid lines
499                         draw_line(x_ini, y, x_end, y);
500
501                         if (i == 90 && _zenith)
502                             draw_zenith(0.0, y);
503                     } else {
504                         // Below zero draw dashed lines.
505                         draw_stipple_line(x_ini, y, x_end, y);
506
507                         if (i == -90 && _nadir)
508                             draw_nadir(0.0, y);
509                     }
510
511                     // Calculate the position of the left text and write it.
512                     draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
513                     draw_text(x_end + text_offset, y - label_height, buf);
514                 }
515             }
516
517         } else { // if (_scr_hole)
518             // Draw ladder with space in the middle of the lines
519             float hole = _scr_hole / 2.0f;
520
521             x_end = -half_span + hole;
522             x_ini2 = half_span - hole;
523
524             for (; i < last; i++) {
525                 if (_type == PITCH)
526                     y = float(i - pitch_value) * _compression + .5;
527                 else // _type == CLIMB_DIVE
528                     y = float(i - actslope) * _compression + .5;
529
530                 if (!(i % _div_units)) {  //  At integral multiple of div
531                     snprintf(buf, BUFSIZE, "%d", i);
532                     font->getBBox(buf, pointsize, italic, &left, &right, &bot, &top);
533                     label_length = right + left;
534                     label_height = (top + bot) / 2.0f;
535                     //printf("%s -- l %f r %f b %f t %f\n", buf, left, right, bot, top);
536
537                     // Start by calculating the points and drawing the
538                     // left side lines.
539                     x_ini = -half_span;
540                     x_end2 = half_span;
541
542                     if (i >= 0) {
543                         // Make zero point wider on left
544                         if (i == 0) {
545                             x_ini -= zero_offset;
546                             x_end2 += zero_offset;
547                         }
548                         //draw climb bar vertical lines
549                         if (climb_dive_ladder) {
550                             // Zero or above draw solid lines
551                             draw_line(x_end, y - 5.0, x_end, y);
552                             draw_line(x_ini2, y - 5.0, x_ini2, y);
553                         }
554                         // draw pitch / climb bar
555                         draw_line(x_ini, y, x_end, y);
556                         draw_line(x_ini2, y, x_end2, y);
557
558                         if (i == 90 && _zenith)
559                             draw_zenith(0.0, y);
560
561                     } else { // i < 0
562                         // draw dive bar vertical lines
563                         if (climb_dive_ladder) {
564                             draw_line(x_end, y + 5.0, x_end, y);
565                             draw_line(x_ini2, y + 5.0, x_ini2, y);
566                         }
567
568                         // draw pitch / dive bars
569                         draw_stipple_line(x_ini, y, x_end, y);
570                         draw_stipple_line(x_ini2, y, x_end2, y);
571
572                         if (i == -90 && _nadir)
573                             draw_nadir(0.0, y);
574                     }
575
576                     // Now calculate the location of the left side label using
577                     draw_text(x_ini - text_offset - label_length + 2.5/*hack*/, y - label_height, buf);
578                     draw_text(x_end2 + text_offset, y - label_height, buf);
579                 }
580             }
581
582             // OBJECT LADDER MARK
583             // TYPE LINE
584             // ATTRIB - ON CONDITION
585             // draw appraoch glide slope marker
586 #ifdef ENABLE_SP_FDM
587             if (_glide_slope_marker && ihook) {
588                 draw_line(-half_span + 15, (_glide_slope - actslope) * _compression,
589                         -half_span + hole, (_glide_slope - actslope) * _compression);
590                 draw_line(half_span - 15, (_glide_slope - actslope) * _compression,
591                         half_span - hole, (_glide_slope - actslope) * _compression);
592             }
593 #endif
594         }
595         _locTextList.draw();
596
597         glLineWidth(0.2);
598
599         _locLineList.draw();
600
601         glEnable(GL_LINE_STIPPLE);
602         glLineStipple(1, 0x00FF);
603         _locStippleLineList.draw();
604         glDisable(GL_LINE_STIPPLE);
605     }
606     glDisable(GL_CLIP_PLANE0);
607     glDisable(GL_CLIP_PLANE1);
608     glDisable(GL_CLIP_PLANE2);
609     glPopMatrix();
610     //*************************************************************
611
612     //*************************************************************
613 #ifdef ENABLE_SP_FDM
614     if (_waypoint_marker) {
615         //waypoint marker computation
616         float fromwp_lat, towp_lat, fromwp_lon, towp_lon, dist, delx, dely, hyp, theta, brg;
617
618         fromwp_lon = get__longitude() * SGD_DEGREES_TO_RADIANS;
619         fromwp_lat = get__latitude() * SGD_DEGREES_TO_RADIANS;
620         towp_lon = get__aux2() * SGD_DEGREES_TO_RADIANS;
621         towp_lat = get__aux1() * SGD_DEGREES_TO_RADIANS;
622
623         dist = acos(sin(fromwp_lat) * sin(towp_lat) + cos(fromwp_lat)
624                 * cos(towp_lat) * cos(fabs(fromwp_lon - towp_lon)));
625         delx= towp_lat - fromwp_lat;
626         dely = towp_lon - fromwp_lon;
627         hyp = sqrt(pow(delx, 2) + pow(dely, 2));
628
629         if (hyp != 0)
630             theta = asin(dely / hyp);
631         else
632             theta = 0.0;
633
634         brg = theta * SGD_RADIANS_TO_DEGREES;
635         if (brg > 360.0)
636             brg = 0.0;
637         if (delx < 0)
638             brg = 180 - brg;
639
640         // {Brg  = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
641         // Brg = Brg * SGD_RADIANS_TO_DEGREES; }
642
643         dist *= SGD_RADIANS_TO_DEGREES * 60.0 * 1852.0; //rad->deg->nm->m
644         // end waypoint marker computation
645
646         //*********************************************************
647         // OBJECT MOVING RETICLE
648         // TYPE ARROW
649         // waypoint marker
650         if (fabs(brg - psi) > 10.0) {
651             glPushMatrix();
652             glTranslatef(_center_x, _center_y, 0);
653             glTranslatef(vel_x, vel_y, 0);
654             glRotatef(brg - psi, 0.0, 0.0, -1.0);
655             glBegin(GL_LINE_LOOP);
656             glVertex2f(-2.5, 20.0);
657             glVertex2f(-2.5, 30.0);
658             glVertex2f(-5.0, 30.0);
659             glVertex2f(0.0, 35.0);
660             glVertex2f(5.0, 30.0);
661             glVertex2f(2.5, 30.0);
662             glVertex2f(2.5, 20.0);
663             glEnd();
664             glPopMatrix();
665         }
666
667         // waypoint marker on heading scale
668         if (fabs(brg - psi) < 12.0) {
669             if (!_hat) {
670                 glBegin(GL_LINE_LOOP);
671                 GLfloat x = (brg - psi) * 60 / 25;
672                 glVertex2f(x + 320, 240.0);
673                 glVertex2f(x + 326, 240.0 - 4);
674                 glVertex2f(x + 323, 240.0 - 4);
675                 glVertex2f(x + 323, 240.0 - 8);
676                 glVertex2f(x + 317, 240.0 - 8);
677                 glVertex2f(x + 317, 240.0 - 4);
678                 glVertex2f(x + 314, 240.0 - 4);
679                 glEnd();
680
681             } else { // if (_hat)
682                 float x = (brg - psi) * 60 / 25 + 320, y = 240.0, r = 5.0;
683                 float x1, y1;
684
685                 glEnable(GL_POINT_SMOOTH);
686                 glBegin(GL_POINTS);
687
688                 for (int count = 0; count <= 200; count++) {
689                     float temp = count * SG_PI * 3 / (200.0 * 2.0);
690                     float temp1 = temp - (45.0 * SGD_DEGREES_TO_RADIANS);
691                     x1 = x + r * cos(temp1);
692                     y1 = y + r * sin(temp1);
693                     glVertex2f(x1, y1);
694                 }
695
696                 glEnd();
697                 glDisable(GL_POINT_SMOOTH);
698             }
699
700          } //brg<12
701      } // if _waypoint_marker
702 #endif
703 }//draw
704
705
706 /******************************************************************/
707 //  draws the zenith symbol (highest possible climb angle i.e. 90 degree climb angle)
708 //
709 void HUD::Ladder::draw_zenith(float x, float y)
710 {
711     draw_line(x - 9.0, y, x - 3.0, y + 1.3);
712     draw_line(x - 9.0, y, x - 3.0, y - 1.3);
713
714     draw_line(x + 9.0, y, x + 3.0, y + 1.3);
715     draw_line(x + 9.0, y, x + 3.0, y - 1.3);
716
717     draw_line(x, y + 9.0, x - 1.3, y + 3.0);
718     draw_line(x, y + 9.0, x + 1.3, y + 3.0);
719
720     draw_line(x - 3.9, y + 3.9, x - 3.0, y + 1.3);
721     draw_line(x - 3.9, y + 3.9, x - 1.3, y + 3.0);
722
723     draw_line(x + 3.9, y + 3.9, x + 1.3, y + 3.0);
724     draw_line(x + 3.9, y + 3.9, x + 3.0, y + 1.3);
725
726     draw_line(x - 3.9, y - 3.9, x - 3.0, y - 1.3);
727     draw_line(x - 3.9, y - 3.9, x - 1.3, y - 2.6);
728
729     draw_line(x + 3.9, y - 3.9, x + 3.0, y - 1.3);
730     draw_line(x + 3.9, y - 3.9, x + 1.3, y - 2.6);
731
732     draw_line(x - 1.3, y - 2.6, x, y - 27.0);
733     draw_line(x + 1.3, y - 2.6, x, y - 27.0);
734 }
735
736
737 //  draws the nadir symbol (lowest possible dive angle i.e. 90 degree dive angle))
738 //
739 void HUD::Ladder::draw_nadir(float x, float y)
740 {
741     const float R = 7.5;
742
743     draw_circle(x, y, R);
744     draw_line(x, y + R, x, y + 22.5); // line above the circle
745     draw_line(x - R, y, x + R, y);    // line at middle of circle
746
747     float theta = asin(2.5 / R);
748     float theta1 = asin(5.0 / R);
749     float x1, y1, x2, y2;
750
751     x1 = x + R * cos(theta);
752     y1 = y + 2.5;
753     x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta);
754     y2 = y + 2.5;
755     draw_line(x1, y1, x2, y2);
756
757     x1 = x + R * cos(theta1);
758     y1 = y + 5.0;
759     x2 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) - theta1);
760     y2 = y + 5.0;
761     draw_line(x1, y1, x2, y2);
762
763     x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta);
764     y1 = y - 2.5;
765     x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta);
766     y2 = y - 2.5;
767     draw_line(x1, y1, x2, y2);
768
769     x1 = x + R * cos((180.0 * SGD_DEGREES_TO_RADIANS) + theta1);
770     y1 = y - 5.0;
771     x2 = x + R * cos((360.0 * SGD_DEGREES_TO_RADIANS) - theta1);
772     y2 = y - 5.0;
773     draw_line(x1, y1, x2, y2);
774 }
775
776