lib_LTLIBRARIES = libScenery.la
libScenery_la_SOURCES = \
- obj.c obj.h \
- scenery.c scenery.h \
+ obj.cxx obj.hxx \
+ scenery.cxx scenery.hxx \
texload.c texload.h \
tilecache.cxx tilecache.hxx \
tilemgr.cxx tilemgr.hxx
lib_LTLIBRARIES = libScenery.la
libScenery_la_SOURCES = \
- obj.c obj.h \
- scenery.c scenery.h \
+ obj.cxx obj.hxx \
+ scenery.cxx scenery.hxx \
texload.c texload.h \
tilecache.cxx tilecache.hxx \
tilemgr.cxx tilemgr.hxx
+++ /dev/null
-/* -*- Mode: C++ -*-
- *
- * obj.c -- routines to handle WaveFront .obj format files.
- *
- * Written by Curtis Olson, started October 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- * (Log is kept at end of this file)
- **************************************************************************/
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <Debug/fg_debug.h>
-#include <Include/fg_constants.h>
-#include <Include/fg_zlib.h>
-#include <Math/mat3.h>
-#include <Math/fg_random.h>
-#include <Scenery/obj.h>
-#include <Scenery/scenery.h>
-
-
-#define MAXNODES 100000
-
-static double nodes[MAXNODES][3];
-static double normals[MAXNODES][3];
-
-
-/* given three points defining a triangle, calculate the normal */
-void calc_normal(double p1[3], double p2[3], double p3[3], double normal[3])
-{
- double v1[3], v2[3];
- double temp;
-
- v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; v1[2] = p2[2] - p1[2];
- v2[0] = p3[0] - p1[0]; v2[1] = p3[1] - p1[1]; v2[2] = p3[2] - p1[2];
-
- MAT3cross_product(normal, v1, v2);
- MAT3_NORMALIZE_VEC(normal,temp);
-
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, " Normal = %.2f %.2f %.2f\n",
- normal[0], normal[1], normal[2]);*/
-}
-
-
-#define FG_TEX_CONSTANT 128.0
-
-float calc_lon(double x, double y, double z) {
- float tmp;
- tmp = fmod(
- (RAD_TO_DEG*atan2(y, x)) * FG_TEX_CONSTANT,
- 10.0);
-
- // printf("lon = %.2f\n", (float)tmp);
- return (float)tmp;
-}
-
-
-float calc_lat(double x, double y, double z) {
- float tmp;
-
- tmp = fmod(
- (90.0 - RAD_TO_DEG *
- atan2( sqrt(x*x + y*y), z )) * FG_TEX_CONSTANT,
- 10.0);
-
- // printf("lat = %.2f\n", (float)tmp);
- return (float)tmp;
-}
-
-
-/* Load a .obj file and generate the GL call list */
-GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) {
- char fgpath[256], line[256], winding_str[256];
- double approx_normal[3], normal[3], scale;
- // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
- GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
- GLint tile;
- fgFile f;
- int first, ncount, vncount, n1, n2, n3, n4;
- static int use_per_vertex_norms = 1;
- int winding;
- int last1, last2, odd;
-
- // First try "path.obz" (compressed format)
- strcpy(fgpath, path);
- strcat(fgpath, ".obz");
- if ( (f = fgopen(fgpath, "rb")) == NULL ) {
- // Next try "path.obj" (uncompressed format)
- strcpy(fgpath, path);
- strcat(fgpath, ".obj");
- if ( (f = fgopen(fgpath, "rb")) == NULL ) {
- // Next try "path.obj.gz" (compressed format)
- strcat(fgpath, ".gz");
- if ( (f = fgopen(fgpath, "rb")) == NULL ) {
- strcpy(fgpath, path);
- strcat(fgpath, ".obj");
- fgPrintf( FG_TERRAIN, FG_ALERT,
- "Cannot open file: %s\n", fgpath );
- return(-1);
- }
- }
- }
-
- tile = xglGenLists(1);
- xglNewList(tile, GL_COMPILE);
-
- /*
- xglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
- xglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
- xglTexGenfv(GL_S, GL_OBJECT_PLANE, sgenparams);
- xglTexGenfv(GL_T, GL_OBJECT_PLANE, sgenparams);
- // xglTexGenfv(GL_S, GL_SPHERE_MAP, 0);
- // xglTexGenfv(GL_T, GL_SPHERE_MAP, 0);
- xglEnable(GL_TEXTURE_GEN_S);
- xglEnable(GL_TEXTURE_GEN_T);
- */
-
- first = 1;
- ncount = 1;
- vncount = 1;
-
- while ( fggets(f, line, 250) != NULL ) {
- if ( line[0] == '#' ) {
- /* comment -- ignore */
- } else if ( line[0] == '\n' ) {
- /* 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 ) {
- /* node (vertex) */
- if ( ncount < MAXNODES ) {
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex = %s", line); */
- sscanf(line, "v %lf %lf %lf\n",
- &nodes[ncount][0], &nodes[ncount][1], &nodes[ncount][2]);
-
- /* first time through set min's and max'es */
- /*
- if ( ncount == 1 ) {
- xmin = x;
- xmax = x;
- ymin = y;
- ymax = y;
- zmin = z;
- zmax = z;
- }
- */
-
- /* keep track of min/max vertex values */
- /*
- if ( x < xmin ) xmin = x;
- if ( x > xmax ) xmax = x;
- if ( y < ymin ) ymin = y;
- if ( y > ymax ) ymax = y;
- if ( z < zmin ) zmin = z;
- if ( z > zmax ) zmax = z;
- */
-
- ncount++;
- } else {
- fgPrintf( FG_TERRAIN, FG_EXIT,
- "Read too many nodes ... dying :-(\n");
- }
- } else if ( strncmp(line, "vn ", 3) == 0 ) {
- /* vertex normal */
- if ( vncount < MAXNODES ) {
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex normal = %s", line); */
- sscanf(line, "vn %lf %lf %lf\n",
- &normals[vncount][0], &normals[vncount][1],
- &normals[vncount][2]);
- vncount++;
- } else {
- 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);
- fgPrintf( FG_TERRAIN, FG_DEBUG, " WINDING = %s\n", winding_str);
-
- /* can't call xglFrontFace() between xglBegin() & xglEnd() */
- xglEnd();
- first = 1;
-
- if ( strcmp(winding_str, "cw") == 0 ) {
- xglFrontFace( GL_CW );
- winding = 0;
- } else {
- glFrontFace ( GL_CCW );
- winding = 1;
- }
- } else if ( line[0] == 't' ) {
- /* start a new triangle strip */
-
- n1 = n2 = n3 = n4 = 0;
-
- if ( !first ) {
- /* close out the previous structure and start the next */
- xglEnd();
- } else {
- first = 0;
- }
-
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, " new tri strip = %s",
- line); */
- sscanf(line, "t %d %d %d %d\n", &n1, &n2, &n3, &n4);
-
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, "(t) = "); */
-
- xglBegin(GL_TRIANGLE_STRIP);
-
- if ( winding ) {
- odd = 1;
- scale = 1.0;
- } else {
- odd = 0;
- scale = 1.0;
- }
-
- if ( use_per_vertex_norms ) {
- MAT3_SCALE_VEC(normal, normals[n1], scale);
- xglNormal3dv(normal);
- xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
- nodes[n1][1] + ref->y,
- nodes[n1][2] + ref->z),
- calc_lat(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);
- xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
- nodes[n2][1] + ref->y,
- nodes[n2][2] + ref->z),
- calc_lat(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);
- xglTexCoord2f(calc_lon(nodes[n3][0] + ref->x,
- nodes[n3][1] + ref->y,
- nodes[n3][2] + ref->z),
- calc_lat(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);
- } else {
- calc_normal(nodes[n2], nodes[n1], nodes[n3], approx_normal);
- }
- MAT3_SCALE_VEC(normal, approx_normal, scale);
- xglNormal3dv(normal);
-
- xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
- nodes[n1][1] + ref->y,
- nodes[n1][2] + ref->z),
- calc_lat(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]);
- xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
- nodes[n2][1] + ref->y,
- nodes[n2][2] + ref->z),
- calc_lat(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]);
- xglTexCoord2f(calc_lon(nodes[n3][0] + ref->x,
- nodes[n3][1] + ref->y,
- nodes[n3][2] + ref->z),
- calc_lat(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]);
- }
-
- odd = 1 - odd;
- last1 = n2;
- last2 = n3;
-
- if ( n4 > 0 ) {
- 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);
- xglTexCoord2f(calc_lon(nodes[n4][0] + ref->x,
- nodes[n4][1] + ref->y,
- nodes[n4][2] + ref->z),
- calc_lat(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;
- last2 = n4;
- }
- } else if ( line[0] == 'f' ) {
- /* unoptimized face */
-
- if ( !first ) {
- /* close out the previous structure and start the next */
- xglEnd();
- } else {
- first = 0;
- }
-
- xglBegin(GL_TRIANGLES);
-
- /* 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]);
- xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
- nodes[n1][1] + ref->y,
- nodes[n1][2] + ref->z),
- calc_lat(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]);
- xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
- nodes[n2][1] + ref->y,
- nodes[n2][2] + ref->z),
- calc_lat(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]);
- xglTexCoord2f(calc_lon(nodes[n3][0] + ref->x,
- nodes[n3][1] + ref->y,
- nodes[n3][2] + ref->z),
- calc_lat(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;
-
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, "continued tri strip = %s ",
- line); */
- sscanf(line, "q %d %d\n", &n1, &n2);
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, "read %d %d\n", n1, n2); */
-
- if ( use_per_vertex_norms ) {
- MAT3_SCALE_VEC(normal, normals[n1], scale);
- xglNormal3dv(normal);
- } else {
- if ( odd ) {
- calc_normal(nodes[last1], nodes[last2], nodes[n1],
- approx_normal);
- } else {
- calc_normal(nodes[last2], nodes[last1], nodes[n1],
- approx_normal);
- }
- MAT3_SCALE_VEC(normal, approx_normal, scale);
- xglNormal3dv(normal);
- }
-
- xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
- nodes[n1][1] + ref->y,
- nodes[n1][2] + ref->z),
- calc_lat(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;
- last2 = n1;
-
- if ( n2 > 0 ) {
- /* fgPrintf( FG_TERRAIN, FG_DEBUG, " (cont)\n"); */
-
- if ( use_per_vertex_norms ) {
- MAT3_SCALE_VEC(normal, normals[n2], scale);
- xglNormal3dv(normal);
- } else {
- if ( odd ) {
- calc_normal(nodes[last1], nodes[last2], nodes[n2],
- approx_normal);
- } else {
- calc_normal(nodes[last2], nodes[last1], nodes[n2],
- approx_normal);
- }
- MAT3_SCALE_VEC(normal, approx_normal, scale);
- xglNormal3dv(normal);
- }
-
- xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
- nodes[n2][1] + ref->y,
- nodes[n2][2] + ref->z),
- calc_lat(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;
- last2 = n2;
- }
- } else {
- fgPrintf( FG_TERRAIN, FG_WARN, "Unknown line in %s = %s\n",
- path, line);
- }
- }
-
- xglEnd();
-
- /* Draw normal vectors (for visually verifying normals)*/
- /*
- xglBegin(GL_LINES);
- xglColor3f(0.0, 0.0, 0.0);
- for ( i = 0; i < ncount; i++ ) {
- 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();
- */
-
- // xglDisable(GL_TEXTURE_GEN_S);
- // xglDisable(GL_TEXTURE_GEN_T);
-
- xglFrontFace ( GL_CCW );
-
- xglEndList();
-
- fgclose(f);
-
- /* reference point is the "center" (now included in input file) */
- /*
- ref->x = (xmin + xmax) / 2.0;
- ref->y = (ymin + ymax) / 2.0;
- ref->z = (zmin + zmax) / 2.0;
- */
-
- return(tile);
-}
-
-
-/* $Log$
-/* Revision 1.35 1998/04/28 21:43:26 curt
-/* Wrapped zlib calls up so we can conditionally comment out zlib support.
-/*
- * Revision 1.34 1998/04/28 01:21:42 curt
- * Tweaked texture parameter calculations to keep the number smaller. This
- * avoids the "swimming" problem.
- * Type-ified fgTIME and fgVIEW.
- *
- * Revision 1.33 1998/04/27 15:58:15 curt
- * Screwing around with texture coordinate generation ... still needs work.
- *
- * Revision 1.32 1998/04/27 03:30:13 curt
- * 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
- * Added "file.obj.gz" support.
- *
- * Revision 1.29 1998/04/24 00:51:07 curt
- * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
- * Tweaked the scenery file extentions to be "file.obj" (uncompressed)
- * or "file.obz" (compressed.)
- *
- * Revision 1.28 1998/04/22 13:22:44 curt
- * C++ - ifing the code a bit.
- *
- * Revision 1.27 1998/04/18 04:13:17 curt
- * Added zlib on the fly decompression support for loading scenery objects.
- *
- * Revision 1.26 1998/04/03 22:11:36 curt
- * Converting to Gnu autoconf system.
- *
- * Revision 1.25 1998/03/14 00:30:50 curt
- * Beginning initial terrain texturing experiments.
- *
- * 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.
- *
- * Revision 1.21 1998/01/31 00:43:25 curt
- * Added MetroWorks patches from Carmen Volpe.
- *
- * Revision 1.20 1998/01/29 00:51:39 curt
- * First pass at tile cache, dynamic tile loading and tile unloading now works.
- *
- * 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.
- *
- * Revision 1.16 1997/12/30 23:09:40 curt
- * Worked on winding problem without luck, so back to calling glFrontFace()
- * 3 times for each scenery area.
- *
- * Revision 1.15 1997/12/30 20:47:51 curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.14 1997/12/30 01:38:46 curt
- * Switched back to per vertex normals and smooth shading for terrain.
- *
- * Revision 1.13 1997/12/18 23:32:36 curt
- * First stab at sky dome actually starting to look reasonable. :-)
- *
- * Revision 1.12 1997/12/17 23:13:47 curt
- * Began working on rendering the sky.
- *
- * Revision 1.11 1997/12/15 23:55:01 curt
- * Add xgl wrappers for debugging.
- * Generate terrain normals on the fly.
- *
- * Revision 1.10 1997/12/12 21:41:28 curt
- * More light/material property tweaking ... still a ways off.
- *
- * Revision 1.9 1997/12/12 19:52:57 curt
- * Working on lightling and material properties.
- *
- * Revision 1.8 1997/12/10 01:19:51 curt
- * Tweaks for verion 0.15 release.
- *
- * Revision 1.7 1997/12/08 22:51:17 curt
- * Enhanced to handle ccw and cw tri-stripe winding. This is a temporary
- * admission of defeat. I will eventually go back and get all the stripes
- * wound the same way (ccw).
- *
- * Revision 1.6 1997/11/25 19:25:35 curt
- * Changes to integrate Durk's moon/sun code updates + clean up.
- *
- * Revision 1.5 1997/11/15 18:16:39 curt
- * minor tweaks.
- *
- * Revision 1.4 1997/11/14 00:26:49 curt
- * Transform scenery coordinates earlier in pipeline when scenery is being
- * created, not when it is being loaded. Precalculate normals for each node
- * as average of the normals of each containing polygon so Garoude shading is
- * now supportable.
- *
- * Revision 1.3 1997/10/31 04:49:12 curt
- * Tweaking vertex orders.
- *
- * Revision 1.2 1997/10/30 12:38:45 curt
- * Working on new scenery subsystem.
- *
- * Revision 1.1 1997/10/28 21:14:54 curt
- * Initial revision.
- *
- */
--- /dev/null
+/* -*- Mode: C++ -*-
+ *
+ * obj.c -- routines to handle WaveFront .obj format files.
+ *
+ * Written by Curtis Olson, started October 1997.
+ *
+ * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ * (Log is kept at end of this file)
+ **************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <stdio.h>
+#include <string.h>
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include <Debug/fg_debug.h>
+#include <Include/fg_constants.h>
+#include <Include/fg_zlib.h>
+#include <Main/options.hxx>
+#include <Math/mat3.h>
+#include <Math/fg_random.h>
+#include <Scenery/obj.hxx>
+#include <Scenery/scenery.hxx>
+
+
+#define MAXNODES 100000
+
+static double nodes[MAXNODES][3];
+static double normals[MAXNODES][3];
+
+
+/* given three points defining a triangle, calculate the normal */
+void calc_normal(double p1[3], double p2[3], double p3[3], double normal[3])
+{
+ double v1[3], v2[3];
+ double temp;
+
+ v1[0] = p2[0] - p1[0]; v1[1] = p2[1] - p1[1]; v1[2] = p2[2] - p1[2];
+ v2[0] = p3[0] - p1[0]; v2[1] = p3[1] - p1[1]; v2[2] = p3[2] - p1[2];
+
+ MAT3cross_product(normal, v1, v2);
+ MAT3_NORMALIZE_VEC(normal,temp);
+
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, " Normal = %.2f %.2f %.2f\n",
+ normal[0], normal[1], normal[2]);*/
+}
+
+
+#define FG_TEX_CONSTANT 128.0
+
+float calc_lon(double x, double y, double z) {
+ float tmp;
+ tmp = fmod(
+ (RAD_TO_DEG*atan2(y, x)) * FG_TEX_CONSTANT,
+ 10.0);
+
+ // printf("lon = %.2f\n", (float)tmp);
+ return (float)tmp;
+}
+
+
+float calc_lat(double x, double y, double z) {
+ float tmp;
+
+ tmp = fmod(
+ (90.0 - RAD_TO_DEG *
+ atan2( sqrt(x*x + y*y), z )) * FG_TEX_CONSTANT,
+ 10.0);
+
+ // printf("lat = %.2f\n", (float)tmp);
+ return (float)tmp;
+}
+
+
+/* Load a .obj file and generate the GL call list */
+GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius) {
+ fgOPTIONS *o;
+ char fgpath[256], line[256], winding_str[256];
+ double approx_normal[3], normal[3], scale;
+ // double x, y, z, xmax, xmin, ymax, ymin, zmax, zmin;
+ // GLfloat sgenparams[] = { 1.0, 0.0, 0.0, 0.0 };
+ GLint tile;
+ fgFile f;
+ int first, ncount, vncount, n1, n2, n3, n4;
+ int winding;
+ int last1, last2, odd;
+
+ o = ¤t_options;
+
+ // First try "path.obz" (compressed format)
+ strcpy(fgpath, path);
+ strcat(fgpath, ".obz");
+ if ( (f = fgopen(fgpath, "rb")) == NULL ) {
+ // Next try "path.obj" (uncompressed format)
+ strcpy(fgpath, path);
+ strcat(fgpath, ".obj");
+ if ( (f = fgopen(fgpath, "rb")) == NULL ) {
+ // Next try "path.obj.gz" (compressed format)
+ strcat(fgpath, ".gz");
+ if ( (f = fgopen(fgpath, "rb")) == NULL ) {
+ strcpy(fgpath, path);
+ strcat(fgpath, ".obj");
+ fgPrintf( FG_TERRAIN, FG_ALERT,
+ "Cannot open file: %s\n", fgpath );
+ return(-1);
+ }
+ }
+ }
+
+ tile = xglGenLists(1);
+ xglNewList(tile, GL_COMPILE);
+
+ /*
+ xglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ xglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
+ xglTexGenfv(GL_S, GL_OBJECT_PLANE, sgenparams);
+ xglTexGenfv(GL_T, GL_OBJECT_PLANE, sgenparams);
+ // xglTexGenfv(GL_S, GL_SPHERE_MAP, 0);
+ // xglTexGenfv(GL_T, GL_SPHERE_MAP, 0);
+ xglEnable(GL_TEXTURE_GEN_S);
+ xglEnable(GL_TEXTURE_GEN_T);
+ */
+
+ first = 1;
+ ncount = 1;
+ vncount = 1;
+
+ while ( fggets(f, line, 250) != NULL ) {
+ if ( line[0] == '#' ) {
+ /* comment -- ignore */
+ } else if ( line[0] == '\n' ) {
+ /* 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 ) {
+ /* node (vertex) */
+ if ( ncount < MAXNODES ) {
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex = %s", line); */
+ sscanf(line, "v %lf %lf %lf\n",
+ &nodes[ncount][0], &nodes[ncount][1], &nodes[ncount][2]);
+
+ /* first time through set min's and max'es */
+ /*
+ if ( ncount == 1 ) {
+ xmin = x;
+ xmax = x;
+ ymin = y;
+ ymax = y;
+ zmin = z;
+ zmax = z;
+ }
+ */
+
+ /* keep track of min/max vertex values */
+ /*
+ if ( x < xmin ) xmin = x;
+ if ( x > xmax ) xmax = x;
+ if ( y < ymin ) ymin = y;
+ if ( y > ymax ) ymax = y;
+ if ( z < zmin ) zmin = z;
+ if ( z > zmax ) zmax = z;
+ */
+
+ ncount++;
+ } else {
+ fgPrintf( FG_TERRAIN, FG_EXIT,
+ "Read too many nodes ... dying :-(\n");
+ }
+ } else if ( strncmp(line, "vn ", 3) == 0 ) {
+ /* vertex normal */
+ if ( vncount < MAXNODES ) {
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "vertex normal = %s", line); */
+ sscanf(line, "vn %lf %lf %lf\n",
+ &normals[vncount][0], &normals[vncount][1],
+ &normals[vncount][2]);
+ vncount++;
+ } else {
+ 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);
+ fgPrintf( FG_TERRAIN, FG_DEBUG, " WINDING = %s\n", winding_str);
+
+ /* can't call xglFrontFace() between xglBegin() & xglEnd() */
+ xglEnd();
+ first = 1;
+
+ if ( strcmp(winding_str, "cw") == 0 ) {
+ xglFrontFace( GL_CW );
+ winding = 0;
+ } else {
+ glFrontFace ( GL_CCW );
+ winding = 1;
+ }
+ } else if ( line[0] == 't' ) {
+ /* start a new triangle strip */
+
+ n1 = n2 = n3 = n4 = 0;
+
+ if ( !first ) {
+ /* close out the previous structure and start the next */
+ xglEnd();
+ } else {
+ first = 0;
+ }
+
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, " new tri strip = %s",
+ line); */
+ sscanf(line, "t %d %d %d %d\n", &n1, &n2, &n3, &n4);
+
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "(t) = "); */
+
+ xglBegin(GL_TRIANGLE_STRIP);
+
+ if ( winding ) {
+ odd = 1;
+ scale = 1.0;
+ } else {
+ odd = 0;
+ scale = 1.0;
+ }
+
+ if ( o->shading ) {
+ // Shading model is "GL_SMOOTH" so use precalculated
+ // (averaged) normals
+ MAT3_SCALE_VEC(normal, normals[n1], scale);
+ xglNormal3dv(normal);
+ xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
+ nodes[n1][1] + ref->y,
+ nodes[n1][2] + ref->z),
+ calc_lat(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);
+ xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
+ nodes[n2][1] + ref->y,
+ nodes[n2][2] + ref->z),
+ calc_lat(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);
+ xglTexCoord2f(calc_lon(nodes[n3][0] + ref->x,
+ nodes[n3][1] + ref->y,
+ nodes[n3][2] + ref->z),
+ calc_lat(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 {
+ // Shading model is "GL_FLAT" so calculate per face
+ // normals on the fly.
+ if ( odd ) {
+ calc_normal(nodes[n1], nodes[n2], nodes[n3], approx_normal);
+ } else {
+ calc_normal(nodes[n2], nodes[n1], nodes[n3], approx_normal);
+ }
+ MAT3_SCALE_VEC(normal, approx_normal, scale);
+ xglNormal3dv(normal);
+
+ xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
+ nodes[n1][1] + ref->y,
+ nodes[n1][2] + ref->z),
+ calc_lat(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]);
+ xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
+ nodes[n2][1] + ref->y,
+ nodes[n2][2] + ref->z),
+ calc_lat(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]);
+ xglTexCoord2f(calc_lon(nodes[n3][0] + ref->x,
+ nodes[n3][1] + ref->y,
+ nodes[n3][2] + ref->z),
+ calc_lat(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]);
+ }
+
+ odd = 1 - odd;
+ last1 = n2;
+ last2 = n3;
+
+ if ( n4 > 0 ) {
+ if ( o->shading ) {
+ // Shading model is "GL_SMOOTH"
+ MAT3_SCALE_VEC(normal, normals[n4], scale);
+ } else {
+ // Shading model is "GL_FLAT"
+ calc_normal(nodes[n3], nodes[n2], nodes[n4], approx_normal);
+ MAT3_SCALE_VEC(normal, approx_normal, scale);
+ }
+ xglNormal3dv(normal);
+ xglTexCoord2f(calc_lon(nodes[n4][0] + ref->x,
+ nodes[n4][1] + ref->y,
+ nodes[n4][2] + ref->z),
+ calc_lat(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;
+ last2 = n4;
+ }
+ } else if ( line[0] == 'f' ) {
+ /* unoptimized face */
+
+ if ( !first ) {
+ /* close out the previous structure and start the next */
+ xglEnd();
+ } else {
+ first = 0;
+ }
+
+ xglBegin(GL_TRIANGLES);
+
+ /* 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]);
+ xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
+ nodes[n1][1] + ref->y,
+ nodes[n1][2] + ref->z),
+ calc_lat(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]);
+ xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
+ nodes[n2][1] + ref->y,
+ nodes[n2][2] + ref->z),
+ calc_lat(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]);
+ xglTexCoord2f(calc_lon(nodes[n3][0] + ref->x,
+ nodes[n3][1] + ref->y,
+ nodes[n3][2] + ref->z),
+ calc_lat(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;
+
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "continued tri strip = %s ",
+ line); */
+ sscanf(line, "q %d %d\n", &n1, &n2);
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, "read %d %d\n", n1, n2); */
+
+ if ( o->shading ) {
+ // Shading model is "GL_SMOOTH"
+ MAT3_SCALE_VEC(normal, normals[n1], scale);
+ xglNormal3dv(normal);
+ } else {
+ // Shading model is "GL_FLAT"
+ if ( odd ) {
+ calc_normal(nodes[last1], nodes[last2], nodes[n1],
+ approx_normal);
+ } else {
+ calc_normal(nodes[last2], nodes[last1], nodes[n1],
+ approx_normal);
+ }
+ MAT3_SCALE_VEC(normal, approx_normal, scale);
+ xglNormal3dv(normal);
+ }
+
+ xglTexCoord2f(calc_lon(nodes[n1][0] + ref->x,
+ nodes[n1][1] + ref->y,
+ nodes[n1][2] + ref->z),
+ calc_lat(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;
+ last2 = n1;
+
+ if ( n2 > 0 ) {
+ /* fgPrintf( FG_TERRAIN, FG_DEBUG, " (cont)\n"); */
+
+ if ( o->shading ) {
+ // Shading model is "GL_SMOOTH"
+ MAT3_SCALE_VEC(normal, normals[n2], scale);
+ xglNormal3dv(normal);
+ } else {
+ // Shading model is "GL_FLAT"
+ if ( odd ) {
+ calc_normal(nodes[last1], nodes[last2], nodes[n2],
+ approx_normal);
+ } else {
+ calc_normal(nodes[last2], nodes[last1], nodes[n2],
+ approx_normal);
+ }
+ MAT3_SCALE_VEC(normal, approx_normal, scale);
+ xglNormal3dv(normal);
+ }
+
+ xglTexCoord2f(calc_lon(nodes[n2][0] + ref->x,
+ nodes[n2][1] + ref->y,
+ nodes[n2][2] + ref->z),
+ calc_lat(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;
+ last2 = n2;
+ }
+ } else {
+ fgPrintf( FG_TERRAIN, FG_WARN, "Unknown line in %s = %s\n",
+ path, line);
+ }
+ }
+
+ xglEnd();
+
+ /* Draw normal vectors (for visually verifying normals)*/
+ /*
+ xglBegin(GL_LINES);
+ xglColor3f(0.0, 0.0, 0.0);
+ for ( i = 0; i < ncount; i++ ) {
+ 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();
+ */
+
+ // xglDisable(GL_TEXTURE_GEN_S);
+ // xglDisable(GL_TEXTURE_GEN_T);
+
+ xglFrontFace ( GL_CCW );
+
+ xglEndList();
+
+ fgclose(f);
+
+ /* reference point is the "center" (now included in input file) */
+ /*
+ ref->x = (xmin + xmax) / 2.0;
+ ref->y = (ymin + ymax) / 2.0;
+ ref->z = (zmin + zmax) / 2.0;
+ */
+
+ return(tile);
+}
+
+
+/* $Log$
+/* Revision 1.1 1998/04/30 12:35:28 curt
+/* Added a command line rendering option specify smooth/flat shading.
+/*
+ * Revision 1.35 1998/04/28 21:43:26 curt
+ * Wrapped zlib calls up so we can conditionally comment out zlib support.
+ *
+ * Revision 1.34 1998/04/28 01:21:42 curt
+ * Tweaked texture parameter calculations to keep the number smaller. This
+ * avoids the "swimming" problem.
+ * Type-ified fgTIME and fgVIEW.
+ *
+ * Revision 1.33 1998/04/27 15:58:15 curt
+ * Screwing around with texture coordinate generation ... still needs work.
+ *
+ * Revision 1.32 1998/04/27 03:30:13 curt
+ * 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
+ * Added "file.obj.gz" support.
+ *
+ * Revision 1.29 1998/04/24 00:51:07 curt
+ * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
+ * Tweaked the scenery file extentions to be "file.obj" (uncompressed)
+ * or "file.obz" (compressed.)
+ *
+ * Revision 1.28 1998/04/22 13:22:44 curt
+ * C++ - ifing the code a bit.
+ *
+ * Revision 1.27 1998/04/18 04:13:17 curt
+ * Added zlib on the fly decompression support for loading scenery objects.
+ *
+ * Revision 1.26 1998/04/03 22:11:36 curt
+ * Converting to Gnu autoconf system.
+ *
+ * Revision 1.25 1998/03/14 00:30:50 curt
+ * Beginning initial terrain texturing experiments.
+ *
+ * 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.
+ *
+ * Revision 1.21 1998/01/31 00:43:25 curt
+ * Added MetroWorks patches from Carmen Volpe.
+ *
+ * Revision 1.20 1998/01/29 00:51:39 curt
+ * First pass at tile cache, dynamic tile loading and tile unloading now works.
+ *
+ * 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.
+ *
+ * Revision 1.16 1997/12/30 23:09:40 curt
+ * Worked on winding problem without luck, so back to calling glFrontFace()
+ * 3 times for each scenery area.
+ *
+ * Revision 1.15 1997/12/30 20:47:51 curt
+ * Integrated new event manager with subsystem initializations.
+ *
+ * Revision 1.14 1997/12/30 01:38:46 curt
+ * Switched back to per vertex normals and smooth shading for terrain.
+ *
+ * Revision 1.13 1997/12/18 23:32:36 curt
+ * First stab at sky dome actually starting to look reasonable. :-)
+ *
+ * Revision 1.12 1997/12/17 23:13:47 curt
+ * Began working on rendering the sky.
+ *
+ * Revision 1.11 1997/12/15 23:55:01 curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
+ * Revision 1.10 1997/12/12 21:41:28 curt
+ * More light/material property tweaking ... still a ways off.
+ *
+ * Revision 1.9 1997/12/12 19:52:57 curt
+ * Working on lightling and material properties.
+ *
+ * Revision 1.8 1997/12/10 01:19:51 curt
+ * Tweaks for verion 0.15 release.
+ *
+ * Revision 1.7 1997/12/08 22:51:17 curt
+ * Enhanced to handle ccw and cw tri-stripe winding. This is a temporary
+ * admission of defeat. I will eventually go back and get all the stripes
+ * wound the same way (ccw).
+ *
+ * Revision 1.6 1997/11/25 19:25:35 curt
+ * Changes to integrate Durk's moon/sun code updates + clean up.
+ *
+ * Revision 1.5 1997/11/15 18:16:39 curt
+ * minor tweaks.
+ *
+ * Revision 1.4 1997/11/14 00:26:49 curt
+ * Transform scenery coordinates earlier in pipeline when scenery is being
+ * created, not when it is being loaded. Precalculate normals for each node
+ * as average of the normals of each containing polygon so Garoude shading is
+ * now supportable.
+ *
+ * Revision 1.3 1997/10/31 04:49:12 curt
+ * Tweaking vertex orders.
+ *
+ * Revision 1.2 1997/10/30 12:38:45 curt
+ * Working on new scenery subsystem.
+ *
+ * Revision 1.1 1997/10/28 21:14:54 curt
+ * Initial revision.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * obj.h -- routines to handle WaveFront .obj-ish format files.
- *
- * Written by Curtis Olson, started October 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- * (Log is kept at end of this file)
- **************************************************************************/
-
-
-#ifndef _OBJ_H
-#define _OBJ_H
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <GL/glut.h>
-
-#include <Include/fg_types.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Load a .obj file and generate the GL call list */
-GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _OBJ_H */
-
-
-/* $Log$
-/* Revision 1.11 1998/04/25 22:06:31 curt
-/* Edited cvs log messages in source files ... bad bad bad!
-/*
- * Revision 1.10 1998/04/24 00:51:07 curt
- * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
- * Tweaked the scenery file extentions to be "file.obj" (uncompressed)
- * or "file.obz" (compressed.)
- *
- * Revision 1.9 1998/04/22 13:22:45 curt
- * C++ - ifing the code a bit.
- *
- * Revision 1.8 1998/04/21 17:02:43 curt
- * Prepairing for C++ integration.
- *
- * Revision 1.7 1998/04/03 22:11:37 curt
- * Converting to Gnu autoconf system.
- *
- * Revision 1.6 1998/01/31 00:43:25 curt
- * Added MetroWorks patches from Carmen Volpe.
- *
- * Revision 1.5 1998/01/27 00:48:03 curt
- * Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.4 1998/01/22 02:59:41 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.3 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.2 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.
- *
- * Revision 1.1 1997/10/28 21:14:55 curt
- * Initial revision.
- *
- */
--- /dev/null
+/**************************************************************************
+ * obj.hxx -- routines to handle WaveFront .obj-ish format files.
+ *
+ * Written by Curtis Olson, started October 1997.
+ *
+ * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ * (Log is kept at end of this file)
+ **************************************************************************/
+
+
+#ifndef _OBJ_HXX
+#define _OBJ_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <GL/glut.h>
+
+#include <Include/fg_types.h>
+
+
+/* Load a .obj file and generate the GL call list */
+GLint fgObjLoad(char *path, struct fgCartesianPoint *ref, double *radius);
+
+
+#endif /* _OBJ_HXX */
+
+
+/* $Log$
+/* Revision 1.1 1998/04/30 12:35:29 curt
+/* Added a command line rendering option specify smooth/flat shading.
+/*
+ * Revision 1.11 1998/04/25 22:06:31 curt
+ * Edited cvs log messages in source files ... bad bad bad!
+ *
+ * Revision 1.10 1998/04/24 00:51:07 curt
+ * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
+ * Tweaked the scenery file extentions to be "file.obj" (uncompressed)
+ * or "file.obz" (compressed.)
+ *
+ * Revision 1.9 1998/04/22 13:22:45 curt
+ * C++ - ifing the code a bit.
+ *
+ * Revision 1.8 1998/04/21 17:02:43 curt
+ * Prepairing for C++ integration.
+ *
+ * Revision 1.7 1998/04/03 22:11:37 curt
+ * Converting to Gnu autoconf system.
+ *
+ * Revision 1.6 1998/01/31 00:43:25 curt
+ * Added MetroWorks patches from Carmen Volpe.
+ *
+ * Revision 1.5 1998/01/27 00:48:03 curt
+ * Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.4 1998/01/22 02:59:41 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
+ * Revision 1.3 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.2 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.
+ *
+ * Revision 1.1 1997/10/28 21:14:55 curt
+ * Initial revision.
+ *
+ */
+++ /dev/null
-/* -*- Mode: C++ -*-
- *
- * scenery.c -- data structures and routines for managing scenery.
- *
- * Written by Curtis Olson, started May 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- * (Log is kept at end of this file)
- **************************************************************************/
-
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_WINDOWS_H
-# include <windows.h>
-#endif
-
-#include <GL/glut.h>
-#include <XGL/xgl.h>
-
-#include <stdio.h>
-#include <string.h>
-
-#include <Debug/fg_debug.h>
-#include <Include/general.h>
-#include <Scenery/obj.h>
-#include <Scenery/scenery.h>
-#include <Scenery/texload.h>
-
-
-/* Temporary hack until we get a better texture management system running */
-GLint area_texture;
-
-
-/* Shared structure to hold current scenery parameters */
-struct fgSCENERY scenery;
-
-
-/* Initialize the Scenery Management system */
-int fgSceneryInit( void ) {
- fgGENERAL *g;
- char path[1024], fgpath[1024];
- GLubyte *texbuf;
- int width, height;
-
- g = &general;
-
- fgPrintf(FG_TERRAIN, FG_INFO, "Initializing scenery subsystem\n");
-
- /* set the default terrain detail level */
- // scenery.terrain_skip = 6;
-
- /* temp: load in a demo texture */
- path[0] = '\0';
- strcat(path, g->root_dir);
- strcat(path, "/Textures/");
- strcat(path, "desert.rgb");
-
- // Try uncompressed
- if ( (texbuf = read_rgb_texture(path, &width, &height)) == NULL ) {
- // Try compressed
- strcpy(fgpath, path);
- strcat(fgpath, ".gz");
- if ( (texbuf = read_rgb_texture(fgpath, &width, &height)) == NULL ) {
- fgPrintf( FG_GENERAL, FG_EXIT, "Error in loading texture %s\n",
- path );
- return(0);
- }
- }
-
- xglTexImage2D(GL_TEXTURE_2D, 0, 3, height, width, 0,
- GL_RGB, GL_UNSIGNED_BYTE, texbuf);
-
- return(1);
-}
-
-
-/* Tell the scenery manager where we are so it can load the proper data, and
- * build the proper structures. */
-void fgSceneryUpdate(double lon, double lat, double elev) {
- fgGENERAL *g;
- double max_radius;
- char path[1024];
-
- g = &general;
-
- /* a hardcoded hack follows */
-
- /* this routine should parse the file, and make calls back to the
- * scenery management system to build the appropriate structures */
- path[0] = '\0';
- strcat(path, g->root_dir);
- strcat(path, "/Scenery/");
- strcat(path, "mesa-e.obj");
-
- // fgPrintf(FG_TERRAIN, FG_DEBUG, " Loading Scenery: %s\n", path);
-
- // area_terrain = fgObjLoad(path, &scenery.center, &max_radius);
-}
-
-
-/* Render out the current scene */
-void fgSceneryRender( void ) {
-}
-
-
-/* $Log$
-/* Revision 1.42 1998/04/28 21:43:27 curt
-/* Wrapped zlib calls up so we can conditionally comment out zlib support.
-/*
- * Revision 1.41 1998/04/24 00:51:08 curt
- * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
- * Tweaked the scenery file extentions to be "file.obj" (uncompressed)
- * or "file.obz" (compressed.)
- *
- * Revision 1.40 1998/04/18 04:14:06 curt
- * Moved fg_debug.c to it's own library.
- *
- * Revision 1.39 1998/04/08 23:30:07 curt
- * Adopted Gnu automake/autoconf system.
- *
- * Revision 1.38 1998/04/03 22:11:37 curt
- * Converting to Gnu autoconf system.
- *
- * Revision 1.37 1998/03/23 21:23:05 curt
- * Debugging output tweaks.
- *
- * Revision 1.36 1998/03/14 00:30:50 curt
- * Beginning initial terrain texturing experiments.
- *
- * Revision 1.35 1998/01/31 00:43:26 curt
- * Added MetroWorks patches from Carmen Volpe.
- *
- * 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.
- *
- * Revision 1.31 1998/01/13 00:23:11 curt
- * Initial changes to support loading and management of scenery tiles. Note,
- * there's still a fair amount of work left to be done.
- *
- * Revision 1.30 1998/01/07 03:22:29 curt
- * Moved astro stuff to .../Src/Astro/
- *
- * Revision 1.29 1997/12/30 20:47:52 curt
- * Integrated new event manager with subsystem initializations.
- *
- * Revision 1.28 1997/12/15 23:55:02 curt
- * Add xgl wrappers for debugging.
- * Generate terrain normals on the fly.
- *
- * Revision 1.27 1997/12/12 21:41:30 curt
- * More light/material property tweaking ... still a ways off.
- *
- * Revision 1.26 1997/12/12 19:52:58 curt
- * Working on lightling and material properties.
- *
- * Revision 1.25 1997/12/10 22:37:51 curt
- * Prepended "fg" on the name of all global structures that didn't have it yet.
- * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
- *
- * Revision 1.24 1997/12/08 22:51:18 curt
- * Enhanced to handle ccw and cw tri-stripe winding. This is a temporary
- * admission of defeat. I will eventually go back and get all the stripes
- * wound the same way (ccw).
- *
- * Revision 1.23 1997/11/25 19:25:37 curt
- * Changes to integrate Durk's moon/sun code updates + clean up.
- *
- * Revision 1.22 1997/10/28 21:00:22 curt
- * Changing to new terrain format.
- *
- * Revision 1.21 1997/10/25 03:24:24 curt
- * Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
- *
- * Revision 1.20 1997/10/25 03:18:27 curt
- * Incorporated sun, moon, and planet position and rendering code contributed
- * by Durk Talsma.
- *
- * Revision 1.19 1997/09/05 14:17:30 curt
- * More tweaking with stars.
- *
- * Revision 1.18 1997/09/05 01:35:59 curt
- * Working on getting stars right.
- *
- * Revision 1.17 1997/08/29 17:55:27 curt
- * Worked on properly aligning the stars.
- *
- * Revision 1.16 1997/08/27 21:32:29 curt
- * Restructured view calculation code. Added stars.
- *
- * Revision 1.15 1997/08/27 03:30:32 curt
- * Changed naming scheme of basic shared structures.
- *
- * Revision 1.14 1997/08/25 20:27:24 curt
- * Merged in initial HUD and Joystick code.
- *
- * Revision 1.13 1997/08/22 21:34:41 curt
- * Doing a bit of reorganizing and house cleaning.
- *
- * Revision 1.12 1997/08/19 23:55:08 curt
- * Worked on better simulating real lighting.
- *
- * Revision 1.11 1997/08/13 20:24:22 curt
- * Changed default detail level.
- *
- * Revision 1.10 1997/08/06 00:24:30 curt
- * Working on correct real time sun lighting.
- *
- * Revision 1.9 1997/08/04 17:08:11 curt
- * Testing cvs on IRIX 6.x
- *
- * Revision 1.8 1997/07/18 23:41:27 curt
- * Tweaks for building with Cygnus Win32 compiler.
- *
- * Revision 1.7 1997/07/16 20:04:52 curt
- * Minor tweaks to aid Win32 port.
- *
- * Revision 1.6 1997/07/14 16:26:05 curt
- * Testing/playing -- placed objects randomly across the entire terrain.
- *
- * Revision 1.5 1997/07/11 03:23:19 curt
- * Solved some scenery display/orientation problems. Still have a positioning
- * (or transformation?) problem.
- *
- * Revision 1.4 1997/07/11 01:30:03 curt
- * More tweaking of terrian floor.
- *
- * Revision 1.3 1997/06/29 21:16:50 curt
- * More twiddling with the Scenery Management system.
- *
- * Revision 1.2 1997/06/27 20:03:37 curt
- * Working on Makefile structure.
- *
- * Revision 1.1 1997/06/27 02:26:30 curt
- * Initial revision.
- *
- */
--- /dev/null
+/* -*- Mode: C++ -*-
+ *
+ * scenery.c -- data structures and routines for managing scenery.
+ *
+ * Written by Curtis Olson, started May 1997.
+ *
+ * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ * (Log is kept at end of this file)
+ **************************************************************************/
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_WINDOWS_H
+# include <windows.h>
+#endif
+
+#include <GL/glut.h>
+#include <XGL/xgl.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <Debug/fg_debug.h>
+#include <Include/general.h>
+#include <Scenery/obj.hxx>
+#include <Scenery/scenery.hxx>
+#include <Scenery/texload.h>
+
+
+/* Temporary hack until we get a better texture management system running */
+GLint area_texture;
+
+
+/* Shared structure to hold current scenery parameters */
+struct fgSCENERY scenery;
+
+
+/* Initialize the Scenery Management system */
+int fgSceneryInit( void ) {
+ fgGENERAL *g;
+ char path[1024], fgpath[1024];
+ GLubyte *texbuf;
+ int width, height;
+
+ g = &general;
+
+ fgPrintf(FG_TERRAIN, FG_INFO, "Initializing scenery subsystem\n");
+
+ /* set the default terrain detail level */
+ // scenery.terrain_skip = 6;
+
+ /* temp: load in a demo texture */
+ path[0] = '\0';
+ strcat(path, g->root_dir);
+ strcat(path, "/Textures/");
+ strcat(path, "forest.rgb");
+
+ // Try uncompressed
+ if ( (texbuf = read_rgb_texture(path, &width, &height)) == NULL ) {
+ // Try compressed
+ strcpy(fgpath, path);
+ strcat(fgpath, ".gz");
+ if ( (texbuf = read_rgb_texture(fgpath, &width, &height)) == NULL ) {
+ fgPrintf( FG_GENERAL, FG_EXIT, "Error in loading texture %s\n",
+ path );
+ return(0);
+ }
+ }
+
+ xglTexImage2D(GL_TEXTURE_2D, 0, 3, height, width, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, texbuf);
+
+ return(1);
+}
+
+
+/* Tell the scenery manager where we are so it can load the proper data, and
+ * build the proper structures. */
+void fgSceneryUpdate(double lon, double lat, double elev) {
+ fgGENERAL *g;
+ double max_radius;
+ char path[1024];
+
+ g = &general;
+
+ /* a hardcoded hack follows */
+
+ /* this routine should parse the file, and make calls back to the
+ * scenery management system to build the appropriate structures */
+ path[0] = '\0';
+ strcat(path, g->root_dir);
+ strcat(path, "/Scenery/");
+ strcat(path, "mesa-e.obj");
+
+ // fgPrintf(FG_TERRAIN, FG_DEBUG, " Loading Scenery: %s\n", path);
+
+ // area_terrain = fgObjLoad(path, &scenery.center, &max_radius);
+}
+
+
+/* Render out the current scene */
+void fgSceneryRender( void ) {
+}
+
+
+/* $Log$
+/* Revision 1.1 1998/04/30 12:35:30 curt
+/* Added a command line rendering option specify smooth/flat shading.
+/*
+ * Revision 1.42 1998/04/28 21:43:27 curt
+ * Wrapped zlib calls up so we can conditionally comment out zlib support.
+ *
+ * Revision 1.41 1998/04/24 00:51:08 curt
+ * Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
+ * Tweaked the scenery file extentions to be "file.obj" (uncompressed)
+ * or "file.obz" (compressed.)
+ *
+ * Revision 1.40 1998/04/18 04:14:06 curt
+ * Moved fg_debug.c to it's own library.
+ *
+ * Revision 1.39 1998/04/08 23:30:07 curt
+ * Adopted Gnu automake/autoconf system.
+ *
+ * Revision 1.38 1998/04/03 22:11:37 curt
+ * Converting to Gnu autoconf system.
+ *
+ * Revision 1.37 1998/03/23 21:23:05 curt
+ * Debugging output tweaks.
+ *
+ * Revision 1.36 1998/03/14 00:30:50 curt
+ * Beginning initial terrain texturing experiments.
+ *
+ * Revision 1.35 1998/01/31 00:43:26 curt
+ * Added MetroWorks patches from Carmen Volpe.
+ *
+ * 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.
+ *
+ * Revision 1.31 1998/01/13 00:23:11 curt
+ * Initial changes to support loading and management of scenery tiles. Note,
+ * there's still a fair amount of work left to be done.
+ *
+ * Revision 1.30 1998/01/07 03:22:29 curt
+ * Moved astro stuff to .../Src/Astro/
+ *
+ * Revision 1.29 1997/12/30 20:47:52 curt
+ * Integrated new event manager with subsystem initializations.
+ *
+ * Revision 1.28 1997/12/15 23:55:02 curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
+ * Revision 1.27 1997/12/12 21:41:30 curt
+ * More light/material property tweaking ... still a ways off.
+ *
+ * Revision 1.26 1997/12/12 19:52:58 curt
+ * Working on lightling and material properties.
+ *
+ * Revision 1.25 1997/12/10 22:37:51 curt
+ * Prepended "fg" on the name of all global structures that didn't have it yet.
+ * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
+ *
+ * Revision 1.24 1997/12/08 22:51:18 curt
+ * Enhanced to handle ccw and cw tri-stripe winding. This is a temporary
+ * admission of defeat. I will eventually go back and get all the stripes
+ * wound the same way (ccw).
+ *
+ * Revision 1.23 1997/11/25 19:25:37 curt
+ * Changes to integrate Durk's moon/sun code updates + clean up.
+ *
+ * Revision 1.22 1997/10/28 21:00:22 curt
+ * Changing to new terrain format.
+ *
+ * Revision 1.21 1997/10/25 03:24:24 curt
+ * Incorporated sun, moon, and star positioning code contributed by Durk Talsma.
+ *
+ * Revision 1.20 1997/10/25 03:18:27 curt
+ * Incorporated sun, moon, and planet position and rendering code contributed
+ * by Durk Talsma.
+ *
+ * Revision 1.19 1997/09/05 14:17:30 curt
+ * More tweaking with stars.
+ *
+ * Revision 1.18 1997/09/05 01:35:59 curt
+ * Working on getting stars right.
+ *
+ * Revision 1.17 1997/08/29 17:55:27 curt
+ * Worked on properly aligning the stars.
+ *
+ * Revision 1.16 1997/08/27 21:32:29 curt
+ * Restructured view calculation code. Added stars.
+ *
+ * Revision 1.15 1997/08/27 03:30:32 curt
+ * Changed naming scheme of basic shared structures.
+ *
+ * Revision 1.14 1997/08/25 20:27:24 curt
+ * Merged in initial HUD and Joystick code.
+ *
+ * Revision 1.13 1997/08/22 21:34:41 curt
+ * Doing a bit of reorganizing and house cleaning.
+ *
+ * Revision 1.12 1997/08/19 23:55:08 curt
+ * Worked on better simulating real lighting.
+ *
+ * Revision 1.11 1997/08/13 20:24:22 curt
+ * Changed default detail level.
+ *
+ * Revision 1.10 1997/08/06 00:24:30 curt
+ * Working on correct real time sun lighting.
+ *
+ * Revision 1.9 1997/08/04 17:08:11 curt
+ * Testing cvs on IRIX 6.x
+ *
+ * Revision 1.8 1997/07/18 23:41:27 curt
+ * Tweaks for building with Cygnus Win32 compiler.
+ *
+ * Revision 1.7 1997/07/16 20:04:52 curt
+ * Minor tweaks to aid Win32 port.
+ *
+ * Revision 1.6 1997/07/14 16:26:05 curt
+ * Testing/playing -- placed objects randomly across the entire terrain.
+ *
+ * Revision 1.5 1997/07/11 03:23:19 curt
+ * Solved some scenery display/orientation problems. Still have a positioning
+ * (or transformation?) problem.
+ *
+ * Revision 1.4 1997/07/11 01:30:03 curt
+ * More tweaking of terrian floor.
+ *
+ * Revision 1.3 1997/06/29 21:16:50 curt
+ * More twiddling with the Scenery Management system.
+ *
+ * Revision 1.2 1997/06/27 20:03:37 curt
+ * Working on Makefile structure.
+ *
+ * Revision 1.1 1997/06/27 02:26:30 curt
+ * Initial revision.
+ *
+ */
+++ /dev/null
-/**************************************************************************
- * scenery.h -- data structures and routines for managing scenery.
- *
- * Written by Curtis Olson, started May 1997.
- *
- * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * $Id$
- * (Log is kept at end of this file)
- **************************************************************************/
-
-
-#ifndef _SCENERY_H
-#define _SCENERY_H
-
-
-#include <Include/fg_types.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Define a structure containing global scenery parameters */
-struct fgSCENERY {
- /* number of terrain data points to skip */
- int terrain_skip;
-
- /* center of current scenery chunk */
- struct fgCartesianPoint center;
-
- /* next center of current scenery chunk */
- struct fgCartesianPoint next_center;
-
- /* angle of sun relative to current local horizontal */
- double sun_angle;
-};
-
-extern struct fgSCENERY scenery;
-
-
-/* Initialize the Scenery Management system */
-int fgSceneryInit( void );
-
-
-/* Tell the scenery manager where we are so it can load the proper data, and
- * build the proper structures. */
-void fgSceneryUpdate(double lon, double lat, double elev);
-
-
-/* Render out the current scene */
-void fgSceneryRender( void );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _SCENERY_H */
-
-
-/* $Log$
-/* Revision 1.21 1998/04/25 22:06:31 curt
-/* Edited cvs log messages in source files ... bad bad bad!
-/*
- * Revision 1.20 1998/04/22 13:22:45 curt
- * C++ - ifing the code a bit.
- *
- * Revision 1.19 1998/04/21 17:02:43 curt
- * Prepairing for C++ integration.
- *
- * Revision 1.18 1998/03/14 00:30:51 curt
- * Beginning initial terrain texturing experiments.
- *
- * Revision 1.17 1998/02/20 00:16:24 curt
- * Thursday's tweaks.
- *
- * Revision 1.16 1998/01/27 00:48:03 curt
- * Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
- * system and commandline/config file processing code.
- *
- * Revision 1.15 1998/01/22 02:59:41 curt
- * Changed #ifdef FILE_H to #ifdef _FILE_H
- *
- * Revision 1.14 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.13 1998/01/19 18:40:38 curt
- * Tons of little changes to clean up the code and to remove fatal errors
- * when building with the c++ compiler.
- *
- * Revision 1.12 1997/12/15 23:55:03 curt
- * Add xgl wrappers for debugging.
- * Generate terrain normals on the fly.
- *
- * Revision 1.11 1997/12/10 22:37:52 curt
- * Prepended "fg" on the name of all global structures that didn't have it yet.
- * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
- *
- * Revision 1.10 1997/09/04 02:17:37 curt
- * Shufflin' stuff.
- *
- * Revision 1.9 1997/08/27 03:30:33 curt
- * Changed naming scheme of basic shared structures.
- *
- * Revision 1.8 1997/08/06 00:24:30 curt
- * Working on correct real time sun lighting.
- *
- * Revision 1.7 1997/07/23 21:52:27 curt
- * Put comments around the text after an #endif for increased portability.
- *
- * Revision 1.6 1997/07/11 01:30:03 curt
- * More tweaking of terrian floor.
- *
- * Revision 1.5 1997/06/26 22:14:57 curt
- * Beginning work on a scenery management system.
- *
- * Revision 1.4 1997/06/21 17:57:21 curt
- * directory shuffling ...
- *
- * Revision 1.2 1997/05/23 15:40:43 curt
- * Added GNU copyright headers.
- *
- * Revision 1.1 1997/05/16 16:07:07 curt
- * Initial revision.
- *
- */
--- /dev/null
+/**************************************************************************
+ * scenery.hxx -- data structures and routines for managing scenery.
+ *
+ * Written by Curtis Olson, started May 1997.
+ *
+ * Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id$
+ * (Log is kept at end of this file)
+ **************************************************************************/
+
+
+#ifndef _SCENERY_HXX
+#define _SCENERY_HXX
+
+
+#ifndef __cplusplus
+# error This library requires C++
+#endif
+
+
+#include <Include/fg_types.h>
+
+
+/* Define a structure containing global scenery parameters */
+struct fgSCENERY {
+ /* number of terrain data points to skip */
+ int terrain_skip;
+
+ /* center of current scenery chunk */
+ struct fgCartesianPoint center;
+
+ /* next center of current scenery chunk */
+ struct fgCartesianPoint next_center;
+
+ /* angle of sun relative to current local horizontal */
+ double sun_angle;
+};
+
+extern struct fgSCENERY scenery;
+
+
+/* Initialize the Scenery Management system */
+int fgSceneryInit( void );
+
+
+/* Tell the scenery manager where we are so it can load the proper data, and
+ * build the proper structures. */
+void fgSceneryUpdate(double lon, double lat, double elev);
+
+
+/* Render out the current scene */
+void fgSceneryRender( void );
+
+
+#endif /* _SCENERY_HXX */
+
+
+/* $Log$
+/* Revision 1.1 1998/04/30 12:35:31 curt
+/* Added a command line rendering option specify smooth/flat shading.
+/*
+ * Revision 1.21 1998/04/25 22:06:31 curt
+ * Edited cvs log messages in source files ... bad bad bad!
+ *
+ * Revision 1.20 1998/04/22 13:22:45 curt
+ * C++ - ifing the code a bit.
+ *
+ * Revision 1.19 1998/04/21 17:02:43 curt
+ * Prepairing for C++ integration.
+ *
+ * Revision 1.18 1998/03/14 00:30:51 curt
+ * Beginning initial terrain texturing experiments.
+ *
+ * Revision 1.17 1998/02/20 00:16:24 curt
+ * Thursday's tweaks.
+ *
+ * Revision 1.16 1998/01/27 00:48:03 curt
+ * Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
+ * system and commandline/config file processing code.
+ *
+ * Revision 1.15 1998/01/22 02:59:41 curt
+ * Changed #ifdef FILE_H to #ifdef _FILE_H
+ *
+ * Revision 1.14 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.13 1998/01/19 18:40:38 curt
+ * Tons of little changes to clean up the code and to remove fatal errors
+ * when building with the c++ compiler.
+ *
+ * Revision 1.12 1997/12/15 23:55:03 curt
+ * Add xgl wrappers for debugging.
+ * Generate terrain normals on the fly.
+ *
+ * Revision 1.11 1997/12/10 22:37:52 curt
+ * Prepended "fg" on the name of all global structures that didn't have it yet.
+ * i.e. "struct WEATHER {}" became "struct fgWEATHER {}"
+ *
+ * Revision 1.10 1997/09/04 02:17:37 curt
+ * Shufflin' stuff.
+ *
+ * Revision 1.9 1997/08/27 03:30:33 curt
+ * Changed naming scheme of basic shared structures.
+ *
+ * Revision 1.8 1997/08/06 00:24:30 curt
+ * Working on correct real time sun lighting.
+ *
+ * Revision 1.7 1997/07/23 21:52:27 curt
+ * Put comments around the text after an #endif for increased portability.
+ *
+ * Revision 1.6 1997/07/11 01:30:03 curt
+ * More tweaking of terrian floor.
+ *
+ * Revision 1.5 1997/06/26 22:14:57 curt
+ * Beginning work on a scenery management system.
+ *
+ * Revision 1.4 1997/06/21 17:57:21 curt
+ * directory shuffling ...
+ *
+ * Revision 1.2 1997/05/23 15:40:43 curt
+ * Added GNU copyright headers.
+ *
+ * Revision 1.1 1997/05/16 16:07:07 curt
+ * Initial revision.
+ *
+ */
/**************************************************************************
- * tilecache.c -- routines to handle scenery tile caching
+ * tilecache.cxx -- routines to handle scenery tile caching
*
* Written by Curtis Olson, started January 1998.
*
#include <Debug/fg_debug.h>
#include <Main/views.hxx>
-#include "obj.h"
+#include "obj.hxx"
#include "tilecache.hxx"
/* $Log$
-/* Revision 1.4 1998/04/28 01:21:43 curt
-/* Tweaked texture parameter calculations to keep the number smaller. This
-/* avoids the "swimming" problem.
-/* Type-ified fgTIME and fgVIEW.
+/* Revision 1.5 1998/04/30 12:35:31 curt
+/* Added a command line rendering option specify smooth/flat shading.
/*
+ * Revision 1.4 1998/04/28 01:21:43 curt
+ * Tweaked texture parameter calculations to keep the number smaller. This
+ * avoids the "swimming" problem.
+ * Type-ified fgTIME and fgVIEW.
+ *
* Revision 1.3 1998/04/25 22:06:32 curt
* Edited cvs log messages in source files ... bad bad bad!
*
/**************************************************************************
- * tilecache.h -- routines to handle scenery tile caching
+ * tilecache.hxx -- routines to handle scenery tile caching
*
* Written by Curtis Olson, started January 1998.
*
**************************************************************************/
-#ifndef _TILECACHE_H
-#define _TILECACHE_H
+#ifndef _TILECACHE_HXX
+#define _TILECACHE_HXX
#ifndef __cplusplus
struct fgCartesianPoint *local_ref );
-#endif /* _TILECACHE_H */
+#endif /* _TILECACHE_HXX */
/* $Log$
-/* Revision 1.3 1998/04/25 22:06:32 curt
-/* Edited cvs log messages in source files ... bad bad bad!
+/* Revision 1.4 1998/04/30 12:35:31 curt
+/* Added a command line rendering option specify smooth/flat shading.
/*
+ * 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:08 curt
* Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
* Tweaked the scenery file extentions to be "file.obj" (uncompressed)
#include <GL/glut.h>
#include <XGL/xgl.h>
-#include <Scenery/scenery.h>
-#include <Scenery/obj.h>
+#include <Scenery/obj.hxx>
+#include <Scenery/scenery.hxx>
#include <Scenery/tilecache.hxx>
#include <Aircraft/aircraft.h>
/* $Log$
-/* Revision 1.4 1998/04/27 03:30:14 curt
-/* 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.5 1998/04/30 12:35:32 curt
+/* Added a command line rendering option specify smooth/flat shading.
/*
+ * Revision 1.4 1998/04/27 03:30:14 curt
+ * 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!
*