More tweaking of terrian floor.
This commit is contained in:
parent
1f718dcc8f
commit
5667631a45
5 changed files with 89 additions and 52 deletions
|
@ -193,9 +193,9 @@ static void fgUpdateViewParams() {
|
||||||
|
|
||||||
printf("View pos = %.4f, %.4f, %.4f\n", view_pos.y, view_pos.z,
|
printf("View pos = %.4f, %.4f, %.4f\n", view_pos.y, view_pos.z,
|
||||||
FG_Altitude * FEET_TO_METER);
|
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],
|
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]);
|
up[0], up[1], up[2]);
|
||||||
|
|
||||||
glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
|
glLightfv( GL_LIGHT0, GL_POSITION, sun_vec );
|
||||||
|
@ -410,7 +410,7 @@ static void fgMainLoop( void ) {
|
||||||
|
|
||||||
/* now set aircraft altitude above ground */
|
/* now set aircraft altitude above ground */
|
||||||
FG_Altitude = rough_elev * METER_TO_FEET + 3.758099;
|
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_Altitude * FEET_TO_METER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -499,6 +499,7 @@ int main( int argc, char *argv[] ) {
|
||||||
/* FG_Latitude = 0.0;
|
/* FG_Latitude = 0.0;
|
||||||
FG_Longitude = 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,
|
printf("Initial position is: (%.4f, %.4f, %.2f)\n", FG_Latitude,
|
||||||
FG_Longitude, FG_Altitude);
|
FG_Longitude, FG_Altitude);
|
||||||
|
@ -548,7 +549,7 @@ int main( int argc, char *argv[] ) {
|
||||||
* eventually */
|
* eventually */
|
||||||
rough_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
|
rough_elev = mesh_altitude(FG_Longitude * RAD_TO_DEG * 3600.0,
|
||||||
FG_Latitude * 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;
|
FG_Runway_altitude = rough_elev * METER_TO_FEET;
|
||||||
|
|
||||||
if ( FG_Altitude < FG_Runway_altitude ) {
|
if ( FG_Altitude < FG_Runway_altitude ) {
|
||||||
|
@ -610,12 +611,15 @@ int main( int argc, char *argv[] ) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.30 1997/07/10 04:26:37 curt
|
/* Revision 1.31 1997/07/11 01:29:58 curt
|
||||||
/* We now can interpolated ground elevation for any position in the grid. We
|
/* More tweaking of terrian floor.
|
||||||
/* 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.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
|
* Revision 1.29 1997/07/09 21:31:12 curt
|
||||||
* Working on making the ground "hard."
|
* Working on making the ground "hard."
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include "../constants.h"
|
#include "../constants.h"
|
||||||
#include "../Scenery/mesh.h"
|
#include "../Scenery/mesh.h"
|
||||||
|
#include "../Scenery/scenery.h"
|
||||||
#include "../Math/mat3.h"
|
#include "../Math/mat3.h"
|
||||||
#include "../Math/polar.h"
|
#include "../Math/polar.h"
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ GLint mesh2GL(struct mesh *m) {
|
||||||
|
|
||||||
printf("In mesh2GL(), generating GL call list.\n");
|
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 */
|
/* setup the batch transformation */
|
||||||
fgRotateBatchInit(-m->originx * ARCSEC_TO_RAD, -m->originy * ARCSEC_TO_RAD);
|
fgRotateBatchInit(-m->originx * ARCSEC_TO_RAD, -m->originy * ARCSEC_TO_RAD);
|
||||||
|
@ -132,12 +133,15 @@ GLint mesh2GL(struct mesh *m) {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.28 1997/07/10 04:26:37 curt
|
/* Revision 1.29 1997/07/11 01:29:58 curt
|
||||||
/* We now can interpolated ground elevation for any position in the grid. We
|
/* More tweaking of terrian floor.
|
||||||
/* 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.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
|
* Revision 1.27 1997/07/09 21:31:13 curt
|
||||||
* Working on making the ground "hard."
|
* Working on making the ground "hard."
|
||||||
*
|
*
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
|
#include "scenery.h"
|
||||||
#include "mesh.h"
|
#include "mesh.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
|
@ -158,7 +159,9 @@ double mesh_altitude(double lon, double lat) {
|
||||||
double xlocal, ylocal, dx, dy, zA, zB, elev;
|
double xlocal, ylocal, dx, dy, zA, zB, elev;
|
||||||
int x1, y1, z1, x2, y2, z2, x3, y3, z3;
|
int x1, y1, z1, x2, y2, z2, x3, y3, z3;
|
||||||
int xindex, yindex;
|
int xindex, yindex;
|
||||||
|
int skip;
|
||||||
|
|
||||||
|
skip = cur_scenery_params.terrain_skip;
|
||||||
/* determine if we are in the lower triangle or the upper triangle
|
/* determine if we are in the lower triangle or the upper triangle
|
||||||
______
|
______
|
||||||
| /|
|
| /|
|
||||||
|
@ -173,81 +176,88 @@ double mesh_altitude(double lon, double lat) {
|
||||||
xlocal = (lon - eg.originx) / eg.col_step;
|
xlocal = (lon - eg.originx) / eg.col_step;
|
||||||
ylocal = (lat - eg.originy) / eg.row_step;
|
ylocal = (lat - eg.originy) / eg.row_step;
|
||||||
|
|
||||||
xindex = (int)xlocal;
|
xindex = (int)(xlocal / skip) * skip;
|
||||||
yindex = (int)ylocal;
|
yindex = (int)(ylocal / skip) * skip;
|
||||||
|
|
||||||
|
if ( (xindex < 0) || (xindex + skip >= eg.cols) ||
|
||||||
|
(yindex < 0) || (yindex + skip >= eg.rows) ) {
|
||||||
|
return(-9999);
|
||||||
|
}
|
||||||
|
|
||||||
dx = xlocal - xindex;
|
dx = xlocal - xindex;
|
||||||
dy = ylocal - yindex;
|
dy = ylocal - yindex;
|
||||||
|
|
||||||
if ( dx > dy ) {
|
if ( dx > dy ) {
|
||||||
/* lower triangle */
|
/* lower triangle */
|
||||||
printf(" Lower triangle\n");
|
/* printf(" Lower triangle\n"); */
|
||||||
|
|
||||||
x1 = xindex;
|
x1 = xindex;
|
||||||
y1 = yindex;
|
y1 = yindex;
|
||||||
z1 = eg.mesh_data[x1 * eg.rows + y1];
|
z1 = eg.mesh_data[x1 * eg.rows + y1];
|
||||||
|
|
||||||
x2 = xindex + eg.col_step;
|
x2 = xindex + skip;
|
||||||
y2 = yindex;
|
y2 = yindex;
|
||||||
z2 = eg.mesh_data[x2 * eg.rows + y2];
|
z2 = eg.mesh_data[x2 * eg.rows + y2];
|
||||||
|
|
||||||
x3 = xindex + eg.col_step;
|
x3 = xindex + skip;
|
||||||
y3 = yindex + eg.row_step;
|
y3 = yindex + skip;
|
||||||
z3 = eg.mesh_data[x3 * eg.rows + y3];
|
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(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
|
||||||
printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
|
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;
|
zA = dx * (z2 - z1) / skip + z1;
|
||||||
zB = dx * (z3 - z1) / eg.col_step + 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 {
|
} else {
|
||||||
/* upper triangle */
|
/* upper triangle */
|
||||||
printf(" Upper triangle\n");
|
/* printf(" Upper triangle\n"); */
|
||||||
|
|
||||||
x1 = xindex;
|
x1 = xindex;
|
||||||
y1 = yindex;
|
y1 = yindex;
|
||||||
z1 = eg.mesh_data[x1 * eg.rows + y1];
|
z1 = eg.mesh_data[x1 * eg.rows + y1];
|
||||||
|
|
||||||
x2 = xindex;
|
x2 = xindex;
|
||||||
y2 = yindex + eg.row_step;
|
y2 = yindex + skip;
|
||||||
z2 = eg.mesh_data[x2 * eg.rows + y2];
|
z2 = eg.mesh_data[x2 * eg.rows + y2];
|
||||||
|
|
||||||
x3 = xindex + eg.col_step;
|
x3 = xindex + skip;
|
||||||
y3 = yindex + eg.row_step;
|
y3 = yindex + skip;
|
||||||
z3 = eg.mesh_data[x3 * eg.rows + y3];
|
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(" (x1,y1,z1) = (%d,%d,%d)\n", x1, y1, z1);
|
||||||
printf(" (x2,y2,z2) = (%d,%d,%d)\n", x2, y2, z2);
|
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;
|
zA = dy * (z2 - z1) / skip + z1;
|
||||||
zB = dy * (z3 - z1) / eg.row_step + z1;
|
zB = dy * (z3 - z1) / skip + z1;
|
||||||
|
|
||||||
printf(" zA = %.2f zB = %.2f\n", zA, zB );
|
/* printf(" zA = %.2f zB = %.2f\n", zA, zB );
|
||||||
printf(" dx = %.2f xB - xA = %.2f\n", dx,
|
printf(" xB - xA = %.2f\n", eg.col_step * dy / eg.row_step); */
|
||||||
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);
|
return(elev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.10 1997/07/10 04:26:38 curt
|
/* Revision 1.11 1997/07/11 01:30:02 curt
|
||||||
/* We now can interpolated ground elevation for any position in the grid. We
|
/* More tweaking of terrian floor.
|
||||||
/* 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.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
|
* Revision 1.9 1997/07/10 02:22:10 curt
|
||||||
* Working on terrain elevation interpolation routine.
|
* Working on terrain elevation interpolation routine.
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,9 +34,14 @@
|
||||||
GLint mesh_hack;
|
GLint mesh_hack;
|
||||||
|
|
||||||
|
|
||||||
|
/* Shared structure to hold current scenery parameters */
|
||||||
|
struct scenery_params cur_scenery_params;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the Scenery Management system */
|
/* Initialize the Scenery Management system */
|
||||||
void fgSceneryInit() {
|
void fgSceneryInit() {
|
||||||
/* nothing to do here yet */
|
/* set the default terrain detail level */
|
||||||
|
cur_scenery_params.terrain_skip = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,9 +65,12 @@ void fgSceneryRender() {
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.3 1997/06/29 21:16:50 curt
|
/* Revision 1.4 1997/07/11 01:30:03 curt
|
||||||
/* More twiddling with the Scenery Management system.
|
/* More tweaking of terrian floor.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.3 1997/06/29 21:16:50 curt
|
||||||
|
* More twiddling with the Scenery Management system.
|
||||||
|
*
|
||||||
* Revision 1.2 1997/06/27 20:03:37 curt
|
* Revision 1.2 1997/06/27 20:03:37 curt
|
||||||
* Working on Makefile structure.
|
* Working on Makefile structure.
|
||||||
*
|
*
|
||||||
|
|
|
@ -28,6 +28,14 @@
|
||||||
#define SCENERY_H
|
#define SCENERY_H
|
||||||
|
|
||||||
|
|
||||||
|
/* Define a structure containing global scenery parameters */
|
||||||
|
struct scenery_params {
|
||||||
|
int terrain_skip; /* number of terrain data points to skip */
|
||||||
|
};
|
||||||
|
|
||||||
|
extern struct scenery_params cur_scenery_params;
|
||||||
|
|
||||||
|
|
||||||
/* Initialize the Scenery Management system */
|
/* Initialize the Scenery Management system */
|
||||||
void fgSceneryInit();
|
void fgSceneryInit();
|
||||||
|
|
||||||
|
@ -43,9 +51,12 @@ void fgSceneryRender();
|
||||||
|
|
||||||
|
|
||||||
/* $Log$
|
/* $Log$
|
||||||
/* Revision 1.5 1997/06/26 22:14:57 curt
|
/* Revision 1.6 1997/07/11 01:30:03 curt
|
||||||
/* Beginning work on a scenery management system.
|
/* More tweaking of terrian floor.
|
||||||
/*
|
/*
|
||||||
|
* Revision 1.5 1997/06/26 22:14:57 curt
|
||||||
|
* Beginning work on a scenery management system.
|
||||||
|
*
|
||||||
* Revision 1.4 1997/06/21 17:57:21 curt
|
* Revision 1.4 1997/06/21 17:57:21 curt
|
||||||
* directory shuffling ...
|
* directory shuffling ...
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue