From b5293f1f44ddfc61d44d2ff86270f260c75c5865 Mon Sep 17 00:00:00 2001 From: curt Date: Thu, 30 Oct 1997 12:38:35 +0000 Subject: [PATCH] Working on new scenery subsystem. --- Cockpit/depend | 10 +++++++++ Main/GLUTmain.c | 10 ++++++--- Main/fg_init.c | 9 +++++--- Scenery/depend | 3 ++- Scenery/mesh.c | 10 ++++++--- Scenery/obj.c | 53 ++++++++++++++++++++++++++++++++++++---------- Scenery/stars.c | 8 ++++--- Simulator/Makefile | 6 ++++-- Time/depend | 2 +- 9 files changed, 84 insertions(+), 27 deletions(-) diff --git a/Cockpit/depend b/Cockpit/depend index 04135f2ba..a271456de 100644 --- a/Cockpit/depend +++ b/Cockpit/depend @@ -18,3 +18,13 @@ hud.o: hud.c hud.h ../Aircraft/aircraft.h \ ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \ ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \ ../Math/fg_random.h ../Weather/weather.h +test.o: test.c test.h ../Aircraft/aircraft.h \ + ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \ + ../Aircraft/../Flight/LaRCsim/ls_interface.h \ + ../Aircraft/../Flight/LaRCsim/../flight.h \ + ../Aircraft/../Controls/controls.h \ + ../Aircraft/../Controls/../limits.h ../Flight/flight.h \ + ../Controls/controls.h ../constants.h ../Scenery/mesh.h \ + ../Scenery/scenery.h ../Scenery/../types.h ../Math/mat3.h \ + ../Math/polar.h ../Math/../types.h ../Time/fg_timer.h \ + ../Math/fg_random.h ../Weather/weather.h diff --git a/Main/GLUTmain.c b/Main/GLUTmain.c index 7ecd89eab..9338ffab6 100644 --- a/Main/GLUTmain.c +++ b/Main/GLUTmain.c @@ -143,7 +143,8 @@ static void fgUpdateViewParams() { struct VIEW *v; double x_2, x_4, x_8, x_10; double ambient, diffuse, sky; - GLfloat color[4] = { 1.0, 1.0, 0.50, 1.0 }; + /* GLfloat color[4] = { 1.0, 1.0, 0.50, 1.0 };*/ + GLfloat color[4] = { 1.0, 0.0, 0.00, 1.0 }; GLfloat amb[3], diff[3], fog[4], clear[4]; f = ¤t_aircraft.flight; @@ -577,9 +578,12 @@ int main( int argc, char *argv[] ) { /* $Log$ -/* Revision 1.21 1997/09/23 00:29:38 curt -/* Tweaks to get things to compile with gcc-win32. +/* Revision 1.22 1997/10/30 12:38:41 curt +/* Working on new scenery subsystem. /* + * Revision 1.21 1997/09/23 00:29:38 curt + * Tweaks to get things to compile with gcc-win32. + * * Revision 1.20 1997/09/22 14:44:19 curt * Continuing to try to align stars correctly. * diff --git a/Main/fg_init.c b/Main/fg_init.c index 6d16f99e1..620c4e88c 100644 --- a/Main/fg_init.c +++ b/Main/fg_init.c @@ -101,7 +101,7 @@ void fgInitSubsystems( void ) { FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD; FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD; FG_Altitude = FG_Runway_altitude + 3.758099; - /* FG_Altitude = 20000; */ + FG_Altitude = 20000; /* Initial Position north of the city of Globe */ /* FG_Longitude = ( -398673.28 / 3600.0 ) * DEG_TO_RAD; */ @@ -224,9 +224,12 @@ void fgInitSubsystems( void ) { /* $Log$ -/* Revision 1.10 1997/10/25 03:24:23 curt -/* Incorporated sun, moon, and star positioning code contributed by Durk Talsma. +/* Revision 1.11 1997/10/30 12:38:42 curt +/* Working on new scenery subsystem. /* + * Revision 1.10 1997/10/25 03:24:23 curt + * Incorporated sun, moon, and star positioning code contributed by Durk Talsma. + * * Revision 1.9 1997/09/23 00:29:39 curt * Tweaks to get things to compile with gcc-win32. * diff --git a/Scenery/depend b/Scenery/depend index 0feaa8bc9..7fca180de 100644 --- a/Scenery/depend +++ b/Scenery/depend @@ -9,7 +9,8 @@ moon.o: moon.c orbits.h ../Time/fg_time.h ../Time/../types.h \ ../Time/../Flight/LaRCsim/../flight.h moon.h ../Main/views.h \ ../Main/../types.h ../Main/../Flight/flight.h ../Main/../Math/mat3.h \ ../general.h -obj.o: obj.c obj.h +obj.o: obj.c obj.h scenery.h ../types.h ../constants.h \ + ../Math/fg_geodesy.h ../Math/polar.h ../Math/../types.h orbits.o: orbits.c orbits.h ../Time/fg_time.h ../Time/../types.h \ ../Time/../Flight/flight.h ../Time/../Flight/Slew/slew.h \ ../Time/../Flight/LaRCsim/ls_interface.h \ diff --git a/Scenery/mesh.c b/Scenery/mesh.c index 6b36d36d9..595c23287 100644 --- a/Scenery/mesh.c +++ b/Scenery/mesh.c @@ -274,7 +274,8 @@ double mesh_altitude(double lon, double lat) { GLint mesh_to_OpenGL(struct MESH *m) { GLint mesh; /* static GLfloat color[4] = { 0.5, 0.4, 0.25, 1.0 }; */ /* dark desert */ - static GLfloat color[4] = { 0.5, 0.5, 0.25, 1.0 }; + /* static GLfloat color[4] = { 0.5, 0.5, 0.25, 1.0 }; */ + static GLfloat color[4] = { 1.0, 0.0, 0.0, 1.0 }; double centerx, centery; double randx, randy; @@ -395,9 +396,12 @@ GLint mesh_to_OpenGL(struct MESH *m) { /* $Log$ -/* Revision 1.22 1997/10/28 21:00:21 curt -/* Changing to new terrain format. +/* Revision 1.23 1997/10/30 12:38:44 curt +/* Working on new scenery subsystem. /* + * Revision 1.22 1997/10/28 21:00:21 curt + * Changing to new terrain format. + * * Revision 1.21 1997/08/27 03:30:27 curt * Changed naming scheme of basic shared structures. * diff --git a/Scenery/obj.c b/Scenery/obj.c index ea92cffa2..3955f09f9 100644 --- a/Scenery/obj.c +++ b/Scenery/obj.c @@ -32,6 +32,7 @@ #include #include "obj.h" +#include "scenery.h" #include "../constants.h" #include "../types.h" @@ -50,18 +51,18 @@ struct fgCartesianPoint geod_to_cart(float geod[3]) { struct fgCartesianPoint p; double gc_lon, gc_lat, sl_radius; - printf("A geodetic point is (%.2f, %.2f, %.2f)\n", - geod[0], geod[1], geod[2]); + /* printf("A geodetic point is (%.2f, %.2f, %.2f)\n", + geod[0], geod[1], geod[2]); */ gc_lon = geod[0]*ARCSEC_TO_RAD; fgGeodToGeoc(geod[1]*ARCSEC_TO_RAD, geod[2], &sl_radius, &gc_lat); - printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, - gc_lat, sl_radius+geod[2]); + /* printf("A geocentric point is (%.2f, %.2f, %.2f)\n", gc_lon, + gc_lat, sl_radius+geod[2]); */ p = fgPolarToCart(gc_lon, gc_lat, sl_radius+geod[2]); - printf("A cart point is (%.8f, %.8f, %.8f)\n", p.x, p.y, p.z); + /* printf("A cart point is (%.8f, %.8f, %.8f)\n", p.x, p.y, p.z); */ return(p); } @@ -71,10 +72,10 @@ struct fgCartesianPoint geod_to_cart(float geod[3]) { GLint fgObjLoad(char *path) { char line[256]; static GLfloat color[4] = { 0.5, 0.5, 0.25, 1.0 }; - struct fgCartesianPoint p1, p2, p3; + struct fgCartesianPoint p1, p2, p3, p4, ref; GLint area; FILE *f; - int first, ncount, n1, n2, n3; + int first, ncount, n1, n2, n3, n4; if ( (f = fopen(path, "r")) == NULL ) { printf("Cannot open file: %s\n", path); @@ -98,9 +99,14 @@ GLint fgObjLoad(char *path) { } else if ( line[0] == 'v' ) { /* node (vertex) */ if ( ncount < MAXNODES ) { - printf("vertex = %s", line); + /* printf("vertex = %s", line); */ sscanf(line, "v %f %f %f\n", &nodes[ncount][0], &nodes[ncount][1], &nodes[ncount][2]); + if ( ncount == 1 ) { + /* first node becomes the reference point */ + ref = geod_to_cart(nodes[ncount]); + scenery.center = ref; + } ncount++; } else { printf("Read too many nodes ... dying :-(\n"); @@ -109,11 +115,14 @@ GLint fgObjLoad(char *path) { } else if ( line[0] == 't' ) { /* start a new triangle strip */ + n1 = n2 = n3 = n4 = 0; + if ( !first ) { /* close out the previous structure and start the next */ - first = 0; glEnd(); glBegin(GL_TRIANGLE_STRIP); + } else { + first = 0; } printf("new tri strip = %s", line); @@ -122,6 +131,17 @@ GLint fgObjLoad(char *path) { p1 = geod_to_cart(nodes[n1]); p2 = geod_to_cart(nodes[n2]); p3 = geod_to_cart(nodes[n3]); + + glNormal3d(0.0, 0.0, -1.0); + + glVertex3d(p1.x - ref.x, p1.y - ref.y, p1.z - ref.z); + glVertex3d(p2.x - ref.x, p2.y - ref.y, p2.z - ref.z); + glVertex3d(p3.x - ref.x, p3.y - ref.y, p3.z - ref.z); + + if ( n4 > 0 ) { + p4 = geod_to_cart(nodes[n4]); + glVertex3d(p4.x - ref.x, p4.y - ref.y, p4.z - ref.z); + } } else if ( line[0] == 'q' ) { /* continue a triangle strip */ n1 = n2 = 0; @@ -129,6 +149,14 @@ GLint fgObjLoad(char *path) { printf("continued tri strip = %s", line); sscanf(line, "q %d %d\n", &n1, &n2); printf("read %d %d\n", n1, n2); + + p1 = geod_to_cart(nodes[n1]); + glVertex3d(p1.x - ref.x, p1.y - ref.y, p1.z - ref.z); + + if ( n2 > 0 ) { + p2 = geod_to_cart(nodes[n2]); + glVertex3d(p2.x - ref.x, p2.y - ref.y, p2.z - ref.z); + } } else { printf("Unknown line in %s = %s\n", path, line); } @@ -144,7 +172,10 @@ GLint fgObjLoad(char *path) { /* $Log$ -/* Revision 1.1 1997/10/28 21:14:54 curt -/* Initial revision. +/* Revision 1.2 1997/10/30 12:38:45 curt +/* Working on new scenery subsystem. /* + * Revision 1.1 1997/10/28 21:14:54 curt + * Initial revision. + * */ diff --git a/Scenery/stars.c b/Scenery/stars.c index a645500c3..4c3f985b3 100644 --- a/Scenery/stars.c +++ b/Scenery/stars.c @@ -41,7 +41,6 @@ #include "../constants.h" #include "../general.h" - #include "../Aircraft/aircraft.h" #include "../Main/views.h" #include "../Time/fg_time.h" @@ -271,9 +270,12 @@ void fgStarsRender() { /* $Log$ -/* Revision 1.14 1997/10/28 21:00:22 curt -/* Changing to new terrain format. +/* Revision 1.15 1997/10/30 12:38:45 curt +/* Working on new scenery subsystem. /* + * Revision 1.14 1997/10/28 21:00:22 curt + * Changing to new terrain format. + * * Revision 1.13 1997/10/25 03:18:28 curt * Incorporated sun, moon, and planet position and rendering code contributed * by Durk Talsma. diff --git a/Simulator/Makefile b/Simulator/Makefile index 8c77fe352..109decca9 100644 --- a/Simulator/Makefile +++ b/Simulator/Makefile @@ -28,8 +28,7 @@ include make.inc SUBSUBDIRS = Flight/LaRCsim Flight/Slew -SUBDIRS = Aircraft Cockpit Controls Flight Joystick Math Scenery \ - Time Weather +SUBDIRS = Aircraft Cockpit Controls Flight Joystick Math Scenery Time Weather MAIN = Main @@ -93,6 +92,9 @@ bin-zip: #--------------------------------------------------------------------------- # $Log$ +# Revision 1.29 1997/10/30 12:38:35 curt +# Working on new scenery subsystem. +# # Revision 1.28 1997/10/28 19:35:40 curt # Organizational changes. # diff --git a/Time/depend b/Time/depend index c73ae5e35..b6739f0e6 100644 --- a/Time/depend +++ b/Time/depend @@ -2,7 +2,7 @@ fg_time.o: fg_time.c fg_time.h ../types.h ../Flight/flight.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ ../Flight/LaRCsim/../flight.h ../constants.h ../Time/fg_time.h fg_timer.o: fg_timer.c fg_timer.h -sptest.o: sptest.c sunpos.h ../types.h ../constants.h +sidereal.o: sidereal.c ../constants.h sunpos.o: sunpos.c sunpos.h ../types.h fg_time.h ../Flight/flight.h \ ../Flight/Slew/slew.h ../Flight/LaRCsim/ls_interface.h \ ../Flight/LaRCsim/../flight.h ../constants.h ../Main/views.h \ -- 2.39.2