#include "../constants.h"
#include "../Aircraft/aircraft.h"
+#include "../Scenery/mesh.h"
#include "../Scenery/scenery.h"
#include "../Math/mat3.h"
#include "../Math/polar.h"
static void fgMainLoop( void ) {
static int remainder = 0;
int elapsed, multi_loop;
+ double rough_elev;
+ struct flight_params *f;
+
+ f = ¤t_aircraft.flight;
elapsed = fgGetTimeInterval();
printf("Time interval is = %d, previous remainder is = %d\n", elapsed,
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;
+ }
}
int main( int argc, char *argv[] ) {
struct flight_params *f;
+ double rough_elev;
f = ¤t_aircraft.flight;
/* 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 );
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.
**********************************************************************/
/* $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.
*
../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
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);
/* $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.
*
static vrmlGeometryType;
-static struct mesh eg;
+struct mesh eg;
/* Begin a new vrml geometry statement */
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.
*
/* 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) {
}
+/* 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.
*
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.
*
/* 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.
+ * */