]> git.mxchange.org Git - flightgear.git/blob - Scenery/tilemgr.cxx
Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
[flightgear.git] / Scenery / tilemgr.cxx
1 // tilemgr.cxx -- routines to handle dynamic management of scenery tiles
2 //
3 // Written by Curtis Olson, started January 1998.
4 //
5 // Copyright (C) 1997  Curtis L. Olson  - curt@infoplane.com
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22 // (Log is kept at end of this file)
23
24
25 #ifdef HAVE_CONFIG_H
26 #  include <config.h>
27 #endif
28
29 #ifdef HAVE_WINDOWS_H
30 #  include <windows.h>
31 #endif
32
33 #include <GL/glut.h>
34 #include <XGL/xgl.h>
35
36 #include <Aircraft/aircraft.h>
37
38 #include <Bucket/bucketutils.h>
39 #include <Debug/fg_debug.h>
40 #include <Include/fg_constants.h>
41 #include <Include/fg_types.h>
42 #include <Main/options.hxx>
43 #include <Main/views.hxx>
44 #include <Math/fg_geodesy.h>
45 #include <Math/mat3.h>
46 #include <Math/polar3d.hxx>
47 #include <Math/vector.hxx>
48
49 #include "material.hxx"
50 #include "obj.hxx"
51 #include "scenery.hxx"
52 #include "tilecache.hxx"
53
54
55 #define FG_LOCAL_X_Y         81  // max(o->tile_diameter) ** 2
56
57
58 // closest (potentially viewable) tiles, centered on current tile.
59 // This is an array of pointers to cache indexes.
60 int tiles[FG_LOCAL_X_Y];
61
62
63 // Initialize the Tile Manager subsystem
64 int fgTileMgrInit( void ) {
65     fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
66
67     // load default material library
68     material_mgr.load_lib();
69
70     return 1;
71 }
72
73
74 // load a tile
75 void fgTileMgrLoadTile( fgBUCKET *p, int *index) {
76     fgTILECACHE *c;
77
78     c = &global_tile_cache;
79
80     fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating for bucket %d %d %d %d\n", 
81            p->lon, p->lat, p->x, p->y);
82     
83     // if not in cache, load tile into the next available slot
84     if ( (*index = c->Exists(p)) < 0 ) {
85         *index = c->NextAvail();
86         c->EntryFillIn(*index, p);
87     }
88
89     fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index);
90 }
91
92
93 // given the current lon/lat, fill in the array of local chunks.  If
94 // the chunk isn't already in the cache, then read it from disk.
95 int fgTileMgrUpdate( void ) {
96     fgTILECACHE *c;
97     fgFLIGHT *f;
98     fgOPTIONS *o;
99     fgBUCKET p1, p2;
100     static fgBUCKET p_last = {-1000, 0, 0, 0};
101     int i, j, dw, dh;
102
103     c = &global_tile_cache;
104     f = current_aircraft.flight;
105     o = &current_options;
106
107     fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p1);
108     dw = o->tile_diameter / 2;
109     dh = o->tile_diameter / 2;
110
111     if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
112          (p1.x == p_last.x) && (p1.y == p_last.y) ) {
113         // same bucket as last time
114         fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n");
115     } else if ( p_last.lon == -1000 ) {
116         // First time through, initialize the system and load all
117         // relavant tiles
118
119         fgPrintf( FG_TERRAIN, FG_INFO, "  First time through ... ");
120         fgPrintf( FG_TERRAIN, FG_INFO, "  Updating Tile list for %d,%d %d,%d\n",
121                   p1.lon, p1.lat, p1.x, p1.y);
122         fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n", 
123                   o->tile_diameter * o->tile_diameter);
124
125         // wipe/initialize tile cache
126         c->Init();
127
128         // build the local area list and update cache
129         for ( j = 0; j < o->tile_diameter; j++ ) {
130             for ( i = 0; i < o->tile_diameter; i++ ) {
131                 fgBucketOffset(&p1, &p2, i - dw, j - dh);
132                 fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + i]);
133             }
134         }
135     } else {
136         // We've moved to a new bucket, we need to scroll our
137         // structures, and load in the new tiles
138
139         // CURRENTLY THIS ASSUMES WE CAN ONLY MOVE TO ADJACENT TILES.
140         // AT ULTRA HIGH SPEEDS THIS ASSUMPTION MAY NOT BE VALID IF
141         // THE AIRCRAFT CAN SKIP A TILE IN A SINGLE ITERATION.
142
143         fgPrintf( FG_TERRAIN, FG_INFO, "Updating Tile list for %d,%d %d,%d\n",
144                   p1.lon, p1.lat, p1.x, p1.y);
145
146         if ( (p1.lon > p_last.lon) ||
147              ( (p1.lon == p_last.lon) && (p1.x > p_last.x) ) ) {
148             fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n", 
149                       o->tile_diameter);
150             for ( j = 0; j < o->tile_diameter; j++ ) {
151                 // scrolling East
152                 for ( i = 0; i < o->tile_diameter - 1; i++ ) {
153                     tiles[(j*o->tile_diameter) + i] = 
154                         tiles[(j*o->tile_diameter) + i + 1];
155                 }
156                 // load in new column
157                 fgBucketOffset(&p_last, &p2, dw + 1, j - dh);
158                 fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + 
159                                              o->tile_diameter - 1]);
160             }
161         } else if ( (p1.lon < p_last.lon) ||
162                     ( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) {
163             fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n", 
164                       o->tile_diameter);
165             for ( j = 0; j < o->tile_diameter; j++ ) {
166                 // scrolling West
167                 for ( i = o->tile_diameter - 1; i > 0; i-- ) {
168                     tiles[(j*o->tile_diameter) + i] = 
169                         tiles[(j*o->tile_diameter) + i - 1];
170                 }
171                 // load in new column
172                 fgBucketOffset(&p_last, &p2, -dw - 1, j - dh);
173                 fgTileMgrLoadTile(&p2, &tiles[(j*o->tile_diameter) + 0]);
174             }
175         }
176
177         if ( (p1.lat > p_last.lat) ||
178              ( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) {
179             fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n", 
180                       o->tile_diameter);
181             for ( i = 0; i < o->tile_diameter; i++ ) {
182                 // scrolling North
183                 for ( j = 0; j < o->tile_diameter - 1; j++ ) {
184                     tiles[(j * o->tile_diameter) + i] =
185                         tiles[((j+1) * o->tile_diameter) + i];
186                 }
187                 // load in new column
188                 fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
189                 fgTileMgrLoadTile(&p2, &tiles[((o->tile_diameter-1) * 
190                                                o->tile_diameter) + i]);
191             }
192         } else if ( (p1.lat < p_last.lat) ||
193                     ( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
194             fgPrintf( FG_TERRAIN, FG_INFO, "  Loading %d tiles\n", 
195                       o->tile_diameter);
196             for ( i = 0; i < o->tile_diameter; i++ ) {
197                 // scrolling South
198                 for ( j = o->tile_diameter - 1; j > 0; j-- ) {
199                     tiles[(j * o->tile_diameter) + i] = 
200                         tiles[((j-1) * o->tile_diameter) + i];
201                 }
202                 // load in new column
203                 fgBucketOffset(&p_last, &p2, i - dw, -dh - 1);
204                 fgTileMgrLoadTile(&p2, &tiles[0 + i]);
205             }
206         }
207     }
208     p_last.lon = p1.lon;
209     p_last.lat = p1.lat;
210     p_last.x = p1.x;
211     p_last.y = p1.y;
212     return 1;
213 }
214
215
216 // Calculate shortest distance from point to line
217 static double point_line_dist( fgPoint3d *tc, fgPoint3d *vp, MAT3vec d) {
218     MAT3vec p, p0;
219     double dist;
220
221     p[0] = tc->x; p[1] = tc->y; p[2] = tc->z;
222     p0[0] = vp->x; p0[1] = vp->y; p0[2] = vp->z;
223
224     dist = fgPointLine(p, p0, d);
225
226     // printf("dist = %.2f\n", dist);
227
228     return(dist);
229 }
230
231
232 // Calculate if point/radius is inside view frustum
233 static int viewable( fgPoint3d *cp, double radius ) {
234     fgVIEW *v;
235     MAT3hvec world, eye;
236     int viewable = 1; // start by assuming it's viewable
237     double x0, x1, y1, slope;
238
239     v = &current_view;
240
241     MAT3_SET_HVEC(world, cp->x, cp->y, cp->z, 1.0);
242     MAT3mult_vec(eye, world, v->WORLD_TO_EYE);
243     // printf( "\nworld -> eye = %.2f %.2f %.2f  radius = %.2f\n", 
244     //         eye[0], eye[1], eye[2], radius);
245
246     // Check near clip plane
247     if ( eye[2] - radius > 0.0 ) {
248         return(0);
249     }
250
251     // check right clip plane (from eye perspective)
252     // y = m * (x - x0) = equation of a line intercepting X axis at x0
253     x1 = v->cos_fov_x * radius;
254     y1 = v->sin_fov_x * radius;
255     slope = v->slope_x;
256     x0 = x1 - y1 / slope;
257
258     // printf("(r) x1 = %.2f  y1 = %.2f\n", x1, y1);
259     // printf("eye[0] = %.2f  eye[2] = %.2f\n", eye[0], eye[2]);
260     // printf("(r) x0 = %.2f  slope_x = %.2f  radius = %.2f\n", 
261     //        x0, slope, radius);
262
263     if ( eye[2] > slope * (eye[0] - x0) ) {
264         return(0);
265     }
266
267     // check left clip plane (from eye perspective)
268     x1 = -x1;
269     slope = -slope;
270     x0 = x1 - y1 / slope;
271
272     // printf("(r) x1 = %.2f  y1 = %.2f\n", x1, y1);
273     // printf("eye[0] = %.2f  eye[2] = %.2f\n", eye[0], eye[2]);
274     // printf("(r) x0 = %.2f  slope_x = %.2f  radius = %.2f\n", 
275     //        x0, slope, radius);
276
277     if ( eye[2] > slope * (eye[0] - x0) ) {
278         return(0);
279     }
280
281     // check bottom clip plane (from eye perspective)
282     x1 = -(v->cos_fov_y) * radius;
283     y1 = v->sin_fov_y * radius;
284     slope = v->slope_y;
285     x0 = x1 - y1 / slope;
286
287     // printf("(r) x1 = %.2f  y1 = %.2f\n", x1, y1);
288     // printf("eye[1] = %.2f  eye[2] = %.2f\n", eye[1], eye[2]);
289     // printf("(r) x0 = %.2f  slope_y = %.2f  radius = %.2f\n", 
290     //       x0, slope, radius);
291
292     if ( eye[2] > slope * (eye[1] - x0) ) {
293         return(0);
294     }
295
296     // check top clip plane (from eye perspective)
297     x1 = -x1;
298     slope = -slope;
299     x0 = x1 - y1 / slope;
300
301     // printf("(r) x1 = %.2f  y1 = %.2f\n", x1, y1);
302     // printf("eye[1] = %.2f  eye[2] = %.2f\n", eye[1], eye[2]);
303     // printf("(r) x0 = %.2f  slope_y = %.2f  radius = %.2f\n", 
304     //        x0, slope, radius);
305
306     if ( eye[2] > slope * (eye[1] - x0) ) {
307         return(0);
308     }
309
310     return(viewable);
311 }
312
313
314 // Render the local tiles
315 void fgTileMgrRender( void ) {
316     fgTILECACHE *c;
317     fgFLIGHT *f;
318     fgOPTIONS *o;
319     fgTILE *t;
320     fgVIEW *v;
321     fgBUCKET p;
322     fgPoint3d frag_offset, fc, pp;
323     fgFRAGMENT *frag_ptr;
324     fgMATERIAL *mtl_ptr;
325     fgTILE *last_tile_ptr;
326     GLdouble *m;
327     double dist, min_dist, lat_geod, alt, sea_level_r;
328     double x, y, z;
329     list < fgFRAGMENT > :: iterator current;
330     list < fgFRAGMENT > :: iterator last;
331     int i, j, size;
332     int index;
333     int culled = 0;
334     int drawn = 0;
335
336     c = &global_tile_cache;
337     f = current_aircraft.flight;
338     o = &current_options;
339     v = &current_view;
340
341     // Find current translation offset
342     fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p);
343     index = c->Exists(&p);
344     t = c->GetTile(index);
345
346     fgPrintf( FG_TERRAIN, FG_DEBUG, 
347               "Pos = (%.2f, %.2f) Current bucket = %d %d %d %d  Index = %ld\n", 
348               FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG,
349               p.lon, p.lat, p.x, p.y, fgBucketGenIndex(&p) );
350
351     // initialize the transient per-material fragment lists
352     material_mgr.init_transient_material_lists();
353     min_dist = 100000.0;
354
355     // Pass 1
356     // traverse the potentially viewable tile list
357     for ( i = 0; i < (o->tile_diameter * o->tile_diameter); i++ ) {
358         index = tiles[i];
359         // fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index);
360         t = c->GetTile(index);
361
362         // calculate tile offset
363         x = t->offset.x = t->center.x - scenery.center.x;
364         y = t->offset.y = t->center.y - scenery.center.y;
365         z = t->offset.z = t->center.z - scenery.center.z;
366
367         m = t->model_view;
368         for ( j = 0; j < 16; j++ ) {
369             m[j] = v->MODEL_VIEW[j];
370         }
371
372         // Calculate the model_view transformation matrix for this tile
373         m[12] = m[0] * x + m[4] * y + m[8]  * z + m[12];
374         m[13] = m[1] * x + m[5] * y + m[9]  * z + m[13];
375         m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
376         m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
377
378         // temp ... calc current terrain elevation
379         // calculate distance from vertical tangent line at
380         // current position to center of tile.
381         dist = point_line_dist(&(t->offset), &(v->view_pos), v->local_up);
382         if ( dist < t->bounding_radius ) {
383
384             // traverse fragment list for tile
385             current = t->fragment_list.begin();
386             last = t->fragment_list.end();
387
388             while ( current != last ) {
389                 frag_ptr = &(*current);
390                 current++;
391                 dist = point_line_dist( &(frag_ptr->center), &(v->view_pos), 
392                                         v->local_up);
393                 if ( dist <= frag_ptr->bounding_radius ) {
394                     if ( dist < min_dist ) {
395                         min_dist = dist;
396                         // compute geocentric coordinates of tile center
397                         pp = fgCartToPolar3d(frag_ptr->center);
398                         // convert to geodetic coordinates
399                         fgGeocToGeod(pp.lat, pp.radius, &lat_geod, 
400                                      &alt, &sea_level_r);
401                     }
402                 }
403             }
404
405             if ( min_dist <= t->bounding_radius ) {
406                 printf("min_dist = %.2f  alt = %.2f\n", min_dist, alt);
407             }
408         }
409
410         // Course (tile based) culling
411         if ( viewable(&(t->offset), t->bounding_radius) ) {
412             // at least a portion of this tile could be viewable
413             
414             // xglPushMatrix();
415             // xglTranslatef(t->offset.x, t->offset.y, t->offset.z);
416
417             // traverse fragment list for tile
418             current = t->fragment_list.begin();
419             last = t->fragment_list.end();
420
421             while ( current != last ) {
422                 frag_ptr = &(*current);
423                 current++;
424                 
425                 if ( frag_ptr->display_list >= 0 ) {
426                     // Fine (fragment based) culling
427                     frag_offset.x = frag_ptr->center.x - scenery.center.x;
428                     frag_offset.y = frag_ptr->center.y - scenery.center.y;
429                     frag_offset.z = frag_ptr->center.z - scenery.center.z;
430
431                     if ( viewable(&frag_offset, frag_ptr->bounding_radius*2) ) {
432                         // add to transient per-material property fragment list
433                         // frag_ptr->tile_offset.x = t->offset.x;
434                         // frag_ptr->tile_offset.y = t->offset.y;
435                         // frag_ptr->tile_offset.z = t->offset.z;
436
437                         mtl_ptr = (fgMATERIAL *)(frag_ptr->material_ptr);
438                         // printf(" lookup = %s\n", mtl_ptr->texture_name);
439                         if ( mtl_ptr->list_size < FG_MAX_MATERIAL_FRAGS ) {
440                             mtl_ptr->list[mtl_ptr->list_size] = frag_ptr;
441                             (mtl_ptr->list_size)++;
442                         } else {
443                             fgPrintf( FG_TERRAIN, FG_ALERT,
444                                       "Overran material sorting array\n" );
445                         }
446
447                         // xglCallList(frag_ptr->display_list);
448                         drawn++;
449                     } else {
450                         // printf("Culled a fragment %.2f %.2f %.2f %.2f\n",
451                         //        frag_ptr->center.x, frag_ptr->center.y,
452                         //        frag_ptr->center.z, frag_ptr->bounding_radius);
453                         culled++;
454                     }
455                 }
456             }
457
458             // xglPopMatrix();
459         } else {
460             culled += t->fragment_list.size();
461         }
462     }
463
464     if ( (drawn + culled) > 0 ) {
465         v->vfc_ratio = (double)culled / (double)(drawn + culled);
466     } else {
467         v->vfc_ratio = 0.0;
468     }
469     // printf("drawn = %d  culled = %d  saved = %.2f\n", drawn, culled, 
470     //        v->vfc_ratio);
471
472     // Pass 2
473     // traverse the transient per-material fragment lists and render
474     // out all fragments for each material property.
475     map < string, fgMATERIAL, less<string> > :: iterator mapcurrent = 
476         material_mgr.material_map.begin();
477     map < string, fgMATERIAL, less<string> > :: iterator maplast = 
478         material_mgr.material_map.end();
479
480     xglPushMatrix();
481
482     while ( mapcurrent != maplast ) {
483         // (char *)key = (*mapcurrent).first;
484         // (fgMATERIAL)value = (*mapcurrent).second;
485         mtl_ptr = &(*mapcurrent).second;
486
487         last_tile_ptr = NULL;
488
489         size = mtl_ptr->list_size;
490         if ( size > 0 ) {
491             if ( o->textures ) {
492 #ifdef GL_VERSION_1_1
493                 xglBindTexture(GL_TEXTURE_2D, mtl_ptr->texture_id);
494 #elif GL_EXT_texture_object
495                 xglBindTextureEXT(GL_TEXTURE_2D, mtl_ptr->texture_id);
496 #else
497 #  error port me
498 #endif
499             } else {
500                 xglMaterialfv (GL_FRONT, GL_AMBIENT, mtl_ptr->ambient);
501                 xglMaterialfv (GL_FRONT, GL_DIFFUSE, mtl_ptr->diffuse);
502             }
503
504             // printf("traversing = %s, size = %d\n", 
505             //       mtl_ptr->texture_name, size);
506             for ( i = 0; i < size; i++ ) {
507                 frag_ptr = mtl_ptr->list[i];
508                 
509                 if ( frag_ptr->tile_ptr == last_tile_ptr ) {
510                     // same tile as last time, no transform necessary
511                 } else {
512                     // new tile, new translate
513                     // xglLoadMatrixf( frag_ptr->matrix );
514                     t = (fgTILE *)(frag_ptr->tile_ptr);
515                     xglLoadMatrixd(t->model_view );
516                 }
517             
518                 // Woohoo!!!  We finally get to draw something!
519                 // printf("  display_list = %d\n", frag_ptr->display_list);
520                 xglCallList(frag_ptr->display_list);
521
522                 last_tile_ptr = (fgTILE *)(frag_ptr->tile_ptr);
523             }
524         }
525
526         *mapcurrent++;
527     }
528
529     xglPopMatrix();
530 }
531
532
533 // $Log$
534 // Revision 1.23  1998/07/08 14:47:23  curt
535 // Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
536 // polare3d.h renamed to polar3d.hxx
537 // fg{Cartesian,Polar}Point3d consolodated.
538 // Added some initial support for calculating local current ground elevation.
539 //
540 // Revision 1.22  1998/07/04 00:54:31  curt
541 // Added automatic mipmap generation.
542 //
543 // When rendering fragments, use saved model view matrix from associated tile
544 // rather than recalculating it with push() translate() pop().
545 //
546 // Revision 1.21  1998/06/27 16:54:59  curt
547 // Check for GL_VERSION_1_1 or GL_EXT_texture_object to decide whether to use
548 //   "EXT" versions of texture management routines.
549 //
550 // Revision 1.20  1998/06/17 21:36:42  curt
551 // Load and manage multiple textures defined in the Materials library.
552 // Boost max material fagments for each material property to 800.
553 // Multiple texture support when rendering.
554 //
555 // Revision 1.19  1998/06/08 17:57:54  curt
556 // Working first pass at material proporty sorting.
557 //
558 // Revision 1.18  1998/06/06 01:09:32  curt
559 // I goofed on the log message in the last commit ... now fixed.
560 //
561 // Revision 1.17  1998/06/06 01:07:18  curt
562 // Increased per material fragment list size from 100 to 400.
563 // Now correctly draw viewable fragments in per material order.
564 //
565 // Revision 1.16  1998/06/05 22:39:55  curt
566 // Working on sorting by, and rendering by material properties.
567 //
568 // Revision 1.15  1998/06/03 00:47:51  curt
569 // No .h for STL includes.
570 // Minor view culling optimizations.
571 //
572 // Revision 1.14  1998/06/01 17:56:20  curt
573 // Incremental additions to material.cxx (not fully functional)
574 // Tweaked vfc_ratio math to avoid divide by zero.
575 //
576 // Revision 1.13  1998/05/24 02:49:10  curt
577 // Implimented fragment level view frustum culling.
578 //
579 // Revision 1.12  1998/05/23 14:09:23  curt
580 // Added tile.cxx and tile.hxx.
581 // Working on rewriting the tile management system so a tile is just a list
582 // fragments, and the fragment record contains the display list for that fragment.
583 //
584 // Revision 1.11  1998/05/20 20:53:55  curt
585 // Moved global ref point and radius (bounding sphere info, and offset) to
586 // data file rather than calculating it on the fly.
587 // Fixed polygon winding problem in scenery generation stage rather than
588 // compensating for it on the fly.
589 // Made a fgTILECACHE class.
590 //
591 // Revision 1.10  1998/05/17 16:59:34  curt
592 // Frist pass at view frustum culling now operational.
593 //
594 // Revision 1.9  1998/05/16 13:09:58  curt
595 // Beginning to add support for view frustum culling.
596 // Added some temporary code to calculate bouding radius, until the
597 //   scenery generation tools and scenery can be updated.
598 //
599 // Revision 1.8  1998/05/07 23:15:21  curt
600 // Fixed a glTexImage2D() usage bug where width and height were mis-swapped.
601 // Added support for --tile-radius=n option.
602 //
603 // Revision 1.7  1998/05/06 03:16:42  curt
604 // Added an option to control square tile radius.
605 //
606 // Revision 1.6  1998/05/02 01:52:18  curt
607 // Playing around with texture coordinates.
608 //
609 // Revision 1.5  1998/04/30 12:35:32  curt
610 // Added a command line rendering option specify smooth/flat shading.
611 //
612 // Revision 1.4  1998/04/27 03:30:14  curt
613 // Minor transformation adjustments to try to keep scenery tiles closer to
614 // (0, 0, 0)  GLfloats run out of precision at the distances we need to model
615 // the earth, but we can do a bunch of pre-transformations using double math
616 // and then cast to GLfloat once everything is close in where we have less
617 // precision problems.
618 //
619 // Revision 1.3  1998/04/25 22:06:32  curt
620 // Edited cvs log messages in source files ... bad bad bad!
621 //
622 // Revision 1.2  1998/04/24 00:51:09  curt
623 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
624 // Tweaked the scenery file extentions to be "file.obj" (uncompressed)
625 // or "file.obz" (compressed.)
626 //
627 // Revision 1.1  1998/04/22 13:22:48  curt
628 // C++ - ifing the code a bit.
629 //
630 // Revision 1.25  1998/04/18 04:14:07  curt
631 // Moved fg_debug.c to it's own library.
632 //
633 // Revision 1.24  1998/04/14 02:23:18  curt
634 // Code reorganizations.  Added a Lib/ directory for more general libraries.
635 //
636 // Revision 1.23  1998/04/08 23:30:08  curt
637 // Adopted Gnu automake/autoconf system.
638 //
639 // Revision 1.22  1998/04/03 22:11:38  curt
640 // Converting to Gnu autoconf system.
641 //
642 // Revision 1.21  1998/03/23 21:23:05  curt
643 // Debugging output tweaks.
644 //
645 // Revision 1.20  1998/03/14 00:30:51  curt
646 // Beginning initial terrain texturing experiments.
647 //
648 // Revision 1.19  1998/02/20 00:16:25  curt
649 // Thursday's tweaks.
650 //
651 // Revision 1.18  1998/02/19 13:05:54  curt
652 // Incorporated some HUD tweaks from Michelle America.
653 // Tweaked the sky's sunset/rise colors.
654 // Other misc. tweaks.
655 //
656 // Revision 1.17  1998/02/16 13:39:46  curt
657 // Miscellaneous weekend tweaks.  Fixed? a cache problem that caused whole
658 // tiles to occasionally be missing.
659 //
660 // Revision 1.16  1998/02/12 21:59:53  curt
661 // Incorporated code changes contributed by Charlie Hotchkiss
662 // <chotchkiss@namg.us.anritsu.com>
663 //
664 // Revision 1.14  1998/02/09 21:30:19  curt
665 // Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.
666 //
667 // Revision 1.13  1998/02/07 15:29:46  curt
668 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
669 // <chotchkiss@namg.us.anritsu.com>
670 //
671 // Revision 1.12  1998/02/01 03:39:55  curt
672 // Minor tweaks.
673 //
674 // Revision 1.11  1998/01/31 00:43:27  curt
675 // Added MetroWorks patches from Carmen Volpe.
676 //
677 // Revision 1.10  1998/01/29 00:51:40  curt
678 // First pass at tile cache, dynamic tile loading and tile unloading now works.
679 //
680 // Revision 1.9  1998/01/27 03:26:44  curt
681 // Playing with new fgPrintf command.
682 //
683 // Revision 1.8  1998/01/27 00:48:04  curt
684 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
685 // system and commandline/config file processing code.
686 //
687 // Revision 1.7  1998/01/26 15:55:25  curt
688 // Progressing on building dynamic scenery system.
689 //
690 // Revision 1.6  1998/01/24 00:03:30  curt
691 // Initial revision.
692 //
693 // Revision 1.5  1998/01/19 19:27:18  curt
694 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
695 // This should simplify things tremendously.
696 //
697 // Revision 1.4  1998/01/19 18:40:38  curt
698 // Tons of little changes to clean up the code and to remove fatal errors
699 // when building with the c++ compiler.
700 //
701 // Revision 1.3  1998/01/13 00:23:11  curt
702 // Initial changes to support loading and management of scenery tiles.  Note,
703 // there's still a fair amount of work left to be done.
704 //
705 // Revision 1.2  1998/01/08 02:22:27  curt
706 // Continue working on basic features.
707 //
708 // Revision 1.1  1998/01/07 23:50:51  curt
709 // "area" renamed to "tile"
710 //
711 // Revision 1.2  1998/01/07 03:29:29  curt
712 // Given an arbitrary lat/lon, we can now:
713 //   generate a unique index for the chunk containing the lat/lon
714 //   generate a path name to the chunk file
715 //   build a list of the indexes of all the nearby areas.
716 //
717 // Revision 1.1  1998/01/07 02:05:48  curt
718 // Initial revision.