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