]> git.mxchange.org Git - flightgear.git/commitdiff
The following changes were made to flightgear-0.7.5 code to implement the follow
authorcurt <curt>
Thu, 19 Oct 2000 19:46:13 +0000 (19:46 +0000)
committercurt <curt>
Thu, 19 Oct 2000 19:46:13 +0000 (19:46 +0000)
ing features:

a) ADA Flight model - ADA.cxx, ADA.hxx, flight.hxx
b) Fighter a/c HUD       - flight.hxx, hud.hxx, hud.cxx, cockpit.cxx, hud_ladr.c
xx, hud_card.cxx
c) 3-window display      - options.hxx, options.cxx, viewer.cxx
d) Moving objects (ship) - main.cxx
e) Patches               - main.cxx

ADA.cxx, ADA.hxx
--------------------------
Interface to the external ADA flight dynamics package.

flight.hxx
----------
Included prototypes for accepting additional data fron the External flight
model for fighter aircraft HUD

Hud.hxx
-------
Included prototypes for accepting additional data for fighter HUD from Exernal F
light model.
Defined FIGHTER_HUD pre-processor directive to enable compilation of fighter hud
 code.

hud.cxx, cockpit.cxx, hud_ladr.cxx, hud_card.cxx
---------------------------------------
Included code to initialise additional reticles/text for fighter HUD which is co
nditionally
compiled if FIGHTER_HUD is defined.

options.hxx
-----------
Added window_offset, and function to retrieve its value for 3 windows

options.cxx
-----------
Changed few options to suit ADA/CEF projection system/screens and checks for win
dow offset.

views.cxx
---------
Added code to retrieve view offset for window.

Main.cxx
--------
Added code to load and move an aircraft carrier.
Patch to enable clouds from command line until Curtis fixes it. By default cloud
s are disabled.

31 files changed:
FlightGear.dsp
src/Cockpit/cockpit.cxx
src/Cockpit/hud.cxx
src/Cockpit/hud.hxx
src/Cockpit/hud_card.cxx
src/Cockpit/hud_ladr.cxx
src/Cockpit/panel.cxx
src/FDM/ADA.cxx [new file with mode: 0644]
src/FDM/ADA.hxx [new file with mode: 0644]
src/FDM/Makefile.am
src/FDM/flight.hxx
src/GUI/gui.cxx
src/Main/Makefile.am
src/Main/fg_init.cxx
src/Main/globals.hxx
src/Main/keyboard.cxx
src/Main/main.cxx
src/Main/options.cxx
src/Main/options.hxx
src/Main/splash.cxx
src/Main/viewer.cxx [new file with mode: 0644]
src/Main/viewer.hxx [new file with mode: 0644]
src/Main/views.cxx
src/Main/views.hxx
src/NetworkOLK/net_send.cxx
src/Objects/matlib.cxx
src/Scenery/tilecache.cxx
src/Scenery/tilemgr.cxx
src/Time/light.cxx
src/Time/moonpos.cxx
src/Time/sunpos.cxx

index 639bdec7668775f2de7276e6968d8ea0fc99b6ca..e658ec97397071984e098859c00c256d4049698c 100644 (file)
@@ -2238,7 +2238,7 @@ SOURCE=.\src\Main\splash.cxx
 # End Source File\r
 # Begin Source File\r
 \r
-SOURCE=.\src\Main\views.cxx\r
+SOURCE=.\src\Main\viewer.cxx\r
 \r
 !IF  "$(CFG)" == "FlightGear - Win32 Release"\r
 \r
index c26c65e867f71cfd324afbe839729c8ec75e9c47..3a88b6a5dc7d02e227bb620a57172bc89a336b33 100644 (file)
@@ -43,9 +43,9 @@
 
 #include <Aircraft/aircraft.hxx>
 #include <Include/general.hxx>
+#include <FDM/ADA.hxx>
 #include <Main/globals.hxx>
 #include <Main/options.hxx>
-#include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
 #include <Time/fg_timer.hxx>
 #include <GUI/gui.h>
@@ -275,20 +275,245 @@ float get_climb_rate( void )
 
 float get_view_direction( void )
 {
-    double view;
-    view = FG_2PI - current_view.get_view_offset();
-    view = ( current_aircraft.fdm_state->get_Psi() + view) * RAD_TO_DEG;
+    double view_off = FG_2PI - globals->get_current_view()->get_view_offset();
+    double view = ( current_aircraft.fdm_state->get_Psi() + view_off)
+       * RAD_TO_DEG;
     
     if(view > 360.)
         view -= 360.;
     else if(view<0.)
         view += 360.;
     
-    float fview = view;
-    return( fview );
+    return view;
 }
 
+// $$$ begin - added, VS Renganathan 13 Oct 2K
+#ifdef FIGHTER_HUD
+float get_Vx   ( void )
+{
+    float Vxx = current_aircraft.fdm_state->get_V_north_rel_ground();
+    return (Vxx);
+}
+
+float get_Vy   ( void )
+{
+    float Vyy = current_aircraft.fdm_state->get_V_east_rel_ground();
+    return (Vyy);
+}
+
+float get_Vz   ( void )
+{
+    float Vzz = current_aircraft.fdm_state->get_V_down_rel_ground();
+    return (Vzz);
+}
+
+float get_Ax   ( void )
+{
+    float Ax = current_aircraft.fdm_state->get_V_dot_north();
+    return (Ax);
+}
+
+float get_Ay   ( void )
+{
+    float Ay = current_aircraft.fdm_state->get_V_dot_east();
+    return (Ay);
+}
+
+float get_Az   ( void )
+{
+    float Az = current_aircraft.fdm_state->get_V_dot_down();
+    return (Az);
+}
+
+float get_anzg   ( void )
+{
+    float anzg = current_aircraft.fdm_state->get_N_Z_cg();
+    return (anzg);
+}
+
+int get_iaux1 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux1();
+}
+
+int get_iaux2 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux2();
+}
+
+int get_iaux3 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux3();
+}
+
+int get_iaux4 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux4();
+}
+
+int get_iaux5 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux5();
+}
+
+int get_iaux6 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux6();
+}
+
+int get_iaux7 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux7();
+}
+
+int get_iaux8 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux8();
+}
+
+int get_iaux9 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux9();
+}
+
+int get_iaux10 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux10();
+}
+
+int get_iaux11 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_iaux11();
+}
+
+int get_iaux12 (void)
+{
+     FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+     return fdm->get_iaux12();
+}
+
+float get_aux1 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux1();
+}
+
+float get_aux2 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux2();
+}
+
+float get_aux3 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux3();
+}
+
+float get_aux4 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux4();
+}
+
+float get_aux5 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux5();
+}
+
+float get_aux6 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux6();
+}
+
+float get_aux7 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux7();
+}
+
+float get_aux8 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux8();
+}
+
+float get_aux9 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux9();
+}
+
+float get_aux10 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux10();
+}
+
+float get_aux11 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux11();
+}
+
+float get_aux12 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux12();
+}
+
+float get_aux13 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux13();
+}
+
+float get_aux14 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux14();
+}
+
+float get_aux15 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux15();
+}
+
+float get_aux16 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux16();
+}
+
+float get_aux17 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux17();
+}
+
+float get_aux18 (void)
+{
+    FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
+    return fdm->get_aux18();
+}
+#endif
+// $$$ end - added, VS Renganathan 13 Oct 2K
+
+
 #ifdef NOT_USED
 /****************************************************************************/
 /* Convert degrees to dd mm'ss.s" (DMS-Format)                              */
@@ -475,8 +700,8 @@ void fgCockpitUpdate( void ) {
         "Cockpit: code " << ac_cockpit->code() << " status " 
         << ac_cockpit->status() );
 
-       int iwidth   = current_view.get_winWidth();
-       int iheight  = current_view.get_winHeight();
+       int iwidth   = globals->get_current_view()->get_winWidth();
+       int iheight  = globals->get_current_view()->get_winHeight();
        float width  = iwidth;
        float height = iheight;
 
index 8b233493578f1a24e726f3a6bbf77190a6634981..79dc7593af9cf0c4e39bbe476c32cd0726e42f77 100644 (file)
@@ -189,22 +189,41 @@ int getStringWidth ( char *str )
 
 int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
 {
-  instr_item *HIptr;
-//  int index;
-
-//  int off = 50;
-  int min_x = 25; //off/2;
-  int max_x = 615; //640-(off/2);
-//  int min_y = off;
-  int max_y = 430; //480-off;
-  int cen_x = 320;
-  int cen_y = 240;
-  unsigned int text_h = 10;
-  unsigned int ladr_w2 = 60;
-  int ladr_h2 = 90;
-  int ladr_t = 35;
-  int compass_w = 200;
-  int gap = 10;
+    instr_item *HIptr;
+    //  int index;
+
+    // $$$ begin - added VS Renganathan
+#ifdef FIGHTER_HUD
+    //  int off = 400;
+    int min_x = 200; 
+    int max_x = 440; 
+    //  int min_y = 100;
+    int max_y = 380; 
+    int cen_x = 320;
+    int cen_y = 240;
+    unsigned int text_h = 10;
+    unsigned int ladr_w2 = 60;
+    int ladr_h2 = 90;
+    int ladr_t = 35;
+    int compass_w = 120;
+    int gap = 10;
+#else
+    // $$$ end - added VS Renganathan
+
+    //  int off = 50;
+    int min_x = 25; //off/2;
+    int max_x = 615; //640-(off/2);
+    //  int min_y = off;
+    int max_y = 430; //480-off;
+    int cen_x = 320;
+    int cen_y = 240;
+    unsigned int text_h = 10;
+    unsigned int ladr_w2 = 60;
+    int ladr_h2 = 90;
+    int ladr_t = 35;
+    int compass_w = 200;
+    int gap = 10;
+#endif
 
 //  int font_size = current_options.get_xsize() / 60;
   int font_size = (current_options.get_xsize() > 1000) ? LARGE : SMALL;
@@ -233,6 +252,357 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
 //  int x = 290; /*cen_x-30*/
 //  int y = 45;  /*off-5*/
 //  HIptr = (instr_item *) new fgTBI_instr( x, y, ladr_w2, text_h );
+// $$$ begin - added, VS Renganathan 13 Oct 2K
+#ifdef FIGHTER_HUD
+//      case 1:     // Artificial Horizon
+  HIptr = (instr_item *) new HudLadder( cen_x-ladr_w2, cen_y-ladr_h2,
+                                        2*ladr_w2, 2*ladr_h2 );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+//      case 4:    // GYRO COMPASS
+  HIptr = (instr_item *) new hud_card( cen_x-(compass_w/2),
+                                       cen_y+8.0,  //CENTER_DIAMOND_SIZE
+                                       compass_w,
+                                       28,
+                                       get_heading,
+                                       HUDS_TOP,
+                                       360, 0,
+                                       1.0,
+                                       10,   1,
+                                       360,
+                                       0,
+                                       25,
+                                       true);
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+//      case 10:    // Digital KIAS
+        HIptr = (instr_item *) new instr_label ( cen_x-190,
+                                                 cen_y+25,
+                                                  40,
+                                                  30,
+                                                 get_speed,
+                                                 "%5.0f",
+                                                 NULL,
+                                                 " ",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 RIGHT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+// Mach no
+        HIptr = (instr_item *) new instr_label ( cen_x-180,
+                                                 cen_y+5,
+                                                  40,
+                                                  30,
+                                                 get_mach,
+                                                 "%5.2f",
+                                                 NULL,
+                                                 " ",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 RIGHT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+// Pressure Altitude
+        HIptr = (instr_item *) new instr_label ( cen_x+110,
+                                                 cen_y+25,
+                                                  40,
+                                                  30,
+                                                 get_altitude,
+                                                 "%5.0f",
+                                                 NULL,
+                                                 " ",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+// Radio Altitude
+        HIptr = (instr_item *) new instr_label ( cen_x+110,
+                                                 cen_y+5,
+                                                  40,
+                                                  30,
+                                                 get_agl,
+                                                 "%5.0f",
+                                                 NULL,
+                                                 " R",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+//      case 2:    // AOA
+  HIptr = (instr_item *) new hud_card( cen_x-145.0, //min_x +18,
+                                       cen_y-190,
+                                       28,
+                                       120,
+                                       get_aoa,
+                                       HUDS_LEFT | HUDS_VERT,
+//                                       HUDS_RIGHT | HUDS_VERT,                                     
+                                       30.0, -15.0,
+                                       1.0,
+                                       10,  2,
+                                       0,
+                                       0,
+                                       60.0,
+                                       true);
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+//      case 2:    // normal acceleration at cg, g's
+  HIptr = (instr_item *) new hud_card( cen_x-185, //min_x +18,
+                                       cen_y-220,
+                                       18,
+                                       130,
+                                       get_anzg,
+                                       HUDS_LEFT | HUDS_VERT,
+//                                       HUDS_RIGHT | HUDS_VERT,                                     
+                                       10.0, -5.0,
+                                       1.0,
+                                       2,  1,
+                                       0,
+                                       0,
+                                       20.0,
+                                       true);
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+//      case 2:    // VSI
+  HIptr = (instr_item *) new hud_card( (2*cen_x)-195.0, //min_x +18,
+                                       cen_y-190,
+                                       28,
+                                       120,
+                                       get_climb_rate, //fix
+//                                       HUDS_LEFT | HUDS_VERT,
+                                       HUDS_RIGHT | HUDS_VERT,                                     
+                                       500.0, -500.0,
+                                       1.0,
+                                       5,  1,
+                                       0,
+                                       0,
+                                       15.0,
+                                       true);
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+
+// Aux parameter 16 - xposn
+        HIptr = (instr_item *) new instr_label ( cen_x+170,
+                                                 cen_y+200,
+                                                  40,
+                                                  30,
+                                                 get_aux16,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " pstick",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+  
+
+// Aux parameter 17 - xposn
+        HIptr = (instr_item *) new instr_label ( cen_x+170,
+                                                 cen_y+190,
+                                                  40,
+                                                  30,
+                                                 get_aux17,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " rstick",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+  
+  
+  
+  
+  
+  
+  
+// Aux parameter 1 - xposn
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+200,
+                                                  40,
+                                                  30,
+                                                 get_aux1,
+                                                 "%5.0f",
+                                                 NULL,
+                                                 " m",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 2 - pla
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+190,
+                                                  40,
+                                                  30,
+                                                 get_aux9,
+                                                 "%5.0f",
+                                                 NULL,
+                                                 " pla",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 3 - xtd
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+170,
+                                                  40,
+                                                  30,
+                                                 get_aux11,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " xtd",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 4 - ytd
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+160,
+                                                  40,
+                                                  30,
+                                                 get_aux12,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " ytd",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 5 - nztd
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+150,
+                                                  40,
+                                                  30,
+                                                 get_aux10,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " nztd",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 6 - vvtd
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+140,
+                                                  40,
+                                                  30,
+                                                 get_aux13,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " vvtd",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 7 - vtd
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+130,
+                                                  40,
+                                                  30,
+                                                 get_aux14,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " vtd",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 8 - alftd
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+120,
+                                                  40,
+                                                  30,
+                                                 get_aux15,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " alftd",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 9 - fnr
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+100,
+                                                  40,
+                                                  30,
+                                                 get_aux8,
+                                                 "%5.1f",
+                                                 NULL,
+                                                 " fnose",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+
+// Aux parameter 10 - Ax
+        HIptr = (instr_item *) new instr_label ( cen_x+240,
+                                                 cen_y+90,
+                                                  40,
+                                                  30,
+                                                 get_Ax,
+                                                 "%5.2f",
+                                                 NULL,
+                                                 " Ax",
+                                                 1.0,
+                                                 HUDS_TOP,
+                                                 LEFT_JUST,
+                                                 font_size,
+                                                 0,
+                                                 TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+#else
+// $$$ end - added , VS Renganathan 13 Oct 2K
+
   HIptr = (instr_item *) new fgTBI_instr( 290, 45, 60, 10 );  
   HUD_deque.insert( HUD_deque.begin(), HIptr);
 
@@ -376,6 +746,7 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
                                            0.0
                                           );
   HUD_deque.insert( HUD_deque.begin(), HIptr);
+#endif
 // Remove this when below uncommented       
 //      case 10:
   HIptr = (instr_item *) new instr_label( 10,
@@ -394,7 +765,40 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
                                           TRUE );
   HUD_deque.insert( HUD_deque.begin(), HIptr);
   
-  HIptr = (instr_item *) new lat_label(  (cen_x - (compass_w/2))/2,
+// $$$ begin - added VS Renganthan 19 Oct 2K
+#ifdef FIGHTER_HUD
+  HIptr = (instr_item *) new lat_label(  70,
+                                          40,    
+                                          1,
+                                          text_h,
+                                          get_latitude,
+                                          "%s%", //"%.0f",
+                                          "", //"Lat ",
+                                          "",
+                                          1.0,
+                                          HUDS_TOP,
+                                          CENTER_JUST,
+                                          font_size,
+                                          0,
+                                          TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+    
+    HIptr = (instr_item *) new lon_label( 475,
+                                          40,
+                                          1, text_h,
+                                          get_longitude,
+                                          "%s%",//"%.0f",
+                                          "", //"Lon ", 
+                                          "",
+                                          1.0,
+                                          HUDS_TOP,
+                                          CENTER_JUST,
+                                          font_size,
+                                          0,
+                                          TRUE );
+  HUD_deque.insert( HUD_deque.begin(), HIptr);
+#else
+    HIptr = (instr_item *) new lat_label(  (cen_x - (compass_w/2))/2,
                                           max_y,    
                                           1,
                                           text_h,
@@ -424,7 +828,8 @@ int fgHUDInit( fgAIRCRAFT * /* current_aircraft */ )
                                           0,
                                           TRUE );
   HUD_deque.insert( HUD_deque.begin(), HIptr);
-    
+#endif
+// $$$ end - added VS Renganthan 19 Oct 2K
 /*
 //      case 10:    // Digital KIAS
         HIptr = (instr_item *) new instr_label ( 110,
index c6d004d0218d490e12be213c25457e2c0cf18408..857b642f84cdae03acb0beb20715cff4c290cd12 100644 (file)
@@ -191,6 +191,46 @@ extern char *coord_format_lat(float);
 extern char *coord_format_lon(float);
 //extern char *coord_format_latlon(float latitude, float longitude);  // cockpit.cxx
 
+// $$$ begin - added, VS Renganathan, 13 Oct 2K
+// #define FIGHTER_HUD
+extern float get_anzg (void);
+extern float get_Vx (void);
+extern float get_Vy (void);
+extern float get_Vz (void);
+extern float get_Ax (void);
+extern float get_Ay (void);
+extern float get_Az (void);
+extern int get_iaux1 (void);
+extern int get_iaux2 (void);
+extern int get_iaux3 (void);
+extern int get_iaux4 (void);
+extern int get_iaux5 (void);
+extern int get_iaux6 (void);
+extern int get_iaux7 (void);
+extern int get_iaux8 (void);
+extern int get_iaux9 (void);
+extern int get_iaux10 (void);
+extern int get_iaux11 (void);
+extern int get_iaux12 (void);
+extern float get_aux1(void);
+extern float get_aux2(void);
+extern float get_aux3(void);
+extern float get_aux4(void);
+extern float get_aux5 (void);
+extern float get_aux6 (void);
+extern float get_aux8(void);
+extern float get_aux9(void);
+extern float get_aux10(void);
+extern float get_aux11(void);
+extern float get_aux12(void);
+extern float get_aux13(void);
+extern float get_aux14(void);
+extern float get_aux15(void);
+extern float get_aux16(void);
+extern float get_aux17(void);
+extern float get_aux18(void);
+// $$$ end - added, VS Renganathan, 13 Oct 2K
+
 extern char *get_formated_gmt_time( void );
 extern void fgHUDReshape(void);
 
index 894aaf3841e041444cd2d04366fc8949fed9ea3e..67ae34a7b14abc4cc6ba42814d4f444eaf6ff932 100644 (file)
@@ -74,6 +74,430 @@ operator = (const hud_card & rhs )
   return *this;
 }
 
+// $$$ begin - added, VS Renganathan, 13 Oct 2K
+#ifdef FIGHTER_HUD
+void hud_card ::
+draw( void ) //  (HUD_scale * pscale )
+{
+  float vmin, vmax;
+  int marker_xs;
+  int marker_xe;
+  int marker_ys;
+  int marker_ye;
+  int lenstr;
+  int height, width;
+  int i, last;
+  char TextScale[80];
+  bool condition;
+  int disp_val = 0;
+  POINT mid_scr    = get_centroid();
+  float cur_value  = get_value();
+  RECT   scrn_rect = get_location();
+  UINT options     = get_options();
+
+  height = scrn_rect.top  + scrn_rect.bottom;
+  width = scrn_rect.left + scrn_rect.right;
+
+  vmin = cur_value - half_width_units; // width units == needle travel
+  vmax = cur_value + half_width_units; // or picture unit span.
+  
+  // Draw the basic markings for the scale...
+  
+  if( huds_vert(options) ) { // Vertical scale
+//    drawOneLine( scrn_rect.left,     // Bottom tick bar
+//                 scrn_rect.top,
+//                 width,
+//                 scrn_rect.top);
+
+//    drawOneLine( scrn_rect.left,    // Top tick bar
+//                 height,
+//                 width,
+//                 height );
+      
+      marker_xs = scrn_rect.left;  // x start
+      marker_xe = width;  // x extent
+      marker_ye = height;
+
+//    glBegin(GL_LINES);
+      
+      // Bottom tick bar
+//    glVertex2f( marker_xs, scrn_rect.top);
+//    glVertex2f( marker_xe, scrn_rect.top);
+
+      // Top tick bar
+//    glVertex2f( marker_xs, marker_ye);
+//    glVertex2f( marker_xe, marker_ye );
+//    glEnd();
+
+    // We do not use else in the following so that combining the two
+    // options produces a "caged" display with double carrots. The
+    // same is done for horizontal card indicators.
+
+      if( huds_left(options) ) {    // Calculate x marker offset
+//          drawOneLine( marker_xe, scrn_rect.top,
+//                       marker_xe, marker_ye); // Cap right side
+
+        marker_xs  = marker_xe - scrn_rect.right / 3;   // Adjust tick xs
+                                                      // Indicator carrot
+//      drawOneLine( marker_xs, mid_scr.y,
+//                   marker_xe, mid_scr.y + scrn_rect.right / 6);
+//      drawOneLine( marker_xs, mid_scr.y,
+//                   marker_xe, mid_scr.y - scrn_rect.right / 6);
+
+        glBegin(GL_LINE_STRIP);
+        glVertex2f( 10+marker_xe, mid_scr.y + scrn_rect.right / 6);
+        glVertex2f( 10+marker_xs, mid_scr.y);
+        glVertex2f( 10+marker_xe, mid_scr.y - scrn_rect.right / 6);
+        glEnd();
+    }
+    if( huds_right(options) ) {  // We'll default this for now.
+//        drawOneLine( scrn_rect.left, scrn_rect.top,
+//                     scrn_rect.left, marker_ye );  // Cap left side
+
+        marker_xe = scrn_rect.left + scrn_rect.right / 3;     // Adjust tick xe
+                                                       // Indicator carrot
+//      drawOneLine( scrn_rect.left, mid_scr.y +  scrn_rect.right / 6,
+//                   marker_xe, mid_scr.y );
+//      drawOneLine( scrn_rect.left, mid_scr.y -  scrn_rect.right / 6,
+//                   marker_xe, mid_scr.y);
+        glBegin(GL_LINE_STRIP);
+        glVertex2f( -10+scrn_rect.left, mid_scr.y +  scrn_rect.right / 6);
+        glVertex2f( -10+marker_xe, mid_scr.y );
+        glVertex2f( -10+scrn_rect.left, mid_scr.y -  scrn_rect.right / 6);
+        glEnd();
+    }
+
+    // At this point marker x_start and x_end values are transposed.
+    // To keep this from confusing things they are now interchanged.
+    if(huds_both(options)) {
+      marker_ye = marker_xs;
+      marker_xs = marker_xe;
+      marker_xe = marker_ye;
+      }
+
+    // Work through from bottom to top of scale. Calculating where to put
+    // minor and major ticks.
+
+//  last = FloatToInt(vmax)+1;
+//  i = FloatToInt(vmin);
+    last = (int)vmax + 1;
+    i = (int)vmin;
+    for( ; i <last ; i++ )
+    {
+
+      condition = true;
+      if( !modulo()) {
+        if( i < min_val()) {
+          condition = false;
+          }
+        }
+
+      if( condition ) {  // Show a tick if necessary
+                         // Calculate the location of this tick
+        marker_ys = scrn_rect.top + FloatToInt(((i - vmin) * factor()/*+.5f*/));
+//        marker_ys = scrn_rect.top + (int)((i - vmin) * factor() + .5);
+        // Block calculation artifact from drawing ticks below min coordinate.
+        // Calculation here accounts for text height.
+
+        if(( marker_ys < (scrn_rect.top + 4)) |
+           ( marker_ys > (height - 4))) {
+            // Magic numbers!!!
+          continue;
+          }
+        if( div_min()) {
+//          if( (i%div_min()) == 0) {
+          if( !(i%(int)div_min())) {            
+            if((( marker_ys - 5) > scrn_rect.top ) &&
+               (( marker_ys + 5) < (height))){
+              if( huds_both(options) ) {
+                drawOneLine( scrn_rect.left, marker_ys,
+                             marker_xs,      marker_ys );
+                drawOneLine( marker_xe,      marker_ys,
+                             width,  marker_ys );
+//                glBegin(GL_LINES);
+//                glVertex2f( scrn_rect.left, marker_ys );
+//                glVertex2f( marker_xs,      marker_ys );
+//                glVertex2f( marker_xe,      marker_ys);
+//                glVertex2f( scrn_rect.left + scrn_rect.right,  marker_ys );
+//                glEnd();
+                  }
+              else {
+                if( huds_left(options) ) {
+                  drawOneLine( marker_xs + 4, marker_ys,
+                               marker_xe,     marker_ys );
+                  }
+                else {
+                  drawOneLine( marker_xs,     marker_ys,
+                               marker_xe - 4, marker_ys );
+                  }
+                }
+              }
+            }
+          }
+        if( div_max() ) {
+          if( !(i%(int)div_max()) )         
+          {
+            if(modulo()) {
+                if( disp_val < 0) {
+                    while(disp_val < 0)
+                        disp_val += modulo();
+//              } else {
+//                  disp_val = i % (int)modulo();
+                }
+                disp_val = i % (int) modulo(); // ?????????
+            } else {
+                disp_val = i;
+            }
+
+            lenstr = sprintf( TextScale, "%d",
+                              FloatToInt(disp_val * data_scaling()/*+.5*/));
+//                            (int)(disp_val  * data_scaling() +.5));
+            if(( (marker_ys - 8 ) > scrn_rect.top ) &&
+               ( (marker_ys + 8) < (height))){
+              if( huds_both(options) ) {
+//                drawOneLine( scrn_rect.left, marker_ys,
+//                             marker_xs,      marker_ys);
+//                drawOneLine( marker_xs, marker_ys,
+//                             scrn_rect.left + scrn_rect.right,
+//                             marker_ys);
+                  glBegin(GL_LINE_STRIP);
+                  glVertex2f( scrn_rect.left, marker_ys );
+                  glVertex2f( marker_xs, marker_ys);
+                  glVertex2f( width, marker_ys);
+                  glEnd();
+                  if( !huds_notext(options)) {
+                      textString ( marker_xs + 2,  marker_ys,
+                                   TextScale,  GLUT_BITMAP_8_BY_13 );
+                  }
+              }
+              else {
+                drawOneLine( marker_xs, marker_ys, marker_xe, marker_ys );
+                if( !huds_notext(options) ) {
+                  if( huds_left(options) )              {
+                      textString( marker_xs -  8 * lenstr - 2,
+                                  marker_ys - 4,
+                                  TextScale, GLUT_BITMAP_8_BY_13 );
+                    }
+                  else  {
+                      textString( marker_xe + 3 * lenstr,
+                                  marker_ys - 4,
+                                  TextScale, GLUT_BITMAP_8_BY_13 );
+                  }
+                  }
+                }
+              } // Else read oriented right
+            } // End if modulo division by major interval is zero
+          }  // End if major interval divisor non-zero
+        } // End if condition
+      } // End for range of i from vmin to vmax
+    }  // End if VERTICAL SCALE TYPE
+  else {                                // Horizontal scale by default
+// commented
+      // left tick bar
+//      drawOneLine( scrn_rect.left, scrn_rect.top,
+//                   scrn_rect.left, height);
+
+      // right tick bar
+//      drawOneLine( width, scrn_rect.top,
+//                 width,
+//                 height );
+      
+      marker_ys = scrn_rect.top;           // Starting point for
+      marker_ye = height;                  // tick y location calcs
+      marker_xe = width;
+
+//    glBegin(GL_LINES);
+      // left tick bar
+//    glVertex2f( scrn_rect.left, scrn_rect.top);
+//    glVertex2f( scrn_rect.left, marker_ye);
+
+      // right tick bar
+//    glVertex2f( marker_xe, scrn_rect.top);
+//    glVertex2f( marker_xe, marker_ye );
+//    glEnd();
+
+    if( huds_top(options) ) {
+        // Bottom box line
+// commented 
+//        drawOneLine( scrn_rect.left,
+//                     scrn_rect.top,
+//                     width,
+//                     scrn_rect.top);
+
+        // Tick point adjust
+        marker_ye  = scrn_rect.top + scrn_rect.bottom / 2;
+        
+        // Bottom arrow
+//      drawOneLine( mid_scr.x, marker_ye,
+//                   mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
+//      drawOneLine( mid_scr.x, marker_ye,
+//                   mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
+
+// commented
+//        glBegin(GL_LINE_STRIP);
+//        glVertex2f( mid_scr.x - scrn_rect.bottom / 4, scrn_rect.top);
+//        glVertex2f( mid_scr.x, marker_ye);
+//        glVertex2f( mid_scr.x + scrn_rect.bottom / 4, scrn_rect.top);
+//        glEnd();
+
+    }
+    if( huds_bottom(options) ) {
+        // Top box line
+        drawOneLine( scrn_rect.left, height,
+                     width, height);
+        // Tick point adjust
+        marker_ys = height - scrn_rect.bottom  / 2;
+        
+        // Top arrow
+//      drawOneLine( mid_scr.x + scrn_rect.bottom / 4,
+//                   scrn_rect.top + scrn_rect.bottom,
+//                   mid_scr.x, marker_ys );
+//      drawOneLine( mid_scr.x - scrn_rect.bottom / 4,
+//                   scrn_rect.top + scrn_rect.bottom,
+//                   mid_scr.x , marker_ys );
+        glBegin(GL_LINE_STRIP);
+        glVertex2f( mid_scr.x + scrn_rect.bottom / 4,
+                    height);
+        glVertex2f( mid_scr.x , marker_ys );
+        glVertex2f( mid_scr.x - scrn_rect.bottom / 4,
+                    height);
+        glEnd();
+    }
+
+//    if(( options & HUDS_BOTTOM) == HUDS_BOTTOM ) {
+//      marker_xe = marker_ys;
+//      marker_ys = marker_ye;
+//      marker_ye = marker_xe;
+//      }
+
+    // printf("vmin = %d  vmax = %d\n", (int)vmin, (int)vmax);
+
+//  last = FloatToInt(vmax)+1;
+//  i    = FloatToInt(vmin);
+    last = (int)vmax + 1;
+    i = (int)vmin;
+    for(; i <last ; i++ )      {
+//    for( i = (int)vmin; i <= (int)vmax; i++ )     {
+      // printf("<*> i = %d\n", i);
+      condition = true;
+      if( !modulo()) {
+        if( i < min_val()) {
+          condition = false;
+          }
+        }
+      // printf("<**> i = %d\n", i);
+      if( condition )        {
+//        marker_xs = scrn_rect.left + (int)((i - vmin) * factor() + .5);
+        marker_xs = scrn_rect.left + FloatToInt(((i - vmin) * factor()/*+ .5f*/));
+        if( div_min()){
+//          if( (i%(int)div_min()) == 0 ) {
+          if( !(i%(int)div_min() )) {           
+            // draw in ticks only if they aren't too close to the edge.
+            if((( marker_xs - 5) > scrn_rect.left ) &&
+               (( marker_xs + 5 )< (scrn_rect.left + scrn_rect.right))){
+
+              if( huds_both(options) ) {
+                drawOneLine( marker_xs, scrn_rect.top,
+                             marker_xs, marker_ys - 4);
+                drawOneLine( marker_xs, marker_ye + 4,
+                             marker_xs, height);
+//                glBegin(GL_LINES);
+//                glVertex2f( marker_xs, scrn_rect.top);
+//                glVertex2f( marker_xs, marker_ys - 4);
+//                glVertex2f( marker_xs, marker_ye + 4);
+//                glVertex2f( marker_xs, scrn_rect.top + scrn_rect.bottom);
+//                glEnd();
+              }
+              else {
+                if( huds_top(options)) {
+                // draw minor ticks
+                  drawOneLine( marker_xs, marker_ys,
+                               marker_xs, marker_ye - 4);
+//  patch for  angled deck heading
+                    if (i == 352) {
+                       glBegin(GL_POLYGON);
+                         glVertex2f( marker_xs, marker_ys+16);
+                         glVertex2f( marker_xs+2, marker_ys+13);
+                         glVertex2f( marker_xs, marker_ys+10);
+                         glVertex2f( marker_xs-2, marker_ys+13);
+                       glEnd();
+                    }
+                  }
+                else {
+                  drawOneLine( marker_xs, marker_ys + 4,
+                               marker_xs, marker_ye);
+                  }
+                }
+              }
+            }
+          }
+    // printf("<***> i = %d\n", i);
+        if( div_max()) {
+      // printf("i = %d\n", i);
+//          if( (i%(int)div_max())==0 ) {
+          if( !(i%(int)div_max()) ) {           
+            if(modulo()) {
+              if( disp_val < 0) {
+                  while(disp_val<0)
+                      disp_val += modulo();
+              }
+              disp_val = i % (int) modulo(); // ?????????
+            } else {
+              disp_val = i;
+            }
+        // printf("disp_val = %d\n", disp_val);
+        // printf("%d\n", (int)(disp_val  * (double)data_scaling() + 0.5));
+            lenstr = sprintf( TextScale, "%d",
+//                            (int)(disp_val  * data_scaling() +.5));
+                              FloatToInt(disp_val * data_scaling()/*+.5*/));
+            // Draw major ticks and text only if far enough from the edge.
+            if(( (marker_xs - 10)> scrn_rect.left ) &&
+               ( (marker_xs + 10) < (scrn_rect.left + scrn_rect.right))){
+              if( huds_both(options) ) {
+//                drawOneLine( marker_xs, scrn_rect.top,
+//                             marker_xs, marker_ys);
+//                drawOneLine( marker_xs, marker_ye,
+//                             marker_xs, scrn_rect.top + scrn_rect.bottom);
+                  glBegin(GL_LINE_STRIP);
+                  glVertex2f( marker_xs, scrn_rect.top);
+                  glVertex2f( marker_xs, marker_ye);
+                  glVertex2f( marker_xs, height);
+                  glEnd();
+                if( !huds_notext(options) ) {
+                  textString ( marker_xs - 4 * lenstr,
+                               marker_ys + 4,
+                               TextScale,  GLUT_BITMAP_8_BY_13 );
+                  }
+                }
+              else {
+                // draw major ticks
+                drawOneLine( marker_xs, marker_ys,
+                             marker_xs, marker_ye );
+                if( !huds_notext(options)) {
+                  if( huds_top(options) )              {
+                    textString ( marker_xs - 4 * lenstr,
+                                 height - 10,
+                                 TextScale, GLUT_BITMAP_8_BY_13 );
+                    }
+                  else  {
+                    textString( marker_xs - 4 * lenstr,
+                                scrn_rect.top,
+                                TextScale, GLUT_BITMAP_8_BY_13 );
+                    }
+                  }
+                }
+              }
+            }
+      }//if(condition)  
+    // printf("<****> i = %d\n", i);
+         } //if(divmax)
+      } //if(!modulo)
+    } //for
+} //draw
+
+#else
+//$$$ end - VS Renganathan, 13 Oct 2K
+
 void hud_card ::
 draw( void ) //  (HUD_scale * pscale )
 {
@@ -477,3 +901,4 @@ draw( void ) //  (HUD_scale * pscale )
     }
 }
 
+#endif
index 2a62b4d500e672e30423cde9a0372a18b1f236f9..300c091e407742776e8761849cc0a7990d6381c7 100644 (file)
@@ -34,7 +34,13 @@ HudLadder ::   HudLadder(  int       x,
        if( !width_units ) {
            width_units = 45;
        }
+// $$$ begin -added VS Renganthan 16 Oct 2k
+#ifdef FIGHTER_HUD
+       factor = 480.0 / 33.75;
+#else
+// $$$ begin -added VS Renganthan 16 Oct 2k
        factor = (float)get_span() / (float) width_units;
+#endif
        minimal = mini;
    }
    
@@ -72,7 +78,449 @@ HudLadder & HudLadder ::  operator = ( const HudLadder & rhs )
 //
 //  Draws a climb ladder in the center of the HUD
 //
+// $$$ begin - added VS Renganathan, 13 Oct 2K
+#ifdef FIGHTER_HUD
+void HudLadder :: draw( void )
+{
+    float  x_ini;
+    float  x_end;
+    float  y;
+    int count;
+    float cosine, sine,xvvr,yvvr,Vxx,Vyy,Vzz,up_vel,ground_vel,actslope;
+    float Axx,Ayy,Azz,total_vel,pot_slope,t1,t2,psi,alpha,pla;
+    float vel_x,vel_y,drift;
+    char     Textaux[8] ;
+
+    GLdouble eqn_top[4] = {0.0,-1.0,0.0,0.0};
+    GLdouble eqn_left[4] = {-1.0,0.0,0.0,100.0};
+    GLdouble eqn_right[4] = {1.0,0.0,0.0,100.0};
+
+    POINT  centroid    = get_centroid();
+    RECT   box         = get_location();
+
+    float   half_span  = box.right / 2.0;
+    float   roll_value = current_ch2();
+    alpha = get_aoa();
+    pla = get_throttleval();
+
+    int lgear,wown,wowm,iclaw,ihook;
+    iclaw = get_iaux1();
+    lgear = get_iaux2();
+    wown = get_iaux3();
+    wowm = get_iaux4();
+    ihook = get_iaux5();
+    
+    float pitch_value = current_ch1() * RAD_TO_DEG;
+    vmin              = pitch_value - (float)width_units;
+    vmax              = pitch_value + (float)width_units; //$$$
+
+    glPushMatrix();
+    glTranslatef( centroid.x, centroid.y, 0);
+
+//*********************************************************
+//waypoint marker computation
+    float fromwp_lat,towp_lat,fromwp_lon,towp_lon,dist,delx,dely,hyp,theta,brg;
+
+    fromwp_lon = get_longitude()*DEG_TO_RAD;
+    fromwp_lat = get_latitude()*DEG_TO_RAD;
+    towp_lon = get_aux5()*DEG_TO_RAD;
+    towp_lat = get_aux6()*DEG_TO_RAD;
+
+    dist = acos(sin(fromwp_lat)*sin(towp_lat)+cos(fromwp_lat)*cos(towp_lat)*cos(fabs(fromwp_lon-towp_lon)));
+    delx= towp_lat - fromwp_lat;
+    dely = towp_lon - fromwp_lon;
+    hyp = sqrt(pow(delx,2)+pow(dely,2));
+    if (hyp != 0) {
+       theta = asin(dely/hyp);
+    } else {
+    theta = 0.0;
+    }
+    brg = theta*RAD_TO_DEG;
+    if (brg > 360.0) brg = 0.0;
+    if (delx < 0) brg = 180 - brg;
+
+//        {Brg  = asin(cos(towp_lat)*sin(fabs(fromwp_lon-towp_lon))/ sin(dist));
+//        Brg = Brg * RAD_TO_DEG; }
+    dist = dist*RAD_TO_DEG * 60.0*1852.0; //rad->deg->nm->m
+//*********************************************************
+    // Draw the FRL spot and line
+#define FRL_DIAMOND_SIZE 2.0
+    glBegin(GL_LINE_LOOP);
+        glVertex2f( -FRL_DIAMOND_SIZE, 0.0);
+        glVertex2f(0.0, FRL_DIAMOND_SIZE);
+        glVertex2f( FRL_DIAMOND_SIZE, 0.0);
+        glVertex2f(0.0, -FRL_DIAMOND_SIZE);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(0, FRL_DIAMOND_SIZE);
+         glVertex2f(0, 8.0 );
+    glEnd();
+#undef FRL_DIAMOND_SIZE
+
+       //velocity vector reticle - computations
+       Vxx = get_Vx();
+       Vyy = get_Vy();
+       Vzz = get_Vz();
+      Axx = get_Ax();
+       Ayy = get_Ay();
+       Azz = get_Az();
+       psi = get_heading();
+
+    if (psi > 180.0) psi = psi - 360;
+
+    total_vel = sqrt(Vxx*Vxx + Vyy*Vyy + Vzz*Vzz);
+       ground_vel = sqrt(Vxx*Vxx + Vyy*Vyy);
+       up_vel = Vzz;
+
+       if (ground_vel < 2.0) {
+               if (fabs(up_vel) < 2.0) {
+                       actslope = 0.0;
+               } else {
+                       actslope = (up_vel/fabs(up_vel))*90.0;
+               }
+       } else {
+               actslope = atan(up_vel/ground_vel)*RAD_TO_DEG;
+       }
+
+    xvvr = (((atan2(Vyy,Vxx)*RAD_TO_DEG)-psi)*(640.0/45.0));
+    drift = ((atan2(Vyy,Vxx)*RAD_TO_DEG)-psi);
+    yvvr = ((actslope - pitch_value)*factor);
+    vel_y = ((actslope -pitch_value) * cos(roll_value) + drift*sin(roll_value))*factor;
+    vel_x = (-(actslope -pitch_value)*sin(roll_value) + drift*cos(roll_value))*(640/45.0);
+//      printf("%f %f %f %f\n",vel_x,vel_y,drift,psi);
+
+       // drift marker
+    glBegin(GL_LINE_STRIP);
+         glVertex2f((xvvr*25/120)-6, -4);
+         glVertex2f(xvvr*25/120, 8);
+         glVertex2f((xvvr*25/120)+6, -4);
+    glEnd();
+    
+// clip hud ladder
+    glClipPlane(GL_CLIP_PLANE0,eqn_top);
+    glEnable(GL_CLIP_PLANE0);
+    glClipPlane(GL_CLIP_PLANE1,eqn_left);
+    glEnable(GL_CLIP_PLANE1);
+    glClipPlane(GL_CLIP_PLANE2,eqn_right);
+    glEnable(GL_CLIP_PLANE2);
+
+    // alpha bracket - reqd only for landing (tied to hook)
+    if (ihook == 1) {
+    glBegin(GL_LINE_STRIP);
+        glVertex2f(vel_x-20 , vel_y-(16-alpha)*factor);
+        glVertex2f(vel_x-17, vel_y-(16-alpha)*factor);
+        glVertex2f(vel_x-17, vel_y-(14-alpha)*factor);
+        glVertex2f(vel_x-20, vel_y-(14-alpha)*factor);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+        glVertex2f(vel_x+20 , vel_y-(16-alpha)*factor);
+        glVertex2f(vel_x+17, vel_y-(16-alpha)*factor);
+        glVertex2f(vel_x+17, vel_y-(14-alpha)*factor);
+        glVertex2f(vel_x+20, vel_y-(14-alpha)*factor);
+    glEnd();
+       }
+
+       //printf("xvr=%f,yvr=%f,Vx=%f,Vy=%f,Vz=%f\n",xvvr,yvvr,Vx,Vy,Vz);
+       //printf("Ax=%f,Ay=%f,Az=%f\n",Ax,Ay,Az);
+       
+    //energy markers - compute potential slope
+       if (total_vel < 5.0) {
+               t1 = 0;
+               t2 = 0;
+       } else {
+               t1 = up_vel/total_vel;
+               t2 = asin((Vxx*Axx + Vyy*Ayy + Vzz*Azz)/(9.81*total_vel));
+       }
+       pot_slope = ((t2/3)*RAD_TO_DEG)*factor + vel_y;
+
+    //energy markers
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x-20, pot_slope-5);
+         glVertex2f(vel_x-15, pot_slope);
+         glVertex2f(vel_x-20, pot_slope+5);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x+20, pot_slope-5);
+         glVertex2f(vel_x+15, pot_slope);
+         glVertex2f(vel_x+20, pot_slope+5);
+    glEnd();
+    if (pla > (105.0/131.0)) {
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x-24, pot_slope-5);
+         glVertex2f(vel_x-19, pot_slope);
+         glVertex2f(vel_x-24, pot_slope+5);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x+24, pot_slope-5);
+         glVertex2f(vel_x+19, pot_slope);
+         glVertex2f(vel_x+24, pot_slope+5);
+    glEnd();
+    }
+// ramp reticle - for ski jump takeoff only
+    if (iclaw == 1) {
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(-15, -134);
+         glVertex2f(15, -134);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(-6, -134);
+         glVertex2f(-6, t2*RAD_TO_DEG*4.0 - 134);
+         glVertex2f(+6, t2*RAD_TO_DEG*4.0 - 134);
+         glVertex2f(6, -134);
+    glEnd();
+    glBegin(GL_LINE_LOOP);
+         glVertex2f(-6, actslope*4.0 - 134);
+         glVertex2f(0, actslope*4.0 -134 +3);
+         glVertex2f(6, actslope*4.0 - 134);
+         glVertex2f(0, actslope*4.0 -134 -3);
+    glEnd();
+    }
+
+    // Draw the locked velocity vector.
+    glBegin(GL_LINE_LOOP);
+        glVertex2f( -3.0, 0.0+vel_y);
+        glVertex2f(0.0, 6.0+vel_y);
+        glVertex2f( 3.0, 0.0+vel_y);
+        glVertex2f(0.0, -6.0+vel_y);
+    glEnd();
+    
+//  draw velocity vector
+    glBegin(GL_LINE_LOOP);  // Use polygon to approximate a circle 
+        for(count=0; count<50; count++) {             
+                       cosine = 6 * cos(count * 2 * M_PI/50.0); 
+            sine =   6 * sin(count * 2 * M_PI/50.0); 
+            glVertex2f(cosine+vel_x, sine+vel_y);
+               }     
+       glEnd(); 
+
+    //velocity vector reticle orientation lines
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x-12, vel_y);
+         glVertex2f(vel_x-6, vel_y);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x+12, vel_y);
+         glVertex2f(vel_x+6, vel_y);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x, vel_y+12);
+         glVertex2f(vel_x, vel_y+6);
+    glEnd();
+
+    if (lgear == 1) {
+// undercarriage status
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x+8, vel_y);
+         glVertex2f(vel_x+8, vel_y-4);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x-8, vel_y);
+         glVertex2f(vel_x-8, vel_y-4);
+    glEnd();
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x, vel_y-6);
+         glVertex2f(vel_x, vel_y-10);
+    glEnd();
+    }
+
+    if (ihook == 1) {
+// arrestor hook status
+    glBegin(GL_LINE_STRIP);
+         glVertex2f(vel_x-4, vel_y-8);
+         glVertex2f(vel_x, vel_y-10);
+         glVertex2f(vel_x+4, vel_y-8);
+    glEnd();
+    }
+
+       // FRL marker not rotated - this line shifted below
+    glTranslatef( vel_x, vel_y, 0);
+    glRotatef(roll_value * RAD_TO_DEG, 0.0, 0.0, 1.0);
+
+    if( div_units ) {
+  
+        char     TextLadder[8] ;
+        float    label_length ;
+        float    label_height ;
+        float    left ;
+        float    right ;
+        float    bot ;
+        float    top ;
+        float    text_offset = 4.0f ;
+        float    zero_offset = 50.0f ;
+          
+       fntFont *font      = HUDtext->getFont();
+       float    pointsize = HUDtext->getPointSize();
+       float    italic    = HUDtext->getSlant();
+
+        TextList.setFont( HUDtext );
+        TextList.erase();
+        LineList.erase();
+        StippleLineList.erase();
+
+        int last = FloatToInt(vmax)+1;
+        int i    = FloatToInt(vmin);
+
+        if( !scr_hole ) {
+            for( ; i<last ; i++ ) {
+                
+                y =  (((float)(i - pitch_value) * factor) + .5f);
+                if( !(i % div_units ))    {        //  At integral multiple of div
+                
+                    sprintf( TextLadder, "%d", i );
+                    font->getBBox ( TextLadder, pointsize, italic,
+                                    &left, &right, &bot, &top ) ;
+                    label_length  = right - left;
+                    label_length += text_offset;
+                    label_height  = (top - bot)/2.0f;
+                
+                    x_ini = -half_span;
+                    x_end =  half_span;
+                    
+                    if( i >= 0 ) {
+                        // Make zero point wider on left
+                        if( i == 0 )
+                            x_ini -= zero_offset;
+                        // Zero or above draw solid lines
+                        Line(x_ini, y, x_end, y);
+                    } else {
+                        // Below zero draw dashed lines.
+                        StippleLine(x_ini, y, x_end, y);
+                    }
+                    
+                    // Calculate the position of the left text and write it.
+                    Text( x_ini-label_length, y-label_height, TextLadder );
+                    Text( x_end+text_offset,  y-label_height, TextLadder );
+                }
+            }
+        }
+        else // if(scr_hole )
+        {    // Draw ladder with space in the middle of the lines
+            float hole = (float)((scr_hole)/2.0f);
+            for( ; i<last ; i++ )      {
+
+//                y = (((float)(i - pitch_value) * factor) + .5);
+                y = (((float)(i - actslope) * factor) + .5);
+
+                if( !(i % div_units ))    {        //  At integral multiple of div
+
+                    sprintf( TextLadder, "%d", i );
+                    font->getBBox ( TextLadder, pointsize, italic,
+                                    &left, &right, &bot, &top ) ;
+                    label_length  = right - left;
+                    label_length += text_offset;
+                    label_height  = (top - bot)/2.0f;
+//                  printf("l %f r %f b %f t %f\n",left, right, bot, top );
+                
+                    // Start by calculating the points and drawing the
+                    // left side lines.
+                    x_ini = -half_span;
+                    x_end = -half_span + hole;
+                    
+                    if( i >= 0 ) { 
+                        // Make zero point wider on left
+                        if( i == 0 ) {
+                            x_ini -= zero_offset;
+                                               } else {
+                        // Zero or above draw solid lines
+                        Line(x_end, y-5.0, x_end, y);
+                                               }
+
+                        Line(x_ini, y, x_end, y);
+
+                    } else {
+                        // Below zero draw dashed lines.
+                        Line(x_end, y+5.0, x_end, y);
+                        StippleLine(x_ini, y, x_end, y);
+                    }
+                    
+                    // Now calculate the location of the left side label using
+                    Text( x_ini-label_length, y-label_height, TextLadder );
+                    
+                    // Now calculate and draw the right side line location
+                    x_ini = half_span - hole;
+                    x_end = half_span;
+                    
+                    if( i >= 0 ) {
+                        if( i == 0 ) {
+                            x_end += zero_offset;
+                                               } else {
+                           Line(x_ini, y-5.0, x_ini, y);
+                                               }
+                        // Zero or above draw solid lines
+                        Line(x_ini, y, x_end, y);
+                    } else {
+                        // Below zero draw dashed lines.
+                        Line(x_ini, y+5.0, x_ini, y);
+                        StippleLine(x_ini, y, x_end, y);
+                    }
+                    
+                    // Calculate the location and draw the right side label
+                    Text( x_end+text_offset,  y-label_height, TextLadder );
+                }
+            }
+        
+       // draw appraoch glide slope marker - for landing only (tied to hook)
+          if (ihook) {
+             Line(-half_span+15, (-4-actslope)*factor, -half_span + hole, (-4-actslope)*factor);
+             Line(half_span-15, (-4-actslope)*factor, half_span - hole, (-4-actslope)*factor);
+          }
+
+        }
+
+        TextList.draw();
+
+        glLineWidth(0.2);
+        
+        LineList.draw();
+        
+        glEnable(GL_LINE_STIPPLE);
+        glLineStipple( 1, 0x00FF );
+        StippleLineList.draw( );
+        glDisable(GL_LINE_STIPPLE);
+    }
+    glDisable(GL_CLIP_PLANE0);
+    glDisable(GL_CLIP_PLANE1);
+    glDisable(GL_CLIP_PLANE2);
+//      glDisable(GL_SCISSOR_TEST);
+    glPopMatrix();
+//*************************************************************
+// waypoint marker
+if (fabs(brg-psi) > 10.0) {
+    glPushMatrix();
+    glTranslatef( centroid.x, centroid.y, 0);
+    glTranslatef( vel_x, vel_y, 0);
+    glRotatef(brg - psi,0.0,0.0,-1.0);
+    glBegin(GL_LINE_LOOP);
+        glVertex2f(-2.5,20.0);
+        glVertex2f(-2.5,30.0);
+        glVertex2f(-5.0,30.0);
+        glVertex2f(0.0,35.0);
+        glVertex2f(5.0,30.0);
+        glVertex2f(2.5,30.0);
+        glVertex2f(2.5,20.0);
+    glEnd();
+    glPopMatrix();
+}
+// waypoint marker on heading scale
+if (fabs(brg-psi) < 12.0) {
+    glBegin(GL_LINE_LOOP);
+        glVertex2f(((brg-psi)*60/25)+320,240.0);
+        glVertex2f(((brg-psi)*60/25)+326,240.0-4);
+        glVertex2f(((brg-psi)*60/25)+323,240.0-4);
+        glVertex2f(((brg-psi)*60/25)+323,240.0-8);
+        glVertex2f(((brg-psi)*60/25)+317,240.0-8);
+        glVertex2f(((brg-psi)*60/25)+317,240.0-4);
+        glVertex2f(((brg-psi)*60/25)+314,240.0-4);
+    glEnd();
+}
+//*************************************************************
+
+}
+#else
+// $$$ end - added VS Renganathan, 13 Oct 2K
 
+// draw DEFAULT_HUD
 void HudLadder :: draw( void )
 {
     POINT  centroid    = get_centroid();
@@ -232,3 +680,4 @@ void HudLadder :: draw( void )
     glPopMatrix();
 }
 
+#endif  // DEFAULT_HUD
index 7de4b43eabd447b888fb5371438e1b2a4d64ce4a..cc4f10436679107f2f1319b778a4f728ac66c848 100644 (file)
@@ -33,8 +33,8 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/misc/fgpath.hxx>
+#include <Main/globals.hxx>
 #include <Main/options.hxx>
-#include <Main/views.hxx>
 #include <Objects/texload.h>
 
 #include "hud.hxx"
@@ -46,7 +46,7 @@ fgPanelVisible ()
 {
   return ((current_options.get_panel_status()) &&
          (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_PILOT) &&
-         (current_view.get_view_offset() == 0.0));
+         (globals->get_current_view()->get_view_offset() == 0.0));
 }
 
 
@@ -305,8 +305,9 @@ FGPanel::doMouseAction (int button, int updown, int x, int y)
   }
 
                                // Scale for the real window size.
-  x = int(((float)x / current_view.get_winWidth()) * _winw);
-  y = int(_winh - (((float)y / current_view.get_winHeight()) * _winh));
+  x = int(((float)x / globals->get_current_view()->get_winWidth()) * _winw);
+  y = int(_winh - (((float)y / globals->get_current_view()->get_winHeight())
+                  * _winh));
 
                                // Adjust for offsets.
   x -= _x_offset;
diff --git a/src/FDM/ADA.cxx b/src/FDM/ADA.cxx
new file mode 100644 (file)
index 0000000..35612a1
--- /dev/null
@@ -0,0 +1,293 @@
+// ADA.cxx -- interface to the "External"-ly driven ADA flight model
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+// Modified by Cdr. VS Renganthan <vsranga@ada.ernet.in>, 12 Oct 2K
+
+#include <simgear/io/iochannel.hxx>
+
+#include <Controls/controls.hxx>
+#include <GUI/gui.h>
+
+#include "ADA.hxx"
+
+#define numberofbytes 472
+
+struct {
+    double number_of_bytes;
+    double lat_geoc;
+    double lon_geoc;
+    double altitude;
+    double psirad;
+    double thetrad;
+    double phirad;
+    double earth_posn_angle;
+    double radius_to_vehicle;
+    double sea_level_radius;
+    double latitude;
+    double longitude;
+    double Vnorth;
+    double Veast;
+    double Vdown;
+    double Vcas_kts;
+    double prad;
+    double qrad;
+    double rrad;
+    double alpharad;
+    double betarad;
+    double latitude_dot;
+    double longitude_dot;
+    double radius_dot;
+    double Gamma_vert_rad;
+    double Runway_altitude;
+    double throttle;
+    double pstick;
+    double rstick;
+    double rpedal;
+    double U_local;
+    double V_local;
+    double W_local;
+    double U_dot_local;
+    double V_dot_local;
+    double W_dot_local;
+    double Machno;
+    double anxg;
+    double anyg;
+    double anzg;
+    double aux1;
+    double aux2;
+    double aux3;
+    double aux4;
+    double aux5;
+    double aux6;
+    double aux7;
+    double aux8;
+    int iaux1;
+    int iaux2;
+    int iaux3;
+    int iaux4;
+    int iaux5;
+    int iaux6;
+    int iaux7;
+    int iaux8;
+    int iaux9;
+    int iaux10;
+    int iaux11;
+    int iaux12;
+    float aux9;
+    float aux10;
+    float aux11;
+    float aux12;
+    float aux13;
+    float aux14;
+    float aux15;
+    float aux16;
+    float aux17;
+    float aux18;
+} sixdof_to_visuals;
+
+#define number_of_bytes sixdof_to_visuals.number_of_bytes
+#define U_dot_local sixdof_to_visuals.U_dot_local
+#define V_dot_local sixdof_to_visuals.V_dot_local
+#define W_dot_local sixdof_to_visuals.W_dot_local
+#define U_local sixdof_to_visuals.U_local
+#define V_local sixdof_to_visuals.V_local
+#define W_local sixdof_to_visuals.W_local
+#define throttle sixdof_to_visuals.throttle
+#define pstick sixdof_to_visuals.pstick
+#define rstick sixdof_to_visuals.rstick
+#define rpedal sixdof_to_visuals.rpedal
+#define V_north sixdof_to_visuals.Vnorth
+#define V_east sixdof_to_visuals.Veast
+#define V_down sixdof_to_visuals.Vdown
+#define V_calibrated_kts sixdof_to_visuals.Vcas_kts
+#define P_body sixdof_to_visuals.prad
+#define Q_body sixdof_to_visuals.qrad
+#define R_body sixdof_to_visuals.rrad
+#define Latitude_dot sixdof_to_visuals.latitude_dot
+#define Longitude_dot sixdof_to_visuals.longitude_dot
+#define Radius_dot sixdof_to_visuals.radius_dot
+#define Latitude sixdof_to_visuals.latitude
+#define Longitude sixdof_to_visuals.longitude
+#define Lat_geocentric sixdof_to_visuals.lat_geoc
+#define Lon_geocentric sixdof_to_visuals.lon_geoc
+#define Radius_to_vehicle sixdof_to_visuals.radius_to_vehicle
+#define Altitude sixdof_to_visuals.altitude
+#define Phi sixdof_to_visuals.phirad
+#define Theta sixdof_to_visuals.thetrad
+#define Psi sixdof_to_visuals.psirad
+#define Alpha sixdof_to_visuals.alpharad
+#define Beta sixdof_to_visuals.betarad
+#define Sea_level_radius sixdof_to_visuals.sea_level_radius
+#define Earth_position_angle sixdof_to_visuals.earth_posn_angle
+#define Runway_altitude sixdof_to_visuals.Runway_altitude
+#define Gamma_vert_rad sixdof_to_visuals.Gamma_vert_rad
+#define Machno sixdof_to_visuals.Machno
+#define anxg sixdof_to_visuals.anxg
+#define anyg sixdof_to_visuals.anyg
+#define anzg sixdof_to_visuals.anzg
+
+
+// Initialize the ADA flight model, dt is the time increment
+// for each subsequent iteration through the EOM
+bool FGADA::init( double dt ) {
+    // cout << "FGADA::init()" << endl;
+
+    char Buffer[numberofbytes];
+
+    // set valid time for this record
+    stamp_time();
+
+    printf("\nInitialising UDP sockets\n");
+    // initialise a "udp" socket
+    fdmsock = new SGSocket( "reddy_pc", "5001", "udp" );
+
+    // open as a client
+    bool result = fdmsock->open(SG_IO_OUT);
+    if (result == false) {
+       printf ("Socket Open Error\n");
+    } else {
+       // Dummy Write FGExternal structure from socket to establish connection
+       int result = fdmsock->write(Buffer, numberofbytes);
+       printf("Connection established.\n");
+    }
+
+    return true;
+}
+
+
+// Run an iteration of the EOM.  This is essentially a NOP here
+// because these values are getting filled in elsewhere based on
+// external input.
+bool FGADA::update( int multiloop ) {
+    // cout << "FGADA::update()" << endl;
+
+    char Buffer[numberofbytes];
+
+    // Read FGExternal structure from socket
+    int result = fdmsock->read(Buffer, numberofbytes);
+    // Loop to read from top of socket buffer - Last in first out
+    while (result == numberofbytes) {
+       result = fdmsock->read(Buffer, numberofbytes);
+    }
+
+    // Copy buffer into FGExternal structure
+    memcpy (&sixdof_to_visuals, &Buffer, sizeof (Buffer));
+
+    //cout << endl << sixdof_to_visuals.aux18 << endl;
+    // Close Visuals through message/flag from Flight model
+    if (sixdof_to_visuals.aux18 == 1) {
+       fdmsock->close();
+       ConfirmExitDialog();           
+    }
+    //cout << endl << sixdof_to_visuals.aux18 << endl;
+
+    // Convert from the FGExternal struct to the FGInterface struct (input)
+    copy_from_FGADA();
+
+    return true;
+}
+
+// Convert from the FGInterface struct to the FGADA struct (output)
+bool FGADA::copy_to_FGADA () {
+
+    return true;
+}
+
+
+// Convert from the FGADA struct to the FGInterface struct (input)
+bool FGADA::copy_from_FGADA() {
+
+    // Velocities
+    set_Velocities_Local( V_north, V_east, V_down );
+    set_V_calibrated_kts( V_calibrated_kts );
+
+    // Angular rates 
+    set_Omega_Body( P_body, Q_body, R_body );
+    set_Geocentric_Rates( Latitude_dot, Longitude_dot, Radius_dot );
+
+    //    FG_LOG( FG_FLIGHT, FG_DEBUG, "lon = " << Longitude 
+    //     << " lat_geoc = " << Lat_geocentric << " lat_geod = " << Latitude 
+    //     << " alt = " << Altitude << " sl_radius = " << Sea_level_radius 
+    //     << " radius_to_vehicle = " << Radius_to_vehicle );
+           
+    // Positions
+    set_Geocentric_Position( Lat_geocentric, Lon_geocentric,Radius_to_vehicle );
+    set_Geodetic_Position( Latitude, Longitude, Altitude );
+    set_Euler_Angles( Phi, Theta, Psi );
+
+    // Miscellaneous quantities
+    set_Alpha( Alpha );
+    set_Beta( Beta );
+    set_Gamma_vert_rad( Gamma_vert_rad );
+    set_Sea_level_radius( Sea_level_radius );
+    set_Earth_position_angle( Earth_position_angle );
+    set_Runway_altitude( Runway_altitude );
+    set_sin_lat_geocentric(Lat_geocentric);
+    set_cos_lat_geocentric(Lat_geocentric);
+    set_sin_cos_longitude(Longitude);
+    set_sin_cos_latitude(Latitude);
+    set_Accels_Local( U_dot_local, V_dot_local, W_dot_local );
+    set_Velocities_Ground( U_local, V_local, W_local );
+    set_Accels_CG_Body_N( anxg,anyg,anzg);
+    set_Mach_number( Machno);
+
+    //    printf("sr=%f\n",Sea_level_radius);
+    //    printf("psi = %f %f\n",Psi,Psi*RAD_TO_DEG);    
+
+    // controls
+    controls.set_throttle(0,throttle/131.0);
+    controls.set_elevator(pstick);
+    controls.set_aileron(rstick);
+    controls.set_rudder(rpedal);
+
+    // auxilliary parameters for HUD
+    set_iaux1(sixdof_to_visuals.iaux1);
+    set_iaux2(sixdof_to_visuals.iaux2);
+    set_iaux3(sixdof_to_visuals.iaux3);
+    set_iaux4(sixdof_to_visuals.iaux4);
+    set_iaux5(sixdof_to_visuals.iaux5);
+    set_iaux6(sixdof_to_visuals.iaux6);
+    set_iaux7(sixdof_to_visuals.iaux7);
+    set_iaux8(sixdof_to_visuals.iaux8);
+    set_iaux9(sixdof_to_visuals.iaux9);
+    set_iaux10(sixdof_to_visuals.iaux10);
+    set_iaux11(sixdof_to_visuals.iaux11);
+    set_iaux12(sixdof_to_visuals.iaux12);
+    set_aux1(sixdof_to_visuals.aux1);
+    set_aux2(sixdof_to_visuals.aux2);
+    set_aux3(sixdof_to_visuals.aux3);
+    set_aux4(sixdof_to_visuals.aux4);
+    set_aux5(sixdof_to_visuals.aux5);
+    set_aux6(sixdof_to_visuals.aux6);
+    set_aux7(sixdof_to_visuals.aux7);
+    set_aux8(sixdof_to_visuals.aux8);
+    set_aux9(sixdof_to_visuals.aux9);
+    set_aux10(sixdof_to_visuals.aux10);
+    set_aux11(sixdof_to_visuals.aux11);
+    set_aux12(sixdof_to_visuals.aux12);
+    set_aux13(sixdof_to_visuals.aux13);
+    set_aux14(sixdof_to_visuals.aux14);
+    set_aux15(sixdof_to_visuals.aux15);
+    set_aux16(sixdof_to_visuals.aux16);
+    set_aux17(sixdof_to_visuals.aux17);
+    set_aux18(sixdof_to_visuals.aux18);
+    
+    cout << endl << sixdof_to_visuals.aux18 << endl;
+
+    return true;
+}
diff --git a/src/FDM/ADA.hxx b/src/FDM/ADA.hxx
new file mode 100644 (file)
index 0000000..7ba2e9f
--- /dev/null
@@ -0,0 +1,174 @@
+// ADA.hxx -- interface to the "External"-ly driven ADA flight model
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+
+#ifndef _ADA_HXX
+#define _ADA_HXX
+
+
+#include <simgear/io/sg_socket.hxx>
+
+#include "flight.hxx"
+
+
+class FGADA: public FGInterface {
+
+private:
+       
+    SGSocket *fdmsock;
+
+    // Auxilliary Flight Model parameters, basically for HUD
+    double        aux1;           // auxilliary flag
+    double        aux2;           // auxilliary flag
+    double        aux3;           // auxilliary flag
+    double        aux4;           // auxilliary flag
+    double        aux5;           // auxilliary flag
+    double        aux6;           // auxilliary flag
+    double        aux7;           // auxilliary flag
+    double        aux8;           // auxilliary flag
+    float        aux9;            // auxilliary flag
+    float        aux10;           // auxilliary flag
+    float        aux11;           // auxilliary flag
+    float        aux12;           // auxilliary flag
+    float        aux13;           // auxilliary flag
+    float        aux14;           // auxilliary flag
+    float        aux15;           // auxilliary flag
+    float        aux16;           // auxilliary flag
+    float        aux17;           // auxilliary flag
+    float        aux18;           // auxilliary flag
+    int          iaux1;           // auxilliary flag
+    int          iaux2;           // auxilliary flag
+    int          iaux3;           // auxilliary flag
+    int          iaux4;           // auxilliary flag
+    int          iaux5;           // auxilliary flag
+    int          iaux6;           // auxilliary flag
+    int          iaux7;           // auxilliary flag
+    int          iaux8;           // auxilliary flag
+    int          iaux9;           // auxilliary flag
+    int         iaux10;           // auxilliary flag
+    int         iaux11;           // auxilliary flag
+    int         iaux12;           // auxilliary flag
+
+    // copy FDM state to FGADA structures
+    bool copy_to_FGADA();
+
+    // copy FDM state from FGADA structures
+    bool copy_from_FGADA();
+
+public:
+
+    // reset flight params to a specific position 
+    bool init( double dt );
+
+    // update position based on inputs, positions, velocities, etc.
+    bool update( int multiloop );
+
+    // auxiliary data getters and setters
+    inline double get_aux1() const { return aux1; }
+    inline void set_aux1(double aux) { aux1 = aux; }
+
+    inline double get_aux2() const { return aux2; }
+    inline void set_aux2(double aux) { aux2 = aux; }
+
+    inline double get_aux3() const { return aux3; }
+    inline void set_aux3(double aux) { aux3 = aux; }
+
+    inline double get_aux4() const { return aux4; }
+    inline void set_aux4(double aux) { aux4 = aux; }
+
+    inline double get_aux5() const { return aux5; }
+    inline void set_aux5(double aux) { aux5 = aux; }
+
+    inline double get_aux6() const { return aux6; }
+    inline void set_aux6(double aux) { aux6 = aux; }
+
+    inline double get_aux7() const { return aux7; }
+    inline void set_aux7(double aux) { aux7 = aux; }
+
+    inline double get_aux8() const { return aux8; }
+    inline void set_aux8(double aux) { aux8 = aux; }
+
+    inline float get_aux9() const { return aux9; }
+    inline void set_aux9(float aux) { aux9 = aux; }
+
+    inline float get_aux10() const { return aux10; }
+    inline void set_aux10(float aux) { aux10 = aux; }
+
+    inline float get_aux11() const { return aux11; }
+    inline void set_aux11(float aux) { aux11 = aux; }
+
+    inline float get_aux12() const { return aux12; }
+    inline void set_aux12(float aux) { aux12 = aux; }
+
+    inline float get_aux13() const { return aux13; }
+    inline void set_aux13(float aux) { aux13 = aux; }
+
+    inline float get_aux14() const { return aux14; }
+    inline void set_aux14(float aux) { aux14 = aux; }
+
+    inline float get_aux15() const { return aux15; }
+    inline void set_aux15(float aux) { aux15 = aux; }
+
+    inline float get_aux16() const { return aux16; }
+    inline void set_aux16(float aux) { aux16 = aux; }
+
+    inline float get_aux17() const { return aux17; }
+    inline void set_aux17(float aux) { aux17 = aux; }
+
+    inline float get_aux18() const { return aux18; }
+    inline void set_aux18(float aux) { aux18 = aux; }
+
+    inline int get_iaux1() const { return iaux1; }
+    inline void set_iaux1(int iaux) { iaux1 = iaux; }
+
+    inline int get_iaux2() const { return iaux2; }
+    inline void set_iaux2(int iaux) { iaux2 = iaux; }
+
+    inline int get_iaux3() const { return iaux3; }
+    inline void set_iaux3(int iaux) { iaux3 = iaux; }
+
+    inline int get_iaux4() const { return iaux4; }
+    inline void set_iaux4(int iaux) { iaux4 = iaux; }
+
+    inline int get_iaux5() const { return iaux5; }
+    inline void set_iaux5(int iaux) { iaux5 = iaux; }
+
+    inline int get_iaux6() const { return iaux6; }
+    inline void set_iaux6(int iaux) { iaux6 = iaux; }
+
+    inline int get_iaux7() const { return iaux7; }
+    inline void set_iaux7(int iaux) { iaux7 = iaux; }
+
+    inline int get_iaux8() const { return iaux8; }
+    inline void set_iaux8(int iaux) { iaux8 = iaux; }
+
+    inline int get_iaux9() const { return iaux9; }
+    inline void set_iaux9(int iaux) { iaux9 = iaux; }
+
+    inline int get_iaux10() const { return iaux10; }
+    inline void set_iaux10(int iaux) { iaux10 = iaux; }
+
+    inline int get_iaux11() const { return iaux11; }
+    inline void set_iaux11(int iaux) { iaux11 = iaux; }
+
+    inline int get_iaux12() const { return iaux12; }
+    inline void set_iaux12(int iaux) { iaux12 = iaux; }
+};
+
+
+#endif // _ADA_HXX
index edf8ef6d71af28018264db76dbc40ccac890bd3c..c52f3a7d72111410fdbbcf4fdaf3f2de802f0cd9 100644 (file)
@@ -3,6 +3,7 @@ SUBDIRS = Balloon JSBSim LaRCsim UIUCModel
 noinst_LIBRARIES = libFlight.a
 
 libFlight_a_SOURCES = \
+       ADA.cxx ADA.hxx \
        Balloon.cxx Balloon.h \
        External.cxx External.hxx \
        flight.cxx flight.hxx \
index 3a724b562ebb973134dd46df62af1498280207d3..81a15cabbafe6af924f52977005d1422060cc832 100644 (file)
@@ -260,16 +260,19 @@ public:
        // Christian's hot air balloon simulation
        FG_BALLOONSIM = 3,
 
+       // AEronautical DEvelopment AGEncy, Bangalore India
+       FG_ADA = 4,
+
        // The following aren't implemented but are here to spark
        // thoughts and discussions, and maybe even action.
-       FG_ACM = 4,
-       FG_SUPER_SONIC = 5,
-       FG_HELICOPTER = 6,
-       FG_AUTOGYRO = 7,
-       FG_PARACHUTE = 8,
+       FG_ACM = 5,
+       FG_SUPER_SONIC = 6,
+       FG_HELICOPTER = 7,
+       FG_AUTOGYRO = 8,
+       FG_PARACHUTE = 9,
 
        // Driven externally via a serial port, net, file, etc.
-       FG_EXTERNAL = 9
+       FG_EXTERNAL = 10
     };
 
     // ========== Mass properties and geometry values ==========
@@ -461,14 +464,14 @@ public:
     }
 
     // inline double * get_N_cg_body_v() { return n_cg_body_v; }
-    // inline double get_N_X_cg() const { return n_cg_body_v[0]; }
-    // inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
-    // inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
-    // inline void set_Accels_CG_Body_N( double x, double y, double z ) {
-    //    n_cg_body_v[0] = x;
-    //    n_cg_body_v[1] = y;
-    //    n_cg_body_v[2] = z;
-    // }
+    inline double get_N_X_cg() const { return n_cg_body_v[0]; }
+    inline double get_N_Y_cg() const { return n_cg_body_v[1]; }
+    inline double get_N_Z_cg() const { return n_cg_body_v[2]; }
+    inline void set_Accels_CG_Body_N( double x, double y, double z ) {
+       n_cg_body_v[0] = x;
+       n_cg_body_v[1] = y;
+       n_cg_body_v[2] = z;
+    }
 
     // inline double * get_N_pilot_body_v() { return n_pilot_body_v; }
     // inline double get_N_X_pilot() const { return n_pilot_body_v[0]; }
@@ -509,21 +512,20 @@ public:
     // inline double * get_V_local_rel_ground_v() {
     //     return v_local_rel_ground_v;
     // }
-    // inline double get_V_north_rel_ground() const {
-    //     return v_local_rel_ground_v[0];
-    // }
-    // inline double get_V_east_rel_ground() const {
-    //     return v_local_rel_ground_v[1];
-    // }
-    // inline double get_V_down_rel_ground() const {
-    //     return v_local_rel_ground_v[2];
-    // }
-    // inline void set_Velocities_Ground(double north, double east, double down)
-    // {
-    //     v_local_rel_ground_v[0] = north;
-    //     v_local_rel_ground_v[1] = east;
-    //     v_local_rel_ground_v[2] = down;
-    // }
+    inline double get_V_north_rel_ground() const {
+        return v_local_rel_ground_v[0];
+    }
+    inline double get_V_east_rel_ground() const {
+       return v_local_rel_ground_v[1];
+    }
+    inline double get_V_down_rel_ground() const {
+        return v_local_rel_ground_v[2];
+    }
+    inline void set_Velocities_Ground(double north, double east, double down) {
+       v_local_rel_ground_v[0] = north;
+       v_local_rel_ground_v[1] = east;
+       v_local_rel_ground_v[2] = down;
+    }
 
     // inline double * get_V_local_airmass_v() { return v_local_airmass_v; }
     inline double get_V_north_airmass() const { return v_local_airmass_v[0]; }
index 0f87fc35d798fc9e73ef8486084799cb1f50175a..64bd707d88220a7b9827e515d94b948cf834e41c 100644 (file)
@@ -69,7 +69,6 @@
 #include <Main/fg_io.hxx>
 #include <Main/globals.hxx>
 #include <Main/options.hxx>
-#include <Main/views.hxx>
 #include <Main/save.hxx>
 #ifdef FG_NETWORK_OLK
 #include <NetworkOLK/network.h>
@@ -300,7 +299,8 @@ static inline void TurnCursorOn( void )
     }
 #endif
 #if defined(X_CURSOR_TWEAKS)
-    glutWarpPointer( current_view.get_winWidth()/2, current_view.get_winHeight()/2);
+    glutWarpPointer( globals->get_current_view()->get_winWidth()/2,
+                    globals->get_current_view()->get_winHeight()/2);
 #endif
 }
 
@@ -310,7 +310,8 @@ static inline void TurnCursorOff( void )
 #if defined(WIN32_CURSOR_TWEAKS)
     glutSetCursor(GLUT_CURSOR_NONE);
 #elif defined(X_CURSOR_TWEAKS)
-    glutWarpPointer( current_view.get_winWidth(), current_view.get_winHeight());
+    glutWarpPointer( globals->get_current_view()->get_winWidth(),
+                    globals->get_current_view()->get_winHeight());
 #endif
 }
 
@@ -381,8 +382,8 @@ void guiMotionFunc ( int x, int y )
         // reset left click MOUSE_VIEW toggle feature
         _mVtoggle = 0;
         
-        ww = current_view.get_winWidth();
-        wh = current_view.get_winHeight();
+        ww = globals->get_current_view()->get_winWidth();
+        wh = globals->get_current_view()->get_winHeight();
         
         switch (mouse_mode) {
             case MOUSE_YOKE:
@@ -476,7 +477,7 @@ void guiMotionFunc ( int x, int y )
                 // do horizontal pan
                 // this could be done in above quat
                 // but requires redoing view pipeline
-                offset = current_view.get_goal_view_offset();
+                offset = globals->get_current_view()->get_goal_view_offset();
                 offset += ((_mX - x) * FG_2PI / W );
                 while (offset < 0.0) {
                     offset += FG_2PI;
@@ -484,9 +485,9 @@ void guiMotionFunc ( int x, int y )
                 while (offset > FG_2PI) {
                     offset -= FG_2PI;
                 }
-                current_view.set_goal_view_offset(offset);
+                globals->get_current_view()->set_goal_view_offset(offset);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                current_view.set_view_offset(offset);
+                globals->get_current_view()->set_view_offset(offset);
 #endif
                 break;
             
@@ -543,9 +544,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
                         curquat[1] = _quat[1];
                         curquat[2] = _quat[2];
                         curquat[3] = _quat[3];
-                        current_view.set_goal_view_offset(_view_offset);
+                        globals->get_current_view()->set_goal_view_offset(_view_offset);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                        current_view.set_view_offset(_view_offset);
+                        globals->get_current_view()->set_view_offset(_view_offset);
 #endif
                     } else {
                         // center view
@@ -557,13 +558,13 @@ void guiMouseFunc(int button, int updown, int x, int y)
                         _quat[1] = curquat[1];
                         _quat[2] = curquat[2];
                         _quat[3] = curquat[3];
-                        x = current_view.get_winWidth()/2;
-                        y = current_view.get_winHeight()/2;
+                        x = globals->get_current_view()->get_winWidth()/2;
+                        y = globals->get_current_view()->get_winHeight()/2;
                         Quat0();
-                        _view_offset = current_view.get_goal_view_offset();
-                        current_view.set_goal_view_offset(0.0);
+                        _view_offset = globals->get_current_view()->get_goal_view_offset();
+                        globals->get_current_view()->set_goal_view_offset(0.0);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                        current_view.set_view_offset(0.0);
+                        globals->get_current_view()->set_view_offset(0.0);
 #endif
                     }
                     glutWarpPointer( x , y);
@@ -579,8 +580,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
                     _savedX = x;
                     _savedY = y;
                     // start with zero point in center of screen
-                    _mX = current_view.get_winWidth()/2;
-                    _mY = current_view.get_winHeight()/2;
+                    _mX = globals->get_current_view()->get_winWidth()/2;
+                    _mY = globals->get_current_view()->get_winHeight()/2;
                     
                     // try to have the MOUSE_YOKE position
                     // reflect the current stick position
@@ -596,8 +597,8 @@ void guiMouseFunc(int button, int updown, int x, int y)
                 case MOUSE_YOKE:
                     mouse_mode = MOUSE_VIEW;
                     current_options.set_control_mode( fgOPTIONS::FG_JOYSTICK );
-                    x = current_view.get_winWidth()/2;
-                    y = current_view.get_winHeight()/2;
+                    x = globals->get_current_view()->get_winWidth()/2;
+                    y = globals->get_current_view()->get_winHeight()/2;
                     _mVtoggle = 0;
                     Quat0();
                     build_rotmatrix(quat_mat, curquat);
@@ -612,9 +613,9 @@ void guiMouseFunc(int button, int updown, int x, int y)
 #ifdef RESET_VIEW_ON_LEAVING_MOUSE_VIEW
                     Quat0();
                     build_rotmatrix(quat_mat, curquat);
-                    current_view.set_goal_view_offset(0.0);
+                    globals->get_current_view()->set_goal_view_offset(0.0);
 #ifdef NO_SMOOTH_MOUSE_VIEW
-                    current_view.set_view_offset(0.0);
+                    globals->get_current_view()->set_view_offset(0.0);
 #endif
 #endif      // RESET_VIEW_ON_LEAVING_MOUSE_VIEW
                     glutSetCursor(GLUT_CURSOR_INHERIT);
@@ -883,12 +884,12 @@ GLubyte *hiResScreenCapture( int multiplier )
 {
        float oldfov = current_options.get_fov();
        float fov = oldfov / multiplier;
-       FGView *v = &current_view;
+       FGViewer *v = globals->get_current_view();
        current_options.set_fov(fov);
        v->force_update_fov_math();
     fgInitVisuals();
-    int cur_width = current_view.get_winWidth( );
-    int cur_height = current_view.get_winHeight( );
+    int cur_width = globals->get_current_view()->get_winWidth( );
+    int cur_height = globals->get_current_view()->get_winHeight( );
        if (b1) delete( b1 );
        // New empty (mostly) bitmap
        b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
@@ -906,7 +907,7 @@ GLubyte *hiResScreenCapture( int multiplier )
                        b1->copyBitmap( &b2, cur_width*x, cur_height*y );
                }
        }
-       current_view.UpdateViewParams(cur_view_fdm);
+       globals->get_current_view()->UpdateViewParams(cur_view_fdm);
        current_options.set_fov(oldfov);
        v->force_update_fov_math();
        return b1->getBitmap();
@@ -927,8 +928,8 @@ void printScreen ( puObject *obj ) {
     mainMenuBar->hide();
 
     CGlPrinter p( CGlPrinter::PRINT_BITMAP );
-    int cur_width = current_view.get_winWidth( );
-    int cur_height = current_view.get_winHeight( );
+    int cur_width = globals->get_current_view()->get_winWidth( );
+    int cur_height = globals->get_current_view()->get_winHeight( );
     p.Begin( "FlightGear", cur_width*3, cur_height*3 );
        p.End( hiResScreenCapture(3) );
 
@@ -965,7 +966,8 @@ void fgDumpSnapShot () {
     }
 
     fgInitVisuals();
-    fgReshape( current_view.get_winWidth(), current_view.get_winHeight() );
+    fgReshape( globals->get_current_view()->get_winWidth(),
+              globals->get_current_view()->get_winHeight() );
 
     // we need two render frames here to clear the menu and cursor
     // ... not sure why but doing an extra fgFenderFrame() shoulnd't
index 61525a3f4db05913d4869c53484278290d3b9e32..9fbafe6226dd2b491cad5f2f22670eaa8be50e83 100644 (file)
@@ -43,7 +43,7 @@ fgfs_SOURCES = \
        options.cxx options.hxx \
        save.cxx save.hxx \
        splash.cxx splash.hxx \
-       views.cxx views.hxx
+       viewer.cxx viewer.hxx
 
 fgfs_LDADD = \
        $(top_builddir)/src/Aircraft/libAircraft.a \
index 1027381ccc181ea9004cc4bb25d7eab1ba4d764e..b0ab0d5164232af6b699f44c05f6e787d1774fd2 100644 (file)
@@ -64,6 +64,7 @@
 #include <Cockpit/radiostack.hxx>
 #include <Cockpit/panel.hxx>
 #include <Cockpit/panel_io.hxx>
+#include <FDM/ADA.hxx>
 #include <FDM/Balloon.h>
 #include <FDM/External.hxx>
 #include <FDM/JSBSim.hxx>
@@ -93,7 +94,6 @@
 #include "fg_io.hxx"
 #include "globals.hxx"
 #include "options.hxx"
-#include "views.hxx"
 #include "bfi.hxx"
 
 #if defined(FX) && defined(XMESA)
@@ -449,6 +449,8 @@ bool fgInitSubsystems( void ) {
        cur_fdm_state = new FGLaRCsim;
     } else if ( current_options.get_flight_model() == FGInterface::FG_JSBSIM ) {
        cur_fdm_state = new FGJSBsim;
+    } else if ( current_options.get_flight_model() == FGInterface::FG_ADA ) {
+       cur_fdm_state = new FGADA;
     } else if ( current_options.get_flight_model() == 
                FGInterface::FG_BALLOONSIM ) {
        cur_fdm_state = new FGBalloonSim;
@@ -568,12 +570,13 @@ bool fgInitSubsystems( void ) {
 
     // Initialize view parameters
     FG_LOG( FG_GENERAL, FG_DEBUG, "Before current_view.init()");
-    current_view.Init();
-    pilot_view.Init();
+    globals->get_current_view()->Init();
+    globals->get_pilot_view()->Init();
     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
-    current_view.UpdateViewMath(*cur_fdm_state);
-    pilot_view.UpdateViewMath(*cur_fdm_state);
-    FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
+    globals->get_current_view()->UpdateViewMath(*cur_fdm_state);
+    globals->get_pilot_view()->UpdateViewMath(*cur_fdm_state);
+    FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = "
+           << globals->get_current_view()->get_abs_view_pos());
     // current_view.UpdateWorldToEye(f);
 
     // Initialize the planetary subsystem
@@ -840,15 +843,16 @@ void fgReInitSubsystems( void )
     cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
 
     // Initialize view parameters
-    current_view.set_view_offset( 0.0 );
-    current_view.set_goal_view_offset( 0.0 );
-    pilot_view.set_view_offset( 0.0 );
-    pilot_view.set_goal_view_offset( 0.0 );
+    globals->get_current_view()->set_view_offset( 0.0 );
+    globals->get_current_view()->set_goal_view_offset( 0.0 );
+    globals->get_pilot_view()->set_view_offset( 0.0 );
+    globals->get_pilot_view()->set_goal_view_offset( 0.0 );
 
     FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
-    current_view.UpdateViewMath(*cur_fdm_state);
-    pilot_view.UpdateViewMath(*cur_fdm_state);
-    FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = " << current_view.get_abs_view_pos());
+    globals->get_current_view()->UpdateViewMath(*cur_fdm_state);
+    globals->get_pilot_view()->UpdateViewMath(*cur_fdm_state);
+    FG_LOG( FG_GENERAL, FG_DEBUG, "  abs_view_pos = "
+           << globals->get_current_view()->get_abs_view_pos());
 
     // fgFDMInit( current_options.get_flight_model(), cur_fdm_state, 
     //            1.0 / current_options.get_model_hz() );
index 66fdc7131eb143c7d908d5f8c35aeaa3bb3d4810..c9f5691df85630f19adb21f60421708666770843 100644 (file)
@@ -30,6 +30,8 @@
 #include <simgear/route/route.hxx>
 #include <simgear/timing/sg_time.hxx>
 
+#include "viewer.hxx"
+
 
 class FGGlobals {
 
@@ -58,6 +60,9 @@ private:
     // Global autopilot "route"
     SGRoute *route;
 
+    FGViewer *pilot_view;
+    FGViewer *current_view;
+
 public:
 
     FGGlobals();
@@ -85,6 +90,13 @@ public:
 
     inline SGRoute *get_route() const { return route; }
     inline void set_route( SGRoute *r ) { route = r; }
+
+    inline FGViewer *get_pilot_view() const { return pilot_view; }
+    inline void set_pilot_view( FGViewer *v ) { pilot_view = v; }
+    
+    inline FGViewer *get_current_view() const { return current_view; }
+    inline void set_current_view( FGViewer *v ) { current_view = v; }
+    
 };
 
 
index 8606a286401e036bd839bce37e29b13a845a7c9a..217765f943ad226a760e372ba9c68299b73bfeb3 100644 (file)
@@ -72,7 +72,6 @@
 #include "keyboard.hxx"
 #include "options.hxx"
 #include "save.hxx"
-#include "views.hxx"
 
                                // From main.cxx
 extern void fgReshape( int width, int height );
@@ -82,13 +81,13 @@ extern void fgReshape( int width, int height );
 void GLUTkey(unsigned char k, int x, int y) {
     FGInterface *f;
     SGTime *t;
-    FGView *v;
+    FGViewer *v;
     float fov, tmp;
     static bool winding_ccw = true;
     int speed;
 
     f = current_aircraft.fdm_state;
-    v = &current_view;
+    v = globals->get_current_view();
 
     FG_LOG( FG_INPUT, FG_DEBUG, "Key hit = " << k );
     if ( puKeyboard(k, PU_DOWN) ) {
@@ -159,56 +158,56 @@ void GLUTkey(unsigned char k, int x, int y) {
        case 49: // numeric keypad 1
            v->set_goal_view_offset( FG_PI * 0.75 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(-25.0, 25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(-25.0, 25.0, 1.0);
              v->set_view_offset( FG_PI * 0.75 );
            }
            return;
        case 50: // numeric keypad 2
            v->set_goal_view_offset( FG_PI );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(-25.0, 0.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(-25.0, 0.0, 1.0);
              v->set_view_offset( FG_PI );
            }
            return;
        case 51: // numeric keypad 3
            v->set_goal_view_offset( FG_PI * 1.25 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(-25.0, -25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(-25.0, -25.0, 1.0);
              v->set_view_offset( FG_PI * 1.25 );
            }
            return;
        case 52: // numeric keypad 4
            v->set_goal_view_offset( FG_PI * 0.50 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(0.0, 25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(0.0, 25.0, 1.0);
              v->set_view_offset( FG_PI * 0.50 );
            }
            return;
        case 54: // numeric keypad 6
            v->set_goal_view_offset( FG_PI * 1.50 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(0.0, -25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(0.0, -25.0, 1.0);
              v->set_view_offset( FG_PI * 1.50 );
            }
            return;
        case 55: // numeric keypad 7
            v->set_goal_view_offset( FG_PI * 0.25 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(25.0, 25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(25.0, 25.0, 1.0);
              v->set_view_offset( FG_PI * 0.25 );
            }
            return;
        case 56: // numeric keypad 8
            v->set_goal_view_offset( 0.00 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(25.0, 0.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(25.0, 0.0, 1.0);
              v->set_view_offset( 0.00 );
            }
            return;
        case 57: // numeric keypad 9
            v->set_goal_view_offset( FG_PI * 1.75 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(25.0, -25.0, 1.0);
              v->set_view_offset( FG_PI * 1.75 );
            }
            return;
@@ -417,10 +416,10 @@ void GLUTkey(unsigned char k, int x, int y) {
              current_options.set_view_mode(fgOPTIONS::FG_VIEW_FOLLOW);
              v->set_goal_view_offset( FG_PI * 1.75 );
              v->set_view_offset( FG_PI * 1.75 );
-             pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(25.0, -25.0, 1.0);
            }
-           fgReshape( current_view.get_winWidth(),
-                      current_view.get_winHeight() );
+           fgReshape( globals->get_current_view()->get_winWidth(),
+                      globals->get_current_view()->get_winHeight() );
            return;
        case 120: // x key
            fov = current_options.get_fov();
@@ -457,9 +456,9 @@ void GLUTkey(unsigned char k, int x, int y) {
 
 // Handle "special" keyboard events
 void GLUTspecialkey(int k, int x, int y) {
-    FGView *v;
+    FGViewer *v;
 
-    v = &current_view;
+    v = globals->get_current_view();
 
     FG_LOG( FG_INPUT, FG_DEBUG, "Special key hit = " << k );
 
@@ -521,14 +520,14 @@ void GLUTspecialkey(int k, int x, int y) {
        }
        case GLUT_KEY_F5: {
          current_panel->setYOffset(current_panel->getYOffset() - 5);
-         fgReshape(current_view.get_winWidth(),
-                   current_view.get_winHeight());
+         fgReshape(globals->get_current_view()->get_winWidth(),
+                   globals->get_current_view()->get_winHeight());
          return;
        }
        case GLUT_KEY_F6: {
          current_panel->setYOffset(current_panel->getYOffset() + 5);
-         fgReshape(current_view.get_winWidth(),
-                   current_view.get_winHeight());
+         fgReshape(globals->get_current_view()->get_winWidth(),
+                   globals->get_current_view()->get_winHeight());
          return;
        }
        case GLUT_KEY_F7: {
@@ -542,56 +541,56 @@ void GLUTspecialkey(int k, int x, int y) {
        case GLUT_KEY_END: // numeric keypad 1
            v->set_goal_view_offset( FG_PI * 0.75 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(-25.0, 25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(-25.0, 25.0, 1.0);
              v->set_view_offset( FG_PI * 0.75 );
            }
            return;
        case GLUT_KEY_DOWN: // numeric keypad 2
            v->set_goal_view_offset( FG_PI );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(-25.0, 0.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(-25.0, 0.0, 1.0);
              v->set_view_offset( FG_PI );
            }
            return;
        case GLUT_KEY_PAGE_DOWN: // numeric keypad 3
            v->set_goal_view_offset( FG_PI * 1.25 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(-25.0, -25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(-25.0, -25.0, 1.0);
              v->set_view_offset( FG_PI * 1.25 );
            }
            return;
        case GLUT_KEY_LEFT: // numeric keypad 4
            v->set_goal_view_offset( FG_PI * 0.50 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(0.0, 25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(0.0, 25.0, 1.0);
              v->set_view_offset( FG_PI * 0.50 );
            }
            return;
        case GLUT_KEY_RIGHT: // numeric keypad 6
            v->set_goal_view_offset( FG_PI * 1.50 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(0.0, -25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(0.0, -25.0, 1.0);
              v->set_view_offset( FG_PI * 1.50 );
            }
            return;
        case GLUT_KEY_HOME: // numeric keypad 7
            v->set_goal_view_offset( FG_PI * 0.25 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(25.0, 25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(25.0, 25.0, 1.0);
              v->set_view_offset( FG_PI * 0.25 );
            }
            return;
        case GLUT_KEY_UP: // numeric keypad 8
            v->set_goal_view_offset( 0.00 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(25.0, 0.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(25.0, 0.0, 1.0);
              v->set_view_offset( 0.00 );
            }
            return;
        case GLUT_KEY_PAGE_UP: // numeric keypad 9
            v->set_goal_view_offset( FG_PI * 1.75 );
            if (current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW) {
-             pilot_view.set_pilot_offset(25.0, -25.0, 1.0);
+             globals->get_pilot_view()->set_pilot_offset(25.0, -25.0, 1.0);
              v->set_view_offset( FG_PI * 1.75 );
            }
            return;
index b672be5b831b6af3377fd0f2fbc807eba2e69fdf..63a2ec92ee19743fd27b8d740f31eaf2648e0047 100644 (file)
 #include <Time/sunpos.hxx>
 #include <Time/tmp.hxx>
 
+// $$$ begin - added VS Renganathan
+#include <simgear/misc/fgstream.hxx>
+#include <FDM/flight.hxx>
+void fgLoadDCS (void);
+void fgUpdateDCS (void);
+ssgSelector *ship_sel = NULL;
+ssgTransform *ship_pos = NULL;
+//int totalDCSobj = 0;
+// $$$ end - added VS Renganathan
+
 #ifndef FG_OLD_WEATHER
 #  include <WeatherCM/FGLocalWeatherDatabase.h>
 #else
 #include "keyboard.hxx"
 #include "options.hxx"
 #include "splash.hxx"
-#include "views.hxx"
 
 
 // -dw- use custom sioux settings so I can see output window
@@ -309,14 +318,16 @@ void fgRenderFrame( void ) {
        // update view volume parameters
        // cout << "before pilot_view update" << endl;
         if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW ) {
-         float * offset = pilot_view.get_pilot_offset();
-         current_view.set_pilot_offset(offset[0], offset[1], offset[2]);
+         float * offset = globals->get_pilot_view()->get_pilot_offset();
+         globals->get_current_view()->set_pilot_offset( offset[0],
+                                                        offset[1],
+                                                        offset[2] );
        } else {
-         current_view.set_pilot_offset(0.0, 0.0, 0.0);
+         globals->get_current_view()->set_pilot_offset(0.0, 0.0, 0.0);
        }
-       pilot_view.UpdateViewParams(*cur_fdm_state);
+       globals->get_pilot_view()->UpdateViewParams(*cur_fdm_state);
        // cout << "after pilot_view update" << endl;
-       current_view.UpdateViewParams(cur_view_fdm);
+       globals->get_current_view()->UpdateViewParams(cur_view_fdm);
 
        // set the sun position
        glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
@@ -348,7 +359,7 @@ void fgRenderFrame( void ) {
        // ssg does to set up the model view matrix
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
-       ssgSetCamera( current_view.VIEW );
+       ssgSetCamera( (sgMat4)globals->get_current_view()->get_VIEW() );
 
        /*
        sgMat4 vm_tmp, view_mat;
@@ -399,15 +410,15 @@ void fgRenderFrame( void ) {
        if ( current_options.get_skyblend() ) {
            sgVec3 view_pos;
            sgSetVec3( view_pos,
-                      current_view.get_view_pos().x(),
-                      current_view.get_view_pos().y(),
-                      current_view.get_view_pos().z() );
+                      globals->get_current_view()->get_view_pos().x(),
+                      globals->get_current_view()->get_view_pos().y(),
+                      globals->get_current_view()->get_view_pos().z() );
 
            sgVec3 zero_elev;
            sgSetVec3( zero_elev,
-                      current_view.get_cur_zero_elev().x(),
-                      current_view.get_cur_zero_elev().y(),
-                      current_view.get_cur_zero_elev().z() );
+                      globals->get_current_view()->get_cur_zero_elev().x(),
+                      globals->get_current_view()->get_cur_zero_elev().y(),
+                      globals->get_current_view()->get_cur_zero_elev().z() );
 
            /* cout << "thesky->repaint() sky_color = "
                 << cur_light_params.sky_color[0] << " "
@@ -445,7 +456,7 @@ void fgRenderFrame( void ) {
                 << " moon dec = " << globals->get_ephem()->getMoonDeclination() << endl; */
 
            thesky->reposition( view_pos, zero_elev,
-                               current_view.get_local_up(),
+                               globals->get_current_view()->get_local_up(),
                                cur_fdm_state->get_Longitude(),
                                cur_fdm_state->get_Latitude(),
                                cur_fdm_state->get_Altitude() * FEET_TO_METER,
@@ -491,7 +502,7 @@ void fgRenderFrame( void ) {
        // glLoadIdentity();
        float fov = current_options.get_fov();
        // ssgSetFOV(fov * current_view.get_win_ratio(), fov);
-       ssgSetFOV(fov, fov * current_view.get_win_ratio());
+       ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
 
        double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
            - scenery.cur_elev;
@@ -522,9 +533,9 @@ void fgRenderFrame( void ) {
 
            sgMat4 sgTRANS;
            sgMakeTransMat4( sgTRANS, 
-                            pilot_view.view_pos.x(),
-                            pilot_view.view_pos.y(),
-                            pilot_view.view_pos.z() );
+                            globals->get_pilot_view()->get_view_pos().x(),
+                            globals->get_pilot_view()->get_view_pos().y(),
+                            globals->get_pilot_view()->get_view_pos().z() );
 
            sgVec3 ownship_up;
            sgSetVec3( ownship_up, 0.0, 0.0, 1.0);
@@ -540,7 +551,7 @@ void fgRenderFrame( void ) {
            // sgTUX = ( sgROT * pilot_view.VIEW_ROT ) * sgTRANS
            sgMat4 sgTUX;
            sgCopyMat4( sgTUX, sgROT );
-           sgPostMultMat4( sgTUX, pilot_view.VIEW_ROT );
+           sgPostMultMat4( sgTUX, globals->get_pilot_view()->get_VIEW_ROT() );
            sgPostMultMat4( sgTUX, sgTRANS );
        
            sgCoord tuxpos;
@@ -548,6 +559,10 @@ void fgRenderFrame( void ) {
            penguin_pos->setTransform( &tuxpos );
        }
 
+       // $$$ begin - added VS Renganthan 17 Oct 2K
+       fgUpdateDCS();
+       // $$$ end - added VS Renganthan 17 Oct 2K
+
 # ifdef FG_NETWORK_OLK
        if ( current_options.get_network_olk() ) {
            sgCoord fgdpos;
@@ -663,42 +678,42 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
 
     // update the view angle
     for ( i = 0; i < multi_loop; i++ ) {
-       if ( fabs(current_view.get_goal_view_offset() - 
-                 current_view.get_view_offset()) < 0.05 )
+       if ( fabs(globals->get_current_view()->get_goal_view_offset() - 
+                 globals->get_current_view()->get_view_offset()) < 0.05 )
        {
-           current_view.set_view_offset( current_view.get_goal_view_offset() );
+           globals->get_current_view()->set_view_offset( globals->get_current_view()->get_goal_view_offset() );
            break;
        } else {
            // move current_view.view_offset towards current_view.goal_view_offset
-           if ( current_view.get_goal_view_offset() > 
-                current_view.get_view_offset() )
+           if ( globals->get_current_view()->get_goal_view_offset() > 
+                globals->get_current_view()->get_view_offset() )
             {
-               if ( current_view.get_goal_view_offset() - 
-                    current_view.get_view_offset() < FG_PI )
+               if ( globals->get_current_view()->get_goal_view_offset() - 
+                    globals->get_current_view()->get_view_offset() < FG_PI )
                 {
-                   current_view.inc_view_offset( 0.01 );
+                   globals->get_current_view()->inc_view_offset( 0.01 );
                } else {
-                   current_view.inc_view_offset( -0.01 );
+                   globals->get_current_view()->inc_view_offset( -0.01 );
                }
            } else {
-               if ( current_view.get_view_offset() - 
-                    current_view.get_goal_view_offset() < FG_PI )
+               if ( globals->get_current_view()->get_view_offset() - 
+                    globals->get_current_view()->get_goal_view_offset() < FG_PI )
                 {
-                   current_view.inc_view_offset( -0.01 );
+                   globals->get_current_view()->inc_view_offset( -0.01 );
                } else {
-                   current_view.inc_view_offset( 0.01 );
+                   globals->get_current_view()->inc_view_offset( 0.01 );
                }
            }
-           if ( current_view.get_view_offset() > FG_2PI ) {
-               current_view.inc_view_offset( -FG_2PI );
-           } else if ( current_view.get_view_offset() < 0 ) {
-               current_view.inc_view_offset( FG_2PI );
+           if ( globals->get_current_view()->get_view_offset() > FG_2PI ) {
+               globals->get_current_view()->inc_view_offset( -FG_2PI );
+           } else if ( globals->get_current_view()->get_view_offset() < 0 ) {
+               globals->get_current_view()->inc_view_offset( FG_2PI );
            }
        }
     }
 
     double tmp = -(l->sun_rotation + FG_PI) 
-       - (cur_fdm_state->get_Psi() - current_view.get_view_offset() );
+       - (cur_fdm_state->get_Psi() - globals->get_current_view()->get_view_offset() );
     while ( tmp < 0.0 ) {
        tmp += FG_2PI;
     }
@@ -1113,20 +1128,20 @@ static void fgIdleFunction ( void ) {
 // Handle new window size or exposure
 void fgReshape( int width, int height ) {
     if ( ! fgPanelVisible() || idle_state != 1000 ) {
-       current_view.set_win_ratio( (float)height / (float)width );
+       globals->get_current_view()->set_win_ratio( (float)height / (float)width );
        glViewport(0, 0 , (GLint)(width), (GLint)(height) );
     } else {
         int view_h =
          int((current_panel->getViewHeight() - current_panel->getYOffset())
              * (height / 768.0)) + 1;
-       current_view.set_win_ratio( (float)view_h / (float)width );
+       globals->get_current_view()->set_win_ratio( (float)view_h / (float)width );
        glViewport(0, (GLint)(height - view_h),
                   (GLint)(width), (GLint)(view_h) );
     }
 
-    current_view.set_winWidth( width );
-    current_view.set_winHeight( height );
-    current_view.force_update_fov_math();
+    globals->get_current_view()->set_winWidth( width );
+    globals->get_current_view()->set_winHeight( height );
+    globals->get_current_view()->force_update_fov_math();
 
     // set these fov to be the same as in fgRenderFrame()
     // float x_fov = current_options.get_fov();
@@ -1136,7 +1151,7 @@ void fgReshape( int width, int height ) {
     // glViewport ( 0, 0, width, height );
     float fov = current_options.get_fov();
     // ssgSetFOV(fov * current_view.get_win_ratio(), fov);
-    ssgSetFOV(fov, fov * current_view.get_win_ratio());
+    ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
 
     fgHUDReshape();
 
@@ -1144,7 +1159,7 @@ void fgReshape( int width, int height ) {
        // yes we've finished all our initializations and are running
        // the main loop, so this will now work without seg faulting
        // the system.
-       current_view.UpdateViewParams(cur_view_fdm);
+       globals->get_current_view()->UpdateViewParams(cur_view_fdm);
     }
 }
 
@@ -1313,7 +1328,11 @@ int main( int argc, char **argv ) {
     globals = new FGGlobals;
     SGRoute *route = new SGRoute;
     globals->set_route( route );
-
+    FGViewer *pv = new FGViewer;
+    globals->set_pilot_view( pv );
+    FGViewer *cv = new FGViewer;
+    globals->set_current_view( cv );
+    
     // Load the configuration parameters
     if ( !fgInitConfig(argc, argv) ) {
        FG_LOG( FG_GENERAL, FG_ALERT, "Config option parsing failed ..." );
@@ -1451,14 +1470,16 @@ int main( int argc, char **argv ) {
                   globals->get_ephem()->getNumStars(),
                   globals->get_ephem()->getStars(), 60000.0 );
 
-    thesky->add_cloud_layer( 2600.0, 200.0, 50.0, 40000.0,
-                            SG_CLOUD_MOSTLY_SUNNY );
-    thesky->add_cloud_layer( 6000.0, 20.0, 10.0, 40000.0,
-                            SG_CLOUD_CIRRUS );
-
-    // thesky->add_cloud_layer( 1000.0, 200.0, 50.0, SG_CLOUD_MOSTLY_SUNNY );
-    // thesky->add_cloud_layer( 1800.0, 400.0, 100.0, SG_CLOUD_OVERCAST );
-    // thesky->add_cloud_layer( 5000.0, 20.0, 10.0, SG_CLOUD_CIRRUS );
+    if ( current_options.get_clouds() == true ) {
+       thesky->add_cloud_layer( 2600.0, 200.0, 50.0, 40000.0,
+                                SG_CLOUD_MOSTLY_SUNNY );
+       thesky->add_cloud_layer( 6000.0, 20.0, 10.0, 40000.0,
+                                SG_CLOUD_CIRRUS );
+       // thesky->add_cloud_layer( 1000.0, 200.0, 50.0,
+       //                          SG_CLOUD_MOSTLY_SUNNY );
+       // thesky->add_cloud_layer( 1800.0, 400.0, 100.0, SG_CLOUD_OVERCAST );
+       // thesky->add_cloud_layer( 5000.0, 20.0, 10.0, SG_CLOUD_CIRRUS );
+    }
 
     // Initialize MagVar model
     SGMagVar *magvar = new SGMagVar();
@@ -1497,6 +1518,10 @@ int main( int argc, char **argv ) {
     penguin_sel->clrTraversalMaskBits( SSGTRAV_HOT );
     scene->addKid( penguin_sel );
 
+    // $$$ begin - added VS Renganthan 17 Oct 2K
+    fgLoadDCS();
+    // $$$ end - added VS Renganthan 17 Oct 2K
+
 #ifdef FG_NETWORK_OLK
     // Do the network intialization
     if ( current_options.get_network_olk() ) {
@@ -1514,3 +1539,118 @@ int main( int argc, char **argv ) {
     // etc.
     return 0;
 }
+
+
+// $$$ end - added VS Renganathan, 15 Oct 2K
+void fgLoadDCS(void) {
+
+    double obj_lat,obj_lon,obj_alt;
+    int i = 1;
+    string obj_filename;
+
+    FGPath tile_path( current_options.get_fg_root());
+    tile_path.append( "Scenery" );
+    tile_path.append( "Objects.txt" );
+    fg_gzifstream in( tile_path.str() );
+    if ( ! in.is_open() ) {
+       FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << tile_path.str() );
+    }
+
+    FGPath modelpath( current_options.get_fg_root() );
+    modelpath.append( "Models" );
+    modelpath.append( "Geometry" );
+  
+    FGPath texturepath( current_options.get_fg_root() );
+    texturepath.append( "Models" );
+    texturepath.append( "Textures" );
+    ssgModelPath( (char *)modelpath.c_str() );
+    ssgTexturePath( (char *)texturepath.c_str() );
+
+    // while ( ! in.eof() ) {
+    //     in >> obj_filename >> obj_lat >> obj_lon >> obj_alt;
+    //     totalDCSobj = totalDCSobj+1;
+
+    ship_sel = new ssgSelector;
+    ship_pos = new ssgTransform;
+    ssgEntity *ship_obj = ssgLoadOBJ( "saratoga.obj" );
+    if ( ship_obj != NULL ) {
+       ship_pos->addKid( ship_obj ); // add object to transform node
+       ship_sel->addKid( ship_pos ); // add transform node to selector
+       // ssgFlatten( ship_obj );
+       // ssgStripify( ship_sel );
+       ship_sel->clrTraversalMaskBits( SSGTRAV_HOT );
+       scene->addKid( ship_sel ); //add selector node to root node
+    } else {
+       FG_LOG( FG_TERRAIN, FG_ALERT, "Cannot open file: " << "saratoga.obj" );
+    }
+
+    //     if (in.eof()) break;
+
+    // } // while
+    return;
+}
+
+
+void fgUpdateDCS (void) {
+
+    double eye_lat,eye_lon,eye_alt;
+    static double obj_lat=15.377603*DEG_TO_RAD;
+    static double obj_lon= 73.816436*DEG_TO_RAD;
+    static double obj_alt=0.15;
+    static double obj_head;
+    double sl_radius,obj_latgc;
+    float nresultmat[4][4];
+    sgMat4 Trans,rothead,rotlon,rot180,rotlat,resultmat1,resultmat2,resultmat3;
+    double bz[3];
+
+    obj_lat = obj_lat + 0.0000001;
+
+    // Instantaneous Geodetic Lat/Lon/Alt of moving object
+    //    obj_lon = current_aircraft.fdm_state->get_aux5()*DEG_TO_RAD;
+    //    obj_lat = current_aircraft.fdm_state->get_aux6()*DEG_TO_RAD;
+    //    obj_alt = current_aircraft.fdm_state->get_aux7();
+         
+    // Geodetic to Geocentric angles for rotation
+    sgGeodToGeoc(obj_lat,obj_alt,&sl_radius,&obj_latgc);
+
+    // moving object gbs-posn in cartesian coords
+    Point3D obj_posn = Point3D( obj_lon,obj_lat,obj_alt);
+    Point3D obj_pos = sgGeodToCart( obj_posn );
+
+    // Translate moving object w.r.t eye
+    Point3D Objtrans = obj_pos-scenery.center;
+    bz[0]=Objtrans.x();
+    bz[1]=Objtrans.y();
+    bz[2]=Objtrans.z();
+
+    // rotate dynamic objects for lat,lon & alt and other motion about its axes
+    if ( ship_sel != NULL ) {
+       ship_sel->select(1);
+       
+       sgMat4 sgTRANS;
+       sgMakeTransMat4( sgTRANS, bz[0],bz[1],bz[2]);
+
+       sgVec3 ship_fwd,ship_rt,ship_up;
+       sgSetVec3( ship_fwd, 1.0, 0.0, 0.0);//east,roll
+       sgSetVec3( ship_rt, 0.0, 1.0, 0.0);//up,pitch
+       sgSetVec3( ship_up, 0.0, 0.0, 1.0); //north,yaw
+
+       sgMat4 sgROT_lon, sgROT_lat, sgROT_hdg;
+       sgMakeRotMat4( sgROT_lon, obj_lon*RAD_TO_DEG, ship_up );
+       sgMakeRotMat4( sgROT_lat, 90-obj_latgc*RAD_TO_DEG, ship_rt );
+       sgMakeRotMat4( sgROT_hdg, 180.0, ship_up );
+       
+       sgMat4 sgTUX;
+       sgCopyMat4( sgTUX, sgROT_hdg );
+       sgPostMultMat4( sgTUX, sgROT_lat );
+       sgPostMultMat4( sgTUX, sgROT_lon );
+       sgPostMultMat4( sgTUX, sgTRANS );
+
+       sgCoord shippos;
+       sgSetCoord( &shippos, sgTUX );
+       ship_pos->setTransform( &shippos );
+    }
+}
+
+// $$$ end - added VS Renganathan, 15 Oct 2K
index 4cf73e7779ffa3a3b40efa08c8736502376c4751..9bdf21b48832382478c480ffbd1fa51e104f8cd6 100644 (file)
@@ -56,7 +56,6 @@ bool global_fullscreen = true;
 #include "fg_init.hxx"
 #include "globals.hxx"
 #include "options.hxx"
-#include "views.hxx"
 
 FG_USING_STD(string);
 FG_USING_NAMESPACE(std);
@@ -188,6 +187,7 @@ fgOPTIONS::fgOPTIONS() :
     ysize(600),
     bpp(16),
     view_mode(FG_VIEW_PILOT),
+    default_view_offset(0),
 
     // Scenery options
     tile_diameter(5),
@@ -268,7 +268,8 @@ fgOPTIONS::toggle_panel() {
     } */
 
     // fgReshape( xsize, ysize);
-    fgReshape( current_view.get_winWidth(), current_view.get_winHeight() );
+    fgReshape( globals->get_current_view()->get_winWidth(),
+              globals->get_current_view()->get_winHeight() );
 
     if( !freeze )
         globals->set_freeze( false );
@@ -522,7 +523,9 @@ int
 fgOPTIONS::parse_fdm( const string& fm ) {
     // cout << "fdm = " << fm << endl;
 
-    if ( fm == "balloon" ) {
+    if ( fm == "ada" ) {
+       return FGInterface::FG_ADA;
+    } else if ( fm == "balloon" ) {
        return FGInterface::FG_BALLOONSIM;
     } else if ( fm == "external" ) {
        return FGInterface::FG_EXTERNAL;
@@ -896,6 +899,20 @@ int fgOPTIONS::parse_option( const string& arg ) {
        current_properties.setStringValue(name.c_str(), value);
        FG_LOG(FG_GENERAL, FG_INFO, "Setting default value of property "
               << name << " to \"" << value << '"');
+    // $$$ begin - added VS Renganathan, 14 Oct 2K
+    // for multi-window outside window imagery
+    } else if ( arg.find( "--view-offset=" ) != string::npos ) {
+       string woffset = arg.substr( 14 );
+       if ( woffset == "LEFT" ) {
+              default_view_offset = M_PI * 0.25;
+       } else if ( woffset == "RIGHT" ) {
+           default_view_offset = M_PI * 1.75;
+       } else if ( woffset == "CENTER" ) {
+           default_view_offset = 0.00;
+       } else {
+           default_view_offset = atof( woffset.c_str() ) * DEG_TO_RAD;
+       }
+    // $$$ end - added VS Renganathan, 14 Oct 2K
     } else if ( arg.find( "--wp=" ) != string::npos ) {
        parse_wp( arg.substr( 5 ) );
     } else {
@@ -1069,7 +1086,8 @@ void fgOPTIONS::usage ( void ) {
  
     cout << "Flight Model:" << endl;
     cout << "\t--fdm=abcd:  selects the core flight model code." << endl;
-    cout << "\t\tcan be one of jsb, larcsim, magic, or external" << endl;
+    cout << "\t\tcan be one of jsb, larcsim, magic, external, balloon, or ada"
+        << endl;
     cout << "\t--aircraft=abcd:  aircraft model to load" << endl;
     cout << "\t--model-hz=n:  run the FDM this rate (iterations per second)" 
         << endl;
@@ -1126,6 +1144,11 @@ void fgOPTIONS::usage ( void ) {
     cout << "\t--enable-wireframe:  enable wireframe drawing mode" << endl;
     cout << "\t--geometry=WWWxHHH:  window geometry: 640x480, 800x600, etc."
         << endl;
+    cout << "\t--view-offset=xxx:  set the default forward view direction"
+        << endl;
+    cout << "\t\tas an offset from straight ahead.  Allowable values are"
+        << endl;
+    cout << "\t\tLEFT, RIGHT, CENTER, or a specific number of degrees" << endl;
     cout << endl;
 
     cout << "Scenery Options:" << endl;
index cf1df366c465b34eacab1acecec5c7e826331527..f17f524996a83cab08b13fdc65810a87844fefa7 100644 (file)
@@ -182,6 +182,8 @@ private:
     int xsize, ysize;   // window size derived from geometry string
     int bpp;            // bits per pixel
     fgViewMode view_mode; // view mode
+    double default_view_offset;        // default forward view offset (for use by
+                               // multi-display configuration
 
     // Scenery options
     int tile_radius;   // Square radius of rendered tiles (around center 
@@ -286,6 +288,11 @@ public:
     inline int get_ysize() const { return ysize; }
     inline int get_bpp() const { return bpp; }
     inline fgViewMode get_view_mode() const { return view_mode; }
+    inline double get_default_view_offset() const {
+       return default_view_offset;
+    }
+
+
     inline int get_tile_radius() const { return tile_radius; }
     inline int get_tile_diameter() const { return tile_diameter; }
 
index c56be67790f82d2d1a3ad5444edd328facc93b9f..3c1741428d9f95dbb5173cf1091c3c709acb29ea 100644 (file)
@@ -46,8 +46,8 @@
 #include <Main/options.hxx>
 #include <Objects/texload.h>
 
+#include "globals.hxx"
 #include "splash.hxx"
-#include "views.hxx"
 
 
 static GLuint splash_texid;
@@ -110,14 +110,15 @@ void fgSplashUpdate ( double progress ) {
     int xsize = 480;
     int ysize = 380;
 
-    if ( !current_view.get_winWidth() || !current_view.get_winHeight() ) {
+    if ( !globals->get_current_view()->get_winWidth()
+        || !globals->get_current_view()->get_winHeight() ) {
        return;
     }
 
-    xmin = (current_view.get_winWidth() - xsize) / 2;
+    xmin = (globals->get_current_view()->get_winWidth() - xsize) / 2;
     xmax = xmin + xsize;
 
-    ymin = (current_view.get_winHeight() - ysize) / 2;
+    ymin = (globals->get_current_view()->get_winHeight() - ysize) / 2;
     ymax = ymin + ysize;
 
     // first clear the screen;
@@ -128,7 +129,8 @@ void fgSplashUpdate ( double progress ) {
     xglMatrixMode(GL_PROJECTION);
     xglPushMatrix();
     xglLoadIdentity();
-    gluOrtho2D(0, current_view.get_winWidth(), 0, current_view.get_winHeight());
+    gluOrtho2D(0, globals->get_current_view()->get_winWidth(),
+              0, globals->get_current_view()->get_winHeight());
     xglMatrixMode(GL_MODELVIEW);
     xglPushMatrix();
     xglLoadIdentity();
diff --git a/src/Main/viewer.cxx b/src/Main/viewer.cxx
new file mode 100644 (file)
index 0000000..43da10f
--- /dev/null
@@ -0,0 +1,393 @@
+// viewer.cxx -- class for managing a viewer in the flightgear world.
+//
+// Written by Curtis Olson, started August 1997.
+//                          overhaul started October 2000.
+//
+// Copyright (C) 1997 - 2000  Curtis L. Olson  - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+
+#include <simgear/compiler.h>
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <plib/ssg.h>          // plib include
+
+#include <simgear/constants.h>
+#include <simgear/debug/logstream.hxx>
+#include <simgear/math/point3d.hxx>
+#include <simgear/math/polar3d.hxx>
+#include <simgear/math/vector.hxx>
+
+#include <Aircraft/aircraft.hxx>
+#include <Cockpit/panel.hxx>
+#include <Scenery/scenery.hxx>
+
+#include "options.hxx"
+#include "viewer.hxx"
+
+
+// Constructor
+FGViewer::FGViewer( void ) {
+}
+
+#define USE_FAST_VIEWROT
+#ifdef USE_FAST_VIEWROT
+// VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
+// This takes advantage of the fact that VIEWo and VIEW_OFFSET
+// only have entries in the upper 3x3 block
+// and that LARC_TO_SSG is just a shift of rows   NHV
+inline static void fgMakeViewRot( sgMat4 dst, const sgMat4 m1, const sgMat4 m2 )
+{
+    for ( int j = 0 ; j < 3 ; j++ ) {
+       dst[2][j] = m2[0][0] * m1[0][j] +
+           m2[0][1] * m1[1][j] +
+           m2[0][2] * m1[2][j];
+
+       dst[0][j] = m2[1][0] * m1[0][j] +
+           m2[1][1] * m1[1][j] +
+           m2[1][2] * m1[2][j];
+
+       dst[1][j] = m2[2][0] * m1[0][j] +
+           m2[2][1] * m1[1][j] +
+           m2[2][2] * m1[2][j];
+    }
+    dst[0][3] = 
+       dst[1][3] = 
+       dst[2][3] = 
+       dst[3][0] = 
+       dst[3][1] = 
+       dst[3][2] = SG_ZERO;
+    dst[3][3] = SG_ONE;
+}
+#endif
+
+// Initialize a view structure
+void FGViewer::Init( void ) {
+    FG_LOG( FG_VIEW, FG_INFO, "Initializing View parameters" );
+
+    view_offset = goal_view_offset = current_options.get_default_view_offset();
+    sgSetVec3( pilot_offset, 0.0, 0.0, 0.0 );
+
+    winWidth = current_options.get_xsize();
+    winHeight = current_options.get_ysize();
+
+    set_win_ratio( winHeight / winWidth );
+
+#ifndef USE_FAST_VIEWROT
+    // This never changes -- NHV
+    LARC_TO_SSG[0][0] = 0.0; 
+    LARC_TO_SSG[0][1] = 1.0; 
+    LARC_TO_SSG[0][2] = -0.0; 
+    LARC_TO_SSG[0][3] = 0.0; 
+
+    LARC_TO_SSG[1][0] = 0.0; 
+    LARC_TO_SSG[1][1] = 0.0; 
+    LARC_TO_SSG[1][2] = 1.0; 
+    LARC_TO_SSG[1][3] = 0.0;
+       
+    LARC_TO_SSG[2][0] = 1.0; 
+    LARC_TO_SSG[2][1] = -0.0; 
+    LARC_TO_SSG[2][2] = 0.0; 
+    LARC_TO_SSG[2][3] = 0.0;
+       
+    LARC_TO_SSG[3][0] = 0.0; 
+    LARC_TO_SSG[3][1] = 0.0; 
+    LARC_TO_SSG[3][2] = 0.0; 
+    LARC_TO_SSG[3][3] = 1.0; 
+#endif // USE_FAST_VIEWROT
+
+    force_update_fov_math();
+}
+
+
+#define USE_FAST_LOCAL
+#ifdef USE_FAST_LOCAL
+inline static void fgMakeLOCAL( sgMat4 dst, const double Theta,
+                               const double Phi, const double Psi)
+{
+    SGfloat cosTheta = (SGfloat) cos(Theta);
+    SGfloat sinTheta = (SGfloat) sin(Theta);
+    SGfloat cosPhi   = (SGfloat) cos(Phi);
+    SGfloat sinPhi   = (SGfloat) sin(Phi);
+    SGfloat sinPsi   = (SGfloat) sin(Psi) ;
+    SGfloat cosPsi   = (SGfloat) cos(Psi) ;
+       
+    dst[0][0] = cosPhi * cosTheta;
+    dst[0][1] =        sinPhi * cosPsi + cosPhi * -sinTheta * -sinPsi;
+    dst[0][2] =        sinPhi * sinPsi + cosPhi * -sinTheta * cosPsi;
+    dst[0][3] =        SG_ZERO;
+
+    dst[1][0] = -sinPhi * cosTheta;
+    dst[1][1] =        cosPhi * cosPsi + -sinPhi * -sinTheta * -sinPsi;
+    dst[1][2] =        cosPhi * sinPsi + -sinPhi * -sinTheta * cosPsi;
+    dst[1][3] = SG_ZERO ;
+       
+    dst[2][0] = sinTheta;
+    dst[2][1] =        cosTheta * -sinPsi;
+    dst[2][2] =        cosTheta * cosPsi;
+    dst[2][3] = SG_ZERO;
+       
+    dst[3][0] = SG_ZERO;
+    dst[3][1] = SG_ZERO;
+    dst[3][2] = SG_ZERO;
+    dst[3][3] = SG_ONE ;
+}
+#endif
+
+
+// Update the view volume, position, and orientation
+void FGViewer::UpdateViewParams( const FGInterface& f ) {
+    UpdateViewMath(f);
+    
+    if ( ! fgPanelVisible() ) {
+       xglViewport(0, 0 , (GLint)(winWidth), (GLint)(winHeight) );
+    } else {
+        int view_h =
+         int((current_panel->getViewHeight() - current_panel->getYOffset())
+             * (winHeight / 768.0));
+       glViewport(0, (GLint)(winHeight - view_h),
+                  (GLint)(winWidth), (GLint)(view_h) );
+    }
+}
+
+
+// convert sgMat4 to MAT3 and print
+static void print_sgMat4( sgMat4 &in) {
+    int i, j;
+    for ( i = 0; i < 4; i++ ) {
+       for ( j = 0; j < 4; j++ ) {
+           printf("%10.4f ", in[i][j]);
+       }
+       cout << endl;
+    }
+}
+
+
+// Update the view parameters
+void FGViewer::UpdateViewMath( const FGInterface& f ) {
+
+    Point3D p;
+    sgVec3 v0, minus_z, sgvec, forward;
+    sgMat4 VIEWo, TMP;
+
+    if ( update_fov ) {
+       ssgSetFOV( current_options.get_fov(), 
+                  current_options.get_fov() * win_ratio );
+       update_fov = false;
+    }
+               
+    scenery.center = scenery.next_center;
+
+    // printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x,
+    //        scenery.center.y, scenery.center.z);
+
+    // calculate the cartesion coords of the current lat/lon/0 elev
+    p = Point3D( f.get_Longitude(), 
+                f.get_Lat_geocentric(), 
+                f.get_Sea_level_radius() * FEET_TO_METER );
+
+    cur_zero_elev = sgPolarToCart3d(p) - scenery.center;
+
+    // calculate view position in current FG view coordinate system
+    // p.lon & p.lat are already defined earlier, p.radius was set to
+    // the sea level radius, so now we add in our altitude.
+    if ( f.get_Altitude() * FEET_TO_METER > 
+        (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
+       p.setz( p.radius() + f.get_Altitude() * FEET_TO_METER );
+    } else {
+       p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
+    }
+
+    abs_view_pos = sgPolarToCart3d(p);
+       
+    view_pos = abs_view_pos - scenery.center;
+
+    FG_LOG( FG_VIEW, FG_DEBUG, "Polar view pos = " << p );
+    FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = " << abs_view_pos );
+    FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = " << view_pos );
+
+    // code to calculate LOCAL matrix calculated from Phi, Theta, and
+    // Psi (roll, pitch, yaw) in case we aren't running LaRCsim as our
+    // flight model
+       
+#ifdef USE_FAST_LOCAL
+       
+    fgMakeLOCAL( LOCAL, f.get_Theta(), f.get_Phi(), -f.get_Psi() );
+       
+#else // USE_TEXT_BOOK_METHOD
+       
+    sgVec3 rollvec;
+    sgSetVec3( rollvec, 0.0, 0.0, 1.0 );
+    sgMat4 PHI;                // roll
+    sgMakeRotMat4( PHI, f.get_Phi() * RAD_TO_DEG, rollvec );
+
+    sgVec3 pitchvec;
+    sgSetVec3( pitchvec, 0.0, 1.0, 0.0 );
+    sgMat4 THETA;              // pitch
+    sgMakeRotMat4( THETA, f.get_Theta() * RAD_TO_DEG, pitchvec );
+
+    // ROT = PHI * THETA
+    sgMat4 ROT;
+    // sgMultMat4( ROT, PHI, THETA );
+    sgCopyMat4( ROT, PHI );
+    sgPostMultMat4( ROT, THETA );
+
+    sgVec3 yawvec;
+    sgSetVec3( yawvec, 1.0, 0.0, 0.0 );
+    sgMat4 PSI;                // pitch
+    sgMakeRotMat4( PSI, -f.get_Psi() * RAD_TO_DEG, yawvec );
+
+    // LOCAL = ROT * PSI
+    // sgMultMat4( LOCAL, ROT, PSI );
+    sgCopyMat4( LOCAL, ROT );
+    sgPostMultMat4( LOCAL, PSI );
+
+#endif // YIKES
+       
+    // cout << "LOCAL matrix" << endl;
+    // print_sgMat4( LOCAL );
+       
+    sgMakeRotMat4( UP, 
+                  f.get_Longitude() * RAD_TO_DEG,
+                  0.0,
+                  -f.get_Latitude() * RAD_TO_DEG );
+
+    sgSetVec3( local_up, UP[0][0], UP[0][1], UP[0][2] );
+    // sgXformVec3( local_up, UP );
+    // cout << "Local Up = " << local_up[0] << "," << local_up[1] << ","
+    //      << local_up[2] << endl;
+    
+    // Alternative method to Derive local up vector based on
+    // *geodetic* coordinates
+    // alt_up = sgPolarToCart(FG_Longitude, FG_Latitude, 1.0);
+    // printf( "    Alt Up = (%.4f, %.4f, %.4f)\n", 
+    //         alt_up.x, alt_up.y, alt_up.z);
+
+    // VIEWo = LOCAL * UP
+    // sgMultMat4( VIEWo, LOCAL, UP );
+    sgCopyMat4( VIEWo, LOCAL );
+    sgPostMultMat4( VIEWo, UP );
+    // cout << "VIEWo matrix" << endl;
+    // print_sgMat4( VIEWo );
+
+    // generate the sg view up and forward vectors
+    sgSetVec3( view_up, VIEWo[0][0], VIEWo[0][1], VIEWo[0][2] );
+    // cout << "view = " << view[0] << ","
+    //      << view[1] << "," << view[2] << endl;
+    sgSetVec3( forward, VIEWo[2][0], VIEWo[2][1], VIEWo[2][2] );
+    // cout << "forward = " << forward[0] << ","
+    //      << forward[1] << "," << forward[2] << endl;
+
+    // generate the pilot offset vector in world coordinates
+    sgVec3 pilot_offset_world;
+    sgSetVec3( pilot_offset_world, 
+              pilot_offset[2], pilot_offset[1], -pilot_offset[0] );
+    sgXformVec3( pilot_offset_world, pilot_offset_world, VIEWo );
+
+    // generate the view offset matrix
+    sgMakeRotMat4( VIEW_OFFSET, view_offset * RAD_TO_DEG, view_up );
+    // cout << "VIEW_OFFSET matrix" << endl;
+    // print_sgMat4( VIEW_OFFSET );
+    sgXformVec3( view_forward, forward, VIEW_OFFSET );
+    // cout << "view_forward = " << view_forward[0] << ","
+    //      << view_forward[1] << "," << view_forward[2] << endl;
+       
+    // VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
+#ifdef USE_FAST_VIEWROT
+    fgMakeViewRot( VIEW_ROT, VIEW_OFFSET, VIEWo );
+#else
+    // sgMultMat4( VIEW_ROT, VIEW_OFFSET, VIEWo );
+    // sgPreMultMat4( VIEW_ROT, LARC_TO_SSG );
+    sgCopyMat4( VIEW_ROT, VIEWo );
+    sgPostMultMat4( VIEW_ROT, VIEW_OFFSET );
+    sgPreMultMat4( VIEW_ROT, LARC_TO_SSG );
+#endif
+    // cout << "VIEW_ROT matrix" << endl;
+    // print_sgMat4( VIEW_ROT );
+
+    sgVec3 trans_vec;
+    sgSetVec3( trans_vec, 
+              view_pos.x() + pilot_offset_world[0],
+              view_pos.y() + pilot_offset_world[1],
+              view_pos.z() + pilot_offset_world[2] );
+
+    // VIEW = VIEW_ROT * TRANS
+    sgCopyMat4( VIEW, VIEW_ROT );
+    sgPostMultMat4ByTransMat4( VIEW, trans_vec );
+
+    //!!!!!!!!!!!!!!!!!!!      
+    // THIS IS THE EXPERIMENTAL VIEWING ANGLE SHIFTER
+    // THE MAJORITY OF THE WORK IS DONE IN GUI.CXX
+    // this in gui.cxx for now just testing
+    extern float quat_mat[4][4];
+    sgPreMultMat4( VIEW, quat_mat);
+    // !!!!!!!!!! testing      
+
+    // make a vector to the current view position
+    sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
+
+    // Given a vector pointing straight down (-Z), map into onto the
+    // local plane representing "horizontal".  This should give us the
+    // local direction for moving "south".
+    sgSetVec3( minus_z, 0.0, 0.0, -1.0 );
+
+    sgmap_vec_onto_cur_surface_plane(local_up, v0, minus_z, surface_south);
+    sgNormalizeVec3(surface_south);
+    // cout << "Surface direction directly south " << surface_south[0] << ","
+    //      << surface_south[1] << "," << surface_south[2] << endl;
+
+    // now calculate the surface east vector
+#define USE_FAST_SURFACE_EAST
+#ifdef USE_FAST_SURFACE_EAST
+    sgVec3 local_down;
+    sgNegateVec3(local_down, local_up);
+    sgVectorProductVec3(surface_east, surface_south, local_down);
+#else
+#define USE_LOCAL_UP
+#ifdef USE_LOCAL_UP
+    sgMakeRotMat4( TMP, FG_PI_2 * RAD_TO_DEG, local_up );
+#else
+    sgMakeRotMat4( TMP, FG_PI_2 * RAD_TO_DEG, view_up );
+#endif // USE_LOCAL_UP
+    // cout << "sgMat4 TMP" << endl;
+    // print_sgMat4( TMP );
+    sgXformVec3(surface_east, surface_south, TMP);
+#endif //  USE_FAST_SURFACE_EAST
+    // cout << "Surface direction directly east " << surface_east[0] << ","
+    //      << surface_east[1] << "," << surface_east[2] << endl;
+    // cout << "Should be close to zero = "
+    //      << sgScalarProductVec3(surface_south, surface_east) << endl;
+}
+
+
+void FGViewer::CurrentNormalInLocalPlane(sgVec3 dst, sgVec3 src) {
+    sgVec3 tmp;
+    sgSetVec3(tmp, src[0], src[1], src[2] );
+    sgMat4 TMP;
+    sgTransposeNegateMat4 ( TMP, UP ) ;
+    sgXformVec3(tmp, tmp, TMP);
+    sgSetVec3(dst, tmp[2], tmp[1], tmp[0] );
+}
+
+
+// Destructor
+FGViewer::~FGViewer( void ) {
+}
diff --git a/src/Main/viewer.hxx b/src/Main/viewer.hxx
new file mode 100644 (file)
index 0000000..b42d4bb
--- /dev/null
@@ -0,0 +1,206 @@
+// viewer.hxx -- class for managing a viewer in the flightgear world.
+//
+// Written by Curtis Olson, started August 1997.
+//                          overhaul started October 2000.
+//
+// Copyright (C) 1997 - 2000  Curtis L. Olson  - curt@flightgear.org
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 2 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//
+// $Id$
+
+
+#ifndef _VIEWER_HXX
+#define _VIEWER_HXX
+
+
+#ifndef __cplusplus                                                          
+# error This library requires C++
+#endif                                   
+
+#include <simgear/compiler.h>
+#include <simgear/math/point3d.hxx>
+#include <simgear/timing/sg_time.hxx>
+
+#include <list>
+
+#include <plib/sg.h>           // plib include
+
+#include <FDM/flight.hxx>
+#include <Time/light.hxx>
+
+#include "options.hxx"
+
+FG_USING_STD(list);
+
+
+#define FG_FOV_MIN 0.1
+#define FG_FOV_MAX 179.9
+
+
+// Define a structure containing view information
+class FGViewer {
+
+private:
+
+    // the current view offset angle from forward (rotated about the
+    // view_up vector)
+    double view_offset;
+
+    // the goal view offset angle  (used for smooth view changes)
+    double goal_view_offset;
+
+    // flag forcing update of fov related stuff
+    bool update_fov;
+       
+    // fov of view is specified in the X direction, win_ratio is used to
+    // calculate the fov in the Y direction.  fov(y) = fov(x) * win_ratio
+    double win_ratio;
+
+    // width & height of window
+    int winWidth, winHeight;
+
+    // absolute view position in earth coordinates
+    Point3D abs_view_pos;
+
+    // view position in opengl world coordinates (this is the
+    // abs_view_pos translated to scenery.center)
+    Point3D view_pos;
+
+    // pilot offset from center of gravity.  The X axis is positive
+    // out the tail, Y is out the right wing, and Z is positive up.
+    // Distances in meters of course.
+    sgVec3 pilot_offset;
+
+    // cartesion coordinates of current lon/lat if at sea level
+    // translated to scenery.center
+    Point3D cur_zero_elev;
+
+    // vector in cartesian coordinates from current position to the
+    // postion on the earth's surface the sun is directly over
+    sgVec3 to_sun;
+
+    // surface direction to go to head towards sun
+    sgVec3 surface_to_sun;
+
+    // vector in cartesian coordinates from current position to the
+    // postion on the earth's surface the moon is directly over
+    sgVec3 to_moon;
+  
+    // surface direction to go to head towards moon
+    sgVec3 surface_to_moon;
+
+    // surface vector heading south
+    sgVec3 surface_south;
+
+    // surface vector heading east (used to unambiguously align sky
+    // with sun)
+    sgVec3 surface_east;
+
+    // local up vector (normal to the plane tangent to the earth's
+    // surface at the spot we are directly above
+    sgVec3 local_up;
+
+    // up vector for the view (usually point straight up through the
+    // top of the aircraft
+    sgVec3 view_up;
+
+    // the vector pointing straight out the nose of the aircraft
+    sgVec3 view_forward;
+
+    // Transformation matrix for eye coordinates to aircraft coordinates
+    // sgMat4 AIRCRAFT;
+
+    // Transformation matrix for the view direction offset relative to
+    // the AIRCRAFT matrix
+    sgMat4 VIEW_OFFSET;
+
+    // sg versions of our friendly matrices
+    sgMat4 LOCAL, UP, VIEW_ROT, TRANS, VIEW, LARC_TO_SSG;
+
+public:
+
+    // Constructor
+    FGViewer( void );
+
+    // Destructor
+    ~FGViewer( void );
+
+    // Initialize a view class
+    void Init( void );
+
+    // Update the view volume, position, and orientation
+    void UpdateViewParams( const FGInterface& f );
+
+    // Flag to request that UpdateFOV() be called next time
+    // UpdateViewMath() is run.
+    inline void force_update_fov_math() { update_fov = true; }
+
+    // Update the view parameters
+    void UpdateViewMath( const FGInterface& f );
+
+    // Update the field of view coefficients
+    void UpdateFOV( const fgOPTIONS& o );
+
+    // Transform a vector from world coordinates to the local plane
+    void CurrentNormalInLocalPlane(sgVec3 dst, sgVec3 src);
+
+    // accessor functions
+    inline double get_view_offset() const { return view_offset; }
+    inline void set_view_offset( double a ) { view_offset = a; }
+    inline void inc_view_offset( double amt ) { view_offset += amt; }
+    inline double get_goal_view_offset() const { return goal_view_offset; }
+    inline void set_goal_view_offset( double a) { goal_view_offset = a; }
+    inline double get_win_ratio() const { return win_ratio; }
+    inline void set_win_ratio( double r ) { win_ratio = r; }
+    inline int get_winWidth() const { return winWidth; }
+    inline void set_winWidth( int w ) { winWidth = w; }
+    inline int get_winHeight() const { return winHeight; }
+    inline void set_winHeight( int h ) { winHeight = h; }
+    inline Point3D get_abs_view_pos() const { return abs_view_pos; }
+    inline Point3D get_view_pos() const { return view_pos; }
+    inline float *get_pilot_offset() { return pilot_offset; }
+    inline void set_pilot_offset( float x, float y, float z ) {
+       sgSetVec3( pilot_offset, x, y, z );
+    }
+    inline Point3D get_cur_zero_elev() const { return cur_zero_elev; }
+    inline float *get_to_sun() { return to_sun; }
+    inline void set_to_sun( float x, float y, float z ) {
+       sgSetVec3( to_sun, x, y, z );
+    }
+    inline float *get_surface_to_sun() { return surface_to_sun; }
+    inline void set_surface_to_sun( float x, float y, float z) {
+       sgSetVec3( surface_to_sun, x, y, z );
+    }
+    inline float *get_to_moon() { return to_moon; }
+    inline void set_to_moon( float x, float y, float z) {
+       sgSetVec3( to_moon, x, y, z );
+    }
+    inline float *get_surface_to_moon() { return surface_to_moon; }
+    inline void set_surface_to_moon( float x, float y, float z) {
+       sgSetVec3( surface_to_moon, x, y, z );
+    }
+    inline float *get_surface_south() { return surface_south; }
+    inline float *get_surface_east() { return surface_east; }
+    inline float *get_local_up() { return local_up; }
+    inline float *get_view_forward() { return view_forward; }
+
+    inline const sgVec4 *get_VIEW() { return VIEW; }
+    inline const sgVec4 *get_VIEW_ROT() { return VIEW_ROT; }
+};
+
+#endif // _VIEWER_HXX
+
+
index 91118cf8e3544259d27f88ae51fe8a15021695bb..1045b7b227ccb85303f832e75d3c252f8afb32d5 100644 (file)
@@ -21,6 +21,8 @@
 //
 // $Id$
 
+#error do not compile me
+
 #include <simgear/compiler.h>
 
 #ifdef HAVE_CONFIG_H
index 30ea41c38c73decff77c29d75516c8fe68a05bc6..6f5e1fd7e1657c7d1fcb1788bf9dbd1ec66754c1 100644 (file)
@@ -24,6 +24,7 @@
 #ifndef _VIEWS_HXX
 #define _VIEWS_HXX
 
+#error do not include me!
 
 #ifndef __cplusplus                                                          
 # error This library requires C++
@@ -70,10 +71,11 @@ public:
     // width & height of window
     int winWidth, winHeight;
 
-    // absolute view position
+    // absolute view position in earth coordinates
     Point3D abs_view_pos;
 
-    // view position translated to scenery.center
+    // view position in opengl world coordinates (this is the
+    // abs_view_pos translated to scenery.center)
     Point3D view_pos;
 
     // pilot offset from center of gravity.  The X axis is positive
index 891e6f6aedfe7c00f201b33bc7425c01cc1f5b80..a8e5204ae30bc8048832c3b15b7248d542788b3c 100644 (file)
@@ -40,7 +40,7 @@
 
 #include <Cockpit/hud.hxx>
 #include <plib/ssg.h>
-#include <Main/views.hxx>
+#include <Main/globals.hxx>
 
 //#define printf //
 
@@ -208,7 +208,7 @@ int list_not_in( char name[16]) {
    return i;
 }
 
-void fgd_print_Mat4( sgMat4 m ) {
+void fgd_print_Mat4( const sgMat4 m ) {
     printf("0.0 %f 0.1 %f 0.2 %f 0.3 %f\n", 
     m[0][0], m[0][1], m[0][2], m[0][3] );
     printf("1.0 %f 1.1 %f 1.2 %f 1.3 %f\n", 
@@ -286,7 +286,7 @@ void fgd_init(void){
 
 int net_resolv_fgd( char *fgd_host_check ) {
 
-char *fgd_ip_check;
+   char *fgd_ip_check = "";
 
 /* resolving the destination host, here fgd's host */   
    net_r = 0;
@@ -389,11 +389,11 @@ void fgd_send_com( char *FGD_com, char *FGFS_host) {
 
 /* Here sending the previously calculated view.Mat4 by FGFS */
         case 17: if (verbose == 2) printf("Checkpoint\n");
-                 sgCopyMat4(sgFGD_COORD, current_view.VIEW);
+                 sgCopyMat4(sgFGD_COORD, globals->get_current_view()->get_VIEW());
 
                  if (verbose == 2) {
                     printf("current_view\n");
-                    fgd_print_Mat4( current_view.VIEW);
+                    fgd_print_Mat4( globals->get_current_view()->get_VIEW());
                     printf("FGD_COORD\n");
                     fgd_print_Mat4( sgFGD_COORD);
                  }
index 5dbdbf139e6dfd88103c09cfb0b97d5017aa83e3..0597f1eeeeabb709d5f34eba76ead2722cd5fb42 100644 (file)
@@ -47,7 +47,6 @@
 
 #include <Include/general.hxx>
 #include <Main/options.hxx>
-#include <Main/views.hxx>
 #include <Scenery/tileentry.hxx>
 
 #include "matlib.hxx"
index db2d98c6ec1cbbb9b2573e8f68dbef728dd615d2..fb182fb5db23513d714c00fb52624bbb3fe9471b 100644 (file)
@@ -39,8 +39,8 @@
 #include <simgear/misc/fgstream.hxx>
 #include <simgear/misc/fgpath.hxx>
 
+#include <Main/globals.hxx>
 #include <Main/options.hxx>
-#include <Main/views.hxx>
 #include <Objects/obj.hxx>
 #include <Scenery/scenery.hxx>  // for scenery.center
 
@@ -283,7 +283,7 @@ FGTileCache::next_avail( void )
            return(i);
        } else if ( tile_cache[i].is_loaded() || tile_cache[i].is_cached() ) {
            // calculate approximate distance from view point
-           abs_view_pos = current_view.get_abs_view_pos();
+           abs_view_pos = globals->get_current_view()->get_abs_view_pos();
 
            FG_LOG( FG_TERRAIN, FG_DEBUG,
                    "DIST Abs view pos = " << abs_view_pos );
index 6a9e1fd62cd97f6a53e44b236f6f9880bb009dd9..b8c199fa07acab93fd58d9440d840f3ad815491b 100644 (file)
@@ -40,8 +40,8 @@
 #include <simgear/math/vector.hxx>
 
 // #include <Aircraft/aircraft.hxx>
+#include <Main/globals.hxx>
 #include <Main/options.hxx>
-#include <Main/views.hxx>
 #include <Objects/obj.hxx>
 
 #ifndef FG_OLD_WEATHER
@@ -194,14 +194,14 @@ FGTileMgr::current_elev_ssg( const Point3D& abs_view_pos,
        sgSetVec3(tmp, hit_list.get_normal(this_hit));
        ssgState *IntersectedLeafState =
            ((ssgLeaf*)hit_list.get_entity(this_hit))->getState();
-       current_view.CurrentNormalInLocalPlane(tmp, tmp);
+       globals->get_current_view()->CurrentNormalInLocalPlane(tmp, tmp);
        sgdSetVec3( scenery.cur_normal, tmp );
        // cout << "NED: " << tmp[0] << " " << tmp[1] << " " << tmp[2] << endl;
        return true;
     } else {
        FG_LOG( FG_TERRAIN, FG_INFO, "no terrain intersection" );
        scenery.cur_elev = 0.0;
-       float *up = current_view.local_up;
+       float *up = globals->get_current_view()->get_local_up();
        sgdSetVec3(scenery.cur_normal, up[0], up[1], up[2]);
        return false;
     }
@@ -473,8 +473,8 @@ int FGTileMgr::update( double lon, double lat ) {
     } else {
        // cout << "abs view pos = " << current_view.abs_view_pos
        //      << " view pos = " << current_view.view_pos << endl;
-       current_elev_ssg( current_view.abs_view_pos,
-                         current_view.view_pos );
+       current_elev_ssg( globals->get_current_view()->get_abs_view_pos(),
+                         globals->get_current_view()->get_view_pos() );
     }
 
     // cout << "current elevation (ssg) == " << scenery.cur_elev << endl;
index ce92e9d42b8e661f5c4274fc8c33dbeec3f44734..de37b91490d207586b6445bda016b20d8e5ae6f8 100644 (file)
@@ -55,8 +55,8 @@ FG_USING_STD(string);
 #include <simgear/misc/fgpath.hxx>
 
 #include <Aircraft/aircraft.hxx>
+#include <Main/globals.hxx>
 #include <Main/options.hxx>
-#include <Main/views.hxx>
 
 #include "light.hxx"
 #include "sunpos.hxx"
@@ -169,7 +169,7 @@ void fgLIGHT::UpdateAdjFog( void ) {
     // first determine the difference between our view angle and local
     // direction to the sun
     rotation = -(sun_rotation + FG_PI) 
-       - (f->get_Psi() - current_view.get_view_offset());
+       - (f->get_Psi() - globals->get_current_view()->get_view_offset());
     while ( rotation < 0 ) {
        rotation += FG_2PI;
     }
index 62274e91523b49ad4c23cb8c682c951ecc1099aa..23c6524c92ff3b3626f01e3cf5b53a16049e1432 100644 (file)
@@ -60,7 +60,6 @@
 #include <simgear/math/vector.hxx>
 
 #include <Main/globals.hxx>
-#include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
 
 #include "moonpos.hxx"
@@ -334,7 +333,7 @@ static void fgMoonPositionGST(double gst, double *lon, double *lat) {
 // update the cur_time_params structure with the current moon position
 void fgUpdateMoonPos( void ) {
     fgLIGHT *l;
-    FGView *v;
+    FGViewer *v;
     sgVec3 nup, nmoon, v0, surface_to_moon;
     Point3D p, rel_moonpos;
     double dot, east_dot;
@@ -342,7 +341,7 @@ void fgUpdateMoonPos( void ) {
 
     l = &cur_light_params;
     SGTime *t = globals->get_time_params();
-    v = &current_view;
+    v = globals->get_current_view();
 
     FG_LOG( FG_EVENT, FG_INFO, "  Updating Moon position" );
 
index 0d5ca70669f78f98a716061a43036c2c9f814ab6..45cf9e3e175481a1b5474473ddc6208146f287b3 100644 (file)
@@ -62,7 +62,6 @@
 #include <simgear/math/vector.hxx>
 
 #include <Main/globals.hxx>
-#include <Main/views.hxx>
 #include <Scenery/scenery.hxx>
 
 #include "sunpos.hxx"
@@ -243,7 +242,7 @@ static void fgSunPositionGST(double gst, double *lon, double *lat) {
 // update the cur_time_params structure with the current sun position
 void fgUpdateSunPos( void ) {
     fgLIGHT *l;
-    FGView *v;
+    FGViewer *v;
     sgVec3 nup, nsun, v0, surface_to_sun;
     Point3D p, rel_sunpos;
     double dot, east_dot;
@@ -251,7 +250,7 @@ void fgUpdateSunPos( void ) {
 
     l = &cur_light_params;
     SGTime *t = globals->get_time_params();
-    v = &current_view;
+    v = globals->get_current_view();
 
     FG_LOG( FG_EVENT, FG_INFO, "  Updating Sun position" );
     FG_LOG( FG_EVENT, FG_INFO, "  Gst = " << t->getGst() );