1 /**************************************************************************
2 * cockpit.c -- routines to draw a cockpit (initial draft)
4 * Written by Michele America, started September 1997.
6 * Copyright (C) 1997 Michele F. America - nomimarketing@mail.telepac.pt
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 * (Log is kept at end of this file)
24 **************************************************************************/
39 #include <Aircraft/aircraft.h>
40 #include <Debug/fg_debug.h>
41 #include <Include/fg_constants.h>
42 #include <Include/general.h>
43 #include <Main/options.hxx>
44 #include <Math/fg_random.h>
45 #include <Math/mat3.h>
46 #include <Math/polar3d.h>
47 #include <Scenery/scenery.hxx>
48 #include <Time/fg_timer.hxx>
49 #include <Weather/weather.h>
51 #include "cockpit.hxx"
54 // This is a structure that contains all data related to
55 // cockpit/panel/hud system
57 static pCockpit ac_cockpit;
59 // The following routines obtain information concerntin the aircraft's
60 // current state and return it to calling instrument display routines.
61 // They should eventually be member functions of the aircraft.
64 double get_throttleval( void )
66 fgCONTROLS *pcontrols;
68 pcontrols = current_aircraft.controls;
69 return pcontrols->throttle[0]; // Hack limiting to one engine
72 double get_aileronval( void )
74 fgCONTROLS *pcontrols;
76 pcontrols = current_aircraft.controls;
77 return pcontrols->aileron;
80 double get_elevatorval( void )
82 fgCONTROLS *pcontrols;
84 pcontrols = current_aircraft.controls;
85 return pcontrols->elevator;
88 double get_elev_trimval( void )
90 fgCONTROLS *pcontrols;
92 pcontrols = current_aircraft.controls;
93 return pcontrols->elevator_trim;
96 double get_rudderval( void )
98 fgCONTROLS *pcontrols;
100 pcontrols = current_aircraft.controls;
101 return pcontrols->rudder;
104 double get_speed( void )
108 f = current_aircraft.flight;
109 return( FG_V_equiv_kts ); // Make an explicit function call.
112 double get_aoa( void )
116 f = current_aircraft.flight;
117 return( FG_Gamma_vert_rad * RAD_TO_DEG );
120 double get_roll( void )
124 f = current_aircraft.flight;
128 double get_pitch( void )
132 f = current_aircraft.flight;
136 double get_heading( void )
140 f = current_aircraft.flight;
141 return( FG_Psi * RAD_TO_DEG );
144 double get_altitude( void )
147 // double rough_elev;
149 f = current_aircraft.flight;
150 // rough_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
151 // FG_Latitude * RAD_TO_ARCSEC);
153 return( FG_Altitude * FEET_TO_METER /* -rough_elev */ );
156 double get_sideslip( void )
160 f = current_aircraft.flight;
165 double get_frame_rate( void )
171 return g->frame_rate;
174 double get_fov( void )
178 o = ¤t_options;
183 bool fgCockpitInit( fgAIRCRAFT *cur_aircraft )
185 fgPrintf( FG_COCKPIT, FG_INFO, "Initializing cockpit subsystem\n");
187 // cockpit->code = 1; /* It will be aircraft dependent */
188 // cockpit->status = 0;
190 // If aircraft has HUD specified we will get the specs from its def
191 // file. For now we will depend upon hard coding in hud?
193 // We must insure that the existing instrument link is purged.
194 // This is done by deleting the links in the list.
196 // HI_Head is now a null pointer so we can generate a new list from the
199 fgHUDInit( cur_aircraft );
200 ac_cockpit = new fg_Cockpit();
202 fgPrintf( FG_COCKPIT, FG_INFO,
203 " Code %d Status %d\n",
204 ac_cockpit->code(), ac_cockpit->status() );
209 void fgCockpitUpdate( void )
212 fgPrintf( FG_COCKPIT, FG_DEBUG,
213 "Cockpit: code %d status %d\n",
214 ac_cockpit->code(), ac_cockpit->status() );
215 fgUpdateHUD(); // This will check the global hud linked list pointer.
216 // If these is anything to draw it will.
220 /* Revision 1.6 1998/05/13 18:27:53 curt
221 /* Added an fov to hud display.
223 * Revision 1.5 1998/05/11 18:13:10 curt
224 * Complete C++ rewrite of all cockpit code by Charlie Hotchkiss.
226 * Revision 1.4 1998/05/03 00:46:45 curt
227 * polar.h -> polar3d.h
229 * Revision 1.3 1998/04/30 12:36:02 curt
230 * C++-ifying a couple source files.
232 * Revision 1.2 1998/04/25 22:06:26 curt
233 * Edited cvs log messages in source files ... bad bad bad!
235 * Revision 1.1 1998/04/24 00:45:54 curt
236 * C++-ifing the code a bit.
238 * Revision 1.13 1998/04/18 04:14:01 curt
239 * Moved fg_debug.c to it's own library.
241 * Revision 1.12 1998/04/14 02:23:09 curt
242 * Code reorganizations. Added a Lib/ directory for more general libraries.
244 * Revision 1.11 1998/03/14 00:32:13 curt
245 * Changed a printf() to a fgPrintf().
247 * Revision 1.10 1998/02/07 15:29:33 curt
248 * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
249 * <chotchkiss@namg.us.anritsu.com>
251 * Revision 1.9 1998/02/03 23:20:14 curt
252 * Lots of little tweaks to fix various consistency problems discovered by
253 * Solaris' CC. Fixed a bug in fg_debug.c with how the fgPrintf() wrapper
254 * passed arguments along to the real printf(). Also incorporated HUD changes
255 * by Michele America.
257 * Revision 1.8 1998/01/31 00:43:03 curt
258 * Added MetroWorks patches from Carmen Volpe.
260 * Revision 1.7 1998/01/27 00:47:51 curt
261 * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
262 * system and commandline/config file processing code.
264 * Revision 1.6 1998/01/19 19:27:01 curt
265 * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
266 * This should simplify things tremendously.
268 * Revision 1.5 1998/01/19 18:40:19 curt
269 * Tons of little changes to clean up the code and to remove fatal errors
270 * when building with the c++ compiler.
272 * Revision 1.4 1997/12/30 20:47:34 curt
273 * Integrated new event manager with subsystem initializations.
275 * Revision 1.3 1997/12/15 23:54:33 curt
276 * Add xgl wrappers for debugging.
277 * Generate terrain normals on the fly.
279 * Revision 1.2 1997/12/10 22:37:38 curt
280 * Prepended "fg" on the name of all global structures that didn't have it yet.
281 * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
283 * Revision 1.1 1997/08/29 18:03:20 curt