]> git.mxchange.org Git - flightgear.git/commitdiff
Working on establishing a hard ground.
authorcurt <curt>
Tue, 8 Jul 1997 18:20:11 +0000 (18:20 +0000)
committercurt <curt>
Tue, 8 Jul 1997 18:20:11 +0000 (18:20 +0000)
Main/GLmain.c
Main/depend
Main/mesh2GL.c
Scenery/geometry.c
Scenery/mesh.c
Scenery/mesh.h
Simulator/constants.h

index 404633118e98ab4549572cce12f9e3e9d081dc48..998a4e328be2eebfc9a9e34027379068d5fed23c 100644 (file)
@@ -41,6 +41,7 @@
 #include "../constants.h"
 
 #include "../Aircraft/aircraft.h"
+#include "../Scenery/mesh.h"
 #include "../Scenery/scenery.h"
 #include "../Math/mat3.h"
 #include "../Math/polar.h"
@@ -372,6 +373,10 @@ void fgInitTimeDepCalcs() {
 static void fgMainLoop( void ) {
     static int remainder = 0;
     int elapsed, multi_loop;
+    double rough_elev;
+    struct flight_params *f;
+
+    f = &current_aircraft.flight;
 
     elapsed = fgGetTimeInterval();
     printf("Time interval is = %d, previous remainder is = %d\n", elapsed, 
@@ -390,6 +395,17 @@ static void fgMainLoop( void ) {
     if ( ! use_signals ) {
        fgUpdateTimeDepCalcs(multi_loop);
     }
+
+    /* 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 about %.2f meters here.\n", rough_elev);
+    /* FG_Runway_altitude = rough_elev * METER_TO_FEET; */
+
+    if ( FG_Altitude < FG_Runway_altitude ) {
+       FG_Altitude = FG_Runway_altitude + 3.758099;
+    }
 }
 
 
@@ -419,6 +435,7 @@ static void fgReshape( int width, int height ) {
 
 int main( int argc, char *argv[] ) {
     struct flight_params *f;
+    double rough_elev;
 
     f = &current_aircraft.flight;
 
@@ -513,6 +530,25 @@ int main( int argc, char *argv[] ) {
     /* 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 about %.2f meters here.\n", rough_elev);
+    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 );
 
@@ -522,21 +558,6 @@ int main( int argc, char *argv[] ) {
        fgInitTimeDepCalcs();
     }
 
-
-    /**********************************************************************
-     * The following section (and the functions elsewhere in this file) 
-     * set up the scenery management system. This part is a big hack, 
-     * and needs to be moved to it's own area.
-     **********************************************************************/
-
-    /* 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);
-
-
     /**********************************************************************
      * Initialize the Event Handlers.
      **********************************************************************/
@@ -582,10 +603,13 @@ int main( int argc, char *argv[] ) {
 
 
 /* $Log$
-/* Revision 1.27  1997/07/07 20:59:49  curt
-/* Working on scenery transformations to enable us to fly fluidly over the
-/* poles with no discontinuity/distortion in scenery.
+/* Revision 1.28  1997/07/08 18:20:12  curt
+/* Working on establishing a hard ground.
 /*
+ * Revision 1.27  1997/07/07 20:59:49  curt
+ * Working on scenery transformations to enable us to fly fluidly over the
+ * poles with no discontinuity/distortion in scenery.
+ *
  * Revision 1.26  1997/07/05 20:43:34  curt
  * renamed mat3 directory to Math so we could add other math related routines.
  *
index cb706147b50f924f9dbabac2ce7f7115381d5e51..d507caa67c3017ef8fbbc17c13c3602a85145c0d 100644 (file)
@@ -16,7 +16,8 @@ GLmain.o: GLmain.c ../constants.h ../Aircraft/aircraft.h \
  ../Aircraft/../Flight/LaRCsim/ls_interface.h \
  ../Aircraft/../Flight/LaRCsim/../flight.h \
  ../Aircraft/../Controls/controls.h \
- ../Aircraft/../Controls/../limits.h ../Scenery/scenery.h \
- ../Math/mat3.h ../Math/polar.h ../Math/../types.h ../Timer/fg_timer.h
+ ../Aircraft/../Controls/../limits.h ../Scenery/mesh.h \
+ ../Scenery/scenery.h ../Math/mat3.h ../Math/polar.h \
+ ../Math/../types.h ../Timer/fg_timer.h
 mesh2GL.o: mesh2GL.c ../constants.h ../Scenery/mesh.h ../Math/mat3.h \
  ../Math/polar.h ../Math/../types.h
index 846fb73d5ca5105294c8ee5ed0ab7b55626230a9..88ed7acafa83161f7f912f85083d9bb5e60e3b8e 100644 (file)
@@ -47,7 +47,7 @@ GLint mesh2GL(struct mesh *m) {
 
     printf("In mesh2GL(), generating GL call list.\n");
 
-    istep = jstep = 25;  /* Detail level 1 -- 1200 ... */
+    istep = jstep = 4;  /* Detail level 1 -- 1200 ... */
 
     /* setup the batch transformation */
     fgRotateBatchInit(-m->originx * ARCSEC_TO_RAD, -m->originy * ARCSEC_TO_RAD);
@@ -133,10 +133,13 @@ GLint mesh2GL(struct mesh *m) {
 
 
 /* $Log$
-/* Revision 1.25  1997/07/07 20:59:50  curt
-/* Working on scenery transformations to enable us to fly fluidly over the
-/* poles with no discontinuity/distortion in scenery.
+/* Revision 1.26  1997/07/08 18:20:13  curt
+/* Working on establishing a hard ground.
 /*
+ * Revision 1.25  1997/07/07 20:59:50  curt
+ * Working on scenery transformations to enable us to fly fluidly over the
+ * poles with no discontinuity/distortion in scenery.
+ *
  * Revision 1.24  1997/07/05 20:43:35  curt
  * renamed mat3 directory to Math so we could add other math related routines.
  *
index d81c862a97e1c05d36974060c4ee9f2992c699d1..84499f0e24716e3b7d206add4ea452c001f45f4a 100644 (file)
@@ -33,7 +33,7 @@
 
 
 static vrmlGeometryType;
-static struct mesh eg;
+struct mesh eg;
 
 
 /* Begin a new vrml geometry statement */
@@ -109,17 +109,23 @@ int vrmlFreeGeometry() {
 
     switch(vrmlGeometryType) {
     case VRML_ELEV_GRID:
-       free(eg.mesh_data);
+       /* We need to rethink this here, we can't just free the data,
+         * because we need it to calculate current ground elevation
+         * ... */
+       /* free(eg.mesh_data); */
     }
     return(vrmlGeometryType);
 }
 
 
 /* $Log$
-/* Revision 1.2  1997/07/07 20:59:51  curt
-/* Working on scenery transformations to enable us to fly fluidly over the
-/* poles with no discontinuity/distortion in scenery.
+/* Revision 1.3  1997/07/08 18:20:13  curt
+/* Working on establishing a hard ground.
 /*
+ * Revision 1.2  1997/07/07 20:59:51  curt
+ * Working on scenery transformations to enable us to fly fluidly over the
+ * poles with no discontinuity/distortion in scenery.
+ *
  * Revision 1.1  1997/06/29 21:16:48  curt
  * More twiddling with the Scenery Management system.
  *
index 89fa0d7ce575ce2e11c93cd6a606b1c21b110b13..579d1f34fd5b309b2131f8363c97141f06024067 100644 (file)
@@ -37,7 +37,7 @@
 
 /* Temporary hack until we get the scenery management system running */
 extern GLint mesh_hack;
-
+extern struct mesh eg;
 
 /* initialize the non-array mesh values */
 void mesh_init(struct mesh *m) {
@@ -150,10 +150,35 @@ void mesh_do_it(struct mesh *m) {
 }
 
 
+/* return the current altitude based on mesh data.  We should rewrite
+ * this to interpolate exact values, but for now this is good enough */
+double mesh_altitude(double lon, double lat) {
+    /* we expect things in arcsec for now */
+
+    double xoffset, yoffset;
+    int xindex, yindex;
+
+    xoffset = lon - eg.originx;
+    yoffset = lat - eg.originy;
+
+    xindex = xoffset / eg.col_step;
+    yindex = yoffset / eg.row_step;
+
+    if ( (xindex >= 0) && (xindex < eg.cols) ) {
+       if ( (yindex >= 0) && (yindex < eg.rows) ) {
+           return( eg.mesh_data[xindex * eg.rows + yindex] );
+       }
+    }
+}
+
+
 /* $Log$
-/* Revision 1.6  1997/06/29 21:16:49  curt
-/* More twiddling with the Scenery Management system.
+/* Revision 1.7  1997/07/08 18:20:13  curt
+/* Working on establishing a hard ground.
 /*
+ * Revision 1.6  1997/06/29 21:16:49  curt
+ * More twiddling with the Scenery Management system.
+ *
  * Revision 1.5  1997/06/22 21:44:41  curt
  * Working on intergrating the VRML (subset) parser.
  *
index 7d6217269f2fc7f987ce84c102647c11a69a415b..75a144852e9d4d55f08a64205ee6b02f211ce88c 100644 (file)
@@ -64,17 +64,24 @@ void mesh_set_option_name(struct mesh *m, char *name);
 void mesh_set_option_value(struct mesh *m, char *value);
 
 /* do whatever needs to be done with the mesh now that it's been
  loaded, such as generating the OpenGL call list. */
* loaded, such as generating the OpenGL call list. */
 void mesh_do_it(struct mesh *m);
 
+/* return the current altitude based on mesh data.  We should rewrite
+ * this to interpolate exact values, but for now this is good enough */
+double mesh_altitude(double lon, double lat);
+
 
 #endif MESH_H
 
 
 /* $Log$
-/* Revision 1.3  1997/06/22 21:44:41  curt
-/* Working on intergrating the VRML (subset) parser.
+/* Revision 1.4  1997/07/08 18:20:14  curt
+/* Working on establishing a hard ground.
 /*
+ * Revision 1.3  1997/06/22 21:44:41  curt
+ * Working on intergrating the VRML (subset) parser.
+ *
  * Revision 1.2  1997/05/23 15:40:42  curt
  * Added GNU copyright headers.
  *
index 79c7652073fa7d0cf190c1f1d4bf6451c2309460..a06d76e6c910e0242f8c6df50afd7948f46cb007 100644 (file)
 /* Feet to Meters */
 #define FEET_TO_METER    0.3048
 
+/* Meters to Feet */
+#define METER_TO_FEET    3.28083989501312335958  
+
 
 #endif CONSTANTS_H
 
 
 /* $Log$
-/* Revision 1.1  1997/07/07 21:02:36  curt
-/* Initial revision.
-/* */
+/* Revision 1.2  1997/07/08 18:20:11  curt
+/* Working on establishing a hard ground.
+/*
+ * Revision 1.1  1997/07/07 21:02:36  curt
+ * Initial revision.
+ * */