//
// 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.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// $Id$
# include <config.h>
#endif
-#ifdef HAVE_WINDOWS_H
+#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
-#include <GL/glut.h>
+#include <simgear/compiler.h>
+
+#include SG_GLU_H
#include <stdlib.h>
#include <stdio.h>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/polar3d.hxx>
-#include <simgear/misc/props.hxx>
+#include <simgear/props/props.hxx>
+#include <simgear/timing/sg_time.hxx>
#include <Aircraft/aircraft.hxx>
#include <Include/general.hxx>
-#include <FDM/ADA.hxx>
+#ifdef ENABLE_SP_FMDS
+#include <FDM/SP/ADA.hxx>
+#endif
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/viewmgr.hxx>
#include <GUI/gui.h>
#include "cockpit.hxx"
+#include "hud.hxx"
// This is a structure that contains all data related to
{
double a, d;
- a = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
+ a = current_aircraft.fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
if (a < 0.0) {
a = -a;
}
{
static char buf[32];
const struct tm *p = globals->get_time_params()->getGmt();
- sprintf( buf, "%d/%d/%4d %d:%02d:%02d",
+ sprintf( buf, "%d/%d/%4d %d:%02d:%02d",
p->tm_mon+1, p->tm_mday, 1900 + p->tm_year,
p->tm_hour, p->tm_min, p->tm_sec);
float get_long_min( void )
{
double a, d;
- a = current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
+ a = current_aircraft.fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
if (a < 0.0) {
a = -a;
}
d = (double) ( (int) a);
- float lon_min = (a - d) * 60.0;
+ float lon_min = (a - d) * 60.0;
return lon_min;
}
static const SGPropertyNode * speedup_node = fgGetNode("/sim/speed-up");
float speed = current_aircraft.fdm_state->get_V_calibrated_kts()
- * speedup_node->getIntValue();
+ * speedup_node->getIntValue();
return speed;
}
float get_mach(void)
{
return current_aircraft.fdm_state->get_Mach_number();
-}
+}
float get_aoa( void )
{
float altitude;
- if ( startup_units_node->getStringValue() == "feet" ) {
+ if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
altitude = current_aircraft.fdm_state->get_Altitude();
} else {
altitude = (current_aircraft.fdm_state->get_Altitude()
float get_agl( void )
{
+ static const SGPropertyNode *startup_units_node
+ = fgGetNode("/sim/startup/units");
+
float agl;
- if ( fgGetString("/sim/startup/units") == "feet" ) {
+ if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
agl = (current_aircraft.fdm_state->get_Altitude()
- - scenery.get_cur_elev() * SG_METER_TO_FEET);
+ - current_aircraft.fdm_state->get_Runway_altitude());
} else {
- agl = (current_aircraft.fdm_state->get_Altitude() * SG_FEET_TO_METER
- - scenery.get_cur_elev());
+ agl = (current_aircraft.fdm_state->get_Altitude()
+ - current_aircraft.fdm_state->get_Runway_altitude()) * SG_FEET_TO_METER;
}
return agl;
float get_fov( void )
{
- return globals->get_current_view()->get_fov();
+ return globals->get_current_view()->get_fov();
}
float get_vfc_ratio( void )
float get_climb_rate( void )
{
+ static const SGPropertyNode *startup_units_node
+ = fgGetNode("/sim/startup/units");
+
float climb_rate;
- if ( fgGetString("/sim/startup/units") == "feet" ) {
+ if ( !strcmp(startup_units_node->getStringValue(), "feet") ) {
climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * 60.0;
} else {
climb_rate = current_aircraft.fdm_state->get_Climb_Rate() * SG_FEET_TO_METER * 60.0;
float get_view_direction( void )
{
- double view_off = SGD_2PI - globals->get_current_view()->get_view_offset();
+ double view_off = SGD_2PI - globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS;
double view = ( current_aircraft.fdm_state->get_Psi() + view_off)
- * SGD_RADIANS_TO_DEGREES;
-
- if(view > 360.)
+ * SGD_RADIANS_TO_DEGREES;
+
+ if (view > 360.)
view -= 360.;
- else if(view<0.)
+ else if (view<0.)
view += 360.;
-
+
return view;
}
+// Added by Markus Hof on 5. Jan 2004
+float get_dme( void )
+{
+ static const SGPropertyNode * dme_node =
+ fgGetNode("/instrumentation/dme/indicated-distance-nm");
+
+ return dme_node->getFloatValue();
+}
+
// $$$ begin - added, VS Renganathan 13 Oct 2K
// #ifdef FIGHTER_HUD
float get_Vx ( void )
return anzg;
}
+#ifdef ENABLE_SP_FMDS
int get_iaux1 (void)
{
FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
FGADA *fdm = (FGADA *)current_aircraft.fdm_state;
return fdm->get_faux(10);
}
-// #endif
+#endif
// $$$ end - added, VS Renganathan 13 Oct 2K
/****************************************************************************/
char *dmshh_format(double degrees)
{
- static char buf[16];
+ static char buf[16];
int deg_part;
int min_part;
double sec_part;
-
+
if (degrees < 0)
degrees = -degrees;
double sign = 1;
int deg;
- if (dd < 0) {
- sign = -1;
- }
+ if (dd < 0)
+ sign = -1;
+
/* round for minutes expressed to three decimal places */
tempdd = fabs(dd) + (5.0E-4 / 60.0);
deg = (int)tempdd;
double sec;
double sign = 1;
- if(dd < 0) {
- sign = -1;
- }
+ if (dd < 0)
+ sign = -1;
+
/* round up for seconds expressed to one decimal place */
tempdd = fabs(dd) + (0.05 / 3600.0);
deg = (int)tempdd;
// dmshh_format(latitude),
// toDMS(latitude),
// toDM(latitude),
- fgLatLonFormat(latitude),
+ fgLatLonFormat(latitude),
latitude > 0 ? 'N' : 'S');
return buf;
}
{
static int toggle = 0;
- if ( toggle )
+ if ( toggle )
fgLatLonFormat = toDM;
else
fgLatLonFormat = toDMS;
-
+
toggle = ~toggle;
}
// If aircraft has HUD specified we will get the specs from its def
// file. For now we will depend upon hard coding in hud?
-
+
// We must insure that the existing instrument link is purged.
// This is done by deleting the links in the list.
-
+
// HI_Head is now a null pointer so we can generate a new list from the
// current aircraft.
fgHUDInit( cur_aircraft );
ac_cockpit = new fg_Cockpit();
-
+
// Have to set the LatLon display type
fgLatLonFormat = toDM;
-
+
SG_LOG( SG_COCKPIT, SG_INFO,
- " Code " << ac_cockpit->code() << " Status "
+ " Code " << ac_cockpit->code() << " Status "
<< ac_cockpit->status() );
- return true;
+ return true;
}
void fgCockpitUpdate( void ) {
SG_LOG( SG_COCKPIT, SG_DEBUG,
- "Cockpit: code " << ac_cockpit->code() << " status "
+ "Cockpit: code " << ac_cockpit->code() << " status "
<< ac_cockpit->status() );
static const SGPropertyNode * xsize_node = fgGetNode("/sim/startup/xsize");
int iwidth = xsize_node->getIntValue();
int iheight = ysize_node->getIntValue();
- float width = iwidth;
- // float height = iheight;
- // FIXME: inefficient
+ // FIXME: inefficient
if ( hud_visibility_node->getBoolValue() ) {
// This will check the global hud linked list pointer.
- // If these is anything to draw it will.
+ // If there is anything to draw it will.
fgUpdateHUD();
}
-#define DISPLAY_COUNTER
-#ifdef DISPLAY_COUNTER
- else
- {
- char buf[64];
- float fps = get_frame_rate();
-// float tris = fps * get_vfc_tris_drawn();
-// float culled = fps * get_vfc_tris_culled();
-// sprintf(buf,"%-4.1f %7.0f %7.0f", fps, tris, culled);
- sprintf(buf,"%-5.1f", fps);
-
- glMatrixMode( GL_PROJECTION );
- glPushMatrix();
- glLoadIdentity();
- gluOrtho2D( 0, iwidth, 0, iheight );
- glMatrixMode( GL_MODELVIEW );
- glPushMatrix();
- glLoadIdentity();
-
- glDisable( GL_DEPTH_TEST );
- glDisable( GL_LIGHTING );
-
- glColor3f( 0.9, 0.4, 0.2 );
-
- guiFnt.drawString( buf,
- int(width - guiFnt.getStringWidth(buf) - 10),
- 10 );
- glEnable( GL_DEPTH_TEST );
- glEnable( GL_LIGHTING );
- glMatrixMode( GL_PROJECTION );
- glPopMatrix();
- glMatrixMode( GL_MODELVIEW );
- glPopMatrix();
- }
-#endif // #ifdef DISPLAY_COUNTER
-
glViewport( 0, 0, iwidth, iheight );
}
+