From: curt Date: Sat, 21 Feb 1998 14:53:10 +0000 (+0000) Subject: Added Charlie's HUD changes. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=1f0a7128bdfa7ed993251ae46bc8750a9c59ec09;p=flightgear.git Added Charlie's HUD changes. --- diff --git a/Cockpit/hud.c b/Cockpit/hud.c index d426ec7d5..8fd393862 100644 --- a/Cockpit/hud.c +++ b/Cockpit/hud.c @@ -3,7 +3,7 @@ * * 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 * modify it under the terms of the GNU General Public License as @@ -136,7 +136,7 @@ double get_heading( void ) fgFLIGHT *f; f = current_aircraft.flight; - return( FG_Psi*RAD_TO_DEG ); + return( FG_Psi * RAD_TO_DEG ); } double get_altitude( void ) @@ -202,84 +202,67 @@ static void drawscale( HUD_scale * pscale ) double vmin, vmax; int marker_x; int marker_y; - int scr_span; - int mid_scr; register i; - double factor; char TextScale[80]; int condition; double cur_value = (*(pscale->load_value))(); + int disp_val; - vmin = cur_value - pscale->width_units / 2.0; // width units == needle travel - vmax = cur_value + pscale->width_units / 2.0; // 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. + vmin = cur_value - pscale->half_width_units; // width units == needle travel + vmax = cur_value + pscale->half_width_units; // or picture unit span. - 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 { + 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 - marker_x = pscale->scr_pos-6; + marker_x = pscale->scrn_pos.left - 6; else if( pscale->orientation == RIGHT ) - marker_x = pscale->scr_pos; + marker_x = pscale->scrn_pos.right; // 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 ) { - 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 - pscale->scr_max, - pscale->scr_pos, - pscale->scr_max ); + drawOneLine( pscale->scrn_pos.right - 3, // Bottom tick bar + pscale->scrn_pos.bottom, + pscale->scrn_pos.right, + pscale->scrn_pos.bottom ); - drawOneLine( pscale->scr_pos, // Middle tick bar /Index - mid_scr, - pscale->scr_pos+6, - mid_scr ); + drawOneLine( pscale->scrn_pos.right - 3, // Top tick bar + pscale->scrn_pos.top, + pscale->scrn_pos.right, + 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 if( pscale->orientation == RIGHT ) { - drawOneLine( pscale->scr_pos, - pscale->scr_min, - pscale->scr_pos+3, - pscale->scr_min ); - - drawOneLine( pscale->scr_pos, - pscale->scr_max, - pscale->scr_pos+3, - pscale->scr_max ); - - drawOneLine( pscale->scr_pos, - mid_scr, - pscale->scr_pos-6, - mid_scr ); + drawOneLine( pscale->scrn_pos.right, + pscale->scrn_pos.bottom, + pscale->scrn_pos.right+3, + pscale->scrn_pos.bottom ); + + drawOneLine( pscale->scrn_pos.right, + pscale->scrn_pos.top, + pscale->scrn_pos.right+3, + pscale->scrn_pos.top ); + + drawOneLine( pscale->scrn_pos.right, + pscale->mid_scr, + pscale->scrn_pos.right-6, + pscale->mid_scr ); } // 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 { // 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. // 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; } if( (i%pscale->div_min) == 0) { @@ -321,7 +304,19 @@ static void drawscale( HUD_scale * pscale ) if( (i%pscale->div_max) == 0 ) { drawOneLine( marker_x, 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 ) { textString( marker_x - 8 * strlen(TextScale) - 2, marker_y - 4, TextScale, GLUT_BITMAP_8_BY_13 ); @@ -339,52 +334,53 @@ static void drawscale( HUD_scale * pscale ) if( pscale->type == HORIZONTAL ) // Horizontal scale { if( pscale->orientation == TOP ) { - marker_y = pscale->scr_pos; + marker_y = pscale->scrn_pos.bottom; } else { if( pscale->orientation == BOTTOM ) { - marker_y = pscale->scr_pos - 6; + marker_y = pscale->scrn_pos.bottom - 6; } } - drawOneLine( pscale->scr_min, - pscale->scr_pos, - pscale->scr_max, - pscale->scr_pos ); + drawOneLine( pscale->scrn_pos.left, + pscale->scrn_pos.bottom, + pscale->scrn_pos.right, + pscale->scrn_pos.bottom ); + if( pscale->orientation == TOP ) { - drawOneLine( pscale->scr_min, - pscale->scr_pos, - pscale->scr_min, - pscale->scr_pos-3 ); + drawOneLine( pscale->scrn_pos.left, + pscale->scrn_pos.bottom, + pscale->scrn_pos.left, + pscale->scrn_pos.bottom + 3 ); - drawOneLine( pscale->scr_max, - pscale->scr_pos, - pscale->scr_max, - pscale->scr_pos-3 ); + drawOneLine( pscale->scrn_pos.right, + pscale->scrn_pos.bottom, + pscale->scrn_pos.right, + pscale->scrn_pos.bottom + 6 ); - drawOneLine( mid_scr, - pscale->scr_pos, - mid_scr, - pscale->scr_pos-6 ); + drawOneLine( pscale->mid_scr, + pscale->scrn_pos.bottom, + pscale->mid_scr, + pscale->scrn_pos.bottom - 6 ); } else { if( pscale->orientation == BOTTOM ) { - drawOneLine( pscale->scr_min, - pscale->scr_pos, - pscale->scr_min, - pscale->scr_pos+3 ); - - drawOneLine( pscale->scr_max, - pscale->scr_pos, - pscale->scr_max, - pscale->scr_pos+3 ); - - drawOneLine( mid_scr, - pscale->scr_pos, - mid_scr, - pscale->scr_pos+6 ); + drawOneLine( pscale->scrn_pos.left, + pscale->scrn_pos.bottom, + pscale->scrn_pos.left, + pscale->scrn_pos.bottom - 6 ); + + drawOneLine( pscale->scrn_pos.right, + pscale->scrn_pos.bottom, + pscale->scrn_pos.right, + pscale->scrn_pos.bottom - 6 ); + + drawOneLine( pscale->mid_scr, + pscale->scrn_pos.bottom, + pscale->mid_scr, + pscale->scrn_pos.bottom + 6 ); } } @@ -399,33 +395,45 @@ static void drawscale( HUD_scale * pscale ) } } if( condition ) { - marker_x = pscale->scr_min+(i-vmin)*factor; - if( i%pscale->div_min==0 ) { + marker_x = pscale->scrn_pos.left + (i - vmin) * pscale->factor; + if( (i%pscale->div_min) == 0 ) { 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 { 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 ) { 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 ); } else { if( pscale->orientation == BOTTOM ) { 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 ); } } @@ -464,14 +472,14 @@ static void drawladder( HUD_ladder *ladder ) vmin = 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; #ifdef DEBUGHUD mid_scr = scr_min + (scr_max-scr_min)/2; #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; @@ -487,26 +495,26 @@ static void drawladder( HUD_ladder *ladder ) if( ladder->scr_hole == 0 ) { if( i ) { - x_ini = ladder->x_pos - ladder->scr_width/2; + x_ini = ladder->scrn_pos.x - ladder->scr_width/2; } 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; - x_end = ladder->x_pos + ladder->scr_width/2; + x_end = ladder->scrn_pos.x + ladder->scr_width/2; y_end = marker_y; - new_x_ini = ladder->x_pos + \ - (x_ini - ladder->x_pos) * cos(roll_value) - \ - (y_ini - ladder->y_pos) * sin(roll_value); - new_y_ini = ladder->y_pos + \ - (x_ini - ladder->x_pos) * sin(roll_value) + \ - (y_ini - ladder->y_pos) * cos(roll_value); - new_x_end = ladder->x_pos + \ - (x_end - ladder->x_pos) * cos(roll_value) - \ - (y_end - ladder->y_pos) * sin(roll_value); - new_y_end = ladder->y_pos + \ - (x_end - ladder->x_pos) * sin(roll_value) + \ - (y_end - ladder->y_pos) * cos(roll_value); + new_x_ini = ladder->scrn_pos.x + \ + (x_ini - ladder->scrn_pos.x) * cos(roll_value) - \ + (y_ini - ladder->scrn_pos.y) * sin(roll_value); + new_y_ini = ladder->scrn_pos.y + \ + (x_ini - ladder->scrn_pos.x) * sin(roll_value) + \ + (y_ini - ladder->scrn_pos.y) * cos(roll_value); + new_x_end = ladder->scrn_pos.x + \ + (x_end - ladder->scrn_pos.x) * cos(roll_value) - \ + (y_end - ladder->scrn_pos.y) * sin(roll_value); + new_y_end = ladder->scrn_pos.y + \ + (x_end - ladder->scrn_pos.x) * sin(roll_value) + \ + (y_end - ladder->scrn_pos.y) * cos(roll_value); if( i >= 0 ) { @@ -529,26 +537,26 @@ static void drawladder( HUD_ladder *ladder ) else { if( i != 0 ) { - x_ini = ladder->x_pos - ladder->scr_width/2; + x_ini = ladder->scrn_pos.x - ladder->scr_width/2; } 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; - 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; - new_x_ini = ladder->x_pos+ \ - (x_ini - ladder->x_pos) * cos(roll_value) -\ - (y_ini - ladder->y_pos) * sin(roll_value); - new_y_ini = ladder->y_pos+ \ - (x_ini - ladder->x_pos) * sin(roll_value) +\ - (y_ini - ladder->y_pos) * cos(roll_value); - new_x_end = ladder->x_pos+ \ - (x_end - ladder->x_pos) * cos(roll_value) -\ - (y_end - ladder->y_pos) * sin(roll_value); - new_y_end = ladder->y_pos+ \ - (x_end - ladder->x_pos) * sin(roll_value) +\ - (y_end - ladder->y_pos) * cos(roll_value); + new_x_ini = ladder->scrn_pos.x+ \ + (x_ini - ladder->scrn_pos.x) * cos(roll_value) -\ + (y_ini - ladder->scrn_pos.y) * sin(roll_value); + new_y_ini = ladder->scrn_pos.y+ \ + (x_ini - ladder->scrn_pos.x) * sin(roll_value) +\ + (y_ini - ladder->scrn_pos.y) * cos(roll_value); + new_x_end = ladder->scrn_pos.x+ \ + (x_end - ladder->scrn_pos.x) * cos(roll_value) -\ + (y_end - ladder->scrn_pos.y) * sin(roll_value); + new_y_end = ladder->scrn_pos.y+ \ + (x_end - ladder->scrn_pos.x) * sin(roll_value) +\ + (y_end - ladder->scrn_pos.y) * cos(roll_value); if( i >= 0 ) { @@ -565,27 +573,27 @@ static void drawladder( HUD_ladder *ladder ) new_y_ini - 4, 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; if( i != 0 ) { - x_end = ladder->x_pos + ladder->scr_width/2; + x_end = ladder->scrn_pos.x + ladder->scr_width/2; } 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; - new_x_ini = ladder->x_pos + \ - (x_ini-ladder->x_pos)*cos(roll_value) -\ - (y_ini-ladder->y_pos)*sin(roll_value); - new_y_ini = ladder->y_pos + \ - (x_ini-ladder->x_pos)*sin(roll_value) +\ - (y_ini-ladder->y_pos)*cos(roll_value); - new_x_end = ladder->x_pos + \ - (x_end-ladder->x_pos)*cos(roll_value) -\ - (y_end-ladder->y_pos)*sin(roll_value); - new_y_end = ladder->y_pos + \ - (x_end-ladder->x_pos)*sin(roll_value) +\ - (y_end-ladder->y_pos)*cos(roll_value); + new_x_ini = ladder->scrn_pos.x + \ + (x_ini-ladder->scrn_pos.x)*cos(roll_value) -\ + (y_ini-ladder->scrn_pos.y)*sin(roll_value); + new_y_ini = ladder->scrn_pos.y + \ + (x_ini-ladder->scrn_pos.x)*sin(roll_value) +\ + (y_ini-ladder->scrn_pos.y)*cos(roll_value); + new_x_end = ladder->scrn_pos.x + \ + (x_end-ladder->scrn_pos.x)*cos(roll_value) -\ + (y_end-ladder->scrn_pos.y)*sin(roll_value); + new_y_end = ladder->scrn_pos.y + \ + (x_end-ladder->scrn_pos.x)*sin(roll_value) +\ + (y_end-ladder->scrn_pos.y)*cos(roll_value); if( i >= 0 ) { @@ -646,7 +654,7 @@ static void drawhorizon( HUD_horizon *horizon ) double sin_sideslip, cos_sideslip; 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)(); // 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); x_inc2 = (int)(horizon->scr_hole * cos_bank); y_inc2 = (int)(horizon->scr_hole * sin_bank); - + x_t_inc1 = (int)(horizon->tee_height * sin_bank); y_t_inc1 = (int)(horizon->tee_height * cos_bank); - d_bottom_x = horizon->x_pos; - d_bottom_y = horizon->y_pos-horizon->scr_hole; - d_right_x = horizon->x_pos+horizon->scr_hole; - d_right_y = horizon->y_pos; - d_top_x = horizon->x_pos; - d_top_y = horizon->y_pos+horizon->scr_hole; - d_left_x = horizon->x_pos-horizon->scr_hole; - d_left_y = horizon->y_pos; + d_bottom_x = horizon->scrn_pos.x; + d_bottom_y = horizon->scrn_pos.y-horizon->scr_hole; + d_right_x = horizon->scrn_pos.x+horizon->scr_hole; + d_right_y = horizon->scrn_pos.y; + d_top_x = horizon->scrn_pos.x; + d_top_y = horizon->scrn_pos.y+horizon->scr_hole; + d_left_x = horizon->scrn_pos.x-horizon->scr_hole; + d_left_y = horizon->scrn_pos.y; 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 ) { - drawOneLine( horizon->x_pos - x_inc1, horizon->y_pos - y_inc1, \ - horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 ); + drawOneLine( horizon->scrn_pos.x - x_inc1, horizon->scrn_pos.y - y_inc1, \ + horizon->scrn_pos.x + x_inc1, horizon->scrn_pos.y + y_inc1 ); } else { - drawOneLine( horizon->x_pos - x_inc1, horizon->y_pos - y_inc1, \ - horizon->x_pos - x_inc2, horizon->y_pos - y_inc2 ); - drawOneLine( horizon->x_pos + x_inc2, horizon->y_pos + y_inc2, \ - horizon->x_pos + x_inc1, horizon->y_pos + y_inc1 ); + drawOneLine( horizon->scrn_pos.x - x_inc1, horizon->scrn_pos.y - y_inc1, \ + horizon->scrn_pos.x - x_inc2, horizon->scrn_pos.y - y_inc2 ); + drawOneLine( horizon->scrn_pos.x + x_inc2, horizon->scrn_pos.y + y_inc2, \ + horizon->scrn_pos.x + x_inc1, horizon->scrn_pos.y + y_inc1 ); } - - // draw teemarks (?) - drawOneLine( horizon->x_pos + x_inc2, horizon->y_pos + y_inc2, \ - horizon->x_pos + x_inc2 + x_t_inc1, horizon->y_pos + y_inc2 - y_t_inc1 ); - drawOneLine( horizon->x_pos - x_inc2, horizon->y_pos - y_inc2, \ - horizon->x_pos - x_inc2 + x_t_inc1, horizon->y_pos - y_inc2 - y_t_inc1 ); + + // draw teemarks (?) + drawOneLine( horizon->scrn_pos.x + x_inc2, horizon->scrn_pos.y + y_inc2, \ + horizon->scrn_pos.x + x_inc2 + x_t_inc1, horizon->scrn_pos.y + y_inc2 - y_t_inc1 ); + drawOneLine( horizon->scrn_pos.x - x_inc2, horizon->scrn_pos.y - y_inc2, \ + 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 ) 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; */ fgCONTROLS *pCtls; - x_ini = ctrl_surf->x_pos; - y_ini = ctrl_surf->y_pos; + x_ini = ctrl_surf->scrn_pos.x; + y_ini = ctrl_surf->scrn_pos.y; x_end = x_ini + 150; y_end = y_ini + 60; @@ -872,12 +880,12 @@ static void drawlabel( HUD_label *label ) } 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); } else { 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); } } @@ -909,40 +917,41 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft ) // For now lets just hardcode the hud here. // In the future, hud information has to come from the same place // aircraft information came from. - + fgHUDSetTimeMode( hud, NIGHT ); - fgHUDSetBrightness( hud, BRT_LIGHT ); - - // Small, original HUD configuration - // fgHUDAddHorizon( hud, 590, 50, 40, 5, 10, get_roll, get_sideslip ); - // fgHUDAddLadder ( hud, 330, 190, 90, 180, 70, 10, - // NONE, 45, get_roll, get_pitch ); - // fgHUDAddScale ( hud, VERTICAL, LIMIT, 220, 100, 280, 5, 10, - // LEFT, 0, 100, 50, get_speed ); - // fgHUDAddScale ( hud, VERTICAL, NOLIMIT, 440, 100, 280, 1, 5, RIGHT, - // -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, + fgHUDSetBrightness( hud, BRT_LIGHT ); + + // TBI + fgHUDAddHorizon( hud, 330, 100, 40, 5, 10, get_roll, get_sideslip ); + + fgHUDAddLadder ( hud, 330, 285, 120, 180, 70, 10, NONE, 45, get_roll, get_pitch ); - fgHUDAddScale ( hud, VERTICAL, LIMIT, 200, 180, 380, 5, 10, - LEFT, 0, 100, 50, get_speed ); - fgHUDAddScale ( hud, VERTICAL, NOLIMIT, 460, 180, 380, 1, 5, - RIGHT, -40, 50, 25, get_aoa ); - fgHUDAddScale ( hud, HORIZONTAL, NOLIMIT, 380, 200, 460, 5, 10, - TOP, 0, 50, 50, get_heading ); - fgHUDAddLabel ( hud, 160, 165, SMALL, NOBLINK, - RIGHT_JUST, NULL, " Kts", "%5.0f", get_speed ); - fgHUDAddLabel ( hud, 160, 153, SMALL, NOBLINK, - RIGHT_JUST, NULL, " m", "%5.0f", get_altitude ); + // KIAS + fgHUDAddScale ( hud, VERTICAL, LIMIT, 200, 180, 380, 5, 10, + LEFT, 0, 100, 50, 0, get_speed ); + // Angle of Attack + fgHUDAddScale ( hud, HORIZONTAL, NOLIMIT, 180, 250, 410, 1, 5, + BOTTOM, -40, 50, 21, 0, get_aoa ); + // GYRO COMPASS + fgHUDAddScale ( hud, HORIZONTAL, NOLIMIT, 380, 200, 460, 5, 10, + TOP, 0, 50, 50, 360, get_heading ); + // 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 ); // fgHUDAddControl( hud, HORIZONTAL, 50, 25, get_aileronval ); // was 10, 10 @@ -952,6 +961,7 @@ Hptr fgHUDInit( fgAIRCRAFT *current_aircraft ) return( hud ); } + // add_instrument // // 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 // list. -Hptr fgHUDAddHorizon( Hptr hud, \ - int x_pos, \ - int y_pos, \ - int length, \ - int hole_len, \ +Hptr fgHUDAddHorizon( Hptr hud, \ + int x_pos, \ + int y_pos, \ + int length, \ + int hole_len, \ int tee_height,\ - double (*load_roll)(),\ + double (*load_roll)(), double (*load_sideslip)() ) { HUD_horizon *phorizon; @@ -1001,15 +1011,15 @@ Hptr fgHUDAddHorizon( Hptr hud, \ return( NULL ); } - phorizon->x_pos = x_pos; - phorizon->y_pos = y_pos; - phorizon->scr_width = length; + phorizon->scrn_pos.x = x_pos; + phorizon->scrn_pos.y = y_pos; + phorizon->scr_width = length | 1; phorizon->scr_hole = hole_len; phorizon->tee_height = tee_height; phorizon->load_roll = load_roll; phorizon->load_sideslip = load_sideslip; // Install the horizon in the parent. - pinstrument->instr = phorizon; + pinstrument->instr = phorizon; // Install the instrument into hud. add_instrument( hud, pinstrument); @@ -1033,6 +1043,7 @@ Hptr fgHUDAddScale( Hptr hud, \ int min_value, \ int max_value, \ int width_units, \ + int modulus, \ double (*load_value)() ) { HUD_scale *pscale; @@ -1053,18 +1064,48 @@ Hptr fgHUDAddScale( Hptr hud, \ if( pscale == NULL ) { return( NULL ); } - pscale->type = type; - pscale->sub_type = sub_type; - pscale->scr_pos = scr_pos; - pscale->scr_min = scr_min; - pscale->scr_max = scr_max; - pscale->div_min = div_min; - pscale->div_max = div_max; - pscale->orientation = orientation; - pscale->minimum_value = min_value; - pscale->maximum_value = max_value; - pscale->width_units = width_units; - pscale->load_value = load_value; + + pscale->type = type; + pscale->sub_type = sub_type; + pscale->div_min = div_min; + pscale->div_max = div_max; + pscale->orientation = orientation; + pscale->minimum_value = min_value; + pscale->maximum_value = max_value; + pscale->modulo = modulus; + 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 pinstrument->instr = pscale; // Install the instrument into hud. @@ -1106,8 +1147,8 @@ Hptr fgHUDAddLabel( Hptr hud, \ return NULL; } - plabel->x_pos = x_pos; - plabel->y_pos = y_pos; + plabel->scrn_pos.x = x_pos; + plabel->scrn_pos.y = y_pos; plabel->size = size; plabel->blink = blink; plabel->justify = justify; @@ -1158,8 +1199,8 @@ Hptr fgHUDAddLadder( Hptr hud, \ return( NULL ); pladder->type = 0; // Not used. - pladder->x_pos = x_pos; - pladder->y_pos = y_pos; + pladder->scrn_pos.x = x_pos; + pladder->scrn_pos.y = y_pos; pladder->scr_width = scr_width; pladder->scr_height = scr_height; pladder->scr_hole = hole_len; @@ -1208,8 +1249,8 @@ Hptr fgHUDAddControlSurfaces( Hptr hud, return( NULL ); } - pcontrol_surfaces->x_pos = x_pos; - pcontrol_surfaces->y_pos = y_pos; + pcontrol_surfaces->scrn_pos.x = x_pos; + pcontrol_surfaces->scrn_pos.y = y_pos; pcontrol_surfaces->load_value = load_value; pinstrument->instr = pcontrol_surfaces; @@ -1253,8 +1294,8 @@ Hptr fgHUDAddControl( Hptr hud, \ if( !(pcontrol == NULL) ) { return( NULL ); } - pcontrol->ctrl_x = ctrl_x; - pcontrol->ctrl_y = ctrl_y; + pcontrol->scrn_pos.x = ctrl_x; + pcontrol->scrn_pos.y = ctrl_y; pcontrol->ctrl_length = ctrl_length; pcontrol->orientation = orientation; pcontrol->alignment = alignment; @@ -1330,7 +1371,9 @@ void fgUpdateHUD( Hptr hud ) { glDisable(GL_LIGHTING); 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) { switch (hud->brightness) { case BRT_LIGHT: @@ -1355,6 +1398,9 @@ void fgUpdateHUD( Hptr hud ) { 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", hud->code, hud->status ); @@ -1417,9 +1463,12 @@ void fgHUDSetBrightness( Hptr hud, int brightness ) } /* $Log$ -/* Revision 1.17 1998/02/20 00:16:21 curt -/* Thursday's tweaks. +/* Revision 1.18 1998/02/21 14:53:10 curt +/* 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 * Incorporated some HUD tweaks from Michelle America. * Tweaked the sky's sunset/rise colors. diff --git a/Cockpit/hud.h b/Cockpit/hud.h index dec96fd9a..5587cfbd6 100644 --- a/Cockpit/hud.h +++ b/Cockpit/hud.h @@ -27,7 +27,6 @@ #ifndef _HUD_H #define _HUD_H - #include #include #include @@ -125,38 +124,61 @@ enum VIEW_MODES { HUD_VIEW, PANEL_VIEW, CHASE_VIEW, TOWER_VIEW }; // Night_Day(); // Illumination changes appearance/bitmaps. // +// CLO 2/21/98 - added to fix compile error typedef struct { - int type; - int sub_type; - int scr_pos; - int scr_min; - int scr_max; - int div_min; - int div_max; - int orientation; - int minimum_value; - int maximum_value; - int width_units; + int x; + int y; +} POINT; + +// CLO 2/21/98 - added to fix compile error +typedef struct { + int left; + int right; + int top; + int bottom; +} 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 ); + + // 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; typedef struct { int type; - int scr_pos; - int scr_min; - int scr_max; + RECT position; int div_min; int div_max; int orientation; int label_position; int width_units; + int modulo; // for compass, etc. Set to 0 for non_modulo scales. double (*load_value)( void ); }HUD_circular_scale, *pHUD_circscale; typedef struct { int type; - int x_pos; - int y_pos; + POINT scrn_pos; int scr_width; int scr_height; int scr_hole; @@ -183,8 +205,7 @@ typedef struct { typedef struct{ int type; - int x_pos; - int y_pos; + POINT scrn_pos; int scr_width; int scr_hole; int tee_height; @@ -193,14 +214,12 @@ typedef struct{ } HUD_horizon, *pHUDhorizon; typedef struct { - int x_pos; - int y_pos; + POINT scrn_pos; double(*load_value)(void); } HUD_control_surfaces, *pHUDControlSurfaces; typedef struct { - int ctrl_x; - int ctrl_y; + POINT scrn_pos; // ctrl_x, ctrl_y int ctrl_length; int orientation; int alignment; @@ -214,8 +233,7 @@ typedef struct { typedef struct { int type; - int x_pos; - int y_pos; + POINT scrn_pos; int size; int blink; int justify; @@ -228,15 +246,15 @@ typedef struct { // Removed union HUD_instr_data to evolve this to oop code. typedef enum{ HUDno_instr, - HUDscale, - HUDcirc_scale, - HUDladder, - HUDcirc_ladder, - HUDhorizon, - HUDlabel, - HUDcontrol_surfaces, - HUDcontrol - } hudinstype; + HUDscale, + HUDcirc_scale, + HUDladder, + HUDcirc_ladder, + HUDhorizon, + HUDlabel, + HUDcontrol_surfaces, + HUDcontrol + } hudinstype; typedef struct HUD_INSTR_STRUCT{ hudinstype type; @@ -282,6 +300,7 @@ Hptr fgHUDAddScale ( Hptr hud, \ int min_value, \ int max_value, \ int width_units, \ + int modulus, \ double (*load_value)( void ) ); Hptr fgHUDAddLabel ( Hptr hud, \ @@ -354,12 +373,16 @@ Hptr fgHUDAddNumDisp( Hptr hud, void fgUpdateHUD ( Hptr hud ); void fgUpdateHUD2( Hptr hud ); // Future use? + #endif // _HUD_H /* $Log$ -/* Revision 1.13 1998/02/20 00:16:22 curt -/* Thursday's tweaks. +/* Revision 1.14 1998/02/21 14:53:14 curt +/* 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 * Incorporated some HUD tweaks from Michelle America. * Tweaked the sky's sunset/rise colors. diff --git a/Main/fg_init.c b/Main/fg_init.c index 49c234001..bccae77ee 100644 --- a/Main/fg_init.c +++ b/Main/fg_init.c @@ -187,16 +187,17 @@ int fgInitSubsystems( void ) { /* FG_Runway_altitude = 5000.0; */ /* FG_Altitude = FG_Runway_altitude + 3.758099; */ - /* Initial Position: 10125 Jewell St. NE */ - /* FG_Longitude = ( -93.15 ) * DEG_TO_RAD; */ - /* FG_Latitude = ( 45.15 ) * DEG_TO_RAD; */ - /* FG_Altitude = FG_Runway_altitude + 3.758099; */ + // Initial Position: 10125 Jewell St. NE + // FG_Longitude = ( -93.15 ) * DEG_TO_RAD; + // FG_Latitude = ( 45.15 ) * DEG_TO_RAD; + // FG_Runway_altitude = 950.0; + // FG_Altitude = FG_Runway_altitude + 3.758099; // Initial Position: Somewhere near the Grand Canyon - FG_Longitude = ( -112.5 ) * DEG_TO_RAD; - FG_Latitude = ( 36.5 ) * DEG_TO_RAD; - FG_Runway_altitude = 5000.0; - FG_Altitude = FG_Runway_altitude + 3.758099; + // FG_Longitude = ( -112.5 ) * DEG_TO_RAD; + // FG_Latitude = ( 36.5 ) * DEG_TO_RAD; + // FG_Runway_altitude = 5000.0; + // FG_Altitude = FG_Runway_altitude + 3.758099; // Initial Position: (GCN) Grand Canyon Airport, AZ // FG_Longitude = ( -112.1469647 ) * DEG_TO_RAD; @@ -380,11 +381,14 @@ int fgInitSubsystems( void ) { /* $Log$ -/* 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.48 1998/02/21 14:53:15 curt +/* Added Charlie's HUD changes. /* + * 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 * Tweaks to build with SGI OpenGL (and therefor hopefully other accelerated * drivers will work.) diff --git a/Simulator/setup_env b/Simulator/setup_env new file mode 100644 index 000000000..6a78601f4 --- /dev/null +++ b/Simulator/setup_env @@ -0,0 +1,3 @@ +export FG_ROOT=~/projects/FlightGear +export FG_ROOT_SRC=${FG_ROOT}/Src +export FG_ROOT_LIB=${FG_ROOT}/Lib