#include <math.h>
#include <stdio.h>
-#include <Scenery/bucketutils.h>
#include <Include/fg_constants.h>
+#include <Main/fg_debug.h>
+#include <Scenery/bucketutils.h>
/* Generate the unique scenery tile index containing the specified
p->x = (lon - p->lon) * 8;
p->y = (lat - p->lat) * 8;
- printf("Bucket = lon,lat = %d,%d x,y index = %d,%d\n",
- p->lon, p->lat, p->x, p->y);
+ fgPrintf( FG_TERRAIN, FG_DEBUG,
+ "Bucket = lon,lat = %d,%d x,y index = %d,%d\n",
+ p->lon, p->lat, p->x, p->y);
}
for ( i = 0; i < width; i++ ) {
fgBucketOffset(p1, &tiles[(j*width)+i], i - dw, j - dh);
p2 = &tiles[(j*width)+i];
- printf(" bucket = %d %d %d %d index = %ld\n",
- p2->lon, p2->lat, p2->x, p2->y,
- fgBucketGenIndex(&tiles[(j*width)+i]));
+ fgPrintf( FG_TERRAIN, FG_DEBUG,
+ " bucket = %d %d %d %d index = %ld\n",
+ p2->lon, p2->lat, p2->x, p2->y,
+ fgBucketGenIndex(&tiles[(j*width)+i]));
}
}
}
/* $Log$
-/* Revision 1.3 1998/01/27 00:48:01 curt
-/* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
-/* system and commandline/config file processing code.
+/* Revision 1.4 1998/01/27 03:26:41 curt
+/* Playing with new fgPrintf command.
/*
+ * Revision 1.3 1998/01/27 00:48:01 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
* Revision 1.2 1998/01/24 00:03:28 curt
* Initial revision.
*
#include <GL/glut.h>
#include <XGL/xgl.h>
+#include <Main/fg_debug.h>
+#include <Math/mat3.h>
#include <Scenery/obj.h>
#include <Scenery/scenery.h>
-#include <Math/mat3.h>
-
#define MAXNODES 100000
MAT3cross_product(normal, v1, v2);
MAT3_NORMALIZE_VEC(normal,temp);
- /* printf(" Normal = %.2f %.2f %.2f\n", normal[0], normal[1], normal[2]);*/
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, " Normal = %.2f %.2f %.2f\n",
+ normal[0], normal[1], normal[2]);*/
}
/* Load a .obj file and generate the GL call list */
GLint fgObjLoad(char *path, struct fgCartesianPoint *ref) {
char line[256], winding_str[256];
- double v1[3], v2[3], approx_normal[3], normal[3], dot_prod, scale, temp;
+ double approx_normal[3], normal[3], scale;
GLint area;
FILE *f;
int first, ncount, vncount, n1, n2, n3, n4;
static int use_vertex_norms = 1;
- int i, winding;
+ int winding;
int last1, last2, odd;
if ( (f = fopen(path, "r")) == NULL ) {
- printf("Cannot open file: %s\n", path);
+ fgPrintf(FG_TERRAIN, FG_ALERT, "Cannot open file: %s\n", path);
/* exit(-1); */
return(0);
}
} else if ( strncmp(line, "v ", 2) == 0 ) {
/* node (vertex) */
if ( ncount < MAXNODES ) {
- /* printf("vertex = %s", line); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex = %s", line); */
sscanf(line, "v %f %f %f\n",
&nodes[ncount][0], &nodes[ncount][1], &nodes[ncount][2]);
if ( ncount == 1 ) {
}
ncount++;
} else {
- printf("Read too many nodes ... dying :-(\n");
- exit(-1);
+ fgPrintf( FG_TERRAIN, FG_EXIT,
+ "Read too many nodes ... dying :-(\n");
}
} else if ( strncmp(line, "vn ", 3) == 0 ) {
/* vertex normal */
if ( vncount < MAXNODES ) {
- /* printf("vertex normal = %s", line); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex normal = %s", line); */
sscanf(line, "vn %f %f %f\n",
&normals[vncount][0], &normals[vncount][1],
&normals[vncount][2]);
vncount++;
} else {
- printf("Read too many vertex normals ... dying :-(\n");
- exit(-1);
+ fgPrintf( FG_TERRAIN, FG_EXIT,
+ "Read too many vertex normals ... dying :-(\n");
}
} else if ( strncmp(line, "winding ", 8) == 0 ) {
sscanf(line+8, "%s", winding_str);
- printf(" WINDING = %s\n", winding_str);
+ fgPrintf( FG_TERRAIN, FG_DEBUG, " WINDING = %s\n", winding_str);
/* can't call xglFrontFace() between xglBegin() & xglEnd() */
xglEnd();
first = 0;
}
- /* printf(" new tri strip = %s", line); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, " new tri strip = %s",
+ line); */
sscanf(line, "t %d %d %d %d\n", &n1, &n2, &n3, &n4);
- /* printf("(t) = "); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "(t) = "); */
xglBegin(GL_TRIANGLE_STRIP);
xglBegin(GL_TRIANGLES);
- /* printf("new triangle = %s", line);*/
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "new triangle = %s", line);*/
sscanf(line, "f %d %d %d\n", &n1, &n2, &n3);
xglNormal3d(normals[n1][0], normals[n1][1], normals[n1][2]);
/* continue a triangle strip */
n1 = n2 = 0;
- /* printf("continued tri strip = %s ", line); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "continued tri strip = %s ",
+ line); */
sscanf(line, "q %d %d\n", &n1, &n2);
- /* printf("read %d %d\n", n1, n2); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "read %d %d\n", n1, n2); */
if ( use_vertex_norms ) {
MAT3_SCALE_VEC(normal, normals[n1], scale);
last2 = n1;
if ( n2 > 0 ) {
- /* printf(" (cont)\n"); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, " (cont)\n"); */
if ( use_vertex_norms ) {
MAT3_SCALE_VEC(normal, normals[n2], scale);
last2 = n2;
}
} else {
- printf("Unknown line in %s = %s\n", path, line);
+ fgPrintf( FG_TERRAIN, FG_WARN, "Unknown line in %s = %s\n",
+ path, line);
}
}
/* $Log$
-/* Revision 1.18 1998/01/19 19:27:16 curt
-/* Merged in make system changes from Bob Kuehne <rpk@sgi.com>
-/* This should simplify things tremendously.
+/* Revision 1.19 1998/01/27 03:26:42 curt
+/* Playing with new fgPrintf command.
/*
+ * Revision 1.18 1998/01/19 19:27:16 curt
+ * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+ * This should simplify things tremendously.
+ *
* Revision 1.17 1998/01/13 00:23:10 curt
* Initial changes to support loading and management of scenery tiles. Note,
* there's still a fair amount of work left to be done.
#include <string.h>
#include <Include/general.h>
-
+#include <Main/fg_debug.h>
#include <Scenery/obj.h>
#include <Scenery/scenery.h>
/* Initialize the Scenery Management system */
void fgSceneryInit( void ) {
- printf("Initializing scenery subsystem\n");
+ fgPrintf(FG_TERRAIN, FG_INFO, "Initializing scenery subsystem\n");
/* set the default terrain detail level */
scenery.terrain_skip = 6;
strcat(path, "/Scenery/");
strcat(path, "mesa-e.obj");
- printf(" Loading Scenery: %s\n", path);
+ fgPrintf(FG_TERRAIN, FG_DEBUG, " Loading Scenery: %s\n", path);
area_terrain = fgObjLoad(path, &scenery.center);
}
/* $Log$
-/* Revision 1.33 1998/01/19 19:27:17 curt
-/* Merged in make system changes from Bob Kuehne <rpk@sgi.com>
-/* This should simplify things tremendously.
+/* Revision 1.34 1998/01/27 03:26:43 curt
+/* Playing with new fgPrintf command.
/*
+ * Revision 1.33 1998/01/19 19:27:17 curt
+ * Merged in make system changes from Bob Kuehne <rpk@sgi.com>
+ * This should simplify things tremendously.
+ *
* Revision 1.32 1998/01/19 18:40:37 curt
* Tons of little changes to clean up the code and to remove fatal errors
* when building with the c++ compiler.
#include <GL/glut.h>
#include <XGL/xgl.h>
+#include <Include/general.h>
#include <Scenery/bucketutils.h>
#include <Scenery/obj.h>
#include <Scenery/tilecache.h>
+#include <Main/fg_debug.h>
-#include <Include/general.h>
/* tile cache */
struct fgTILE tile_cache[FG_TILE_CACHE_SIZE];
void fgTileCacheInit( void ) {
int i;
- printf("Initializing the tile cache.\n");
+ fgPrintf(FG_TERRAIN, FG_INFO, "Initializing the tile cache.\n");
for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
tile_cache[i].used = 0;
void fgTileCacheEntryInfo( int index, GLint *display_list,
struct fgCartesianPoint *local_ref ) {
*display_list = tile_cache[index].display_list;
- /* printf("Display list = %d\n", *display_list); */
+ /* fgPrintf(FG_TERRAIN, FG_DEBUG, "Display list = %d\n", *display_list); */
local_ref->x = tile_cache[index].local_ref.x;
local_ref->y = tile_cache[index].local_ref.y;
/* $Log$
-/* Revision 1.3 1998/01/27 00:48:03 curt
-/* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
-/* system and commandline/config file processing code.
+/* Revision 1.4 1998/01/27 03:26:43 curt
+/* Playing with new fgPrintf command.
/*
+ * Revision 1.3 1998/01/27 00:48:03 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
* Revision 1.2 1998/01/26 15:55:24 curt
* Progressing on building dynamic scenery system.
*
#include <Aircraft/aircraft.h>
#include <Include/fg_constants.h>
#include <Include/fg_types.h>
+#include <Main/fg_debug.h>
#define FG_LOCAL_X 3 /* should be odd */
/* Initialize the Tile Manager subsystem */
void fgTileMgrInit( void ) {
- printf("Initializing Tile Manager subsystem.\n");
+ fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
fgTileCacheInit();
}
/* load a tile */
void fgTileMgrLoadTile( struct fgBUCKET *p, int *index) {
- printf("Updating for bucket %d %d %d %d\n",
+ fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating for bucket %d %d %d %d\n",
p->lon, p->lat, p->x, p->y);
*index = fgTileCacheNextAvail();
- printf("Selected cache index of %d\n", *index);
+ fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index);
fgTileCacheEntryFillIn(*index, p);
}
if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
(p1.x == p_last.x) && (p1.y == p_last.y) ) {
/* same bucket as last time */
- printf("Same bucket as last time\n");
+ fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n");
} else if ( p_last.lon == -1000 ) {
/* First time through, initialize the system and load all
* relavant tiles */
- printf("First time through ... \n");
- printf("Updating Tile list for %d,%d %d,%d\n",
+ fgPrintf( FG_TERRAIN, FG_DEBUG, "First time through ... \n");
+ fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating Tile list for %d,%d %d,%d\n",
p1.lon, p1.lat, p1.x, p1.y);
/* wipe tile cache */
for ( i = 0; i < FG_LOCAL_X_Y; i++ ) {
index = tiles[i];
- /* printf("Index = %d\n", index); */
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index); */
fgTileCacheEntryInfo(index, &display_list, &local_ref );
xglPushMatrix();
/* $Log$
-/* Revision 1.8 1998/01/27 00:48:04 curt
-/* Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
-/* system and commandline/config file processing code.
+/* Revision 1.9 1998/01/27 03:26:44 curt
+/* Playing with new fgPrintf command.
/*
+ * Revision 1.8 1998/01/27 00:48:04 curt
+ * Incorporated Paul Bleisch's <bleisch@chromatic.com> new debug message
+ * system and commandline/config file processing code.
+ *
* Revision 1.7 1998/01/26 15:55:25 curt
* Progressing on building dynamic scenery system.
*