12 #include <simgear/constants.h>
13 #include <simgear/math/fg_random.h>
14 #include <simgear/math/polar3d.hxx>
16 #include <Aircraft/aircraft.hxx>
17 #include <Scenery/scenery.hxx>
18 #include <Time/fg_timer.hxx>
23 //============ Top of fgTBI_instr class member definitions ==============
36 dual_instr_item( x, y, width, height,
41 BankLimit ((int)(maxBankAngle)),
42 SlewLimit ((int)(maxSlipAngle)),
47 fgTBI_instr :: ~fgTBI_instr() {}
49 fgTBI_instr :: fgTBI_instr( const fgTBI_instr & image):
50 dual_instr_item( (const dual_instr_item &) image),
51 BankLimit( image.BankLimit),
52 SlewLimit( image.SlewLimit),
53 scr_hole ( image.scr_hole )
57 fgTBI_instr & fgTBI_instr ::
58 operator = (const fgTBI_instr & rhs )
60 if( !(this == &rhs)) {
61 dual_instr_item::operator = (rhs);
62 BankLimit = rhs.BankLimit;
63 SlewLimit = rhs.SlewLimit;
64 scr_hole = rhs.scr_hole;
70 // Draws a Turn Bank Indicator on the screen
73 void fgTBI_instr :: draw( void )
75 float bank_angle, sideslip_angle;
76 float ss_const; // sideslip angle pixels per rad
77 float cen_x, cen_y, bank, fspan, tee, hole;
79 int span = get_span();
83 RECT My_box = get_location();
84 POINT centroid = get_centroid();
85 int tee_height = My_box.bottom;
87 bank_angle = current_ch2(); // Roll limit +/- 30 degrees
89 if( bank_angle < -FG_PI_2/3 ) {
90 bank_angle = -FG_PI_2/3;
91 } else if( bank_angle > FG_PI_2/3 ) {
92 bank_angle = FG_PI_2/3;
95 sideslip_angle = current_ch1(); // Sideslip limit +/- 20 degrees
97 if( sideslip_angle < -FG_PI/9 ) {
98 sideslip_angle = -FG_PI/9;
99 } else if( sideslip_angle > FG_PI/9 ) {
100 sideslip_angle = FG_PI/9;
105 bank = bank_angle * RAD_TO_DEG;
109 ss_const = 2 * sideslip_angle * fspan/(FG_2PI/9); // width represents 40 degrees
111 // printf("side_slip: %f fspan: %f\n", sideslip_angle, fspan);
112 // printf("ss_const: %f hole: %f\n", ss_const, hole);
115 glTranslatef(cen_x, cen_y, zero);
116 glRotatef(-bank, zero, zero, 1.0);
122 glVertex2f( -fspan, zero );
123 glVertex2f( fspan, zero );
125 glVertex2f( -fspan, zero );
126 glVertex2f( -hole, zero );
127 glVertex2f( hole, zero );
128 glVertex2f( fspan, zero );
131 glVertex2f( hole, zero );
132 glVertex2f( hole, tee );
133 glVertex2f( -hole, zero );
134 glVertex2f( -hole, tee );
138 glBegin(GL_LINE_LOOP);
139 glVertex2f( ss_const, -hole);
140 glVertex2f( ss_const + hole, zero);
141 glVertex2f( ss_const, hole);
142 glVertex2f( ss_const - hole, zero);