#include <GL/glut.h>
#include "GLUTkey.h"
-#include "../Aircraft/aircraft.h"
+
#include "../constants.h"
-extern double fogDensity;
+#include "../Aircraft/aircraft.h"
+#include "../Weather/weather.h"
+
extern double goal_view_offset;
/* Handle keyboard events */
void GLUTkey(unsigned char k, int x, int y) {
struct control_params *c;
+ struct weather_params *w;
c = ¤t_aircraft.controls;
+ w = ¤t_weather;
printf("Key hit = %d", k);
case 57: /* numeric keypad 9 */
goal_view_offset = FG_PI * 1.75;
return;
+ case 90: /* Z */
+ w->visibility /= 1.10;
+ glFogf(GL_FOG_END, w->visibility);
+ printf("Fog density = %.4f\n", w->visibility);
+ return;
}
} else {
printf("\n");
case 51: /* numeric keypad 3 (Pg Dn) */
fgThrottleMove(0, -0.01);
return;
- case 122:
- fogDensity *= 1.10;
- glFogf(GL_FOG_END, fogDensity);
- printf("Fog density = %.4f\n", fogDensity);
- return;
- case 90:
- fogDensity /= 1.10;
- glFogf(GL_FOG_END, fogDensity);
- printf("Fog density = %.4f\n", fogDensity);
+ case 122: /* z */
+ w->visibility *= 1.10;
+ glFogf(GL_FOG_END, w->visibility);
+ printf("Fog density = %.4f\n", w->visibility);
return;
case 27: /* ESC */
exit(0);
/* $Log$
-/* Revision 1.17 1997/07/19 22:34:02 curt
-/* Moved PI definitions to ../constants.h
-/* Moved random() stuff to ../Utils/ and renamed fg_random()
+/* Revision 1.18 1997/08/22 21:34:38 curt
+/* Doing a bit of reorganizing and house cleaning.
/*
+ * Revision 1.17 1997/07/19 22:34:02 curt
+ * Moved PI definitions to ../constants.h
+ * Moved random() stuff to ../Utils/ and renamed fg_random()
+ *
* Revision 1.16 1997/07/18 23:41:24 curt
* Tweaks for building with Cygnus Win32 compiler.
*
/**************************************************************************
- * GLmain.c -- top level sim routines
+ * GLUTmain.c -- top level sim routines
*
* Written by Curtis Olson for OpenGL, started May 1997.
*
#include "GLUTkey.h"
#endif
+#include "fg_init.h"
+
#include "../constants.h"
+#include "../general.h"
#include "../Aircraft/aircraft.h"
-#include "../Scenery/mesh.h"
-#include "../Scenery/scenery.h"
#include "../Math/fg_geodesy.h"
-#include "../Math/fg_random.h"
#include "../Math/mat3.h"
#include "../Math/polar.h"
+#include "../Scenery/mesh.h"
+#include "../Scenery/scenery.h"
#include "../Time/fg_time.h"
#include "../Time/fg_timer.h"
#include "../Time/sunpos.h"
being operated */
struct aircraft_params current_aircraft;
+/* This is a record containing global housekeeping information */
+struct general_params general;
+
+/* This is a record containing current weather info */
+struct weather_params current_weather;
+
/* view parameters */
static GLfloat win_ratio = 1.0;
/* static GLint scenery, runway; */
/* Another hack */
-double fogDensity = 60000.0; /* in meters */
double view_offset = 0.0;
double goal_view_offset = 0.0;
-/* Another hack */
-#define DEFAULT_TIMER_HZ 20
-#define DEFAULT_MULTILOOP 6
-#define DEFAULT_MODEL_HZ (DEFAULT_TIMER_HZ * DEFAULT_MULTILOOP)
-
double Simtime;
/* Another hack */
**************************************************************************/
static void fgInitVisuals() {
+ struct weather_params *w;
+
+ w = ¤t_weather;
+
glEnable( GL_DEPTH_TEST );
/* glFrontFace(GL_CW); */
glEnable( GL_CULL_FACE );
glEnable( GL_FOG );
glFogi (GL_FOG_MODE, GL_LINEAR);
/* glFogf (GL_FOG_START, 1.0); */
- glFogf (GL_FOG_END, fogDensity);
+ glFogf (GL_FOG_END, w->visibility);
glFogfv (GL_FOG_COLOR, fgFogColor);
- /* glFogf (GL_FOG_DENSITY, fogDensity); */
+ /* glFogf (GL_FOG_DENSITY, w->visibility); */
/* glHint (GL_FOG_HINT, GL_FASTEST); */
glClearColor(fgClearColor[0], fgClearColor[1], fgClearColor[2],
static void fgMainLoop( void ) {
static int remainder = 0;
int elapsed, multi_loop;
- double rough_elev;
+ double cur_elev;
struct flight_params *f;
f = ¤t_aircraft.flight;
/* I'm just sticking this here for now, it should probably move
* eventually */
- rough_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
+ cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
FG_Latitude * RAD_TO_ARCSEC);
- printf("Ground elevation is %.2f meters here.\n", rough_elev);
- /* FG_Runway_altitude = rough_elev * METER_TO_FEET; */
+ printf("Ground elevation is %.2f meters here.\n", cur_elev);
+ /* FG_Runway_altitude = cur_elev * METER_TO_FEET; */
- if ( FG_Altitude * FEET_TO_METER < rough_elev + 3.758099) {
+ if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
/* set this here, otherwise if we set runway height above our
current height we get a really nasty bounce. */
FG_Runway_altitude = FG_Altitude - 3.758099;
/* now set aircraft altitude above ground */
- FG_Altitude = rough_elev * METER_TO_FEET + 3.758099;
+ FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
printf("<*> resetting altitude to %.0f meters\n",
FG_Altitude * FEET_TO_METER);
}
int main( int argc, char *argv[] ) {
struct flight_params *f;
- double rough_elev;
f = ¤t_aircraft.flight;
- printf("Flight Gear: prototype code to test OpenGL, LaRCsim, and VRML\n\n");
-
+ printf("Flight Gear: prototype version %s\n\n", VERSION);
/**********************************************************************
* Initialize the Window/Graphics environment.
glutCreateWindow("Flight Gear");
#endif
- /* seed the random number generater */
- fg_srandom();
+ /* This is the general house keeping init routine */
+ fgInitGeneral();
+
+ /* This is the top level init routine which calls all the other
+ * subsystem initialization routines. If you are adding a
+ * subsystem to flight gear, its initialization call should
+ * located in this routine.*/
+ fgInitSubsystems();
/* setup view parameters, only makes GL calls */
fgInitVisuals();
-
- /****************************************************************
- * The following section sets up the flight model EOM parameters and
- * should really be read in from one or more files.
- ****************************************************************/
-
- /* Globe Aiport, AZ */
- FG_Runway_altitude = 3234.5;
- FG_Runway_latitude = 120070.41;
- FG_Runway_longitude = -398391.28;
- FG_Runway_heading = 102.0 * DEG_TO_RAD;
-
- /* Initial Position at GLOBE airport */
- FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD;
- FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD;
- FG_Altitude = FG_Runway_altitude + 3.758099;
-
- /* Initial Position north of the city of Globe */
- /* FG_Latitude = ( 120625.64 / 3600.0 ) * DEG_TO_RAD; */
- /* FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD; */
- /* FG_Altitude = 0.0 + 3.758099; */
-
- printf("Initial position is: (%.4f, %.4f, %.2f)\n", FG_Latitude,
- FG_Longitude, FG_Altitude);
-
- /* Initial Velocity */
- FG_V_north = 0.0 /* 7.287719E+00 */;
- FG_V_east = 0.0 /* 1.521770E+03 */;
- FG_V_down = 0.0 /* -1.265722E-05 */;
-
- /* Initial Orientation */
- FG_Phi = -2.658474E-06;
- FG_Theta = 7.401790E-03;
- FG_Psi = 270.0 * DEG_TO_RAD;
- /* FG_Psi = 0.0 * DEG_TO_RAD; */
-
- /* Initial Angular B rates */
- FG_P_body = 7.206685E-05;
- FG_Q_body = 0.000000E+00;
- FG_R_body = 9.492658E-05;
-
- FG_Earth_position_angle = 0.000000E+00;
-
- /* Mass properties and geometry values */
- FG_Mass = 8.547270E+01;
- FG_I_xx = 1.048000E+03;
- FG_I_yy = 3.000000E+03;
- FG_I_zz = 3.530000E+03;
- FG_I_xz = 0.000000E+00;
-
- /* CG position w.r.t. ref. point */
- FG_Dx_cg = 0.000000E+00;
- FG_Dy_cg = 0.000000E+00;
- FG_Dz_cg = 0.000000E+00;
-
- /* Set initial position and slew parameters */
- /* fgSlewInit(-398391.3, 120070.41, 244, 3.1415); */ /* GLOBE Airport */
- /* fgSlewInit(-335340,162540, 15, 4.38); */
- /* fgSlewInit(-398673.28,120625.64, 53, 4.38); */
-
- /* Initialize the Scenery Management system */
- fgSceneryInit();
-
- /* Tell the Scenery Management system where we are so it can load
- * the correct scenery data */
- fgSceneryUpdate(FG_Latitude, FG_Longitude, FG_Altitude);
-
- /* I'm just sticking this here for now, it should probably move
- * eventually */
- rough_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
- FG_Latitude * RAD_TO_DEG * 3600.0);
- printf("Ground elevation is %.2f meters here.\n", rough_elev);
- if ( rough_elev > -9990.0 ) {
- FG_Runway_altitude = rough_elev * METER_TO_FEET;
- }
-
- if ( FG_Altitude < FG_Runway_altitude ) {
- FG_Altitude = FG_Runway_altitude + 3.758099;
- }
- /* end of thing that I just stuck in that I should probably move */
-
- /* Initialize the flight model data structures base on above values */
- fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
-
if ( use_signals ) {
/* init timer routines, signals, etc. Arrange for an alarm
signal to be generated, etc. */
fgInitTimeDepCalcs();
}
- /* Initialize the weather modeling subsystem */
- fgWeatherInit();
-
- /**********************************************************************
+ /**********************************************************************
* Initialize the Event Handlers.
**********************************************************************/
/* $Log$
-/* Revision 1.8 1997/08/19 23:55:03 curt
-/* Worked on better simulating real lighting.
+/* Revision 1.9 1997/08/22 21:34:39 curt
+/* Doing a bit of reorganizing and house cleaning.
/*
+ * Revision 1.8 1997/08/19 23:55:03 curt
+ * Worked on better simulating real lighting.
+ *
* Revision 1.7 1997/08/16 12:22:38 curt
* Working on improving the lighting/shading.
*
TARGET=fg0
-CFILES = GLUTmain.c $(INTERFACE_FILES)
+CFILES = fg_init.c $(INTERFACE_FILES)
OFILES = $(CFILES:.c=.o)
AFILES = ../Aircraft/libAircraft.a ../Controls/libControls.a \
../Flight/libFlight.a ../Flight/LaRCsim/libLaRCsim.a \
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.30 1997/08/22 21:34:40 curt
+# Doing a bit of reorganizing and house cleaning.
+#
# Revision 1.29 1997/08/04 20:25:15 curt
# Organizational tweaking.
#
../Aircraft/../Flight/LaRCsim/../flight.h \
../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../limits.h ../constants.h
-GLUTmain.o: GLUTmain.c ../constants.h ../Aircraft/aircraft.h \
- ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \
+GLUTmain.o: GLUTmain.c fg_init.h ../constants.h ../general.h \
+ ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
+ ../Aircraft/../Flight/Slew/slew.h \
../Aircraft/../Flight/LaRCsim/ls_interface.h \
../Aircraft/../Flight/LaRCsim/../flight.h \
../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../limits.h ../Scenery/mesh.h \
../Scenery/scenery.h ../Scenery/../types.h ../Math/fg_geodesy.h \
- ../Math/fg_random.h ../Math/mat3.h ../Math/polar.h ../Math/../types.h \
- ../Time/fg_time.h ../Time/../types.h ../Time/fg_timer.h \
- ../Time/sunpos.h ../Weather/weather.h
+ ../Math/mat3.h ../Math/polar.h ../Math/../types.h ../Time/fg_time.h \
+ ../Time/../types.h ../Time/fg_timer.h ../Time/sunpos.h \
+ ../Weather/weather.h
+fg_init.o: fg_init.c fg_init.h ../constants.h ../general.h \
+ ../Aircraft/aircraft.h ../Aircraft/../Flight/flight.h \
+ ../Aircraft/../Flight/Slew/slew.h \
+ ../Aircraft/../Flight/LaRCsim/ls_interface.h \
+ ../Aircraft/../Flight/LaRCsim/../flight.h \
+ ../Aircraft/../Controls/controls.h \
+ ../Aircraft/../Controls/../limits.h ../Math/fg_random.h
#endif
#include <GL/glut.h>
+#include <string.h>
+
+#include "../general.h"
#include "scenery.h"
#include "parsevrml.h"
/* Initialize the Scenery Management system */
void fgSceneryInit() {
/* set the default terrain detail level */
- scenery.terrain_skip = 5;
+ scenery.terrain_skip = 10;
}
/* Tell the scenery manager where we are so it can load the proper data, and
* build the proper structures. */
void fgSceneryUpdate(double lon, double lat, double elev) {
+ struct general_params *g;
+ char path[1024];
+
+ g = &general;
+
/* a hardcoded hack follows */
/* this routine should parse the file, and make calls back to the
* scenery management system to build the appropriate structures */
- fgParseVRML("mesa-e.wrl");
+ path[0] = '\0';
+ strcat(path, g->root_dir);
+ strcat(path, "/Scenery/");
+ strcat(path, "mesa-e.wrl");
+ fgParseVRML(path);
}
/* $Log$
-/* Revision 1.12 1997/08/19 23:55:08 curt
-/* Worked on better simulating real lighting.
+/* Revision 1.13 1997/08/22 21:34:41 curt
+/* Doing a bit of reorganizing and house cleaning.
/*
+ * Revision 1.12 1997/08/19 23:55:08 curt
+ * Worked on better simulating real lighting.
+ *
* Revision 1.11 1997/08/13 20:24:22 curt
* Changed default detail level.
*
#include <math.h>
+/* This should be defined in the toplevel make.inc */
+#ifndef VERSION
+#define VERSION "\"not defined\""
+#endif
+
+
/* Make sure PI is defined in its various forms */
#ifdef M_PI
# define FG_PI M_PI
#define EPSILON 0.000001
+/* Timing constants for Flight Model updates */
+#define DEFAULT_TIMER_HZ 20
+#define DEFAULT_MULTILOOP 6
+#define DEFAULT_MODEL_HZ (DEFAULT_TIMER_HZ * DEFAULT_MULTILOOP)
+
+
#endif /* CONSTANTS_H */
/* $Log$
-/* Revision 1.8 1997/07/31 22:52:22 curt
-/* Working on redoing internal coordinate systems & scenery transformations.
+/* Revision 1.9 1997/08/22 21:34:32 curt
+/* Doing a bit of reorganizing and house cleaning.
/*
+ * Revision 1.8 1997/07/31 22:52:22 curt
+ * Working on redoing internal coordinate systems & scenery transformations.
+ *
* Revision 1.7 1997/07/23 21:52:10 curt
* Put comments around the text after an #endif for increased portability.
*
#---------------------------------------------------------------------------
-VERSION = 0.08
+VERSION = 0.09
#---------------------------------------------------------------------------
# Choose your weapons
#
#---------------------------------------------------------------------------
-GLOBAL_CFLAGS = -g -Wall
+GLOBAL_CFLAGS = -g -Wall -DVERSION=\"$(VERSION)\"
#---------------------------------------------------------------------------
#
# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = -lglut
-# INTERFACE_FILES = GLUTkey.c
+# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11
# FG_CFLAGS = $(GLOBAL_CFLAGS)
#---------------------------------------------------------------------------
#
INTERFACE_FLAGS = -DGLUT
INTERFACE_LIBS = -lglut
-INTERFACE_FILES = GLUTkey.c
+INTERFACE_FILES = GLUTmain.c GLUTkey.c
MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL
X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11
GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
#
# INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = ../Win32/libglut.a
-# INTERFACE_FILES = GLUTkey.c
+# INTERFACE_FILES = GLUTmain.c GLUTkey.c
# GRAPHICS_LIBS = -lglu32 -lopengl32 -luser32 -lgdi32
# FG_CFLAGS = $(GLOBAL_CFLAGS) -DWIN32 -DUSE_RAND
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# $Log$
+# Revision 1.11 1997/08/22 21:34:33 curt
+# Doing a bit of reorganizing and house cleaning.
+#
# Revision 1.10 1997/08/16 12:22:19 curt
# Tweaks for new version.
#
t = &cur_time_params;
- time_warp += 300; /* increase this to make the world spin real fast */
+ time_warp += 200; /* increase this to make the world spin real fast */
fgSunPosition(time(NULL) + time_warp, &t->sun_lon, &sun_gd_lat);
/* $Log$
-/* Revision 1.4 1997/08/19 23:55:09 curt
-/* Worked on better simulating real lighting.
+/* Revision 1.5 1997/08/22 21:34:41 curt
+/* Doing a bit of reorganizing and house cleaning.
/*
+ * Revision 1.4 1997/08/19 23:55:09 curt
+ * Worked on better simulating real lighting.
+ *
* Revision 1.3 1997/08/13 20:23:49 curt
* The interface to sunpos now updates a global structure rather than returning
* current sun position.
/* Initialize the weather modeling subsystem */
void fgWeatherInit(void) {
+ struct weather_params *w;
+
+ w = ¤t_weather;
+
+ /* Configure some wind */
+ /* FG_V_north_airmass = 15; */ /* ft/s =~ 10mph */
+
+ w->visibility = 60000.0; /* meters = 60km */
}
+
/* Update the weather parameters for the current position */
void fgWeatherUpdate(double lon, double lat, double alt) {
struct flight_params *f;
- f = ¤t_aircraft.flight;
+ struct weather_params *w;
- /* Configure some wind */
- /* FG_V_north_airmass = 15; */ /* ft/s =~ 10mph */
+ f = ¤t_aircraft.flight;
+ w = ¤t_weather;
/* Add some random turbulence */
/* FG_U_gust = fg_random() * 1.0 - 0.5;
FG_V_gust = fg_random() * 1.0 - 0.5;
FG_W_gust = fg_random() * 1.0 - 0.5; */
-
}
+
/* $Log$
-/* Revision 1.4 1997/08/02 16:23:55 curt
-/* Misc. tweaks.
+/* Revision 1.5 1997/08/22 21:34:42 curt
+/* Doing a bit of reorganizing and house cleaning.
/*
+ * Revision 1.4 1997/08/02 16:23:55 curt
+ * Misc. tweaks.
+ *
* Revision 1.3 1997/07/31 22:52:41 curt
* Working on redoing internal coordinate systems & scenery transformations.
*
#define WEATHER_H
+/* holds the current weather values */
+struct weather_params {
+ float visibility;
+};
+
+extern struct weather_params current_weather;
+
+
/* Initialize the weather modeling subsystem */
void fgWeatherInit(void);
/* $Log$
-/* Revision 1.2 1997/07/23 21:52:30 curt
-/* Put comments around the text after an #endif for increased portability.
+/* Revision 1.3 1997/08/22 21:34:43 curt
+/* Doing a bit of reorganizing and house cleaning.
/*
+ * Revision 1.2 1997/07/23 21:52:30 curt
+ * Put comments around the text after an #endif for increased portability.
+ *
* Revision 1.1 1997/07/19 23:03:58 curt
* Initial revision.
*