]> git.mxchange.org Git - flightgear.git/blobdiff - Cockpit/cockpit.cxx
Modifications to incorporate Jon S. Berndts flight model code.
[flightgear.git] / Cockpit / cockpit.cxx
index ed3932cfc8ddada5c1c0cab87b5759382b5baf2a..e01acf7bfc8e58ee1c7faf04a4d6c1afd7e510c0 100644 (file)
@@ -40,9 +40,9 @@
 #include <string.h>
 
 #include <Aircraft/aircraft.hxx>
-#include <Debug/fg_debug.h>
+#include <Debug/logstream.hxx>
 #include <Include/fg_constants.h>
-#include <Include/general.h>
+#include <Include/general.hxx>
 #include <Main/options.hxx>
 #include <Main/views.hxx>
 #include <Math/fg_random.h>
@@ -50,7 +50,6 @@
 #include <Math/polar3d.hxx>
 #include <Scenery/scenery.hxx>
 #include <Time/fg_timer.hxx>
-#include <Weather/weather.h>
 
 #include "cockpit.hxx"
 
@@ -67,170 +66,118 @@ static pCockpit ac_cockpit;
 
 double get_latitude( void )
 {
-       fgFLIGHT *f;
-       f = current_aircraft.flight;
-
-//     return( toDM(FG_Latitude * RAD_TO_DEG) );
-       return((double)((int)( FG_Latitude * RAD_TO_DEG)) );
+    return((double)((int)( current_aircraft.fdm_state->get_Latitude() 
+                          * RAD_TO_DEG)) );
 }
+
 double get_lat_min( void )
 {
-       fgFLIGHT *f;
-       double      a, d;
-
-       f = current_aircraft.flight;
-       
-       a = FG_Latitude * RAD_TO_DEG;   
-       if (a < 0.0) {
-               a = -a;
-       }
-       d = (double) ( (int) a);
-       return( (a - d) * 60.0);
-}
+    double a, d;
 
+    a = current_aircraft.fdm_state->get_Latitude() * RAD_TO_DEG;       
+    if (a < 0.0) {
+       a = -a;
+    }
+    d = (double) ( (int) a);
+    return( (a - d) * 60.0);
+}
 
 double get_longitude( void )
 {
-       fgFLIGHT *f;
-       f = current_aircraft.flight;
-
-//     return( toDM(FG_Longitude * RAD_TO_DEG) );
-       return((double)((int) (FG_Longitude * RAD_TO_DEG)) );
+    return( (double)((int) (current_aircraft.fdm_state->get_Longitude()
+                           * RAD_TO_DEG)) );
 }
+
 double get_long_min( void )
 {
-       fgFLIGHT *f;
-       double  a, d;
-
-       f = current_aircraft.flight;
-       
-       a = FG_Longitude * RAD_TO_DEG;  
-       if (a < 0.0) {
-               a = -a;
-       }
-       d = (double) ( (int) a);
-       return( (a - d) * 60.0);
+    double  a, d;
+    
+    a = current_aircraft.fdm_state->get_Longitude() * RAD_TO_DEG;      
+    if (a < 0.0) {
+       a = -a;
+    }
+    d = (double) ( (int) a);
+    return( (a - d) * 60.0);
 }
 
 double get_throttleval( void )
 {
-       fgCONTROLS *pcontrols;
-
-  pcontrols = current_aircraft.controls;
-  return pcontrols->throttle[0];     // Hack limiting to one engine
+    return controls.get_throttle( 0 );     // Hack limiting to one engine
 }
 
 double get_aileronval( void )
 {
-       fgCONTROLS *pcontrols;
-
-  pcontrols = current_aircraft.controls;
-  return pcontrols->aileron;
+    return controls.get_aileron();
 }
 
 double get_elevatorval( void )
 {
-       fgCONTROLS *pcontrols;
-
-  pcontrols = current_aircraft.controls;
-  return pcontrols->elevator;
+    return controls.get_elevator();
 }
 
 double get_elev_trimval( void )
 {
-       fgCONTROLS *pcontrols;
-
-  pcontrols = current_aircraft.controls;
-  return pcontrols->elevator_trim;
+    return controls.get_elevator_trim();
 }
 
 double get_rudderval( void )
 {
-       fgCONTROLS *pcontrols;
-
-  pcontrols = current_aircraft.controls;
-  return pcontrols->rudder;
+    return controls.get_rudder();
 }
 
 double get_speed( void )
 {
-       fgFLIGHT *f;
-
-       f = current_aircraft.flight;
-       return( FG_V_equiv_kts );    // Make an explicit function call.
+    return( current_aircraft.fdm_state->get_V_equiv_kts() );
 }
 
 double get_aoa( void )
 {
-       fgFLIGHT *f;
-              
-       f = current_aircraft.flight;
-       return( FG_Gamma_vert_rad * RAD_TO_DEG );
+    return( current_aircraft.fdm_state->get_Alpha() * RAD_TO_DEG );
 }
 
 double get_roll( void )
 {
-       fgFLIGHT *f;
-
-       f = current_aircraft.flight;
-       return( FG_Phi );
+    return( current_aircraft.fdm_state->get_Phi() );
 }
 
 double get_pitch( void )
 {
-       fgFLIGHT *f;
-              
-       f = current_aircraft.flight;
-       return( FG_Theta );
+    return( current_aircraft.fdm_state->get_Theta() );
 }
 
 double get_heading( void )
 {
-       fgFLIGHT *f;
-
-       f = current_aircraft.flight;
-       return( FG_Psi * RAD_TO_DEG );
+    return( current_aircraft.fdm_state->get_Psi() * RAD_TO_DEG );
 }
 
 double get_altitude( void )
 {
-       fgFLIGHT *f;
-       // double rough_elev;
-
-       f = current_aircraft.flight;
-       // rough_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
-       //                                 FG_Latitude  * RAD_TO_ARCSEC);
-
-       return( FG_Altitude * FEET_TO_METER /* -rough_elev */ );
+    if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
+       return current_aircraft.fdm_state->get_Altitude();
+    } else {
+       return current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER;
+    }
 }
 
 double get_agl( void )
 {
-        fgFLIGHT *f;
-        double agl;
-
-        f = current_aircraft.flight;
-        agl = FG_Altitude * FEET_TO_METER - scenery.cur_elev;
-
-        return( agl );
+    if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
+       return current_aircraft.fdm_state->get_Altitude()
+           - scenery.cur_elev * METER_TO_FEET;
+    } else {
+       return current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
+           - scenery.cur_elev;
+    }
 }
 
 double get_sideslip( void )
 {
-        fgFLIGHT *f;
-        
-        f = current_aircraft.flight;
-        
-        return( FG_Beta );
+    return( current_aircraft.fdm_state->get_Beta() );
 }
 
 double get_frame_rate( void )
 {
-    fgGENERAL *pgeneral;
-    pgeneral = &general;                     
-    return pgeneral->frame_rate;
+    return (double) general.get_frame_rate();
 }
 
 double get_fov( void )
@@ -240,31 +187,28 @@ double get_fov( void )
 
 double get_vfc_ratio( void )
 {
-    fgVIEW *pview;
-    pview = &current_view;
-    return pview->vfc_ratio;
+    return current_view.get_vfc_ratio();
 }
 
 double get_vfc_tris_drawn   ( void )
 {
-    return current_view.tris_rendered;
+    return current_view.get_tris_rendered();
 }
 
 double get_climb_rate( void )
 {
-       fgFLIGHT *f;
-
-       f = current_aircraft.flight;
-
-       return( FG_Climb_Rate * FEET_TO_METER * 60.0 );
+    if ( current_options.get_units() == fgOPTIONS::FG_UNITS_FEET ) {
+       return current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
+    } else {
+       return current_aircraft.fdm_state->get_Climb_Rate()
+           * FEET_TO_METER * 60.0;
+    }
 }
 
 
 bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
 {
-    fgPrintf( FG_COCKPIT, FG_INFO, "Initializing cockpit subsystem\n");
+    FG_LOG( FG_COCKPIT, FG_INFO, "Initializing cockpit subsystem" );
 
     // cockpit->code = 1;      /* It will be aircraft dependent */
     // cockpit->status = 0;
@@ -285,22 +229,18 @@ bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
        fgPanelInit();
     }
 
-    fgPrintf( FG_COCKPIT, FG_INFO,
-             "  Code %d  Status %d\n",
-             ac_cockpit->code(), ac_cockpit->status() );
+    FG_LOG( FG_COCKPIT, FG_INFO,
+           "  Code " << ac_cockpit->code() << " Status " 
+           << ac_cockpit->status() );
     
     return true;
 }
 
 
 void fgCockpitUpdate( void ) {
-    fgVIEW *pview;
-
-    pview = &current_view;
-
-    fgPrintf( FG_COCKPIT, FG_DEBUG,
-             "Cockpit: code %d   status %d\n",
-             ac_cockpit->code(), ac_cockpit->status() );
+    FG_LOG( FG_COCKPIT, FG_DEBUG,
+           "Cockpit: code " << ac_cockpit->code() << " status " 
+           << ac_cockpit->status() );
 
     if ( current_options.get_hud_status() ) {
        // This will check the global hud linked list pointer.
@@ -309,13 +249,58 @@ void fgCockpitUpdate( void ) {
     }
 
     if ( current_options.get_panel_status() && 
-        (fabs(pview->view_offset) < 0.2) ) {
+        (fabs( current_view.get_view_offset() ) < 0.2) )
+    {
+       xglViewport( 0, 0, 
+                    current_view.get_winWidth(), 
+                    current_view.get_winHeight() );
        fgPanelUpdate();
     }
 }
 
 
 // $Log$
+// Revision 1.30  1999/02/05 21:28:57  curt
+// Modifications to incorporate Jon S. Berndts flight model code.
+//
+// Revision 1.29  1999/01/08 19:27:34  curt
+// Fixed AOA reading on HUD.
+// Continued work on time jitter compensation.
+//
+// Revision 1.28  1999/01/07 20:24:17  curt
+// Update fgGENERAL to FGGeneral.
+//
+// Revision 1.27  1998/12/18 23:35:09  curt
+// Converted to a simpler frame rate counting method.
+//
+// Revision 1.26  1998/12/09 18:50:19  curt
+// Converted "class fgVIEW" to "class FGView" and updated to make data
+// members private and make required accessor functions.
+//
+// Revision 1.25  1998/12/05 15:54:07  curt
+// Renamed class fgFLIGHT to class FGState as per request by JSB.
+//
+// Revision 1.24  1998/12/03 01:16:00  curt
+// Converted fgFLIGHT to a class.
+//
+// Revision 1.23  1998/11/09 23:38:50  curt
+// Panel updates from Friedemann.
+//
+// Revision 1.22  1998/11/06 21:17:45  curt
+// Converted to new logstream debugging facility.  This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUG flag.
+//
+// Revision 1.21  1998/11/02 23:04:02  curt
+// HUD units now display in feet by default with meters being a command line
+// option.
+//
+// Revision 1.20  1998/10/25 14:08:40  curt
+// Turned "struct fgCONTROLS" into a class, with inlined accessor functions.
+//
+// Revision 1.19  1998/10/17 01:33:56  curt
+// C++ ifying ...
+//
 // Revision 1.18  1998/10/16 23:27:23  curt
 // C++-ifying.
 //