From be5527975ff763319921d3296fe9a617f230b269 Mon Sep 17 00:00:00 2001 From: curt Date: Wed, 9 Jul 1997 21:31:08 +0000 Subject: [PATCH] Working on making the ground "hard." --- Main/GLmain.c | 20 +++++++++++++++----- Main/mesh2GL.c | 20 +++++++++++--------- Scenery/mesh.c | 46 +++++++++++++++++++++++++++++++++++++++++++--- Simulator/make.inc | 10 +++++++--- 4 files changed, 76 insertions(+), 20 deletions(-) diff --git a/Main/GLmain.c b/Main/GLmain.c index 998a4e328..7b7dcbc39 100644 --- a/Main/GLmain.c +++ b/Main/GLmain.c @@ -81,7 +81,7 @@ static GLfloat sun_vec[4] = {-3.0, 1.0, 2.0, 0.0 }; /* static GLint scenery, runway; */ /* 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 goal_view_offset = 0.0; @@ -403,8 +403,15 @@ static void fgMainLoop( void ) { 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; + if ( FG_Altitude * FEET_TO_METER < rough_elev ) { + /* 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$ -/* Revision 1.28 1997/07/08 18:20:12 curt -/* Working on establishing a hard ground. +/* Revision 1.29 1997/07/09 21:31:12 curt +/* 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 * Working on scenery transformations to enable us to fly fluidly over the * poles with no discontinuity/distortion in scenery. diff --git a/Main/mesh2GL.c b/Main/mesh2GL.c index 88ed7acaf..2921db190 100644 --- a/Main/mesh2GL.c +++ b/Main/mesh2GL.c @@ -90,7 +90,7 @@ GLint mesh2GL(struct mesh *m) { z21 = 0.001 * m->mesh_data[(j+jstep) * m->rows + i ]; 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; MAT3cross_product(normal, v1, v2); MAT3_NORMALIZE_VEC(normal,temp); @@ -104,17 +104,16 @@ GLint mesh2GL(struct mesh *m) { glVertex3d(p12.y, p12.z, z12); } - glVertex3d(p21.y, p21.z, z21); - - v1[0] = p21.y - p12.y; v1[1] = p21.z - p12.z; v1[2] = z21 - z12; - v2[0] = p22.y - p12.y; v2[1] = p22.z - p12.z; v2[2] = z22 - z12; - MAT3cross_product(normal, v1, v2); + glVertex3d(p22.y, p22.z, z22); + + v2[0] = p21.y - p11.y; v2[1] = p21.z - p11.z; v2[2] = z21 - z11; + MAT3cross_product(normal, v2, v1); MAT3_NORMALIZE_VEC(normal,temp); glNormal3d(normal[0], normal[1], normal[2]); /* printf("normal 2 = (%.2f %.2f %.2f\n", normal[0], normal[1], normal[2]); */ - glVertex3d(p22.y, p22.z, z22); + glVertex3d(p21.y, p21.z, z21); x1 = x2; x2 = x1 + (m->row_step * jstep); @@ -133,9 +132,12 @@ GLint mesh2GL(struct mesh *m) { /* $Log$ -/* Revision 1.26 1997/07/08 18:20:13 curt -/* Working on establishing a hard ground. +/* Revision 1.27 1997/07/09 21:31:13 curt +/* 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 * Working on scenery transformations to enable us to fly fluidly over the * poles with no discontinuity/distortion in scenery. diff --git a/Scenery/mesh.c b/Scenery/mesh.c index 579d1f34f..f91281f4d 100644 --- a/Scenery/mesh.c +++ b/Scenery/mesh.c @@ -153,29 +153,69 @@ 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 */ + /* we expect incoming (lon,lat) to be in arcsec for now */ double xoffset, yoffset; int xindex, yindex; + /* determine if we are in the lower triangle or the upper triangle + ______ + | /| + | / | + | / | + |/ | + ------ + */ + xoffset = lon - eg.originx; yoffset = lat - eg.originy; xindex = xoffset / eg.col_step; yindex = yoffset / eg.row_step; + if ( xindex > yindex ) { + } if ( (xindex >= 0) && (xindex < eg.cols) ) { if ( (yindex >= 0) && (yindex < eg.rows) ) { 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$ -/* Revision 1.7 1997/07/08 18:20:13 curt -/* Working on establishing a hard ground. +/* Revision 1.8 1997/07/09 21:31:15 curt +/* 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 * More twiddling with the Scenery Management system. * diff --git a/Simulator/make.inc b/Simulator/make.inc index 013c50377..4d6201089 100644 --- a/Simulator/make.inc +++ b/Simulator/make.inc @@ -57,8 +57,7 @@ AR = ar # 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_LIBS = -lglut @@ -100,6 +101,9 @@ GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS) #--------------------------------------------------------------------------- # $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 # Working on scenery transformations to enable us to fly fluidly over the # poles with no discontinuity/distortion in scenery. -- 2.39.2