]> git.mxchange.org Git - flightgear.git/commitdiff
The LaRCsim flight model is starting to look like it is working.
authorcurt <curt>
Fri, 30 May 1997 19:26:56 +0000 (19:26 +0000)
committercurt <curt>
Fri, 30 May 1997 19:26:56 +0000 (19:26 +0000)
Aircraft/aircraft.c
LaRCsim/ls_interface.c
Main/GLmain.c
Main/Makefile
Main/mesh2GL.c
Scenery/dem2scene.pl
Scenery/mesh.c
Simulator/Makefile

index c3ffc4e85f43c4892ab7c20e6f800bd706c7c6ae..aac202dd62c7103b712ebd423a551ace87475dd2 100644 (file)
@@ -39,19 +39,22 @@ void aircraft_debug(int type) {
     f = &current_aircraft.flight;
     c = &current_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.
  *
index fc0779fde51cc390a8e5b9bff9a2a73dea281988..9ff1dd431c65e6ae1b0ccd60ed8cbd06812fd0a2 100644 (file)
@@ -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.
  *
index a53dd3ba8b9f57b1e3713f897e76363df1e6e240..592825797e5d5531803c680866b2571d892dba81 100644 (file)
@@ -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 = &current_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.
  *
index dd4c51f1297f587451afb749cd4998539677f839..e19a5f3ae96f1604a7f315a2581ab35aec84c582 100644 (file)
@@ -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.
 #
index 6fa34ef992b03c72468453637ef5bab3b8055b32..52decf023c7f910098cd0e0533224ef65cf97410 100644 (file)
 #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.
  *
index edf5037dd4e1f4c4c91e564455ff2253e3fdecb8..97af872fa4a08ba446e3491e7b90f579d9f56d9e 100755 (executable)
@@ -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)
 #
index 2054cdf5316758eea54240c971d2aef0e72dee24..622ce21df8ad214d4b74b20a42bf6834b6475e25 100644 (file)
@@ -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.
  *
index abc43f2c2794c5780c4dbdea2279c553f64d5c2e..2f535c671d555d1e046e6f71cf72772e2d38331e 100644 (file)
@@ -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.
 #