1
0
Fork 0

Added Charlie's HUD changes.

This commit is contained in:
curt 1998-02-21 14:53:10 +00:00
parent 2805fb7cb2
commit 1f0a7128bd
4 changed files with 359 additions and 280 deletions

View file

@ -3,7 +3,7 @@
* *
* Written by Michele America, started September 1997. * Written by Michele America, started September 1997.
* *
* Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt * Copyright (C) 1997 Michele F. America - micheleamerica@geocities.com
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
@ -136,7 +136,7 @@ double get_heading( void )
fgFLIGHT *f; fgFLIGHT *f;
f = current_aircraft.flight; f = current_aircraft.flight;
return( FG_Psi*RAD_TO_DEG ); return( FG_Psi * RAD_TO_DEG );
} }
double get_altitude( void ) double get_altitude( void )
@ -202,84 +202,67 @@ static void drawscale( HUD_scale * pscale )
double vmin, vmax; double vmin, vmax;
int marker_x; int marker_x;
int marker_y; int marker_y;
int scr_span;
int mid_scr;
register i; register i;
double factor;
char TextScale[80]; char TextScale[80];
int condition; int condition;
double cur_value = (*(pscale->load_value))(); double cur_value = (*(pscale->load_value))();
int disp_val;
vmin = cur_value - pscale->width_units / 2.0; // width units == needle travel vmin = cur_value - pscale->half_width_units; // width units == needle travel
vmax = cur_value + pscale->width_units / 2.0; // or picture unit span. vmax = cur_value + pscale->half_width_units; // or picture unit span.
scr_span = pscale->scr_max - pscale->scr_min; // Run of scan in pix coord
scr_span |= 1; // If span is odd number of units, mid will be correct.
// If not it will be high by one coordinate unit. This is
// an artifact of integer division needed for screen loc's.
mid_scr = (scr_span >> 1) + pscale->scr_min; // Middle is half that +
// starting point.
// Calculate the number of screen units per indicator unit
// We must force floating point calculation or the factor
// will be low and miss locate tics by several units.
factor = (double)scr_span / (double)pscale->width_units;
// Separate calculations for location of markings by scale
// type V vs H.
if( pscale->type == VERTICAL ) // Vertical scale if( pscale->type == VERTICAL ) // Vertical scale
{ {
drawOneLine( pscale->scrn_pos.right, // Vertical scale bar
pscale->scrn_pos.bottom,
pscale->scrn_pos.right,
pscale->scrn_pos.top );
if( pscale->orientation == LEFT ) // Calculate x marker offset if( pscale->orientation == LEFT ) // Calculate x marker offset
marker_x = pscale->scr_pos-6; marker_x = pscale->scrn_pos.left - 6;
else else
if( pscale->orientation == RIGHT ) if( pscale->orientation == RIGHT )
marker_x = pscale->scr_pos; marker_x = pscale->scrn_pos.right;
// Draw the basic markings for the scale... // Draw the basic markings for the scale...
drawOneLine( pscale->scr_pos, // Vertical bar
pscale->scr_min,
pscale->scr_pos,
pscale->scr_max );
if( pscale->orientation == LEFT ) if( pscale->orientation == LEFT )
{ {
drawOneLine( pscale->scr_pos-3, // Bottom tick bar
pscale->scr_min,
pscale->scr_pos,
pscale->scr_min );
drawOneLine( pscale->scr_pos-3, // Top tick bar drawOneLine( pscale->scrn_pos.right - 3, // Bottom tick bar
pscale->scr_max, pscale->scrn_pos.bottom,
pscale->scr_pos, pscale->scrn_pos.right,
pscale->scr_max ); pscale->scrn_pos.bottom );
drawOneLine( pscale->scr_pos, // Middle tick bar /Index drawOneLine( pscale->scrn_pos.right - 3, // Top tick bar
mid_scr, pscale->scrn_pos.top,
pscale->scr_pos+6, pscale->scrn_pos.right,
mid_scr ); pscale->scrn_pos.top );
drawOneLine( pscale->scrn_pos.right, // Middle tick bar /Index
pscale->mid_scr,
pscale->scrn_pos.right + 6,
pscale->mid_scr );
} }
else else
if( pscale->orientation == RIGHT ) if( pscale->orientation == RIGHT )
{ {
drawOneLine( pscale->scr_pos, drawOneLine( pscale->scrn_pos.right,
pscale->scr_min, pscale->scrn_pos.bottom,
pscale->scr_pos+3, pscale->scrn_pos.right+3,
pscale->scr_min ); pscale->scrn_pos.bottom );
drawOneLine( pscale->scr_pos, drawOneLine( pscale->scrn_pos.right,
pscale->scr_max, pscale->scrn_pos.top,
pscale->scr_pos+3, pscale->scrn_pos.right+3,
pscale->scr_max ); pscale->scrn_pos.top );
drawOneLine( pscale->scr_pos, drawOneLine( pscale->scrn_pos.right,
mid_scr, pscale->mid_scr,
pscale->scr_pos-6, pscale->scrn_pos.right-6,
mid_scr ); pscale->mid_scr );
} }
// Work through from bottom to top of scale. Calculating where to put // Work through from bottom to top of scale. Calculating where to put
@ -298,12 +281,12 @@ static void drawscale( HUD_scale * pscale )
if( condition ) // Show a tick if necessary if( condition ) // Show a tick if necessary
{ {
// Calculate the location of this tick // Calculate the location of this tick
marker_y = pscale->scr_min + (i - vmin) * factor; marker_y = pscale->scrn_pos.bottom + (i - vmin) * pscale->factor;
// Block calculation artifact from drawing ticks below min coordinate. // Block calculation artifact from drawing ticks below min coordinate.
// Calculation here accounts for text height. // Calculation here accounts for text height.
if( marker_y < (pscale->scr_min + 4)) { // Magic number!!! if( marker_y < (pscale->scrn_pos.bottom + 4)) { // Magic number!!!
continue; continue;
} }
if( (i%pscale->div_min) == 0) { if( (i%pscale->div_min) == 0) {
@ -321,7 +304,19 @@ static void drawscale( HUD_scale * pscale )
if( (i%pscale->div_max) == 0 ) { if( (i%pscale->div_max) == 0 ) {
drawOneLine( marker_x, marker_y, drawOneLine( marker_x, marker_y,
marker_x + 6, marker_y ); marker_x + 6, marker_y );
sprintf( TextScale, "%d", i ); if(pscale->modulo) {
disp_val = i % pscale->modulo;
if( !disp_val ) {
disp_val = pscale->modulo;
}
if( disp_val < 0) {
disp_val += pscale->modulo;
}
}
else {
disp_val = i;
}
sprintf( TextScale, "%d", disp_val );
if( pscale->orientation == LEFT ) { if( pscale->orientation == LEFT ) {
textString( marker_x - 8 * strlen(TextScale) - 2, marker_y - 4, textString( marker_x - 8 * strlen(TextScale) - 2, marker_y - 4,
TextScale, GLUT_BITMAP_8_BY_13 ); TextScale, GLUT_BITMAP_8_BY_13 );
@ -339,52 +334,53 @@ static void drawscale( HUD_scale * pscale )
if( pscale->type == HORIZONTAL ) // Horizontal scale if( pscale->type == HORIZONTAL ) // Horizontal scale
{ {
if( pscale->orientation == TOP ) { if( pscale->orientation == TOP ) {
marker_y = pscale->scr_pos; marker_y = pscale->scrn_pos.bottom;
} }
else { else {
if( pscale->orientation == BOTTOM ) { if( pscale->orientation == BOTTOM ) {
marker_y = pscale->scr_pos - 6; marker_y = pscale->scrn_pos.bottom - 6;
} }
} }
drawOneLine( pscale->scr_min, drawOneLine( pscale->scrn_pos.left,
pscale->scr_pos, pscale->scrn_pos.bottom,
pscale->scr_max, pscale->scrn_pos.right,
pscale->scr_pos ); pscale->scrn_pos.bottom );
if( pscale->orientation == TOP ) if( pscale->orientation == TOP )
{ {
drawOneLine( pscale->scr_min, drawOneLine( pscale->scrn_pos.left,
pscale->scr_pos, pscale->scrn_pos.bottom,
pscale->scr_min, pscale->scrn_pos.left,
pscale->scr_pos-3 ); pscale->scrn_pos.bottom + 3 );
drawOneLine( pscale->scr_max, drawOneLine( pscale->scrn_pos.right,
pscale->scr_pos, pscale->scrn_pos.bottom,
pscale->scr_max, pscale->scrn_pos.right,
pscale->scr_pos-3 ); pscale->scrn_pos.bottom + 6 );
drawOneLine( mid_scr, drawOneLine( pscale->mid_scr,
pscale->scr_pos, pscale->scrn_pos.bottom,
mid_scr, pscale->mid_scr,
pscale->scr_pos-6 ); pscale->scrn_pos.bottom - 6 );
} }
else { else {
if( pscale->orientation == BOTTOM ) if( pscale->orientation == BOTTOM )
{ {
drawOneLine( pscale->scr_min, drawOneLine( pscale->scrn_pos.left,
pscale->scr_pos, pscale->scrn_pos.bottom,
pscale->scr_min, pscale->scrn_pos.left,
pscale->scr_pos+3 ); pscale->scrn_pos.bottom - 6 );
drawOneLine( pscale->scr_max, drawOneLine( pscale->scrn_pos.right,
pscale->scr_pos, pscale->scrn_pos.bottom,
pscale->scr_max, pscale->scrn_pos.right,
pscale->scr_pos+3 ); pscale->scrn_pos.bottom - 6 );
drawOneLine( mid_scr, drawOneLine( pscale->mid_scr,
pscale->scr_pos, pscale->scrn_pos.bottom,
mid_scr, pscale->mid_scr,
pscale->scr_pos+6 ); pscale->scrn_pos.bottom + 6 );
} }
} }
@ -399,33 +395,45 @@ static void drawscale( HUD_scale * pscale )
} }
} }
if( condition ) { if( condition ) {
marker_x = pscale->scr_min+(i-vmin)*factor; marker_x = pscale->scrn_pos.left + (i - vmin) * pscale->factor;
if( i%pscale->div_min==0 ) { if( (i%pscale->div_min) == 0 ) {
if( pscale->orientation == TOP ) if( pscale->orientation == TOP )
{ {
drawOneLine( marker_x, marker_y, marker_x, marker_y+3 ); drawOneLine( marker_x, marker_y, marker_x, marker_y + 3 );
} }
else { else {
if( pscale->orientation == BOTTOM ) if( pscale->orientation == BOTTOM )
{ {
drawOneLine( marker_x, marker_y+3, marker_x, marker_y+6 ); drawOneLine( marker_x, marker_y + 3, marker_x, marker_y + 6 );
} }
} }
} }
if( i%pscale->div_max==0 ) if( (i%pscale->div_max)==0 )
{ {
sprintf( TextScale, "%d", i ); if(pscale->modulo) {
disp_val = i % pscale->modulo;
if( !disp_val ) {
disp_val = pscale->modulo;
}
if( disp_val < 0) {
disp_val += pscale->modulo;
}
}
else {
disp_val = i;
}
sprintf( TextScale, "%d", disp_val );
if( pscale->orientation == TOP ) if( pscale->orientation == TOP )
{ {
drawOneLine( marker_x, marker_y, marker_x, marker_y+6 ); drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
textString ( marker_x-4*strlen(TextScale), marker_y+14, textString ( marker_x - 4 * strlen(TextScale), marker_y + 14,
TextScale, GLUT_BITMAP_8_BY_13 ); TextScale, GLUT_BITMAP_8_BY_13 );
} }
else { else {
if( pscale->orientation == BOTTOM ) if( pscale->orientation == BOTTOM )
{ {
drawOneLine( marker_x, marker_y, marker_x, marker_y+6 ); drawOneLine( marker_x, marker_y, marker_x, marker_y+6 );
textString ( marker_x+10, marker_y-4, textString ( marker_x - 4 * strlen(TextScale), marker_y - 14,
TextScale, GLUT_BITMAP_8_BY_13 ); TextScale, GLUT_BITMAP_8_BY_13 );
} }
} }
@ -464,14 +472,14 @@ static void drawladder( HUD_ladder *ladder )
vmin = pitch_value - ladder->width_units/2; vmin = pitch_value - ladder->width_units/2;
vmax = pitch_value + ladder->width_units/2; vmax = pitch_value + ladder->width_units/2;
scr_min = ladder->y_pos - (ladder->scr_height/2); scr_min = ladder->scrn_pos.y - (ladder->scr_height/2);
scr_max = scr_min + ladder->scr_height; scr_max = scr_min + ladder->scr_height;
#ifdef DEBUGHUD #ifdef DEBUGHUD
mid_scr = scr_min + (scr_max-scr_min)/2; mid_scr = scr_min + (scr_max-scr_min)/2;
#endif #endif
marker_x = ladder->x_pos - ladder->scr_width/2; marker_x = ladder->scrn_pos.x - ladder->scr_width/2;
factor = (scr_max-scr_min)/ladder->width_units; factor = (scr_max-scr_min)/ladder->width_units;
@ -487,26 +495,26 @@ static void drawladder( HUD_ladder *ladder )
if( ladder->scr_hole == 0 ) if( ladder->scr_hole == 0 )
{ {
if( i ) { if( i ) {
x_ini = ladder->x_pos - ladder->scr_width/2; x_ini = ladder->scrn_pos.x - ladder->scr_width/2;
} }
else { else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10; x_ini = ladder->scrn_pos.x - ladder->scr_width/2 - 10;
} }
y_ini = marker_y; y_ini = marker_y;
x_end = ladder->x_pos + ladder->scr_width/2; x_end = ladder->scrn_pos.x + ladder->scr_width/2;
y_end = marker_y; y_end = marker_y;
new_x_ini = ladder->x_pos + \ new_x_ini = ladder->scrn_pos.x + \
(x_ini - ladder->x_pos) * cos(roll_value) - \ (x_ini - ladder->scrn_pos.x) * cos(roll_value) - \
(y_ini - ladder->y_pos) * sin(roll_value); (y_ini - ladder->scrn_pos.y) * sin(roll_value);
new_y_ini = ladder->y_pos + \ new_y_ini = ladder->scrn_pos.y + \
(x_ini - ladder->x_pos) * sin(roll_value) + \ (x_ini - ladder->scrn_pos.x) * sin(roll_value) + \
(y_ini - ladder->y_pos) * cos(roll_value); (y_ini - ladder->scrn_pos.y) * cos(roll_value);
new_x_end = ladder->x_pos + \ new_x_end = ladder->scrn_pos.x + \
(x_end - ladder->x_pos) * cos(roll_value) - \ (x_end - ladder->scrn_pos.x) * cos(roll_value) - \
(y_end - ladder->y_pos) * sin(roll_value); (y_end - ladder->scrn_pos.y) * sin(roll_value);
new_y_end = ladder->y_pos + \ new_y_end = ladder->scrn_pos.y + \
(x_end - ladder->x_pos) * sin(roll_value) + \ (x_end - ladder->scrn_pos.x) * sin(roll_value) + \
(y_end - ladder->y_pos) * cos(roll_value); (y_end - ladder->scrn_pos.y) * cos(roll_value);
if( i >= 0 ) if( i >= 0 )
{ {
@ -529,26 +537,26 @@ static void drawladder( HUD_ladder *ladder )
else else
{ {
if( i != 0 ) { if( i != 0 ) {
x_ini = ladder->x_pos - ladder->scr_width/2; x_ini = ladder->scrn_pos.x - ladder->scr_width/2;
} }
else { else {
x_ini = ladder->x_pos - ladder->scr_width/2 - 10; x_ini = ladder->scrn_pos.x - ladder->scr_width/2 - 10;
} }
y_ini = marker_y; y_ini = marker_y;
x_end = ladder->x_pos - ladder->scr_width/2 + ladder->scr_hole/2; x_end = ladder->scrn_pos.x - ladder->scr_width/2 + ladder->scr_hole/2;
y_end = marker_y; y_end = marker_y;
new_x_ini = ladder->x_pos+ \ new_x_ini = ladder->scrn_pos.x+ \
(x_ini - ladder->x_pos) * cos(roll_value) -\ (x_ini - ladder->scrn_pos.x) * cos(roll_value) -\
(y_ini - ladder->y_pos) * sin(roll_value); (y_ini - ladder->scrn_pos.y) * sin(roll_value);
new_y_ini = ladder->y_pos+ \ new_y_ini = ladder->scrn_pos.y+ \
(x_ini - ladder->x_pos) * sin(roll_value) +\ (x_ini - ladder->scrn_pos.x) * sin(roll_value) +\
(y_ini - ladder->y_pos) * cos(roll_value); (y_ini - ladder->scrn_pos.y) * cos(roll_value);
new_x_end = ladder->x_pos+ \ new_x_end = ladder->scrn_pos.x+ \
(x_end - ladder->x_pos) * cos(roll_value) -\ (x_end - ladder->scrn_pos.x) * cos(roll_value) -\
(y_end - ladder->y_pos) * sin(roll_value); (y_end - ladder->scrn_pos.y) * sin(roll_value);
new_y_end = ladder->y_pos+ \ new_y_end = ladder->scrn_pos.y+ \
(x_end - ladder->x_pos) * sin(roll_value) +\ (x_end - ladder->scrn_pos.x) * sin(roll_value) +\
(y_end - ladder->y_pos) * cos(roll_value); (y_end - ladder->scrn_pos.y) * cos(roll_value);
if( i >= 0 ) if( i >= 0 )
{ {
@ -565,27 +573,27 @@ static void drawladder( HUD_ladder *ladder )
new_y_ini - 4, new_y_ini - 4,
TextLadder, GLUT_BITMAP_8_BY_13 ); TextLadder, GLUT_BITMAP_8_BY_13 );
x_ini = ladder->x_pos + ladder->scr_width/2 - ladder->scr_hole/2; x_ini = ladder->scrn_pos.x + ladder->scr_width/2 - ladder->scr_hole/2;
y_ini = marker_y; y_ini = marker_y;
if( i != 0 ) { if( i != 0 ) {
x_end = ladder->x_pos + ladder->scr_width/2; x_end = ladder->scrn_pos.x + ladder->scr_width/2;
} }
else { else {
x_end = ladder->x_pos + ladder->scr_width/2 + 10; x_end = ladder->scrn_pos.x + ladder->scr_width/2 + 10;
} }
y_end = marker_y; y_end = marker_y;
new_x_ini = ladder->x_pos + \ new_x_ini = ladder->scrn_pos.x + \
(x_ini-ladder->x_pos)*cos(roll_value) -\ (x_ini-ladder->scrn_pos.x)*cos(roll_value) -\
(y_ini-ladder->y_pos)*sin(roll_value); (y_ini-ladder->scrn_pos.y)*sin(roll_value);
new_y_ini = ladder->y_pos + \ new_y_ini = ladder->scrn_pos.y + \
(x_ini-ladder->x_pos)*sin(roll_value) +\ (x_ini-ladder->scrn_pos.x)*sin(roll_value) +\
(y_ini-ladder->y_pos)*cos(roll_value); (y_ini-ladder->scrn_pos.y)*cos(roll_value);
new_x_end = ladder->x_pos + \ new_x_end = ladder->scrn_pos.x + \
(x_end-ladder->x_pos)*cos(roll_value) -\ (x_end-ladder->scrn_pos.x)*cos(roll_value) -\
(y_end-ladder->y_pos)*sin(roll_value); (y_end-ladder->scrn_pos.y)*sin(roll_value);
new_y_end = ladder->y_pos + \ new_y_end = ladder->scrn_pos.y + \
(x_end-ladder->x_pos)*sin(roll_value) +\ (x_end-ladder->scrn_pos.x)*sin(roll_value) +\
(y_end-ladder->y_pos)*cos(roll_value); (y_end-ladder->scrn_pos.y)*cos(roll_value);
if( i >= 0 ) if( i >= 0 )
{ {
@ -646,7 +654,7 @@ static void drawhorizon( HUD_horizon *horizon )
double sin_sideslip, cos_sideslip; double sin_sideslip, cos_sideslip;
double ss_const; // sideslip angle pixels per rad double ss_const; // sideslip angle pixels per rad
bank_angle = (*horizon->load_roll)(); bank_angle = (*horizon->load_roll)(); // Need roll limit!
sideslip_angle = (*horizon->load_sideslip)(); sideslip_angle = (*horizon->load_sideslip)();
// sin_bank = sin( FG_2PI-FG_Phi ); // sin_bank = sin( FG_2PI-FG_Phi );
@ -660,18 +668,18 @@ static void drawhorizon( HUD_horizon *horizon )
y_inc1 = (int)(horizon->scr_width * sin_bank); y_inc1 = (int)(horizon->scr_width * sin_bank);
x_inc2 = (int)(horizon->scr_hole * cos_bank); x_inc2 = (int)(horizon->scr_hole * cos_bank);
y_inc2 = (int)(horizon->scr_hole * sin_bank); y_inc2 = (int)(horizon->scr_hole * sin_bank);
x_t_inc1 = (int)(horizon->tee_height * sin_bank); x_t_inc1 = (int)(horizon->tee_height * sin_bank);
y_t_inc1 = (int)(horizon->tee_height * cos_bank); y_t_inc1 = (int)(horizon->tee_height * cos_bank);
d_bottom_x = horizon->x_pos; d_bottom_x = horizon->scrn_pos.x;
d_bottom_y = horizon->y_pos-horizon->scr_hole; d_bottom_y = horizon->scrn_pos.y-horizon->scr_hole;
d_right_x = horizon->x_pos+horizon->scr_hole; d_right_x = horizon->scrn_pos.x+horizon->scr_hole;
d_right_y = horizon->y_pos; d_right_y = horizon->scrn_pos.y;
d_top_x = horizon->x_pos; d_top_x = horizon->scrn_pos.x;
d_top_y = horizon->y_pos+horizon->scr_hole; d_top_y = horizon->scrn_pos.y+horizon->scr_hole;
d_left_x = horizon->x_pos-horizon->scr_hole; d_left_x = horizon->scrn_pos.x-horizon->scr_hole;
d_left_y = horizon->y_pos; d_left_y = horizon->scrn_pos.y;
ss_const = (FG_PI_2/2)/(2*horizon->scr_width-2*horizon->scr_hole); ss_const = (FG_PI_2/2)/(2*horizon->scr_width-2*horizon->scr_hole);
@ -682,22 +690,22 @@ static void drawhorizon( HUD_horizon *horizon )
if( horizon->scr_hole == 0 ) if( horizon->scr_hole == 0 )
{ {
drawOneLine( horizon->x_pos - x_inc1, horizon->y_pos - y_inc1, \ drawOneLine( horizon->scrn_pos.x - x_inc1, horizon->scrn_pos.y - y_inc1, \
horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 ); horizon->scrn_pos.x + x_inc1, horizon->scrn_pos.y + y_inc1 );
} }
else else
{ {
drawOneLine( horizon->x_pos - x_inc1, horizon->y_pos - y_inc1, \ drawOneLine( horizon->scrn_pos.x - x_inc1, horizon->scrn_pos.y - y_inc1, \
horizon->x_pos - x_inc2, horizon->y_pos - y_inc2 ); horizon->scrn_pos.x - x_inc2, horizon->scrn_pos.y - y_inc2 );
drawOneLine( horizon->x_pos + x_inc2, horizon->y_pos + y_inc2, \ drawOneLine( horizon->scrn_pos.x + x_inc2, horizon->scrn_pos.y + y_inc2, \
horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 ); horizon->scrn_pos.x + x_inc1, horizon->scrn_pos.y + y_inc1 );
} }
// draw teemarks (?) // draw teemarks (?)
drawOneLine( horizon->x_pos + x_inc2, horizon->y_pos + y_inc2, \ drawOneLine( horizon->scrn_pos.x + x_inc2, horizon->scrn_pos.y + y_inc2, \
horizon->x_pos + x_inc2 + x_t_inc1, horizon->y_pos + y_inc2 - y_t_inc1 ); horizon->scrn_pos.x + x_inc2 + x_t_inc1, horizon->scrn_pos.y + y_inc2 - y_t_inc1 );
drawOneLine( horizon->x_pos - x_inc2, horizon->y_pos - y_inc2, \ drawOneLine( horizon->scrn_pos.x - x_inc2, horizon->scrn_pos.y - y_inc2, \
horizon->x_pos - x_inc2 + x_t_inc1, horizon->y_pos - y_inc2 - y_t_inc1 ); horizon->scrn_pos.x - x_inc2 + x_t_inc1, horizon->scrn_pos.y - y_inc2 - y_t_inc1 );
// draw sideslip diamond (it is not yet positioned correctly ) // draw sideslip diamond (it is not yet positioned correctly )
drawOneLine( d_bottom_x, d_bottom_y, d_right_x, d_right_y ) drawOneLine( d_bottom_x, d_bottom_y, d_right_x, d_right_y )
@ -719,8 +727,8 @@ static void drawControlSurfaces( HUD_control_surfaces *ctrl_surf )
/* int x_2, y_2; */ /* int x_2, y_2; */
fgCONTROLS *pCtls; fgCONTROLS *pCtls;
x_ini = ctrl_surf->x_pos; x_ini = ctrl_surf->scrn_pos.x;
y_ini = ctrl_surf->y_pos; y_ini = ctrl_surf->scrn_pos.y;
x_end = x_ini + 150; x_end = x_ini + 150;
y_end = y_ini + 60; y_end = y_ini + 60;
@ -872,12 +880,12 @@ static void drawlabel( HUD_label *label )
} }
if( label->size == SMALL ) { if( label->size == SMALL ) {
textString( label->x_pos + posincr, label->y_pos, textString( label->scrn_pos.x + posincr, label->scrn_pos.y,
string, GLUT_BITMAP_8_BY_13); string, GLUT_BITMAP_8_BY_13);
} }
else { else {
if( label->size == LARGE ) { if( label->size == LARGE ) {
textString( label->x_pos + posincr, label->y_pos, textString( label->scrn_pos.x + posincr, label->scrn_pos.y,
string, GLUT_BITMAP_9_BY_15); string, GLUT_BITMAP_9_BY_15);
} }
} }
@ -909,40 +917,41 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
// For now lets just hardcode the hud here. // For now lets just hardcode the hud here.
// In the future, hud information has to come from the same place // In the future, hud information has to come from the same place
// aircraft information came from. // aircraft information came from.
fgHUDSetTimeMode( hud, NIGHT );
fgHUDSetBrightness( hud, BRT_LIGHT );
// Small, original HUD configuration fgHUDSetTimeMode( hud, NIGHT );
// fgHUDAddHorizon( hud, 590, 50, 40, 5, 10, get_roll, get_sideslip ); fgHUDSetBrightness( hud, BRT_LIGHT );
// fgHUDAddLadder ( hud, 330, 190, 90, 180, 70, 10,
// NONE, 45, get_roll, get_pitch ); // TBI
// fgHUDAddScale ( hud, VERTICAL, LIMIT, 220, 100, 280, 5, 10, fgHUDAddHorizon( hud, 330, 100, 40, 5, 10, get_roll, get_sideslip );
// LEFT, 0, 100, 50, get_speed );
// fgHUDAddScale ( hud, VERTICAL, NOLIMIT, 440, 100, 280, 1, 5, RIGHT, fgHUDAddLadder ( hud, 330, 285, 120, 180, 70, 10,
// -40, 50, 25, get_aoa );
// fgHUDAddScale ( hud, HORIZONTAL, NOLIMIT, 280, 220, 440, 5, 10,
// TOP, 0, 50, 50, get_heading );
// fgHUDAddLabel ( hud, 180, 85, SMALL, NOBLINK,
// RIGHT_JUST, NULL, " Kts", "%5.0f", get_speed );
// fgHUDAddLabel ( hud, 180, 73, SMALL, NOBLINK,
// RIGHT_JUST, NULL, " m", "%5.0f", get_altitude );
// fgHUDAddControlSurfaces( hud, 10, 10, NULL );
// Bigger and placed a bit higher HUD configuration
fgHUDAddHorizon( hud, 590, 50, 40, 5, 10, get_roll, get_sideslip );
fgHUDAddLadder ( hud, 330, 270, 120, 180, 70, 10,
NONE, 45, get_roll, get_pitch ); NONE, 45, get_roll, get_pitch );
fgHUDAddScale ( hud, VERTICAL, LIMIT, 200, 180, 380, 5, 10, // KIAS
LEFT, 0, 100, 50, get_speed ); fgHUDAddScale ( hud, VERTICAL, LIMIT, 200, 180, 380, 5, 10,
fgHUDAddScale ( hud, VERTICAL, NOLIMIT, 460, 180, 380, 1, 5, LEFT, 0, 100, 50, 0, get_speed );
RIGHT, -40, 50, 25, get_aoa ); // Angle of Attack
fgHUDAddScale ( hud, HORIZONTAL, NOLIMIT, 380, 200, 460, 5, 10, fgHUDAddScale ( hud, HORIZONTAL, NOLIMIT, 180, 250, 410, 1, 5,
TOP, 0, 50, 50, get_heading ); BOTTOM, -40, 50, 21, 0, get_aoa );
fgHUDAddLabel ( hud, 160, 165, SMALL, NOBLINK, // GYRO COMPASS
RIGHT_JUST, NULL, " Kts", "%5.0f", get_speed ); fgHUDAddScale ( hud, HORIZONTAL, NOLIMIT, 380, 200, 460, 5, 10,
fgHUDAddLabel ( hud, 160, 153, SMALL, NOBLINK, TOP, 0, 50, 50, 360, get_heading );
RIGHT_JUST, NULL, " m", "%5.0f", get_altitude ); // AMSL
fgHUDAddScale ( hud, VERTICAL, LIMIT, 460, 180, 380, 25, 100,
RIGHT, 0, 15000, 250, 0, get_altitude);
fgHUDAddLabel ( hud, 160, 150, SMALL, NOBLINK,
RIGHT_JUST, NULL, " Kts", "%5.0f", get_speed );
fgHUDAddLabel ( hud, 160, 135, SMALL, NOBLINK,
RIGHT_JUST, NULL, " m", "%5.0f", get_altitude );
fgHUDAddLabel ( hud, 160, 120, SMALL, NOBLINK,
RIGHT_JUST, NULL, " Roll", "%5.2f", get_roll );
fgHUDAddLabel ( hud, 440, 150, SMALL, NOBLINK,
RIGHT_JUST, NULL, " AOA", "%5.2f", get_aoa );
fgHUDAddLabel ( hud, 440, 135, SMALL, NOBLINK,
RIGHT_JUST, NULL, " Heading", "%5.0f", get_heading );
fgHUDAddLabel ( hud, 440, 120, SMALL, NOBLINK,
RIGHT_JUST, NULL, " Sideslip", "%5.2f", get_sideslip );
fgHUDAddControlSurfaces( hud, 10, 10, NULL ); fgHUDAddControlSurfaces( hud, 10, 10, NULL );
// fgHUDAddControl( hud, HORIZONTAL, 50, 25, get_aileronval ); // was 10, 10 // fgHUDAddControl( hud, HORIZONTAL, 50, 25, get_aileronval ); // was 10, 10
@ -952,6 +961,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft )
return( hud ); return( hud );
} }
// add_instrument // add_instrument
// //
// This is a stand in for linked list code that will get replaced later // This is a stand in for linked list code that will get replaced later
@ -973,13 +983,13 @@ void add_instrument( Hptr hud, HIptr pinstrument )
// Constructs a HUD_horizon "object" and installs it into the hud instrument // Constructs a HUD_horizon "object" and installs it into the hud instrument
// list. // list.
Hptr fgHUDAddHorizon( Hptr hud, \ Hptr fgHUDAddHorizon( Hptr hud, \
int x_pos, \ int x_pos, \
int y_pos, \ int y_pos, \
int length, \ int length, \
int hole_len, \ int hole_len, \
int tee_height,\ int tee_height,\
double (*load_roll)(),\ double (*load_roll)(),
double (*load_sideslip)() ) double (*load_sideslip)() )
{ {
HUD_horizon *phorizon; HUD_horizon *phorizon;
@ -1001,15 +1011,15 @@ Hptr fgHUDAddHorizon( Hptr hud, \
return( NULL ); return( NULL );
} }
phorizon->x_pos = x_pos; phorizon->scrn_pos.x = x_pos;
phorizon->y_pos = y_pos; phorizon->scrn_pos.y = y_pos;
phorizon->scr_width = length; phorizon->scr_width = length | 1;
phorizon->scr_hole = hole_len; phorizon->scr_hole = hole_len;
phorizon->tee_height = tee_height; phorizon->tee_height = tee_height;
phorizon->load_roll = load_roll; phorizon->load_roll = load_roll;
phorizon->load_sideslip = load_sideslip; phorizon->load_sideslip = load_sideslip;
// Install the horizon in the parent. // Install the horizon in the parent.
pinstrument->instr = phorizon; pinstrument->instr = phorizon;
// Install the instrument into hud. // Install the instrument into hud.
add_instrument( hud, pinstrument); add_instrument( hud, pinstrument);
@ -1033,6 +1043,7 @@ Hptr fgHUDAddScale( Hptr hud, \
int min_value, \ int min_value, \
int max_value, \ int max_value, \
int width_units, \ int width_units, \
int modulus, \
double (*load_value)() ) double (*load_value)() )
{ {
HUD_scale *pscale; HUD_scale *pscale;
@ -1053,18 +1064,48 @@ Hptr fgHUDAddScale( Hptr hud, \
if( pscale == NULL ) { if( pscale == NULL ) {
return( NULL ); return( NULL );
} }
pscale->type = type;
pscale->sub_type = sub_type; pscale->type = type;
pscale->scr_pos = scr_pos; pscale->sub_type = sub_type;
pscale->scr_min = scr_min; pscale->div_min = div_min;
pscale->scr_max = scr_max; pscale->div_max = div_max;
pscale->div_min = div_min; pscale->orientation = orientation;
pscale->div_max = div_max; pscale->minimum_value = min_value;
pscale->orientation = orientation; pscale->maximum_value = max_value;
pscale->minimum_value = min_value; pscale->modulo = modulus;
pscale->maximum_value = max_value; pscale->load_value = load_value;
pscale->width_units = width_units;
pscale->load_value = load_value; pscale->half_width_units = width_units / 2.0;
pscale->scr_span = scr_max - scr_min; // Run of scan in pix coord
pscale->scr_span |= 1; // Force odd span of units.
// If span is odd number of units, mid will be correct.
// If not it will be high by one coordinate unit. This is
// an artifact of integer division needed for screen loc's.
pscale->mid_scr = (pscale->scr_span >> 1) + scr_min;
// Calculate the number of screen units per indicator unit
// We must force floating point calculation or the factor
// will be low and miss locate tics by several units.
pscale->factor = (double)pscale->scr_span / (double)width_units;
switch( type ) {
case HORIZONTAL:
pscale->scrn_pos.left = scr_min;
pscale->scrn_pos.top = scr_pos;
pscale->scrn_pos.right = scr_max;
pscale->scrn_pos.bottom = scr_pos;
break;
case VERTICAL:
default:
pscale->scrn_pos.left = scr_pos;
pscale->scrn_pos.top = scr_max;
pscale->scrn_pos.right = scr_pos;
pscale->scrn_pos.bottom = scr_min;
}
// Install the scale // Install the scale
pinstrument->instr = pscale; pinstrument->instr = pscale;
// Install the instrument into hud. // Install the instrument into hud.
@ -1106,8 +1147,8 @@ Hptr fgHUDAddLabel( Hptr hud, \
return NULL; return NULL;
} }
plabel->x_pos = x_pos; plabel->scrn_pos.x = x_pos;
plabel->y_pos = y_pos; plabel->scrn_pos.y = y_pos;
plabel->size = size; plabel->size = size;
plabel->blink = blink; plabel->blink = blink;
plabel->justify = justify; plabel->justify = justify;
@ -1158,8 +1199,8 @@ Hptr fgHUDAddLadder( Hptr hud, \
return( NULL ); return( NULL );
pladder->type = 0; // Not used. pladder->type = 0; // Not used.
pladder->x_pos = x_pos; pladder->scrn_pos.x = x_pos;
pladder->y_pos = y_pos; pladder->scrn_pos.y = y_pos;
pladder->scr_width = scr_width; pladder->scr_width = scr_width;
pladder->scr_height = scr_height; pladder->scr_height = scr_height;
pladder->scr_hole = hole_len; pladder->scr_hole = hole_len;
@ -1208,8 +1249,8 @@ Hptr fgHUDAddControlSurfaces( Hptr hud,
return( NULL ); return( NULL );
} }
pcontrol_surfaces->x_pos = x_pos; pcontrol_surfaces->scrn_pos.x = x_pos;
pcontrol_surfaces->y_pos = y_pos; pcontrol_surfaces->scrn_pos.y = y_pos;
pcontrol_surfaces->load_value = load_value; pcontrol_surfaces->load_value = load_value;
pinstrument->instr = pcontrol_surfaces; pinstrument->instr = pcontrol_surfaces;
@ -1253,8 +1294,8 @@ Hptr fgHUDAddControl( Hptr hud, \
if( !(pcontrol == NULL) ) { if( !(pcontrol == NULL) ) {
return( NULL ); return( NULL );
} }
pcontrol->ctrl_x = ctrl_x; pcontrol->scrn_pos.x = ctrl_x;
pcontrol->ctrl_y = ctrl_y; pcontrol->scrn_pos.y = ctrl_y;
pcontrol->ctrl_length = ctrl_length; pcontrol->ctrl_length = ctrl_length;
pcontrol->orientation = orientation; pcontrol->orientation = orientation;
pcontrol->alignment = alignment; pcontrol->alignment = alignment;
@ -1330,7 +1371,9 @@ void fgUpdateHUD( Hptr hud ) {
glDisable(GL_LIGHTING); glDisable(GL_LIGHTING);
glLineWidth(1); glLineWidth(1);
// This is a good improvement, but needs
// to respond to a dial instead of time
// of day. Of course, we have no dial!
if( hud->time_of_day==DAY) { if( hud->time_of_day==DAY) {
switch (hud->brightness) { switch (hud->brightness) {
case BRT_LIGHT: case BRT_LIGHT:
@ -1355,6 +1398,9 @@ void fgUpdateHUD( Hptr hud ) {
glColor3f (0.5, 0.0, 0.0); glColor3f (0.5, 0.0, 0.0);
} }
} }
else {
glColor3f (0.1, 0.9, 0.1);
}
fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n", fgPrintf( FG_COCKPIT, FG_DEBUG, "HUD Code %d Status %d\n",
hud->code, hud->status ); hud->code, hud->status );
@ -1417,9 +1463,12 @@ void fgHUDSetBrightness( Hptr hud, int brightness )
} }
/* $Log$ /* $Log$
/* Revision 1.17 1998/02/20 00:16:21 curt /* Revision 1.18 1998/02/21 14:53:10 curt
/* Thursday's tweaks. /* Added Charlie's HUD changes.
/* /*
* Revision 1.17 1998/02/20 00:16:21 curt
* Thursday's tweaks.
*
* Revision 1.16 1998/02/19 13:05:49 curt * Revision 1.16 1998/02/19 13:05:49 curt
* Incorporated some HUD tweaks from Michelle America. * Incorporated some HUD tweaks from Michelle America.
* Tweaked the sky's sunset/rise colors. * Tweaked the sky's sunset/rise colors.

View file

@ -27,7 +27,6 @@
#ifndef _HUD_H #ifndef _HUD_H
#define _HUD_H #define _HUD_H
#include <Aircraft/aircraft.h> #include <Aircraft/aircraft.h>
#include <Flight/flight.h> #include <Flight/flight.h>
#include <Controls/controls.h> #include <Controls/controls.h>
@ -125,38 +124,61 @@ enum VIEW_MODES { HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW };
// Night_Day(); // Illumination changes appearance/bitmaps. // Night_Day(); // Illumination changes appearance/bitmaps.
// //
// CLO 2/21/98 - added to fix compile error
typedef struct { typedef struct {
int type; int x;
int sub_type; int y;
int scr_pos; } POINT;
int scr_min;
int scr_max; // CLO 2/21/98 - added to fix compile error
int div_min; typedef struct {
int div_max; int left;
int orientation; int right;
int minimum_value; int top;
int maximum_value; int bottom;
int width_units; } RECT;
typedef struct {
// Parametric defined members
int type;
int sub_type;
int div_min;
int div_max;
int orientation;
int minimum_value;
int maximum_value;
int width_units;
int modulo; // for compass, etc. Set to 0 for non_modulo scales.
double (*load_value)( void ); double (*load_value)( void );
// Pre-calculated members.
int scr_span;
int mid_scr;
RECT scrn_pos; // Screen rectangle for inicator
// Replaces previous parameters as:
// scr_pos -> left,bottom
// scr_max -> top, right
// scr_min -> left,bottom
double factor;
double half_width_units;
}HUD_scale, *pHUDscale; }HUD_scale, *pHUDscale;
typedef struct { typedef struct {
int type; int type;
int scr_pos; RECT position;
int scr_min;
int scr_max;
int div_min; int div_min;
int div_max; int div_max;
int orientation; int orientation;
int label_position; int label_position;
int width_units; int width_units;
int modulo; // for compass, etc. Set to 0 for non_modulo scales.
double (*load_value)( void ); double (*load_value)( void );
}HUD_circular_scale, *pHUD_circscale; }HUD_circular_scale, *pHUD_circscale;
typedef struct { typedef struct {
int type; int type;
int x_pos; POINT scrn_pos;
int y_pos;
int scr_width; int scr_width;
int scr_height; int scr_height;
int scr_hole; int scr_hole;
@ -183,8 +205,7 @@ typedef struct {
typedef struct{ typedef struct{
int type; int type;
int x_pos; POINT scrn_pos;
int y_pos;
int scr_width; int scr_width;
int scr_hole; int scr_hole;
int tee_height; int tee_height;
@ -193,14 +214,12 @@ typedef struct{
} HUD_horizon, *pHUDhorizon; } HUD_horizon, *pHUDhorizon;
typedef struct { typedef struct {
int x_pos; POINT scrn_pos;
int y_pos;
double(*load_value)(void); double(*load_value)(void);
} HUD_control_surfaces, *pHUDControlSurfaces; } HUD_control_surfaces, *pHUDControlSurfaces;
typedef struct { typedef struct {
int ctrl_x; POINT scrn_pos; // ctrl_x, ctrl_y
int ctrl_y;
int ctrl_length; int ctrl_length;
int orientation; int orientation;
int alignment; int alignment;
@ -214,8 +233,7 @@ typedef struct {
typedef struct { typedef struct {
int type; int type;
int x_pos; POINT scrn_pos;
int y_pos;
int size; int size;
int blink; int blink;
int justify; int justify;
@ -228,15 +246,15 @@ typedef struct {
// Removed union HUD_instr_data to evolve this to oop code. // Removed union HUD_instr_data to evolve this to oop code.
typedef enum{ HUDno_instr, typedef enum{ HUDno_instr,
HUDscale, HUDscale,
HUDcirc_scale, HUDcirc_scale,
HUDladder, HUDladder,
HUDcirc_ladder, HUDcirc_ladder,
HUDhorizon, HUDhorizon,
HUDlabel, HUDlabel,
HUDcontrol_surfaces, HUDcontrol_surfaces,
HUDcontrol HUDcontrol
} hudinstype; } hudinstype;
typedef struct HUD_INSTR_STRUCT{ typedef struct HUD_INSTR_STRUCT{
hudinstype type; hudinstype type;
@ -282,6 +300,7 @@ Hptr fgHUDAddScale ( Hptr hud, \
int min_value, \ int min_value, \
int max_value, \ int max_value, \
int width_units, \ int width_units, \
int modulus, \
double (*load_value)( void ) ); double (*load_value)( void ) );
Hptr fgHUDAddLabel ( Hptr hud, \ Hptr fgHUDAddLabel ( Hptr hud, \
@ -354,12 +373,16 @@ Hptr fgHUDAddNumDisp( Hptr hud,
void fgUpdateHUD ( Hptr hud ); void fgUpdateHUD ( Hptr hud );
void fgUpdateHUD2( Hptr hud ); // Future use? void fgUpdateHUD2( Hptr hud ); // Future use?
#endif // _HUD_H #endif // _HUD_H
/* $Log$ /* $Log$
/* Revision 1.13 1998/02/20 00:16:22 curt /* Revision 1.14 1998/02/21 14:53:14 curt
/* Thursday's tweaks. /* Added Charlie's HUD changes.
/* /*
* Revision 1.13 1998/02/20 00:16:22 curt
* Thursday's tweaks.
*
* Revision 1.12 1998/02/19 13:05:52 curt * Revision 1.12 1998/02/19 13:05:52 curt
* Incorporated some HUD tweaks from Michelle America. * Incorporated some HUD tweaks from Michelle America.
* Tweaked the sky's sunset/rise colors. * Tweaked the sky's sunset/rise colors.

View file

@ -187,16 +187,17 @@ int fgInitSubsystems( void ) {
/* FG_Runway_altitude = 5000.0; */ /* FG_Runway_altitude = 5000.0; */
/* FG_Altitude = FG_Runway_altitude + 3.758099; */ /* FG_Altitude = FG_Runway_altitude + 3.758099; */
/* Initial Position: 10125 Jewell St. NE */ // Initial Position: 10125 Jewell St. NE
/* FG_Longitude = ( -93.15 ) * DEG_TO_RAD; */ // FG_Longitude = ( -93.15 ) * DEG_TO_RAD;
/* FG_Latitude = ( 45.15 ) * DEG_TO_RAD; */ // FG_Latitude = ( 45.15 ) * DEG_TO_RAD;
/* FG_Altitude = FG_Runway_altitude + 3.758099; */ // FG_Runway_altitude = 950.0;
// FG_Altitude = FG_Runway_altitude + 3.758099;
// Initial Position: Somewhere near the Grand Canyon // Initial Position: Somewhere near the Grand Canyon
FG_Longitude = ( -112.5 ) * DEG_TO_RAD; // FG_Longitude = ( -112.5 ) * DEG_TO_RAD;
FG_Latitude = ( 36.5 ) * DEG_TO_RAD; // FG_Latitude = ( 36.5 ) * DEG_TO_RAD;
FG_Runway_altitude = 5000.0; // FG_Runway_altitude = 5000.0;
FG_Altitude = FG_Runway_altitude + 3.758099; // FG_Altitude = FG_Runway_altitude + 3.758099;
// Initial Position: (GCN) Grand Canyon Airport, AZ // Initial Position: (GCN) Grand Canyon Airport, AZ
// FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD; // FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD;
@ -380,11 +381,14 @@ int fgInitSubsystems( void ) {
/* $Log$ /* $Log$
/* Revision 1.47 1998/02/19 13:05:53 curt /* Revision 1.48 1998/02/21 14:53:15 curt
/* Incorporated some HUD tweaks from Michelle America. /* Added Charlie's HUD changes.
/* Tweaked the sky's sunset/rise colors.
/* Other misc. tweaks.
/* /*
* Revision 1.47 1998/02/19 13:05:53 curt
* Incorporated some HUD tweaks from Michelle America.
* Tweaked the sky's sunset/rise colors.
* Other misc. tweaks.
*
* Revision 1.46 1998/02/18 15:07:06 curt * Revision 1.46 1998/02/18 15:07:06 curt
* Tweaks to build with SGI OpenGL (and therefor hopefully other accelerated * Tweaks to build with SGI OpenGL (and therefor hopefully other accelerated
* drivers will work.) * drivers will work.)

3
Simulator/setup_env Normal file
View file

@ -0,0 +1,3 @@
export FG_ROOT=~/projects/FlightGear
export FG_ROOT_SRC=${FG_ROOT}/Src
export FG_ROOT_LIB=${FG_ROOT}/Lib