printf("View pos = %.4f, %.4f, %.4f\n", view_pos.y, view_pos.z,
FG_Altitude * FEET_TO_METER);
- gluLookAt(view_pos.y, view_pos.z, (FG_Altitude+3.0)*FEET_TO_METER * 0.0011,
+ gluLookAt(view_pos.y, view_pos.z, FG_Altitude*FEET_TO_METER * 0.0011,
view_pos.y + fwrd_view[0], view_pos.z + fwrd_view[1],
- (FG_Altitude+3.0)*FEET_TO_METER * 0.001 + fwrd_view[2],
+ FG_Altitude*FEET_TO_METER * 0.001 + fwrd_view[2],
up[0], up[1], up[2]);
glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
/* now set aircraft altitude above ground */
FG_Altitude = rough_elev * METER_TO_FEET + 3.758099;
- printf("<*> reseting altitude to %.0f meters\n",
+ printf("<*> resetting altitude to %.0f meters\n",
FG_Altitude * FEET_TO_METER);
}
}
FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD;
/* FG_Latitude = 0.0;
FG_Longitude = 0.0; */
- FG_Altitude = FG_Runway_altitude + 3.758099;
+ FG_Altitude = FG_Runway_altitude + 3.758099;
+ FG_Altitude = 15000.0;
printf("Initial position is: (%.4f, %.4f, %.2f)\n", FG_Latitude,
FG_Longitude, FG_Altitude);
* 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);
+ printf("Ground elevation is %.2f meters here.\n", rough_elev);
FG_Runway_altitude = rough_elev * METER_TO_FEET;
if ( FG_Altitude < FG_Runway_altitude ) {
/* $Log$
-/* Revision 1.30 1997/07/10 04:26:37 curt
-/* We now can interpolated ground elevation for any position in the grid. We
-/* can use this to enforce a "hard" ground. We still need to enforce some
-/* bounds checking so that we don't try to lookup data points outside the
-/* grid data set.
+/* Revision 1.31 1997/07/11 01:29:58 curt
+/* More tweaking of terrian floor.
/*
+ * Revision 1.30 1997/07/10 04:26:37 curt
+ * We now can interpolated ground elevation for any position in the grid. We
+ * can use this to enforce a "hard" ground. We still need to enforce some
+ * bounds checking so that we don't try to lookup data points outside the
+ * grid data set.
+ *
* Revision 1.29 1997/07/09 21:31:12 curt
* Working on making the ground "hard."
*
#include "../constants.h"
#include "../Scenery/mesh.h"
+#include "../Scenery/scenery.h"
#include "../Math/mat3.h"
#include "../Math/polar.h"
printf("In mesh2GL(), generating GL call list.\n");
- istep = jstep = 10; /* Detail level 1 -- 1200 ... */
+ istep = jstep = cur_scenery_params.terrain_skip ; /* Detail level */
/* setup the batch transformation */
fgRotateBatchInit(-m->originx * ARCSEC_TO_RAD, -m->originy * ARCSEC_TO_RAD);
/* $Log$
-/* Revision 1.28 1997/07/10 04:26:37 curt
-/* We now can interpolated ground elevation for any position in the grid. We
-/* can use this to enforce a "hard" ground. We still need to enforce some
-/* bounds checking so that we don't try to lookup data points outside the
-/* grid data set.
+/* Revision 1.29 1997/07/11 01:29:58 curt
+/* More tweaking of terrian floor.
/*
+ * Revision 1.28 1997/07/10 04:26:37 curt
+ * We now can interpolated ground elevation for any position in the grid. We
+ * can use this to enforce a "hard" ground. We still need to enforce some
+ * bounds checking so that we don't try to lookup data points outside the
+ * grid data set.
+ *
* Revision 1.27 1997/07/09 21:31:13 curt
* Working on making the ground "hard."
*
#include <GL/glut.h>
+#include "scenery.h"
#include "mesh.h"
#include "common.h"
double xlocal, ylocal, dx, dy, zA, zB, elev;
int x1, y1, z1, x2, y2, z2, x3, y3, z3;
int xindex, yindex;
+ int skip;
+ skip = cur_scenery_params.terrain_skip;
/* determine if we are in the lower triangle or the upper triangle
______
| /|
then calculate our end points
*/
- xlocal = ( lon - eg.originx ) / eg.col_step;
- ylocal = ( lat - eg.originy ) / eg.row_step;
+ xlocal = (lon - eg.originx) / eg.col_step;
+ ylocal = (lat - eg.originy) / eg.row_step;
- xindex = (int)xlocal;
- yindex = (int)ylocal;
+ xindex = (int)(xlocal / skip) * skip;
+ yindex = (int)(ylocal / skip) * skip;
+
+ if ( (xindex < 0) || (xindex + skip >= eg.cols) ||
+ (yindex < 0) || (yindex + skip >= eg.rows) ) {
+ return(-9999);
+ }
dx = xlocal - xindex;
dy = ylocal - yindex;
if ( dx > dy ) {
/* lower triangle */
- printf(" Lower triangle\n");
+ /* printf(" Lower triangle\n"); */
x1 = xindex;
y1 = yindex;
z1 = eg.mesh_data[x1 * eg.rows + y1];
- x2 = xindex + eg.col_step;
+ x2 = xindex + skip;
y2 = yindex;
z2 = eg.mesh_data[x2 * eg.rows + y2];
- x3 = xindex + eg.col_step;
- y3 = yindex + eg.row_step;
+ x3 = xindex + skip;
+ y3 = yindex + skip;
z3 = eg.mesh_data[x3 * eg.rows + y3];
+ /* printf(" dx = %.2f dy = %.2f\n", dx, dy);
printf(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
- printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
+ printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3); */
- zA = dx * (z2 - z1) / eg.col_step + z1;
- zB = dx * (z3 - z1) / eg.col_step + z1;
+ zA = dx * (z2 - z1) / skip + z1;
+ zB = dx * (z3 - z1) / skip + z1;
- printf(" zA = %.2f zB = %.2f\n", zA, zB);
+ /* printf(" zA = %.2f zB = %.2f\n", zA, zB); */
- elev = dy * (zB - zA) * eg.col_step / (eg.row_step * dx) + zA;
+ elev = dy * (zB - zA) / dx + zA;
} else {
/* upper triangle */
- printf(" Upper triangle\n");
+ /* printf(" Upper triangle\n"); */
x1 = xindex;
y1 = yindex;
z1 = eg.mesh_data[x1 * eg.rows + y1];
x2 = xindex;
- y2 = yindex + eg.row_step;
+ y2 = yindex + skip;
z2 = eg.mesh_data[x2 * eg.rows + y2];
- x3 = xindex + eg.col_step;
- y3 = yindex + eg.row_step;
+ x3 = xindex + skip;
+ y3 = yindex + skip;
z3 = eg.mesh_data[x3 * eg.rows + y3];
+ /* printf(" dx = %.2f dy = %.2f\n", dx, dy);
printf(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
- printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3);
+ printf(" (x3,y3,z3) = (%d,%d,%d)\n", x3, y3, z3); */
- zA = dy * (z2 - z1) / eg.row_step + z1;
- zB = dy * (z3 - z1) / eg.row_step + z1;
+ zA = dy * (z2 - z1) / skip + z1;
+ zB = dy * (z3 - z1) / skip + z1;
- printf(" zA = %.2f zB = %.2f\n", zA, zB );
- printf(" dx = %.2f xB - xA = %.2f\n", dx,
- eg.col_step * dy / eg.row_step);
+ /* printf(" zA = %.2f zB = %.2f\n", zA, zB );
+ printf(" xB - xA = %.2f\n", eg.col_step * dy / eg.row_step); */
- elev = dx * (zB - zA) * eg.row_step / (eg.col_step * dy) + zA;
+ elev = dx * (zB - zA) / dy + zA;
}
- printf("Our true ground elevation is %.2f\n", elev);
-
return(elev);
}
/* $Log$
-/* Revision 1.10 1997/07/10 04:26:38 curt
-/* We now can interpolated ground elevation for any position in the grid. We
-/* can use this to enforce a "hard" ground. We still need to enforce some
-/* bounds checking so that we don't try to lookup data points outside the
-/* grid data set.
+/* Revision 1.11 1997/07/11 01:30:02 curt
+/* More tweaking of terrian floor.
/*
+ * Revision 1.10 1997/07/10 04:26:38 curt
+ * We now can interpolated ground elevation for any position in the grid. We
+ * can use this to enforce a "hard" ground. We still need to enforce some
+ * bounds checking so that we don't try to lookup data points outside the
+ * grid data set.
+ *
* Revision 1.9 1997/07/10 02:22:10 curt
* Working on terrain elevation interpolation routine.
*