GLint tile;
FILE *f;
int first, ncount, vncount, n1, n2, n3, n4;
- static int use_vertex_norms = 0;
+ static int use_per_vertex_norms = 1;
int winding;
int last1, last2, odd;
if ( z < zmin ) zmin = z;
if ( z > zmax ) zmax = z;
- /* reference point is the "center" */
- /* this is overkill to calculate it everytime we get a
- * new node, but it's hard to know with the .obj
- * format when we are done with vertices */
- ref->x = (xmin + xmax) / 2;
- ref->y = (ymin + ymax) / 2;
- ref->z = (zmin + zmax) / 2;
-
ncount++;
} else {
fgPrintf( FG_TERRAIN, FG_EXIT,
scale = 1.0;
}
- if ( use_vertex_norms ) {
+ if ( use_per_vertex_norms ) {
MAT3_SCALE_VEC(normal, normals[n1], scale);
xglNormal3dv(normal);
- xglVertex3d(nodes[n1][0] - ref->x, nodes[n1][1] - ref->y,
- nodes[n1][2] - ref->z);
+ xglVertex3d(nodes[n1][0], nodes[n1][1], nodes[n1][2]);
MAT3_SCALE_VEC(normal, normals[n2], scale);
xglNormal3dv(normal);
- xglVertex3d(nodes[n2][0] - ref->x, nodes[n2][1] - ref->y,
- nodes[n2][2] - ref->z);
+ xglVertex3d(nodes[n2][0], nodes[n2][1], nodes[n2][2]);
MAT3_SCALE_VEC(normal, normals[n3], scale);
xglNormal3dv(normal);
- xglVertex3d(nodes[n3][0] - ref->x, nodes[n3][1] - ref->y,
- nodes[n3][2] - ref->z);
+ xglVertex3d(nodes[n3][0], nodes[n3][1], nodes[n3][2]);
} else {
if ( odd ) {
calc_normal(nodes[n1], nodes[n2], nodes[n3], approx_normal);
MAT3_SCALE_VEC(normal, approx_normal, scale);
xglNormal3dv(normal);
- xglVertex3d(nodes[n1][0] - ref->x, nodes[n1][1] - ref->y,
- nodes[n1][2] - ref->z);
- xglVertex3d(nodes[n2][0] - ref->x, nodes[n2][1] - ref->y,
- nodes[n2][2] - ref->z);
- xglVertex3d(nodes[n3][0] - ref->x, nodes[n3][1] - ref->y,
- nodes[n3][2] - ref->z);
+ xglVertex3d(nodes[n1][0], nodes[n1][1], nodes[n1][2]);
+ xglVertex3d(nodes[n2][0], nodes[n2][1], nodes[n2][2]);
+ xglVertex3d(nodes[n3][0], nodes[n3][1], nodes[n3][2]);
}
odd = 1 - odd;
last2 = n3;
if ( n4 > 0 ) {
- if ( use_vertex_norms ) {
+ if ( use_per_vertex_norms ) {
MAT3_SCALE_VEC(normal, normals[n4], scale);
} else {
calc_normal(nodes[n3], nodes[n2], nodes[n4], approx_normal);
MAT3_SCALE_VEC(normal, approx_normal, scale);
}
xglNormal3dv(normal);
- xglVertex3d(nodes[n4][0] - ref->x, nodes[n4][1] - ref->y,
- nodes[n4][2] - ref->z);
+ xglVertex3d(nodes[n4][0], nodes[n4][1], nodes[n4][2]);
odd = 1 - odd;
last1 = n3;
sscanf(line, "f %d %d %d\n", &n1, &n2, &n3);
xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
- xglVertex3d(nodes[n1][0] - ref->x, nodes[n1][1] - ref->y,
- nodes[n1][2] - ref->z);
+ xglVertex3d(nodes[n1][0], nodes[n1][1], nodes[n1][2]);
xglNormal3d(normals[n2][0], normals[n2][1], normals[n2][2]);
- xglVertex3d(nodes[n2][0] - ref->x, nodes[n2][1] - ref->y,
- nodes[n2][2] - ref->z);
+ xglVertex3d(nodes[n2][0], nodes[n2][1], nodes[n2][2]);
xglNormal3d(normals[n3][0], normals[n3][1], normals[n3][2]);
- xglVertex3d(nodes[n3][0] - ref->x, nodes[n3][1] - ref->y,
- nodes[n3][2] - ref->z);
+ xglVertex3d(nodes[n3][0], nodes[n3][1], nodes[n3][2]);
} else if ( line[0] == 'q' ) {
/* continue a triangle strip */
n1 = n2 = 0;
sscanf(line, "q %d %d\n", &n1, &n2);
/* fgPrintf( FG_TERRAIN, FG_DEBUG, "read %d %d\n", n1, n2); */
- if ( use_vertex_norms ) {
+ if ( use_per_vertex_norms ) {
MAT3_SCALE_VEC(normal, normals[n1], scale);
xglNormal3dv(normal);
} else {
xglNormal3dv(normal);
}
- xglVertex3d(nodes[n1][0] - ref->x, nodes[n1][1] - ref->y,
- nodes[n1][2] - ref->z);
+ xglVertex3d(nodes[n1][0], nodes[n1][1], nodes[n1][2]);
odd = 1 - odd;
last1 = last2;
if ( n2 > 0 ) {
/* fgPrintf( FG_TERRAIN, FG_DEBUG, " (cont)\n"); */
- if ( use_vertex_norms ) {
+ if ( use_per_vertex_norms ) {
MAT3_SCALE_VEC(normal, normals[n2], scale);
xglNormal3dv(normal);
} else {
xglNormal3dv(normal);
}
- xglVertex3d(nodes[n2][0] - ref->x, nodes[n2][1] - ref->y,
- nodes[n2][2] - ref->z);
+ xglVertex3d(nodes[n2][0], nodes[n2][1], nodes[n2][2]);
odd = 1 -odd;
last1 = last2;
xglBegin(GL_LINES);
xglColor3f(0.0, 0.0, 0.0);
for ( i = 0; i < ncount; i++ ) {
- xglVertex3d(nodes[i][0] - ref->x,
- nodes[i][1] - ref->y,
- nodes[i][2] - ref->z);
- xglVertex3d(nodes[i][0] - ref->x + 500*normals[i][0],
- nodes[i][1] - ref->y + 500*normals[i][1],
- nodes[i][2] - ref->z + 500*normals[i][2]);
+ xglVertex3d(nodes[i][0],
+ nodes[i][1] ,
+ nodes[i][2]);
+ xglVertex3d(nodes[i][0] + 500*normals[i][0],
+ nodes[i][1] + 500*normals[i][1],
+ nodes[i][2] + 500*normals[i][2]);
}
xglEnd();
*/
fclose(f);
+ /* reference point is the "center" */
+ ref->x = (xmin + xmax) / 2.0;
+ ref->y = (ymin + ymax) / 2.0;
+ ref->z = (zmin + zmax) / 2.0;
+
return(tile);
}
/* $Log$
-/* Revision 1.23 1998/02/09 15:07:52 curt
-/* Minor tweaks.
+/* Revision 1.24 1998/02/09 21:30:18 curt
+/* Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.
/*
+ * Revision 1.23 1998/02/09 15:07:52 curt
+ * Minor tweaks.
+ *
* Revision 1.22 1998/02/01 03:39:54 curt
* Minor tweaks.
*
/* Render the local tiles */
void fgTileMgrRender( void ) {
+ fgFLIGHT *f;
+ struct fgBUCKET p;
static GLfloat terrain_color[4] = { 0.6, 0.8, 0.4, 1.0 };
static GLfloat terrain_ambient[4];
static GLfloat terrain_diffuse[4];
int i;
int index;
+ f = current_aircraft.flight;
+
for ( i = 0; i < 4; i++ ) {
terrain_ambient[i] = terrain_color[i] * 0.5;
terrain_diffuse[i] = terrain_color[i];
xglMaterialfv(GL_FRONT, GL_AMBIENT, terrain_ambient);
xglMaterialfv(GL_FRONT, GL_DIFFUSE, terrain_diffuse);
+ /* Find current translation offset */
+ fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p);
+ index = fgTileCacheExists(&p);
+ fgTileCacheEntryInfo(index, &display_list, &scenery.center );
+
for ( i = 0; i < FG_LOCAL_X_Y; i++ ) {
index = tiles[i];
/* fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index); */
if ( display_list >= 0 ) {
xglPushMatrix();
- xglTranslatef(local_ref.x - scenery.center.x,
+ /* xglTranslatef(local_ref.x - scenery.center.x,
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,
+ -scenery.center.z);
xglCallList(display_list);
xglPopMatrix();
}
/* $Log$
-/* Revision 1.13 1998/02/07 15:29:46 curt
-/* Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
-/* <chotchkiss@namg.us.anritsu.com>
+/* Revision 1.14 1998/02/09 21:30:19 curt
+/* Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.
/*
+ * Revision 1.13 1998/02/07 15:29:46 curt
+ * Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
+ * <chotchkiss@namg.us.anritsu.com>
+ *
* Revision 1.12 1998/02/01 03:39:55 curt
* Minor tweaks.
*