From 392f23ab352e9c1f3b6020305f06219536d2f5e4 Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 12 Jul 1997 02:27:07 +0000 Subject: [PATCH] Looking at potential scenery transformation/coordinate system problems. --- Main/depend | 5 +++-- Main/mesh2GL.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- Scenery/depend | 2 +- Scenery/mesh.c | 13 +++++++++---- 4 files changed, 59 insertions(+), 11 deletions(-) diff --git a/Main/depend b/Main/depend index d507caa67..96bb33611 100644 --- a/Main/depend +++ b/Main/depend @@ -19,5 +19,6 @@ GLmain.o: GLmain.c ../constants.h ../Aircraft/aircraft.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 +mesh2GL.o: mesh2GL.c ../constants.h ../Scenery/mesh.h \ + ../Scenery/scenery.h ../Math/mat3.h ../Math/polar.h \ + ../Math/../types.h diff --git a/Main/mesh2GL.c b/Main/mesh2GL.c index 2b84ce9fd..4b2d47265 100644 --- a/Main/mesh2GL.c +++ b/Main/mesh2GL.c @@ -33,6 +33,39 @@ #include "../Math/polar.h" +/* The following routine is a real hack used for testing puposes only + * and should probably be removed. */ +void mesh_make_test_object(double lon, double lat) { + struct fgCartesianPoint origin; + double elev; + double b = 0.25; + double h = 0.50; + static GLfloat color[4] = { 1.0, 0.25, 0.25, 1.0 }; + + glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, color ); + + elev = mesh_altitude(lon, lat) * 0.001; + printf("Elevation of test structure is: %.2f\n", elev); + + printf("Center of structure geodetic: (%.2f, %.2f\n", lon, lat); + origin = fgGeodetic2Cartesian(lon*ARCSEC_TO_RAD, lat*ARCSEC_TO_RAD); + printf("Center (unit circle) is (%.8f, %.8f, %.8f)\n", origin.x, origin.y, + origin.z); + + origin = fgRotateCartesianPoint(origin); + printf("Center of structure is: (%.4f, %.4f\n", origin.y, origin.z); + + glBegin(GL_TRIANGLE_STRIP); + glVertex3d(origin.y + b, origin.z-b, elev); + glVertex3d(origin.y - b, origin.z-b, elev); + glVertex3d(origin.y, origin.z, elev+h); + glVertex3d(origin.y - b, origin.z+b, elev); + glVertex3d(origin.y + b, origin.z+b, elev); + glVertex3d(origin.y + b, origin.z-b, elev); + glEnd(); + +} + /* walk through mesh and make ogl calls */ GLint mesh2GL(struct mesh *m) { GLint mesh; @@ -48,7 +81,10 @@ GLint mesh2GL(struct mesh *m) { printf("In mesh2GL(), generating GL call list.\n"); - istep = jstep = cur_scenery_params.terrain_skip ; /* Detail level */ + /* Detail level. This is how big a step we take as we walk + * through the DEM data set. This value is initialized in + * .../Scenery/scenery.c:fgSceneryInit() */ + istep = jstep = cur_scenery_params.terrain_skip ; /* setup the batch transformation */ fgRotateBatchInit(-m->originx * ARCSEC_TO_RAD, -m->originy * ARCSEC_TO_RAD); @@ -125,6 +161,9 @@ GLint mesh2GL(struct mesh *m) { y2 += m->col_step * istep; } + /* this will go, it's only here for testing/debugging */ + mesh_make_test_object(-398391.28, 120070.41); + glEndList(); return(mesh); @@ -133,10 +172,13 @@ GLint mesh2GL(struct mesh *m) { /* $Log$ -/* Revision 1.30 1997/07/11 03:23:18 curt -/* Solved some scenery display/orientation problems. Still have a positioning -/* (or transformation?) problem. +/* Revision 1.31 1997/07/12 02:27:07 curt +/* Looking at potential scenery transformation/coordinate system problems. /* + * Revision 1.30 1997/07/11 03:23:18 curt + * Solved some scenery display/orientation problems. Still have a positioning + * (or transformation?) problem. + * * Revision 1.29 1997/07/11 01:29:58 curt * More tweaking of terrian floor. * diff --git a/Scenery/depend b/Scenery/depend index 7a6e5240e..0dbd7ff05 100644 --- a/Scenery/depend +++ b/Scenery/depend @@ -1,6 +1,6 @@ common.o: common.c common.h geometry.o: geometry.c geometry.h mesh.h -mesh.o: mesh.c mesh.h common.h +mesh.o: mesh.c scenery.h mesh.h common.h parser.o: parser.c parsevrml.h geometry.h common.h mesh.h scenery.h scanner.o: scanner.c parser.h scenery.o: scenery.c scenery.h parsevrml.h diff --git a/Scenery/mesh.c b/Scenery/mesh.c index ff49208f5..f540bb37c 100644 --- a/Scenery/mesh.c +++ b/Scenery/mesh.c @@ -24,7 +24,9 @@ **************************************************************************/ -#include +#ifndef __CYGWIN32__ +# include +#endif #include #include /* atof(), atoi() */ #include @@ -249,10 +251,13 @@ double mesh_altitude(double lon, double lat) { /* $Log$ -/* Revision 1.12 1997/07/11 03:23:19 curt -/* Solved some scenery display/orientation problems. Still have a positioning -/* (or transformation?) problem. +/* Revision 1.13 1997/07/12 02:27:11 curt +/* Looking at potential scenery transformation/coordinate system problems. /* + * Revision 1.12 1997/07/11 03:23:19 curt + * Solved some scenery display/orientation problems. Still have a positioning + * (or transformation?) problem. + * * Revision 1.11 1997/07/11 01:30:02 curt * More tweaking of terrian floor. * -- 2.39.2