WE CAN NOW FLY!!!
Continuing work on the LaRCsim flight model integration. Added some MSFS-like keyboard input handling.
This commit is contained in:
parent
305c0fa027
commit
220ee54f33
7 changed files with 112 additions and 33 deletions
|
@ -497,14 +497,14 @@ int initialize;
|
||||||
int ls_cockpit() {
|
int ls_cockpit() {
|
||||||
struct control_params *c;
|
struct control_params *c;
|
||||||
|
|
||||||
|
sim_control_.paused = 0;
|
||||||
|
|
||||||
c = ¤t_aircraft.controls;
|
c = ¤t_aircraft.controls;
|
||||||
|
|
||||||
Lat_control = -c->aileron;
|
Lat_control = -c->aileron;
|
||||||
Long_control = -c->elev;
|
Long_control = -c->elev;
|
||||||
|
Rudder_pedal = c->rudder;
|
||||||
sim_control_.paused = 0;
|
Throttle_pct = c->throttle[0];
|
||||||
|
|
||||||
Throttle_pct = 0.95;
|
|
||||||
|
|
||||||
/* printf("Mach = %.2f ", Mach_number);
|
/* printf("Mach = %.2f ", Mach_number);
|
||||||
printf("%.4f,%.4f,%.2f ", Latitude, Longitude, Altitude);
|
printf("%.4f,%.4f,%.2f ", Latitude, Longitude, Altitude);
|
||||||
|
@ -908,6 +908,12 @@ int fgLaRCsim_2_Flight (struct flight_params *f) {
|
||||||
/* Flight Gear Modification Log
|
/* Flight Gear Modification Log
|
||||||
*
|
*
|
||||||
* $Log$
|
* $Log$
|
||||||
|
* Revision 1.6 1997/05/31 04:13:53 curt
|
||||||
|
* WE CAN NOW FLY!!!
|
||||||
|
*
|
||||||
|
* Continuing work on the LaRCsim flight model integration.
|
||||||
|
* Added some MSFS-like keyboard input handling.
|
||||||
|
*
|
||||||
* Revision 1.5 1997/05/30 23:26:25 curt
|
* Revision 1.5 1997/05/30 23:26:25 curt
|
||||||
* Added elevator/aileron controls.
|
* Added elevator/aileron controls.
|
||||||
*
|
*
|
||||||
|
|
|
@ -42,30 +42,34 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
printf("Key hit = %d\n", k);
|
printf("Key hit = %d\n", k);
|
||||||
|
|
||||||
switch (k) {
|
switch (k) {
|
||||||
case GLUT_KEY_UP:
|
case 50: /* numeric keypad 2 */
|
||||||
c->elev -= 0.01;
|
|
||||||
return;
|
|
||||||
case GLUT_KEY_DOWN:
|
|
||||||
c->elev += 0.01;
|
c->elev += 0.01;
|
||||||
return;
|
return;
|
||||||
case GLUT_KEY_LEFT:
|
case 56: /* numeric keypad 8 */
|
||||||
|
c->elev -= 0.01;
|
||||||
|
return;
|
||||||
|
case 52: /* numeric keypad 4 */
|
||||||
c->aileron += 0.01;
|
c->aileron += 0.01;
|
||||||
return;
|
return;
|
||||||
case GLUT_KEY_RIGHT:
|
case 54: /* numeric keypad 6 */
|
||||||
c->aileron -= 0.01;
|
c->aileron -= 0.01;
|
||||||
return;
|
return;
|
||||||
case 1 /* TK_END */:
|
case 48: /* numeric keypad Ins */
|
||||||
c->rudder -= 0.01;
|
c->rudder -= 0.01;
|
||||||
return;
|
return;
|
||||||
case 2 /* TK_PGDWN */:
|
case 13: /* numeric keypad Enter */
|
||||||
c->rudder += 0.01;
|
c->rudder += 0.01;
|
||||||
return;
|
return;
|
||||||
case 3:
|
case 53: /* numeric keypad 5 */
|
||||||
c->throttle[0] -= 0.05;
|
c->aileron = 0.0;
|
||||||
return;
|
c->elev = 0.0;
|
||||||
case 4:
|
c->rudder = 0.0;
|
||||||
|
case 57: /* numeric keypad 9 (Pg Up) */
|
||||||
c->throttle[0] += 0.05;
|
c->throttle[0] += 0.05;
|
||||||
return;
|
return;
|
||||||
|
case 51: /* numeric keypad 3 (Pg Dn) */
|
||||||
|
c->throttle[0] -= 0.05;
|
||||||
|
return;
|
||||||
case 122:
|
case 122:
|
||||||
fogDensity *= 1.10;
|
fogDensity *= 1.10;
|
||||||
glFogf(GL_FOG_END, fogDensity);
|
glFogf(GL_FOG_END, fogDensity);
|
||||||
|
@ -83,10 +87,42 @@ void GLUTkey(unsigned char k, int x, int y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Handle "special" keyboard events */
|
||||||
|
void GLUTspecialkey(unsigned char k, int x, int y) {
|
||||||
|
struct control_params *c;
|
||||||
|
|
||||||
|
c = ¤t_aircraft.controls;
|
||||||
|
|
||||||
|
printf("Special key hit = %d\n", k);
|
||||||
|
|
||||||
|
switch (k) {
|
||||||
|
case GLUT_KEY_UP:
|
||||||
|
c->elev -= 0.01;
|
||||||
|
return;
|
||||||
|
case GLUT_KEY_DOWN:
|
||||||
|
c->elev += 0.01;
|
||||||
|
return;
|
||||||
|
case GLUT_KEY_LEFT:
|
||||||
|
c->aileron += 0.01;
|
||||||
|
return;
|
||||||
|
case GLUT_KEY_RIGHT:
|
||||||
|
c->aileron -= 0.01;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.5 1997/05/30 23:26:19 curt
|
/* Revision 1.6 1997/05/31 04:13:52 curt
|
||||||
/* Added elevator/aileron controls.
|
/* WE CAN NOW FLY!!!
|
||||||
/*
|
/*
|
||||||
|
/* Continuing work on the LaRCsim flight model integration.
|
||||||
|
/* Added some MSFS-like keyboard input handling.
|
||||||
|
/*
|
||||||
|
* Revision 1.5 1997/05/30 23:26:19 curt
|
||||||
|
* Added elevator/aileron controls.
|
||||||
|
*
|
||||||
* Revision 1.4 1997/05/27 17:44:31 curt
|
* Revision 1.4 1997/05/27 17:44:31 curt
|
||||||
* Renamed & rearranged variables and routines. Added some initial simple
|
* Renamed & rearranged variables and routines. Added some initial simple
|
||||||
* timer/alarm routines so the flight model can be updated on a regular interval.
|
* timer/alarm routines so the flight model can be updated on a regular interval.
|
||||||
|
|
|
@ -37,16 +37,23 @@
|
||||||
|
|
||||||
/* Handle keyboard events */
|
/* Handle keyboard events */
|
||||||
void GLUTkey(unsigned char k, int x, int y);
|
void GLUTkey(unsigned char k, int x, int y);
|
||||||
|
void GLUTspecialkey(unsigned char k, int x, int y);
|
||||||
|
|
||||||
|
|
||||||
#endif GLUTKEY_H
|
#endif GLUTKEY_H
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.2 1997/05/23 15:40:25 curt
|
/* Revision 1.3 1997/05/31 04:13:52 curt
|
||||||
/* Added GNU copyright headers.
|
/* WE CAN NOW FLY!!!
|
||||||
/* Fog now works!
|
|
||||||
/*
|
/*
|
||||||
|
/* Continuing work on the LaRCsim flight model integration.
|
||||||
|
/* Added some MSFS-like keyboard input handling.
|
||||||
|
/*
|
||||||
|
* Revision 1.2 1997/05/23 15:40:25 curt
|
||||||
|
* Added GNU copyright headers.
|
||||||
|
* Fog now works!
|
||||||
|
*
|
||||||
* Revision 1.1 1997/05/21 15:57:51 curt
|
* Revision 1.1 1997/05/21 15:57:51 curt
|
||||||
* Renamed due to added GLUT support.
|
* Renamed due to added GLUT support.
|
||||||
*
|
*
|
||||||
|
|
|
@ -59,6 +59,9 @@ struct aircraft_params current_aircraft;
|
||||||
/* view parameters */
|
/* view parameters */
|
||||||
static GLfloat win_ratio = 1.0;
|
static GLfloat win_ratio = 1.0;
|
||||||
|
|
||||||
|
/* sun direction */
|
||||||
|
static GLfloat sun_vec[4] = {-3.0, 1.0, 2.0, 0.0 };
|
||||||
|
|
||||||
/* temporary hack */
|
/* temporary hack */
|
||||||
extern struct mesh *mesh_ptr;
|
extern struct mesh *mesh_ptr;
|
||||||
/* Function prototypes */
|
/* Function prototypes */
|
||||||
|
@ -82,7 +85,6 @@ double Simtime;
|
||||||
|
|
||||||
static void fgInitVisuals() {
|
static void fgInitVisuals() {
|
||||||
/* if the 4th field is 0.0, this specifies a direction ... */
|
/* if the 4th field is 0.0, this specifies a direction ... */
|
||||||
static GLfloat sun_vec[4] = {3.0, 1.0, 3.0, 0.0 };
|
|
||||||
static GLfloat color[4] = { 0.3, 0.7, 0.2, 1.0 };
|
static GLfloat color[4] = { 0.3, 0.7, 0.2, 1.0 };
|
||||||
static GLfloat fogColor[4] = {0.65, 0.65, 0.85, 1.0};
|
static GLfloat fogColor[4] = {0.65, 0.65, 0.85, 1.0};
|
||||||
|
|
||||||
|
@ -122,6 +124,7 @@ static void fgUpdateViewParams() {
|
||||||
struct flight_params *f;
|
struct flight_params *f;
|
||||||
MAT3mat R, tmp;
|
MAT3mat R, tmp;
|
||||||
MAT3vec vec, forward, up;
|
MAT3vec vec, forward, up;
|
||||||
|
MAT3hvec sun;
|
||||||
|
|
||||||
f = ¤t_aircraft.flight;
|
f = ¤t_aircraft.flight;
|
||||||
|
|
||||||
|
@ -170,6 +173,7 @@ static void fgUpdateViewParams() {
|
||||||
pos_x + forward[0], pos_y + forward[1], pos_z + forward[2],
|
pos_x + forward[0], pos_y + forward[1], pos_z + forward[2],
|
||||||
up[0], up[1], up[2]);
|
up[0], up[1], up[2]);
|
||||||
|
|
||||||
|
glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -210,6 +214,9 @@ void fgTimerCatch() {
|
||||||
static double lastSimtime = -99.9;
|
static double lastSimtime = -99.9;
|
||||||
int Overrun;
|
int Overrun;
|
||||||
|
|
||||||
|
/* ignore any SIGALRM's until we come back from our EOM iteration */
|
||||||
|
signal(SIGALRM, SIG_IGN);
|
||||||
|
|
||||||
f = ¤t_aircraft.flight;
|
f = ¤t_aircraft.flight;
|
||||||
|
|
||||||
/* printf("In fgTimerCatch()\n"); */
|
/* printf("In fgTimerCatch()\n"); */
|
||||||
|
@ -390,7 +397,7 @@ int main( int argc, char *argv[] ) {
|
||||||
/* fgSlewInit(-335340,162540, 15, 4.38); */
|
/* fgSlewInit(-335340,162540, 15, 4.38); */
|
||||||
/* fgSlewInit(-398673.28,120625.64, 53, 4.38); */
|
/* fgSlewInit(-398673.28,120625.64, 53, 4.38); */
|
||||||
|
|
||||||
fgFlightModelInit(FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ);
|
fgFlightModelInit(FG_LARCSIM, f, 1.0/(DEFAULT_MODEL_HZ*DEFAULT_MULTILOOP));
|
||||||
|
|
||||||
/* build all objects */
|
/* build all objects */
|
||||||
fgSceneryInit();
|
fgSceneryInit();
|
||||||
|
@ -404,7 +411,7 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
/* call key() on keyboard event */
|
/* call key() on keyboard event */
|
||||||
glutKeyboardFunc( GLUTkey );
|
glutKeyboardFunc( GLUTkey );
|
||||||
glutSpecialFunc( GLUTkey );
|
glutSpecialFunc( GLUTspecialkey );
|
||||||
|
|
||||||
/* call fgMainLoop() whenever there is nothing else to do */
|
/* call fgMainLoop() whenever there is nothing else to do */
|
||||||
glutIdleFunc( fgMainLoop );
|
glutIdleFunc( fgMainLoop );
|
||||||
|
@ -439,9 +446,15 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.9 1997/05/30 19:27:01 curt
|
/* Revision 1.10 1997/05/31 04:13:52 curt
|
||||||
/* The LaRCsim flight model is starting to look like it is working.
|
/* WE CAN NOW FLY!!!
|
||||||
/*
|
/*
|
||||||
|
/* Continuing work on the LaRCsim flight model integration.
|
||||||
|
/* Added some MSFS-like keyboard input handling.
|
||||||
|
/*
|
||||||
|
* Revision 1.9 1997/05/30 19:27:01 curt
|
||||||
|
* The LaRCsim flight model is starting to look like it is working.
|
||||||
|
*
|
||||||
* Revision 1.8 1997/05/30 03:54:10 curt
|
* Revision 1.8 1997/05/30 03:54:10 curt
|
||||||
* Made a bit more progress towards integrating the LaRCsim flight model.
|
* Made a bit more progress towards integrating the LaRCsim flight model.
|
||||||
*
|
*
|
||||||
|
|
|
@ -53,12 +53,12 @@ INTERFACE_FILES = GLUTkey.c
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
# For OpenGL
|
# For OpenGL
|
||||||
GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11
|
# GRAPHICS_LIBS = -lGLU -lGL -lXmu -lX11
|
||||||
|
|
||||||
# For Mesa
|
# For Mesa
|
||||||
# MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL
|
MESA_LIBS = -L/usr/lib/mesa -lMesatk -lMesaaux -lMesaGLU -lMesaGL
|
||||||
# X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11
|
X11_LIBS = -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11
|
||||||
# GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
|
GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
|
||||||
|
|
||||||
|
|
||||||
CFLAGS = $(STD_CFLAGS) $(INTERFACE_FLAGS)
|
CFLAGS = $(STD_CFLAGS) $(INTERFACE_FLAGS)
|
||||||
|
@ -103,6 +103,12 @@ mesh2GL.o: mesh2GL.c ../scenery/mesh.h
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
# $Log$
|
# $Log$
|
||||||
|
# Revision 1.10 1997/05/31 04:13:53 curt
|
||||||
|
# WE CAN NOW FLY!!!
|
||||||
|
#
|
||||||
|
# Continuing work on the LaRCsim flight model integration.
|
||||||
|
# Added some MSFS-like keyboard input handling.
|
||||||
|
#
|
||||||
# Revision 1.9 1997/05/30 23:26:19 curt
|
# Revision 1.9 1997/05/30 23:26:19 curt
|
||||||
# Added elevator/aileron controls.
|
# Added elevator/aileron controls.
|
||||||
#
|
#
|
||||||
|
|
|
@ -44,7 +44,7 @@ GLint mesh2GL(struct mesh *m) {
|
||||||
int i, j, istep, jstep, iend, jend;
|
int i, j, istep, jstep, iend, jend;
|
||||||
float temp;
|
float temp;
|
||||||
|
|
||||||
istep = jstep = 4; /* Detail level 1 -- 1200 ... */
|
istep = jstep = 12; /* Detail level 1 -- 1200 ... */
|
||||||
|
|
||||||
mesh = glGenLists(1);
|
mesh = glGenLists(1);
|
||||||
glNewList(mesh, GL_COMPILE);
|
glNewList(mesh, GL_COMPILE);
|
||||||
|
@ -104,9 +104,15 @@ GLint mesh2GL(struct mesh *m) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.12 1997/05/30 23:26:20 curt
|
/* Revision 1.13 1997/05/31 04:13:53 curt
|
||||||
/* Added elevator/aileron controls.
|
/* WE CAN NOW FLY!!!
|
||||||
/*
|
/*
|
||||||
|
/* Continuing work on the LaRCsim flight model integration.
|
||||||
|
/* Added some MSFS-like keyboard input handling.
|
||||||
|
/*
|
||||||
|
* Revision 1.12 1997/05/30 23:26:20 curt
|
||||||
|
* Added elevator/aileron controls.
|
||||||
|
*
|
||||||
* Revision 1.11 1997/05/30 19:27:02 curt
|
* Revision 1.11 1997/05/30 19:27:02 curt
|
||||||
* The LaRCsim flight model is starting to look like it is working.
|
* The LaRCsim flight model is starting to look like it is working.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,6 +22,11 @@ Strucures and code to implement various flight models. Provides a
|
||||||
standardized interface to all interesting flight model variabls.
|
standardized interface to all interesting flight model variabls.
|
||||||
|
|
||||||
|
|
||||||
|
mat3/
|
||||||
|
-----
|
||||||
|
Contains miscellaneous matrix/vector routines.
|
||||||
|
|
||||||
|
|
||||||
scenery/
|
scenery/
|
||||||
--------
|
--------
|
||||||
Scenery parsing/generating code.
|
Scenery parsing/generating code.
|
||||||
|
|
Loading…
Add table
Reference in a new issue