Working on scenery transformations to enable us to fly fluidly over the
poles with no discontinuity/distortion in scenery.
This commit is contained in:
parent
37a2b12501
commit
09c494327b
8 changed files with 113 additions and 48 deletions
|
@ -11,7 +11,7 @@
|
|||
TARGET = libLaRCsim.a
|
||||
|
||||
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
|
||||
|
||||
|
@ -55,6 +55,10 @@ include depend
|
|||
|
||||
#---------------------------------------------------------------------------
|
||||
# $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
|
||||
# Working on Makefile structure.
|
||||
#
|
||||
|
|
|
@ -38,15 +38,15 @@
|
|||
#include "GLTKkey.h"
|
||||
#endif
|
||||
|
||||
#include "../constants.h"
|
||||
|
||||
#include "../Aircraft/aircraft.h"
|
||||
#include "../Scenery/scenery.h"
|
||||
#include "../Math/mat3.h"
|
||||
#include "../Math/polar.h"
|
||||
#include "../Timer/fg_timer.h"
|
||||
|
||||
|
||||
#define DEG_TO_RAD 0.017453292
|
||||
#define RAD_TO_DEG 57.29577951
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
@ -80,7 +80,7 @@ static GLfloat sun_vec[4] = {-3.0, 1.0, 2.0, 0.0 };
|
|||
/* static GLint scenery, runway; */
|
||||
|
||||
/* Another hack */
|
||||
double fogDensity = 2000.0;
|
||||
double fogDensity = 80.0; /* in meters = about 70 miles */
|
||||
double view_offset = 0.0;
|
||||
double goal_view_offset = 0.0;
|
||||
|
||||
|
@ -134,7 +134,7 @@ static void fgInitVisuals() {
|
|||
**************************************************************************/
|
||||
|
||||
static void fgUpdateViewParams() {
|
||||
double pos_x, pos_y, pos_z;
|
||||
struct fgCartesianPoint view_pos;
|
||||
struct flight_params *f;
|
||||
MAT3mat R, TMP;
|
||||
MAT3vec vec, up, forward, fwrd_view;
|
||||
|
@ -144,17 +144,16 @@ static void fgUpdateViewParams() {
|
|||
/* Tell GL we are about to modify the projection parameters */
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
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);
|
||||
glLoadIdentity();
|
||||
|
||||
/* calculate position in arc seconds */
|
||||
pos_x = (FG_Longitude * RAD_TO_DEG) * 3600.0;
|
||||
pos_y = (FG_Latitude * RAD_TO_DEG) * 3600.0;
|
||||
pos_z = FG_Altitude * 0.01; /* (Convert feet to aproximate arcsecs) */
|
||||
/* calculate position in current FG view coordinate system */
|
||||
view_pos = fgGeodetic2Cartesian(FG_Longitude, FG_Latitude);
|
||||
view_pos = fgRotateCartesianPoint(view_pos);
|
||||
|
||||
printf("*** pos_z = %.2f\n", pos_z);
|
||||
printf("*** Altitude = %.2f meters\n", FG_Altitude * FEET_TO_METER);
|
||||
|
||||
/* build current rotation matrix */
|
||||
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
|
||||
|
@ -191,8 +190,11 @@ static void fgUpdateViewParams() {
|
|||
MAT3rotate(TMP, up, view_offset);
|
||||
MAT3mult_vec(fwrd_view, forward, TMP);
|
||||
|
||||
gluLookAt(pos_x, pos_y, pos_z,
|
||||
pos_x + fwrd_view[0], pos_y + fwrd_view[1], pos_z + fwrd_view[2],
|
||||
printf("View pos = %.4f, %.4f, %.4f\n", view_pos.y, view_pos.z,
|
||||
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]);
|
||||
|
||||
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;
|
||||
|
||||
/* Initial Position */
|
||||
/* FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD;
|
||||
FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD; */
|
||||
FG_Latitude = 0.0;
|
||||
FG_Longitude = 0.0;
|
||||
FG_Latitude = ( 120070.41 / 3600.0 ) * DEG_TO_RAD;
|
||||
FG_Longitude = ( -398391.28 / 3600.0 ) * DEG_TO_RAD;
|
||||
/* FG_Latitude = 0.0;
|
||||
FG_Longitude = 0.0; */
|
||||
FG_Altitude = FG_Runway_altitude + 3.758099;
|
||||
|
||||
printf("Initial position is: (%.4f, %.4f, %.2f)\n", FG_Latitude,
|
||||
|
@ -580,9 +582,13 @@ int main( int argc, char *argv[] ) {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* 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.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.
|
||||
/*
|
||||
* 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
|
||||
* Working on scenery management system.
|
||||
*
|
||||
|
|
|
@ -11,11 +11,12 @@ GLUTkey.o: GLUTkey.c GLUTkey.h ../Aircraft/aircraft.h \
|
|||
../Aircraft/../Flight/LaRCsim/../flight.h \
|
||||
../Aircraft/../Controls/controls.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/LaRCsim/ls_interface.h \
|
||||
../Aircraft/../Flight/LaRCsim/../flight.h \
|
||||
../Aircraft/../Controls/controls.h \
|
||||
../Aircraft/../Controls/../limits.h ../Scenery/scenery.h \
|
||||
../Math/mat3.h ../Timer/fg_timer.h
|
||||
mesh2GL.o: mesh2GL.c ../Scenery/mesh.h ../Math/mat3.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
|
||||
|
|
|
@ -26,16 +26,20 @@
|
|||
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "../constants.h"
|
||||
#include "../Scenery/mesh.h"
|
||||
#include "../Math/mat3.h"
|
||||
#include "../Math/polar.h"
|
||||
|
||||
|
||||
/* walk through mesh and make ogl calls */
|
||||
GLint mesh2GL(struct mesh *m) {
|
||||
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;
|
||||
struct fgCartesianPoint p11, p12, p21, p22;
|
||||
|
||||
MAT3vec v1, v2, normal;
|
||||
int i, j, istep, jstep, iend, jend;
|
||||
|
@ -43,7 +47,10 @@ GLint mesh2GL(struct mesh *m) {
|
|||
|
||||
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);
|
||||
glNewList(mesh, GL_COMPILE);
|
||||
|
@ -63,31 +70,51 @@ GLint mesh2GL(struct mesh *m) {
|
|||
glBegin(GL_TRIANGLE_STRIP);
|
||||
|
||||
for ( j = 0; j < jend; j += jstep ) {
|
||||
z11 = 0.03 * m->mesh_data[j * m->rows + i ];
|
||||
z12 = 0.03 * m->mesh_data[j * m->rows + (i+istep)];
|
||||
z21 = 0.03 * m->mesh_data[(j+jstep) * m->rows + i ];
|
||||
z22 = 0.03 * m->mesh_data[(j+jstep) * m->rows + (i+istep)];
|
||||
p11 = fgGeodetic2Cartesian(x1*ARCSEC_TO_RAD, y1*ARCSEC_TO_RAD);
|
||||
/* printf("A geodetic is (%.2f, %.2f)\n", x1, y1); */
|
||||
/* printf("A cart is (%.8f, %.8f, %.8f)\n", p11.x, p11.y, p11.z); */
|
||||
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;
|
||||
v2[0] = 0; v2[1] = y2 - y1; v2[2] = z12 - z11;
|
||||
p12 = fgGeodetic2Cartesian(x1*ARCSEC_TO_RAD, y2*ARCSEC_TO_RAD);
|
||||
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);
|
||||
MAT3_NORMALIZE_VEC(normal,temp);
|
||||
glNormal3d(normal[0], normal[1], normal[2]);
|
||||
|
||||
/* printf("normal 1 = (%.2f %.2f %.2f\n", normal[0], normal[1],
|
||||
normal[2]); */
|
||||
|
||||
if ( j == 0 ) {
|
||||
/* first time through */
|
||||
glVertex3f(x1, y1, z11);
|
||||
glVertex3f(x1, y2, z12);
|
||||
glVertex3d(p11.y, p11.z, z11);
|
||||
glVertex3d(p12.y, p12.z, z12);
|
||||
}
|
||||
|
||||
glVertex3f(x2, y1, z21);
|
||||
|
||||
v1[0] = x2 - x1; v1[1] = y1 - y2; v1[2] = z21 - z12;
|
||||
v2[0] = x2 - x1; v2[1] = 0; v2[2] = z22 - 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);
|
||||
MAT3_NORMALIZE_VEC(normal,temp);
|
||||
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;
|
||||
x2 = x1 + (m->row_step * jstep);
|
||||
|
@ -104,10 +131,15 @@ GLint mesh2GL(struct mesh *m) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/* $Log$
|
||||
/* 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.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.
|
||||
/*
|
||||
* 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
|
||||
* Playing with terrain color.
|
||||
*
|
||||
|
|
|
@ -58,7 +58,11 @@ void vrmlGeomOptionName(char *name) {
|
|||
|
||||
switch(vrmlGeometryType) {
|
||||
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");
|
||||
} else if ( strcmp(name, "zDimension") == 0 ) {
|
||||
mesh_set_option_name(&eg, "cols");
|
||||
|
@ -112,9 +116,13 @@ int vrmlFreeGeometry() {
|
|||
|
||||
|
||||
/* $Log$
|
||||
/* Revision 1.1 1997/06/29 21:16:48 curt
|
||||
/* More twiddling with the Scenery Management system.
|
||||
/* Revision 1.2 1997/07/07 20:59:51 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/29 21:16:48 curt
|
||||
* More twiddling with the Scenery Management system.
|
||||
*
|
||||
* Revision 1.1 1997/06/22 21:42:35 curt
|
||||
* Initial revision of VRML (subset) parser.
|
||||
*
|
||||
|
|
|
@ -52,12 +52,21 @@ clean:
|
|||
|
||||
tar: clean
|
||||
(cd ../..; \
|
||||
tar cvf prototype-0.04.tar FlightGear/COPYING FlightGear/Docs \
|
||||
FlightGear/Scenery/mesa-e.scn FlightGear/Src FlightGear/Thanks)
|
||||
tar cvf prototype-0.05.tar FlightGear/COPYING FlightGear/Docs \
|
||||
FlightGear/Src FlightGear/Thanks)
|
||||
|
||||
zip: clean
|
||||
(cd ../..; \
|
||||
zip -r prototype-0.05.zip FlightGear/COPYING FlightGear/Docs \
|
||||
FlightGear/Src FlightGear/Thanks)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# $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
|
||||
# renamed mat3 directory to Math so we could add other math related routines.
|
||||
#
|
||||
|
|
|
@ -22,7 +22,7 @@ Strucures and code to implement various flight models. Provides a
|
|||
standardized interface to all interesting flight model variabls.
|
||||
|
||||
|
||||
mat3/
|
||||
Math/
|
||||
-----
|
||||
Contains miscellaneous matrix/vector routines.
|
||||
|
||||
|
|
|
@ -57,7 +57,8 @@ AR = ar
|
|||
# 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$
|
||||
# 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
|
||||
# Working on Makefile structure.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue