1
0
Fork 0

Working on scenery transformations to enable us to fly fluidly over the

poles with no discontinuity/distortion in scenery.
This commit is contained in:
curt 1997-07-07 20:59:47 +00:00
parent 37a2b12501
commit 09c494327b
8 changed files with 113 additions and 48 deletions

View file

@ -11,7 +11,7 @@
TARGET = libLaRCsim.a TARGET = libLaRCsim.a
LaRCsimFILES = atmos_62.c ls_accel.c ls_aux.c ls_geodesy.c ls_gravity.c \ LaRCsimFILES = atmos_62.c ls_accel.c ls_aux.c ls_geodesy.c ls_gravity.c \
ls_step.c ls_model.c default_model_routines.c ls_init.c ls_sync.c ls_step.c ls_model.c default_model_routines.c ls_init.c # ls_sync.c
NavionFILES = navion_aero.c navion_engine.c navion_gear.c navion_init.c NavionFILES = navion_aero.c navion_engine.c navion_gear.c navion_init.c
@ -55,6 +55,10 @@ include depend
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# $Log$ # $Log$
# Revision 1.7 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.
#
# Revision 1.6 1997/06/27 21:38:06 curt # Revision 1.6 1997/06/27 21:38:06 curt
# Working on Makefile structure. # Working on Makefile structure.
# #

View file

@ -38,15 +38,15 @@
#include "GLTKkey.h" #include "GLTKkey.h"
#endif #endif
#include "../constants.h"
#include "../Aircraft/aircraft.h" #include "../Aircraft/aircraft.h"
#include "../Scenery/scenery.h" #include "../Scenery/scenery.h"
#include "../Math/mat3.h" #include "../Math/mat3.h"
#include "../Math/polar.h"
#include "../Timer/fg_timer.h" #include "../Timer/fg_timer.h"
#define DEG_TO_RAD 0.017453292
#define RAD_TO_DEG 57.29577951
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 /* pi */ #define M_PI 3.14159265358979323846 /* pi */
#endif #endif
@ -80,7 +80,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 = 2000.0; double fogDensity = 80.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;
@ -134,7 +134,7 @@ static void fgInitVisuals() {
**************************************************************************/ **************************************************************************/
static void fgUpdateViewParams() { static void fgUpdateViewParams() {
double pos_x, pos_y, pos_z; struct fgCartesianPoint view_pos;
struct flight_params *f; struct flight_params *f;
MAT3mat R, TMP; MAT3mat R, TMP;
MAT3vec vec, up, forward, fwrd_view; MAT3vec vec, up, forward, fwrd_view;
@ -144,17 +144,16 @@ static void fgUpdateViewParams() {
/* Tell GL we are about to modify the projection parameters */ /* Tell GL we are about to modify the projection parameters */
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
gluPerspective(45.0, 1.0/win_ratio, 0.01, 6000.0); gluPerspective(45.0, 1.0/win_ratio, 0.1, 200000.0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
/* calculate position in arc seconds */ /* calculate position in current FG view coordinate system */
pos_x = (FG_Longitude * RAD_TO_DEG) * 3600.0; view_pos = fgGeodetic2Cartesian(FG_Longitude, FG_Latitude);
pos_y = (FG_Latitude * RAD_TO_DEG) * 3600.0; view_pos = fgRotateCartesianPoint(view_pos);
pos_z = FG_Altitude * 0.01; /* (Convert feet to aproximate arcsecs) */
printf("*** pos_z = %.2f\n", pos_z); printf("*** Altitude = %.2f meters\n", FG_Altitude * FEET_TO_METER);
/* build current rotation matrix */ /* build current rotation matrix */
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0); MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
@ -191,8 +190,11 @@ static void fgUpdateViewParams() {
MAT3rotate(TMP, up, view_offset); MAT3rotate(TMP, up, view_offset);
MAT3mult_vec(fwrd_view, forward, TMP); MAT3mult_vec(fwrd_view, forward, TMP);
gluLookAt(pos_x, pos_y, pos_z, printf("View pos = %.4f, %.4f, %.4f\n", view_pos.y, view_pos.z,
pos_x + fwrd_view[0], pos_y + fwrd_view[1], pos_z + fwrd_view[2], FG_Altitude * FEET_TO_METER);
gluLookAt(view_pos.y, view_pos.z, FG_Altitude * FEET_TO_METER * 0.001,
view_pos.y + fwrd_view[0], view_pos.z + fwrd_view[1],
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 );
@ -468,10 +470,10 @@ int main( int argc, char *argv[] ) {
FG_Runway_heading = 102.0 * DEG_TO_RAD; FG_Runway_heading = 102.0 * DEG_TO_RAD;
/* Initial Position */ /* Initial Position */
/* FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD; FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD;
FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD; */ FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD;
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;
printf("Initial position is: (%.4f, %.4f, %.2f)\n", FG_Latitude, printf("Initial position is: (%.4f, %.4f, %.2f)\n", FG_Latitude,
@ -580,9 +582,13 @@ int main( int argc, char *argv[] ) {
/* $Log$ /* $Log$
/* Revision 1.26 1997/07/05 20:43:34 curt /* Revision 1.27 1997/07/07 20:59:49 curt
/* renamed mat3 directory to Math so we could add other math related routines. /* Working on scenery transformations to enable us to fly fluidly over the
/* poles with no discontinuity/distortion in scenery.
/* /*
* Revision 1.26 1997/07/05 20:43:34 curt
* renamed mat3 directory to Math so we could add other math related routines.
*
* Revision 1.25 1997/06/29 21:19:17 curt * Revision 1.25 1997/06/29 21:19:17 curt
* Working on scenery management system. * Working on scenery management system.
* *

View file

@ -11,11 +11,12 @@ GLUTkey.o: GLUTkey.c GLUTkey.h ../Aircraft/aircraft.h \
../Aircraft/../Flight/LaRCsim/../flight.h \ ../Aircraft/../Flight/LaRCsim/../flight.h \
../Aircraft/../Controls/controls.h \ ../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../limits.h ../Aircraft/../Controls/../limits.h
GLmain.o: GLmain.c ../Aircraft/aircraft.h \ GLmain.o: GLmain.c ../constants.h ../Aircraft/aircraft.h \
../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \ ../Aircraft/../Flight/flight.h ../Aircraft/../Flight/Slew/slew.h \
../Aircraft/../Flight/LaRCsim/ls_interface.h \ ../Aircraft/../Flight/LaRCsim/ls_interface.h \
../Aircraft/../Flight/LaRCsim/../flight.h \ ../Aircraft/../Flight/LaRCsim/../flight.h \
../Aircraft/../Controls/controls.h \ ../Aircraft/../Controls/controls.h \
../Aircraft/../Controls/../limits.h ../Scenery/scenery.h \ ../Aircraft/../Controls/../limits.h ../Scenery/scenery.h \
../Math/mat3.h ../Timer/fg_timer.h ../Math/mat3.h ../Math/polar.h ../Math/../types.h ../Timer/fg_timer.h
mesh2GL.o: mesh2GL.c ../Scenery/mesh.h ../Math/mat3.h mesh2GL.o: mesh2GL.c ../constants.h ../Scenery/mesh.h ../Math/mat3.h \
../Math/polar.h ../Math/../types.h

View file

@ -26,16 +26,20 @@
#include <GL/glut.h> #include <GL/glut.h>
#include "../constants.h"
#include "../Scenery/mesh.h" #include "../Scenery/mesh.h"
#include "../Math/mat3.h" #include "../Math/mat3.h"
#include "../Math/polar.h"
/* walk through mesh and make ogl calls */ /* walk through mesh and make ogl calls */
GLint mesh2GL(struct mesh *m) { GLint mesh2GL(struct mesh *m) {
GLint mesh; GLint mesh;
static GLfloat color[4] = { 0.5, 0.4, 0.25, 1.0 }; /* 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 };
float x1, y1, x2, y2, z11, z12, z21, z22; float x1, y1, x2, y2, z11, z12, z21, z22;
struct fgCartesianPoint p11, p12, p21, p22;
MAT3vec v1, v2, normal; MAT3vec v1, v2, normal;
int i, j, istep, jstep, iend, jend; int i, j, istep, jstep, iend, jend;
@ -43,7 +47,10 @@ GLint mesh2GL(struct mesh *m) {
printf("In mesh2GL(), generating GL call list.\n"); printf("In mesh2GL(), generating GL call list.\n");
istep = jstep = 4; /* Detail level 1 -- 1200 ... */ istep = jstep = 25; /* Detail level 1 -- 1200 ... */
/* setup the batch transformation */
fgRotateBatchInit(-m->originx * ARCSEC_TO_RAD, -m->originy * ARCSEC_TO_RAD);
mesh = glGenLists(1); mesh = glGenLists(1);
glNewList(mesh, GL_COMPILE); glNewList(mesh, GL_COMPILE);
@ -63,31 +70,51 @@ GLint mesh2GL(struct mesh *m) {
glBegin(GL_TRIANGLE_STRIP); glBegin(GL_TRIANGLE_STRIP);
for ( j = 0; j < jend; j += jstep ) { for ( j = 0; j < jend; j += jstep ) {
z11 = 0.03 * m->mesh_data[j * m->rows + i ]; p11 = fgGeodetic2Cartesian(x1*ARCSEC_TO_RAD, y1*ARCSEC_TO_RAD);
z12 = 0.03 * m->mesh_data[j * m->rows + (i+istep)]; /* printf("A geodetic is (%.2f, %.2f)\n", x1, y1); */
z21 = 0.03 * m->mesh_data[(j+jstep) * m->rows + i ]; /* printf("A cart is (%.8f, %.8f, %.8f)\n", p11.x, p11.y, p11.z); */
z22 = 0.03 * m->mesh_data[(j+jstep) * m->rows + (i+istep)]; p11 = fgRotateCartesianPoint(p11);
/* printf("A point is (%.8f, %.8f, %.8f)\n", p11.y, p11.z, z11); */
v1[0] = x2 - x1; v1[1] = 0; v1[2] = z21 - z11; p12 = fgGeodetic2Cartesian(x1*ARCSEC_TO_RAD, y2*ARCSEC_TO_RAD);
v2[0] = 0; v2[1] = y2 - y1; v2[2] = z12 - z11; p12 = fgRotateCartesianPoint(p12);
p21 = fgGeodetic2Cartesian(x2*ARCSEC_TO_RAD, y1*ARCSEC_TO_RAD);
p21 = fgRotateCartesianPoint(p21);
p22 = fgGeodetic2Cartesian(x2*ARCSEC_TO_RAD, y2*ARCSEC_TO_RAD);
p22 = fgRotateCartesianPoint(p22);
z11 = 0.001 * m->mesh_data[j * m->rows + i ];
z12 = 0.001 * m->mesh_data[j * m->rows + (i+istep)];
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;
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);
glNormal3d(normal[0], normal[1], normal[2]); glNormal3d(normal[0], normal[1], normal[2]);
/* printf("normal 1 = (%.2f %.2f %.2f\n", normal[0], normal[1],
normal[2]); */
if ( j == 0 ) { if ( j == 0 ) {
/* first time through */ /* first time through */
glVertex3f(x1, y1, z11); glVertex3d(p11.y, p11.z, z11);
glVertex3f(x1, y2, z12); glVertex3d(p12.y, p12.z, z12);
} }
glVertex3f(x2, y1, z21); glVertex3d(p21.y, p21.z, z21);
v1[0] = x2 - x1; v1[1] = y1 - y2; v1[2] = z21 - z12; v1[0] = p21.y - p12.y; v1[1] = p21.z - p12.z; v1[2] = z21 - z12;
v2[0] = x2 - x1; v2[1] = 0; v2[2] = z22 - z12; v2[0] = p22.y - p12.y; v2[1] = p22.z - p12.z; v2[2] = z22 - z12;
MAT3cross_product(normal, v1, v2); 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]);
glVertex3f(x2, y2, z22); /* printf("normal 2 = (%.2f %.2f %.2f\n", normal[0], normal[1],
normal[2]); */
glVertex3d(p22.y, p22.z, z22);
x1 = x2; x1 = x2;
x2 = x1 + (m->row_step * jstep); x2 = x1 + (m->row_step * jstep);
@ -104,10 +131,15 @@ GLint mesh2GL(struct mesh *m) {
} }
/* $Log$ /* $Log$
/* Revision 1.24 1997/07/05 20:43:35 curt /* Revision 1.25 1997/07/07 20:59:50 curt
/* renamed mat3 directory to Math so we could add other math related routines. /* Working on scenery transformations to enable us to fly fluidly over the
/* poles with no discontinuity/distortion in scenery.
/* /*
* Revision 1.24 1997/07/05 20:43:35 curt
* renamed mat3 directory to Math so we could add other math related routines.
*
* Revision 1.23 1997/07/03 00:51:14 curt * Revision 1.23 1997/07/03 00:51:14 curt
* Playing with terrain color. * Playing with terrain color.
* *

View file

@ -58,7 +58,11 @@ void vrmlGeomOptionName(char *name) {
switch(vrmlGeometryType) { switch(vrmlGeometryType) {
case VRML_ELEV_GRID: case VRML_ELEV_GRID:
if ( strcmp(name, "xDimension") == 0 ) { if ( strcmp(name, "xOrigin") == 0 ) {
mesh_set_option_name(&eg, "origin_lon");
} else if ( strcmp(name, "zOrigin") == 0 ) {
mesh_set_option_name(&eg, "origin_lat");
} else if ( strcmp(name, "xDimension") == 0 ) {
mesh_set_option_name(&eg, "rows"); mesh_set_option_name(&eg, "rows");
} else if ( strcmp(name, "zDimension") == 0 ) { } else if ( strcmp(name, "zDimension") == 0 ) {
mesh_set_option_name(&eg, "cols"); mesh_set_option_name(&eg, "cols");
@ -112,9 +116,13 @@ int vrmlFreeGeometry() {
/* $Log$ /* $Log$
/* Revision 1.1 1997/06/29 21:16:48 curt /* Revision 1.2 1997/07/07 20:59:51 curt
/* More twiddling with the Scenery Management system. /* Working on scenery transformations to enable us to fly fluidly over the
/* poles with no discontinuity/distortion in scenery.
/* /*
* Revision 1.1 1997/06/29 21:16:48 curt
* More twiddling with the Scenery Management system.
*
* Revision 1.1 1997/06/22 21:42:35 curt * Revision 1.1 1997/06/22 21:42:35 curt
* Initial revision of VRML (subset) parser. * Initial revision of VRML (subset) parser.
* *

View file

@ -52,12 +52,21 @@ clean:
tar: clean tar: clean
(cd ../..; \ (cd ../..; \
tar cvf prototype-0.04.tar FlightGear/COPYING FlightGear/Docs \ tar cvf prototype-0.05.tar FlightGear/COPYING FlightGear/Docs \
FlightGear/Scenery/mesa-e.scn FlightGear/Src FlightGear/Thanks) FlightGear/Src FlightGear/Thanks)
zip: clean
(cd ../..; \
zip -r prototype-0.05.zip FlightGear/COPYING FlightGear/Docs \
FlightGear/Src FlightGear/Thanks)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# $Log$ # $Log$
# Revision 1.16 1997/07/07 20:59:47 curt
# Working on scenery transformations to enable us to fly fluidly over the
# poles with no discontinuity/distortion in scenery.
#
# Revision 1.15 1997/07/05 20:43:27 curt # Revision 1.15 1997/07/05 20:43:27 curt
# renamed mat3 directory to Math so we could add other math related routines. # renamed mat3 directory to Math so we could add other math related routines.
# #

View file

@ -22,7 +22,7 @@ Strucures and code to implement various flight models. Provides a
standardized interface to all interesting flight model variabls. standardized interface to all interesting flight model variabls.
mat3/ Math/
----- -----
Contains miscellaneous matrix/vector routines. Contains miscellaneous matrix/vector routines.

View file

@ -57,7 +57,8 @@ AR = ar
# much smoother. # much smoother.
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
FG_CFLAGS = -g -Wall -DUSE_ITIMER # FG_CFLAGS = -g -Wall -DUSE_ITIMER
FG_CFLAGS = -g -Wall
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
@ -99,6 +100,10 @@ GRAPHICS_LIBS = $(MESA_LIBS) $(X11_LIBS)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# $Log$ # $Log$
# 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.
#
# Revision 1.1 1997/06/27 21:38:00 curt # Revision 1.1 1997/06/27 21:38:00 curt
# Working on Makefile structure. # Working on Makefile structure.
# #