1
0
Fork 0

Minor transformation adjustments to try to keep scenery tiles closer to

(0, 0, 0)  GLfloats run out of precision at the distances we need to model
the earth, but we can do a bunch of pre-transformations using double math
and then cast to GLfloat once everything is close in where we have less
precision problems.
This commit is contained in:
curt 1998-04-27 03:30:13 +00:00
parent 4a487175c9
commit ed0acbad5b
2 changed files with 35 additions and 14 deletions

View file

@ -95,7 +95,7 @@ float calc_lat(double x, double y, double z) {
GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) { GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) {
char gzpath[256], line[256], winding_str[256]; char gzpath[256], line[256], winding_str[256];
double approx_normal[3], normal[3], scale; double approx_normal[3], normal[3], scale;
double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin; // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 }; GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
GLint tile; GLint tile;
gzFile f; gzFile f;
@ -143,16 +143,18 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) {
/* comment -- ignore */ /* comment -- ignore */
} else if ( line[0] == '\n' ) { } else if ( line[0] == '\n' ) {
/* empty line -- ignore */ /* empty line -- ignore */
} else if ( strncmp(line, "ref ", 4) == 0 ) {
/* reference point (center offset) */
sscanf(line, "ref %lf %lf %lf\n", &ref->x, &ref->y, &ref->z);
} else if ( strncmp(line, "v ", 2) == 0 ) { } else if ( strncmp(line, "v ", 2) == 0 ) {
/* node (vertex) */ /* node (vertex) */
if ( ncount < MAXNODES ) { if ( ncount < MAXNODES ) {
/* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex = %s", line); */ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex = %s", line); */
sscanf(line, "v %lf %lf %lf\n", &x, &y, &z); sscanf(line, "v %lf %lf %lf\n",
nodes[ncount][0] = x; &nodes[ncount][0], &nodes[ncount][1], &nodes[ncount][2]);
nodes[ncount][1] = y;
nodes[ncount][2] = z;
/* first time through set min's and max'es */ /* first time through set min's and max'es */
/*
if ( ncount == 1 ) { if ( ncount == 1 ) {
xmin = x; xmin = x;
xmax = x; xmax = x;
@ -161,14 +163,17 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) {
zmin = z; zmin = z;
zmax = z; zmax = z;
} }
*/
/* keep track of min/max vertex values */ /* keep track of min/max vertex values */
/*
if ( x < xmin ) xmin = x; if ( x < xmin ) xmin = x;
if ( x > xmax ) xmax = x; if ( x > xmax ) xmax = x;
if ( y < ymin ) ymin = y; if ( y < ymin ) ymin = y;
if ( y > ymax ) ymax = y; if ( y > ymax ) ymax = y;
if ( z < zmin ) zmin = z; if ( z < zmin ) zmin = z;
if ( z > zmax ) zmax = z; if ( z > zmax ) zmax = z;
*/
ncount++; ncount++;
} else { } else {
@ -395,19 +400,28 @@ GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) {
gzclose(f); gzclose(f);
/* reference point is the "center" */ /* reference point is the "center" (now included in input file) */
/*
ref->x = (xmin + xmax) / 2.0; ref->x = (xmin + xmax) / 2.0;
ref->y = (ymin + ymax) / 2.0; ref->y = (ymin + ymax) / 2.0;
ref->z = (zmin + zmax) / 2.0; ref->z = (zmin + zmax) / 2.0;
*/
return(tile); return(tile);
} }
/* $Log$ /* $Log$
/* Revision 1.31 1998/04/25 15:09:57 curt /* Revision 1.32 1998/04/27 03:30:13 curt
/* Changed "r" to "rb" in gzopen() options. This fixes bad behavior in win32. /* Minor transformation adjustments to try to keep scenery tiles closer to
/* (0, 0, 0) GLfloats run out of precision at the distances we need to model
/* the earth, but we can do a bunch of pre-transformations using double math
/* and then cast to GLfloat once everything is close in where we have less
/* precision problems.
/* /*
* Revision 1.31 1998/04/25 15:09:57 curt
* Changed "r" to "rb" in gzopen() options. This fixes bad behavior in win32.
*
* Revision 1.30 1998/04/24 14:21:08 curt * Revision 1.30 1998/04/24 14:21:08 curt
* Added "file.obj.gz" support. * Added "file.obj.gz" support.
* *

View file

@ -208,11 +208,11 @@ void fgTileMgrRender( void ) {
if ( display_list >= 0 ) { if ( display_list >= 0 ) {
xglPushMatrix(); xglPushMatrix();
/* xglTranslatef(local_ref.x - scenery.center.x, xglTranslatef(local_ref.x - scenery.center.x,
local_ref.y - scenery.center.y, local_ref.y - scenery.center.y,
local_ref.z - scenery.center.z); */ local_ref.z - scenery.center.z);
xglTranslatef(-scenery.center.x, -scenery.center.y, /* xglTranslatef(-scenery.center.x, -scenery.center.y,
-scenery.center.z); -scenery.center.z); */
xglCallList(display_list); xglCallList(display_list);
xglPopMatrix(); xglPopMatrix();
} }
@ -221,9 +221,16 @@ void fgTileMgrRender( void ) {
/* $Log$ /* $Log$
/* Revision 1.3 1998/04/25 22:06:32 curt /* Revision 1.4 1998/04/27 03:30:14 curt
/* Edited cvs log messages in source files ... bad bad bad! /* Minor transformation adjustments to try to keep scenery tiles closer to
/* (0, 0, 0) GLfloats run out of precision at the distances we need to model
/* the earth, but we can do a bunch of pre-transformations using double math
/* and then cast to GLfloat once everything is close in where we have less
/* precision problems.
/* /*
* Revision 1.3 1998/04/25 22:06:32 curt
* Edited cvs log messages in source files ... bad bad bad!
*
* Revision 1.2 1998/04/24 00:51:09 curt * Revision 1.2 1998/04/24 00:51:09 curt
* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H" * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
* Tweaked the scenery file extentions to be "file.obj" (uncompressed) * Tweaked the scenery file extentions to be "file.obj" (uncompressed)