1
0
Fork 0

Working on making the ground "hard."

This commit is contained in:
curt 1997-07-09 21:31:08 +00:00
parent 134081456f
commit be5527975f
4 changed files with 76 additions and 20 deletions

View file

@ -81,7 +81,7 @@ static GLfloat sun_vec[4] = {-3.0, 1.0, 2.0, 0.0 };
/* static GLint scenery, runway; */ /* static GLint scenery, runway; */
/* Another hack */ /* Another hack */
double fogDensity = 80.0; /* in meters = about 70 miles */ double fogDensity = 60.0; /* in meters = about 70 miles */
double view_offset = 0.0; double view_offset = 0.0;
double goal_view_offset = 0.0; double goal_view_offset = 0.0;
@ -403,8 +403,15 @@ static void fgMainLoop( void ) {
printf("Ground elevation is about %.2f meters here.\n", rough_elev); printf("Ground elevation is about %.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 * FEET_TO_METER < rough_elev ) {
FG_Altitude = FG_Runway_altitude + 3.758099; /* set this here, otherwise if we set runway height above our
current height we get a really nasty bounce. */
FG_Runway_altitude = FG_Altitude - 3.758099;
/* now set aircraft altitude above ground */
FG_Altitude = rough_elev * METER_TO_FEET + 3.758099;
printf("<*> reseting altitude to %.0f meters\n",
FG_Altitude * FEET_TO_METER);
} }
} }
@ -603,9 +610,12 @@ int main( int argc, char *argv[] ) {
/* $Log$ /* $Log$
/* Revision 1.28 1997/07/08 18:20:12 curt /* Revision 1.29 1997/07/09 21:31:12 curt
/* Working on establishing a hard ground. /* Working on making the ground "hard."
/* /*
* 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 * Revision 1.27 1997/07/07 20:59:49 curt
* Working on scenery transformations to enable us to fly fluidly over the * Working on scenery transformations to enable us to fly fluidly over the
* poles with no discontinuity/distortion in scenery. * poles with no discontinuity/distortion in scenery.

View file

@ -90,7 +90,7 @@ GLint mesh2GL(struct mesh *m) {
z21 = 0.001 * m->mesh_data[(j+jstep) * m->rows + i ]; z21 = 0.001 * m->mesh_data[(j+jstep) * m->rows + i ];
z22 = 0.001 * m->mesh_data[(j+jstep) * m->rows + (i+istep)]; z22 = 0.001 * m->mesh_data[(j+jstep) * m->rows + (i+istep)];
v1[0] = p21.y - p11.y; v1[1] = p21.z - p11.z; v1[2] = z21 - z11; v1[0] = p22.y - p11.y; v1[1] = p22.z - p11.z; v1[2] = z22 - z11;
v2[0] = p12.y - p11.y; v2[1] = p12.z - p11.z; v2[2] = z12 - z11; v2[0] = p12.y - p11.y; v2[1] = p12.z - p11.z; v2[2] = z12 - z11;
MAT3cross_product(normal, v1, v2); MAT3cross_product(normal, v1, v2);
MAT3_NORMALIZE_VEC(normal,temp); MAT3_NORMALIZE_VEC(normal,temp);
@ -104,17 +104,16 @@ GLint mesh2GL(struct mesh *m) {
glVertex3d(p12.y, p12.z, z12); glVertex3d(p12.y, p12.z, z12);
} }
glVertex3d(p21.y, p21.z, z21); glVertex3d(p22.y, p22.z, z22);
v1[0] = p21.y - p12.y; v1[1] = p21.z - p12.z; v1[2] = z21 - z12; v2[0] = p21.y - p11.y; v2[1] = p21.z - p11.z; v2[2] = z21 - z11;
v2[0] = p22.y - p12.y; v2[1] = p22.z - p12.z; v2[2] = z22 - z12; MAT3cross_product(normal, v2, v1);
MAT3cross_product(normal, v1, v2);
MAT3_NORMALIZE_VEC(normal,temp); MAT3_NORMALIZE_VEC(normal,temp);
glNormal3d(normal[0], normal[1], normal[2]); glNormal3d(normal[0], normal[1], normal[2]);
/* printf("normal 2 = (%.2f %.2f %.2f\n", normal[0], normal[1], /* printf("normal 2 = (%.2f %.2f %.2f\n", normal[0], normal[1],
normal[2]); */ normal[2]); */
glVertex3d(p22.y, p22.z, z22); glVertex3d(p21.y, p21.z, z21);
x1 = x2; x1 = x2;
x2 = x1 + (m->row_step * jstep); x2 = x1 + (m->row_step * jstep);
@ -133,9 +132,12 @@ GLint mesh2GL(struct mesh *m) {
/* $Log$ /* $Log$
/* Revision 1.26 1997/07/08 18:20:13 curt /* Revision 1.27 1997/07/09 21:31:13 curt
/* Working on establishing a hard ground. /* Working on making the ground "hard."
/* /*
* 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 * Revision 1.25 1997/07/07 20:59:50 curt
* Working on scenery transformations to enable us to fly fluidly over the * Working on scenery transformations to enable us to fly fluidly over the
* poles with no discontinuity/distortion in scenery. * poles with no discontinuity/distortion in scenery.

View file

@ -153,29 +153,69 @@ void mesh_do_it(struct mesh *m) {
/* return the current altitude based on mesh data. We should rewrite /* return the current altitude based on mesh data. We should rewrite
* this to interpolate exact values, but for now this is good enough */ * this to interpolate exact values, but for now this is good enough */
double mesh_altitude(double lon, double lat) { double mesh_altitude(double lon, double lat) {
/* we expect things in arcsec for now */ /* we expect incoming (lon,lat) to be in arcsec for now */
double xoffset, yoffset; double xoffset, yoffset;
int xindex, yindex; int xindex, yindex;
/* determine if we are in the lower triangle or the upper triangle
______
| /|
| / |
| / |
|/ |
------
*/
xoffset = lon - eg.originx; xoffset = lon - eg.originx;
yoffset = lat - eg.originy; yoffset = lat - eg.originy;
xindex = xoffset / eg.col_step; xindex = xoffset / eg.col_step;
yindex = yoffset / eg.row_step; yindex = yoffset / eg.row_step;
if ( xindex > yindex ) {
}
if ( (xindex >= 0) && (xindex < eg.cols) ) { if ( (xindex >= 0) && (xindex < eg.cols) ) {
if ( (yindex >= 0) && (yindex < eg.rows) ) { if ( (yindex >= 0) && (yindex < eg.rows) ) {
return( eg.mesh_data[xindex * eg.rows + yindex] ); return( eg.mesh_data[xindex * eg.rows + yindex] );
} }
} }
/*
given (x1, y1, z1) (x2, y2, z2) and (x3, y3, z3)
calculate z = ax + by + c (the equation of the plane intersecting the
three given points
Then, given a position we can calculate the current ground elevation
tmp1 = (x2 * z1 / x1 - z2);
tmp2 = (y2 - x2 * y1 / x1);
tmp3 = (x2 * y1 / x1 - y2);
tmp4 = (1 - x2 / x1);
tmp5 = (x3*(z1 + y1*tmp1 / tmp2) / x1 - z3 + y3*tmp1 / tmp3);
tmp6 = x3*(y1*tmp4 / tmp2 - 1);
tmp7 = tmp5 / (y3*tmp4 / tmp2 - tmp6 / x1 - 1);
tmp8 = (tmp6 / x1 + y3*tmp4 / tmp3 + 1);
tmp9 = (z1 + tmp5 / tmp8);
tmp10 = (tmp7 + x2*tmp9 / x1 - z2);
a = (tmp9 + y1*tmp10 / tmp2) / x1;
b = tmp10 / tmp3;
c = tmp7;
*/
} }
/* $Log$ /* $Log$
/* Revision 1.7 1997/07/08 18:20:13 curt /* Revision 1.8 1997/07/09 21:31:15 curt
/* Working on establishing a hard ground. /* Working on making the ground "hard."
/* /*
* 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 * Revision 1.6 1997/06/29 21:16:49 curt
* More twiddling with the Scenery Management system. * More twiddling with the Scenery Management system.
* *

View file

@ -57,8 +57,7 @@ AR = ar
# much smoother. # much smoother.
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# FG_CFLAGS = -g -Wall -DUSE_ITIMER FG_CFLAGS = -g -Wall
FG_CFLAGS = -g -Wall
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -69,7 +68,9 @@ FG_CFLAGS = -g -Wall
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# SGI IRIX with the GLUT toolkit # SGI IRIX with the GLUT toolkit (surprisingly, this also works on our
# SunOS 4.x machine with the way we have
# Mesa & Glut installed.)
# #
# INTERFACE_FLAGS = -DGLUT # INTERFACE_FLAGS = -DGLUT
# INTERFACE_LIBS = -lglut # INTERFACE_LIBS = -lglut
@ -100,6 +101,9 @@ GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# $Log$ # $Log$
# Revision 1.3 1997/07/09 21:31:08 curt
# Working on making the ground "hard."
#
# Revision 1.2 1997/07/07 20:59:48 curt # Revision 1.2 1997/07/07 20:59:48 curt
# Working on scenery transformations to enable us to fly fluidly over the # Working on scenery transformations to enable us to fly fluidly over the
# poles with no discontinuity/distortion in scenery. # poles with no discontinuity/distortion in scenery.