From b5d432032d95c95b4f8865d577936e51cf25f35d Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 30 May 1997 19:26:56 +0000 Subject: [PATCH] The LaRCsim flight model is starting to look like it is working. --- Aircraft/aircraft.c | 15 +++++++------ LaRCsim/ls_interface.c | 5 ++++- Main/GLmain.c | 48 +++++++++++++++++++++++++++++++++++------- Main/Makefile | 10 +++++---- Main/mesh2GL.c | 44 ++++++++++++++------------------------ Scenery/dem2scene.pl | 7 ++++-- Scenery/mesh.c | 11 ++++++---- Simulator/Makefile | 5 ++++- 8 files changed, 91 insertions(+), 54 deletions(-) diff --git a/Aircraft/aircraft.c b/Aircraft/aircraft.c index c3ffc4e85..aac202dd6 100644 --- a/Aircraft/aircraft.c +++ b/Aircraft/aircraft.c @@ -39,19 +39,22 @@ void aircraft_debug(int type) { f = ¤t_aircraft.flight; c = ¤t_aircraft.controls; - printf("Pos = (%.2f,%.2f,%.2f) Dir = %.2f Mach = %.2f\n", + printf("Pos = (%.2f,%.2f,%.2f) (Phi,Theta,Psi)=(%.2f,%.2f,%.2f)\n", FG_RAD_2_DEG(FG_Longitude) * 3600.0, FG_RAD_2_DEG(FG_Latitude) * 3600.0, - FG_Altitude, FG_Psi, FG_Mach_number); - printf("Elev = %.2f, Aileron = %.2f, Rudder = %.2f\n", - c->elev, c->aileron, c->rudder); + FG_Altitude, FG_Phi, FG_Theta, FG_Psi); + printf("Mach = %.2f Elev = %.2f, Aileron = %.2f, Rudder = %.2f\n", + FG_Mach_number, c->elev, c->aileron, c->rudder); } /* $Log$ -/* Revision 1.4 1997/05/30 03:54:11 curt -/* Made a bit more progress towards integrating the LaRCsim flight model. +/* Revision 1.5 1997/05/30 19:30:14 curt +/* The LaRCsim flight model is starting to look like it is working. /* + * Revision 1.4 1997/05/30 03:54:11 curt + * Made a bit more progress towards integrating the LaRCsim flight model. + * * Revision 1.3 1997/05/29 22:39:56 curt * Working on incorporating the LaRCsim flight model. * diff --git a/LaRCsim/ls_interface.c b/LaRCsim/ls_interface.c index fc0779fde..9ff1dd431 100644 --- a/LaRCsim/ls_interface.c +++ b/LaRCsim/ls_interface.c @@ -496,7 +496,7 @@ int initialize; int ls_cockpit() { sim_control_.paused = 0; - Throttle_pct = 0.99; + Throttle_pct = 0.95; /* printf("Mach = %.2f ", Mach_number); printf("%.4f,%.4f,%.2f ", Latitude, Longitude, Altitude); @@ -900,6 +900,9 @@ int fgLaRCsim_2_Flight (struct flight_params *f) { /* Flight Gear Modification Log * * $Log$ + * Revision 1.4 1997/05/30 19:30:15 curt + * The LaRCsim flight model is starting to look like it is working. + * * Revision 1.3 1997/05/30 03:54:12 curt * Made a bit more progress towards integrating the LaRCsim flight model. * diff --git a/Main/GLmain.c b/Main/GLmain.c index a53dd3ba8..592825797 100644 --- a/Main/GLmain.c +++ b/Main/GLmain.c @@ -46,6 +46,8 @@ #include "../aircraft/aircraft.h" #include "../scenery/scenery.h" +#include "../mat3/mat3.h" + #define FG_RAD_2_DEG(RAD) ((RAD) * 180.0 / M_PI) #define FG_DEG_2_RAD(DEG) ((DEG) * M_PI / 180.0) @@ -118,6 +120,8 @@ static void fgInitVisuals() { static void fgUpdateViewParams() { double pos_x, pos_y, pos_z; struct flight_params *f; + MAT3mat R, tmp; + MAT3vec vec, forward, up; f = ¤t_aircraft.flight; @@ -129,17 +133,42 @@ static void fgUpdateViewParams() { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); + /* calculate position in arc seconds */ pos_x = FG_RAD_2_DEG(FG_Longitude) * 3600.0; pos_y = FG_RAD_2_DEG(FG_Latitude) * 3600.0; pos_z = FG_Altitude * 0.01; /* (Convert feet to aproximate arcsecs) */ - glRotatef(FG_Phi, 1.0, 0.0, 0.0); - glRotatef(FG_Theta, 0.0, 1.0, 0.0); - glRotatef(FG_Psi, 0.0, 0.0, 1.0); + /* build current rotation matrix */ + MAT3_SET_VEC(vec, 1.0, 0.0, 0.0); + MAT3rotate(R, vec, FG_Phi); + /* printf("Roll matrix\n"); */ + /* MAT3print(R, stdout); */ + + MAT3_SET_VEC(vec, 0.0, -1.0, 0.0); + MAT3rotate(tmp, vec, FG_Theta); + /* printf("Pitch matrix\n"); */ + /* MAT3print(tmp, stdout); */ + MAT3mult(R, R, tmp); + + MAT3_SET_VEC(vec, 0.0, 0.0, -1.0); + MAT3rotate(tmp, vec, M_PI + M_PI_2 + FG_Psi ); + /* printf("Yaw matrix\n"); + MAT3print(tmp, stdout); */ + MAT3mult(R, R, tmp); + + /* MAT3print(R, stdout); */ + + /* generate the current forward and up vectors */ + MAT3_SET_VEC(vec, 1.0, 0.0, 0.0); + MAT3mult_vec(forward, vec, R); + printf("Forward vector is (%.2f,%.2f,%.2f)\n", forward[0], forward[1], + forward[2]); + MAT3_SET_VEC(vec, 0.0, 0.0, 1.0); + MAT3mult_vec(up, vec, R); gluLookAt(pos_x, pos_y, pos_z, - pos_x + 1.0, pos_y, pos_z, - 0.0, 0.0, 1.0); + pos_x + forward[0], pos_y + forward[1], pos_z + forward[2], + up[0], up[1], up[2]); } @@ -335,7 +364,7 @@ int main( int argc, char *argv[] ) { /* Initial Orientation */ FG_Phi = -2.658474E-06; FG_Theta = 7.401790E-03; - FG_Psi = 4.38; + FG_Psi = 2.14 /* 4.38 */; /* Initial Angular B rates */ FG_P_body = 7.206685E-05; @@ -410,9 +439,12 @@ int main( int argc, char *argv[] ) { /* $Log$ -/* Revision 1.8 1997/05/30 03:54:10 curt -/* Made a bit more progress towards integrating the LaRCsim flight model. +/* 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 + * Made a bit more progress towards integrating the LaRCsim flight model. + * * Revision 1.7 1997/05/29 22:39:49 curt * Working on incorporating the LaRCsim flight model. * diff --git a/Main/Makefile b/Main/Makefile index dd4c51f12..e19a5f3ae 100644 --- a/Main/Makefile +++ b/Main/Makefile @@ -66,10 +66,9 @@ LIBS = $(INTERFACE_LIBS) $(GRAPHICS_LIBS) -lm -lfl CFILES = GLmain.c $(INTERFACE_FILES) mesh2GL.c OFILES = $(CFILES:.c=.o) -AFILES = ../flight/libflight.a ../flight/slew/libslew.a \ - ../flight/LaRCsim/libLaRCsim.a ../aircraft/libaircraft.a \ - ../scenery/libscenery.a - +AFILES = ../aircraft/libaircraft.a ../flight/libflight.a \ + ../flight/LaRCsim/libLaRCsim.a ../flight/slew/libslew.a \ + ../mat3/libmat3.a ../scenery/libscenery.a #--------------------------------------------------------------------------- @@ -104,6 +103,9 @@ mesh2GL.o: mesh2GL.c ../scenery/mesh.h #--------------------------------------------------------------------------- # $Log$ +# Revision 1.8 1997/05/30 19:27:02 curt +# The LaRCsim flight model is starting to look like it is working. +# # Revision 1.7 1997/05/29 22:39:50 curt # Working on incorporating the LaRCsim flight model. # diff --git a/Main/mesh2GL.c b/Main/mesh2GL.c index 6fa34ef99..52decf023 100644 --- a/Main/mesh2GL.c +++ b/Main/mesh2GL.c @@ -32,22 +32,7 @@ #endif #include "../scenery/mesh.h" -#include "mat3.h" - - -/* Sets the first vector to be the cross-product of the last two - vectors. */ -static void mat3_cross_product(float result_vec[3], register float vec1[3], - register float vec2[3]) { - float tempvec[3]; - register float *temp = tempvec; - - temp[0] = vec1[1] * vec2[2] - vec1[2] * vec2[1]; - temp[1] = vec1[2] * vec2[0] - vec1[0] * vec2[2]; - temp[2] = vec1[0] * vec2[1] - vec1[1] * vec2[0]; - - MAT3_COPY_VEC(result_vec, temp); -} +#include "../mat3/mat3.h" /* walk through mesh and make ogl calls */ @@ -55,11 +40,11 @@ GLint mesh2GL(struct mesh *m) { GLint mesh; float x1, y1, x2, y2, z11, z12, z21, z22; - float v1[3], v2[3], normal[3]; + MAT3vec v1, v2, normal; int i, j, istep, jstep, iend, jend; float temp; - istep = jstep = 25; /* Detail level 1 -- 1200 ... */ + istep = jstep = 10; /* Detail level 1 -- 1200 ... */ mesh = glGenLists(1); glNewList(mesh, GL_COMPILE); @@ -84,24 +69,24 @@ GLint mesh2GL(struct mesh *m) { v1[0] = x2 - x1; v1[1] = 0; v1[2] = z21 - z11; v2[0] = 0; v2[1] = y2 - y1; v2[2] = z12 - z11; - mat3_cross_product(normal, v1, v2); + MAT3cross_product(normal, v1, v2); MAT3_NORMALIZE_VEC(normal,temp); - glNormal3fv(normal); + glNormal3d(normal[0], normal[1], normal[2]); if ( j == 0 ) { /* first time through */ - glVertex3f(x1, y1, z11); - glVertex3f(x1, y2, z12); + glVertex3f(x1, y1, z11-45); + glVertex3f(x1, y2, z12-45); } - glVertex3f(x2, y1, z21); + glVertex3f(x2, y1, z21-45); v1[0] = x2 - x1; v1[1] = y1 - y2; v1[2] = z21 - z12; v2[0] = x2 - x1; v2[1] = 0; v2[2] = z22 - z12; - mat3_cross_product(normal, v1, v2); + MAT3cross_product(normal, v1, v2); MAT3_NORMALIZE_VEC(normal,temp); - glNormal3fv(normal); - glVertex3f(x2, y2, z22); + glNormal3d(normal[0], normal[1], normal[2]); + glVertex3f(x2, y2, z22-45); x1 = x2; x2 = x1 + (m->row_step * jstep); @@ -119,9 +104,12 @@ GLint mesh2GL(struct mesh *m) { /* $Log$ -/* Revision 1.10 1997/05/30 03:54:11 curt -/* Made a bit more progress towards integrating the LaRCsim flight model. +/* Revision 1.11 1997/05/30 19:27:02 curt +/* The LaRCsim flight model is starting to look like it is working. /* + * Revision 1.10 1997/05/30 03:54:11 curt + * Made a bit more progress towards integrating the LaRCsim flight model. + * * Revision 1.9 1997/05/29 22:39:51 curt * Working on incorporating the LaRCsim flight model. * diff --git a/Scenery/dem2scene.pl b/Scenery/dem2scene.pl index edf5037dd..97af872fa 100755 --- a/Scenery/dem2scene.pl +++ b/Scenery/dem2scene.pl @@ -182,8 +182,8 @@ sub output_scene_hdr { $dem_x1 =~ s/D/E/; $dem_x1 += 0.0; $dem_y1 =~ s/D/E/; $dem_y1 += 0.0; print " // This mesh is rooted at the following coordinates (in arc seconds)\n"; - print " origin_lat = $dem_x1\n"; - print " origin_lon = $dem_y1\n"; + print " origin_lon = $dem_x1\n"; + print " origin_lat = $dem_y1\n"; print "\n"; print " // Number of rows and columns (needed by the parser so it can create\n"; @@ -293,6 +293,9 @@ while ( ($token = &next_token()) ne "_END_OF_FILE_" ) { #--------------------------------------------------------------------------- # $Log$ +# Revision 1.2 1997/05/30 19:30:16 curt +# The LaRCsim flight model is starting to look like it is working. +# # Revision 1.1 1997/05/27 21:56:02 curt # Initial revision (with data skipping support) # diff --git a/Scenery/mesh.c b/Scenery/mesh.c index 2054cdf53..622ce21df 100644 --- a/Scenery/mesh.c +++ b/Scenery/mesh.c @@ -82,9 +82,9 @@ void mesh_set_option_name(struct mesh *m, char *name) { void mesh_set_option_value(struct mesh *m, char *value) { printf("Setting %s to %s\n", m->option_name, value); - if ( strcmp(m->option_name, "origin_lat") == 0 ) { + if ( strcmp(m->option_name, "origin_lon") == 0 ) { m->originx = atof(value); - } else if ( strcmp(m->option_name, "origin_lon") == 0 ) { + } else if ( strcmp(m->option_name, "origin_lat") == 0 ) { m->originy = atof(value); } else if ( strcmp(m->option_name, "rows") == 0 ) { m->rows = atoi(value); @@ -102,9 +102,12 @@ void mesh_set_option_value(struct mesh *m, char *value) { /* $Log$ -/* Revision 1.3 1997/05/23 15:40:41 curt -/* Added GNU copyright headers. +/* Revision 1.4 1997/05/30 19:30:17 curt +/* The LaRCsim flight model is starting to look like it is working. /* + * Revision 1.3 1997/05/23 15:40:41 curt + * Added GNU copyright headers. + * * Revision 1.2 1997/05/19 18:20:50 curt * Slight change to origin key words. * diff --git a/Simulator/Makefile b/Simulator/Makefile index abc43f2c2..2f535c671 100644 --- a/Simulator/Makefile +++ b/Simulator/Makefile @@ -28,7 +28,7 @@ CC = gcc SUBSUBDIRS = flight/LaRCsim flight/slew -SUBDIRS = aircraft controls flight scenery +SUBDIRS = aircraft controls flight mat3 scenery MAIN = OpenGL @@ -53,6 +53,9 @@ clean: #--------------------------------------------------------------------------- # $Log$ +# Revision 1.5 1997/05/30 19:26:56 curt +# The LaRCsim flight model is starting to look like it is working. +# # Revision 1.4 1997/05/29 02:31:43 curt # Update subdirectory structure. # -- 2.39.2