1 // tilemgr.cxx -- routines to handle dynamic management of scenery tiles
3 // Written by Curtis Olson, started January 1998.
5 // Copyright (C) 1997 Curtis L. Olson - curt@infoplane.com
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.
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.
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.
22 // (Log is kept at end of this file)
36 #include <Aircraft/aircraft.hxx>
38 #include <Bucket/bucketutils.h>
39 #include <Debug/fg_debug.h>
40 #include <Include/fg_constants.h>
41 #include <Main/options.hxx>
42 #include <Main/views.hxx>
43 #include <Math/fg_geodesy.hxx>
44 #include <Math/mat3.h>
45 #include <Math/point3d.hxx>
46 #include <Math/polar3d.hxx>
47 #include <Math/vector.hxx>
48 #include <Objects/material.hxx>
49 #include <Objects/obj.hxx>
50 #include <Weather/weather.hxx>
52 #include "scenery.hxx"
54 #include "tilecache.hxx"
57 // to test clipping speedup in fgTileMgrRender()
58 #if defined ( USE_FAST_FOV_CLIP )
59 // #define TEST_FOV_CLIP
64 #define FG_LOCAL_X_Y 81 // max(o->tile_diameter) ** 2
66 #define FG_SQUARE( X ) ( (X) * (X) )
69 # define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
71 # define FG_MEM_COPY(to,from,n) bcopy(from, to, n)
74 // closest (potentially viewable) tiles, centered on current tile.
75 // This is an array of pointers to cache indexes.
76 int tiles[FG_LOCAL_X_Y];
79 // Initialize the Tile Manager subsystem
80 int fgTileMgrInit( void ) {
81 fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
83 // load default material library
84 material_mgr.load_lib();
91 void fgTileMgrLoadTile( fgBUCKET *p, int *index) {
94 c = &global_tile_cache;
96 fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating for bucket %d %d %d %d\n",
97 p->lon, p->lat, p->x, p->y);
99 // if not in cache, load tile into the next available slot
100 if ( (*index = c->exists(p)) < 0 ) {
101 *index = c->next_avail();
102 c->fill_in(*index, p);
105 fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index);
109 // given the current lon/lat, fill in the array of local chunks. If
110 // the chunk isn't already in the cache, then read it from disk.
111 int fgTileMgrUpdate( void ) {
115 static fgBUCKET p_last = {-1000, 0, 0, 0};
119 c = &global_tile_cache;
120 f = current_aircraft.flight;
122 tile_diameter = current_options.get_tile_diameter();
124 fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p1);
125 dw = tile_diameter / 2;
126 dh = tile_diameter / 2;
128 if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
129 (p1.x == p_last.x) && (p1.y == p_last.y) ) {
130 // same bucket as last time
131 fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n");
132 } else if ( p_last.lon == -1000 ) {
133 // First time through, initialize the system and load all
136 fgPrintf( FG_TERRAIN, FG_INFO, " First time through ... ");
137 fgPrintf( FG_TERRAIN, FG_INFO, " Updating Tile list for %d,%d %d,%d\n",
138 p1.lon, p1.lat, p1.x, p1.y);
139 fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
140 tile_diameter * tile_diameter);
142 // wipe/initialize tile cache
145 // build the local area list and update cache
146 for ( j = 0; j < tile_diameter; j++ ) {
147 for ( i = 0; i < tile_diameter; i++ ) {
148 fgBucketOffset(&p1, &p2, i - dw, j - dh);
149 fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + i]);
153 // We've moved to a new bucket, we need to scroll our
154 // structures, and load in the new tiles
156 // CURRENTLY THIS ASSUMES WE CAN ONLY MOVE TO ADJACENT TILES.
157 // AT ULTRA HIGH SPEEDS THIS ASSUMPTION MAY NOT BE VALID IF
158 // THE AIRCRAFT CAN SKIP A TILE IN A SINGLE ITERATION.
160 fgPrintf( FG_TERRAIN, FG_INFO, "Updating Tile list for %d,%d %d,%d\n",
161 p1.lon, p1.lat, p1.x, p1.y);
163 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",
167 for ( j = 0; j < tile_diameter; j++ ) {
169 for ( i = 0; i < tile_diameter - 1; i++ ) {
170 tiles[(j*tile_diameter) + i] =
171 tiles[(j*tile_diameter) + i + 1];
173 // load in new column
174 fgBucketOffset(&p_last, &p2, dw + 1, j - dh);
175 fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) +
178 } else if ( (p1.lon < p_last.lon) ||
179 ( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) {
180 fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
182 for ( j = 0; j < tile_diameter; j++ ) {
184 for ( i = tile_diameter - 1; i > 0; i-- ) {
185 tiles[(j*tile_diameter) + i] =
186 tiles[(j*tile_diameter) + i - 1];
188 // load in new column
189 fgBucketOffset(&p_last, &p2, -dw - 1, j - dh);
190 fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + 0]);
194 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",
198 for ( i = 0; i < tile_diameter; i++ ) {
200 for ( j = 0; j < tile_diameter - 1; j++ ) {
201 tiles[(j * tile_diameter) + i] =
202 tiles[((j+1) * tile_diameter) + i];
204 // load in new column
205 fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
206 fgTileMgrLoadTile(&p2, &tiles[((tile_diameter-1) *
207 tile_diameter) + i]);
209 } else if ( (p1.lat < p_last.lat) ||
210 ( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
211 fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
213 for ( i = 0; i < tile_diameter; i++ ) {
215 for ( j = tile_diameter - 1; j > 0; j-- ) {
216 tiles[(j * tile_diameter) + i] =
217 tiles[((j-1) * tile_diameter) + i];
219 // load in new column
220 fgBucketOffset(&p_last, &p2, i - dw, -dh - 1);
221 fgTileMgrLoadTile(&p2, &tiles[0 + i]);
233 // Calculate shortest distance from point to line
234 static double point_line_dist_squared( const Point3D& tc, const Point3D& vp,
240 p[0] = tc.x(); p[1] = tc.y(); p[2] = tc.z();
241 p0[0] = vp.x(); p0[1] = vp.y(); p0[2] = vp.z();
243 dist = fgPointLineSquared(p, p0, d);
245 // printf("dist = %.2f\n", dist);
251 // Calculate if point/radius is inside view frustum
252 static int viewable( const Point3D& cp, double radius ) {
253 int viewable = 1; // start by assuming it's viewable
256 /********************************/
257 #if defined( USE_FAST_FOV_CLIP ) // views.hxx
258 /********************************/
268 mat = (double *)(current_view.WORLD_TO_EYE);
270 eye[2] = x*mat[2] + y*mat[6] + z*mat[10] + mat[14];
272 // Check near and far clip plane
273 if( ( eye[2] > radius ) ||
274 ( eye[2] + radius + current_weather.visibility < 0) )
279 eye[0] = (x*mat[0] + y*mat[4] + z*mat[8] + mat[12]) * current_view.slope_x;
281 // check right and left clip plane (from eye perspective)
282 x1 = radius * current_view.fov_x_clip;
283 if( (eye[2] > -(eye[0]+x1)) || (eye[2] > (eye[0]-x1)) )
288 eye[1] = (x*mat[1] + y*mat[5] + z*mat[9] + mat[13]) * current_view.slope_y;
290 // check bottom and top clip plane (from eye perspective)
291 y1 = radius * current_view.fov_y_clip;
292 if( (eye[2] > -(eye[1]+y1)) || (eye[2] > (eye[1]-y1)) )
297 /********************************/
298 #else // DO NOT USE_FAST_FOV_CLIP
299 /********************************/
307 MAT3_SET_HVEC(world, cp->x, cp->y, cp->z, 1.0);
308 // MAT3mult_vec(eye, world, v->WORLD_TO_EYE);
309 // printf( "\nworld -> eye = %.2f %.2f %.2f radius = %.2f\n",
310 // eye[0], eye[1], eye[2], radius);
312 // Use lazy evaluation for calculating eye hvec.
314 #define mat v->WORLD_TO_EYE
315 eye[2] = vec[0]*mat[0][2]+vec[1]*mat[1][2]+vec[2]*mat[2][2]+mat[3][2];
317 // Check near clip plane
318 if ( eye[2] > radius ) {
322 // Check far clip plane
323 if ( eye[2] + radius < -current_weather.visibility ) {
327 // check right clip plane (from eye perspective)
328 // y = m * (x - x0) = equation of a line intercepting X axis at x0
329 x1 = v->cos_fov_x * radius;
330 y1 = v->sin_fov_x * radius;
332 eye[0] = vec[0]*mat[0][0]+vec[1]*mat[1][0]+vec[2]*mat[2][0]+mat[3][0];
334 if ( eye[2] > ((slope * (eye[0] - x1)) + y1) ) {
338 // check left clip plane (from eye perspective)
339 if ( eye[2] > -((slope * (eye[0] + x1)) - y1) ) {
343 // check bottom clip plane (from eye perspective)
344 x1 = -(v->cos_fov_y) * radius;
345 y1 = v->sin_fov_y * radius;
347 eye[1] = vec[0]*mat[0][1]+vec[1]*mat[1][1]+vec[2]*mat[2][1]+mat[3][1];
351 if ( eye[2] > ((slope * (eye[1] - x1)) + y1) ) {
355 // check top clip plane (from eye perspective)
356 if ( eye[2] > -((slope * (eye[1] + x1)) - y1) ) {
360 #endif // defined( USE_FAST_FOV_CLIP )
368 // inrange() IS THIS POINT WITHIN POSSIBLE VIEWING RANGE ?
369 // calculate distance from vertical tangent line at
370 // current position to center of object.
371 // this is equivalent to
372 // dist = point_line_dist_squared( &(t->center), &(v->abs_view_pos),
374 // if ( dist < FG_SQUARE(t->bounding_radius) ) {
376 // the compiler should inline this for us
379 inrange( const double radius, const Point3D& center, const Point3D& vp,
386 u[0] = center.x() - vp.x();
387 u[1] = center.y() - vp.y();
388 u[2] = center.z() - vp.z();
390 // calculate the projection, u1, of u along d.
391 // u1 = ( dot_prod(u, d) / dot_prod(d, d) ) * d;
393 MAT3_SCALE_VEC(u1, up,
394 (MAT3_DOT_PRODUCT(u, up) / MAT3_DOT_PRODUCT(up, up)) );
396 // v = u - u1 = vector from closest point on line, p1, to the
397 // original point, p.
398 MAT3_SUB_VEC(v, u, u1);
400 return( FG_SQUARE(radius) >= MAT3_DOT_PRODUCT(v, v));
404 // Determine scenery altitude. Normally this just happens when we
405 // render the scene, but we'd also like to be able to do this
406 // explicitely. lat & lon are in radians. abs_view_pos in meters.
407 // Returns result in meters.
408 double fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) {
412 fgFRAGMENT *frag_ptr;
414 Point3D earth_center, result;
417 list < fgFRAGMENT > :: iterator current;
418 list < fgFRAGMENT > :: iterator last;
419 double dist, lat_geod, alt, sea_level_r;
423 c = &global_tile_cache;
424 // v = ¤t_view;
426 local_up[0] = abs_view_pos.x();
427 local_up[1] = abs_view_pos.y();
428 local_up[2] = abs_view_pos.z();
430 // Find current translation offset
431 fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
432 index = c->exists(&p);
433 t = c->get_tile(index);
435 scenery.next_center = t->center;
437 earth_center = Point3D(0.0, 0.0, 0.0);
439 fgPrintf( FG_TERRAIN, FG_DEBUG,
440 "Pos = (%.2f, %.2f) Current bucket = %d %d %d %d Index = %ld\n",
441 lon * RAD_TO_DEG, lat * RAD_TO_DEG,
442 p.lon, p.lat, p.x, p.y, fgBucketGenIndex(&p) );
444 // calculate tile offset
445 // x = (t->offset.x = t->center.x - scenery.center.x);
446 // y = (t->offset.y = t->center.y - scenery.center.y);
447 // z = (t->offset.z = t->center.z - scenery.center.z);
449 // calc current terrain elevation calculate distance from
450 // vertical tangent line at current position to center of
453 /* printf("distance squared = %.2f, bounding radius = %.2f\n",
454 point_line_dist_squared(&(t->offset), &(v->view_pos),
455 v->local_up), t->bounding_radius); */
457 dist = point_line_dist_squared( t->center, abs_view_pos, local_up );
458 if ( dist < FG_SQUARE(t->bounding_radius) ) {
460 // traverse fragment list for tile
461 current = t->fragment_list.begin();
462 last = t->fragment_list.end();
464 for ( ; current != last; ++current ) {
465 frag_ptr = &(*current);
466 /* printf("distance squared = %.2f, bounding radius = %.2f\n",
467 point_line_dist_squared( &(frag_ptr->center),
468 &abs_view_pos), local_up),
469 frag_ptr->bounding_radius); */
471 dist = point_line_dist_squared( frag_ptr->center,
474 if ( dist <= FG_SQUARE(frag_ptr->bounding_radius) ) {
475 if ( frag_ptr->intersect( abs_view_pos,
476 earth_center, 0, result ) ) {
477 // compute geocentric coordinates of tile center
478 pp = fgCartToPolar3d(result);
479 // convert to geodetic coordinates
480 fgGeocToGeod(pp.lat(), pp.radius(), &lat_geod,
482 // printf("alt = %.2f\n", alt);
483 // exit since we found an intersection
490 printf("no terrain intersection found\n");
495 // NEW for legibility
497 // update this tile's geometry for current view
498 // The Compiler should inline this
500 update_tile_geometry( fgTILE *t, GLdouble *MODEL_VIEW)
505 // calculate tile offset
506 t->offset = t->center - scenery.center;
514 // Calculate the model_view transformation matrix for this tile
515 FG_MEM_COPY( m, MODEL_VIEW, 16*sizeof(GLdouble) );
517 // This is equivalent to doing a glTranslatef(x, y, z);
518 m[12] += (m[0]*x + m[4]*y + m[8] *z);
519 m[13] += (m[1]*x + m[5]*y + m[9] *z);
520 m[14] += (m[2]*x + m[6]*y + m[10]*z);
521 // m[15] += (m[3]*x + m[7]*y + m[11]*z);
522 // m[3] m7[] m[11] are 0.0 see LookAt() in views.cxx
523 // so m[15] is unchanged
527 // Render the local tiles
528 void fgTileMgrRender( void ) {
534 fgFRAGMENT *frag_ptr;
536 list < fgFRAGMENT > :: iterator current;
537 list < fgFRAGMENT > :: iterator last;
544 c = &global_tile_cache;
545 f = current_aircraft.flight;
548 tile_diameter = current_options.get_tile_diameter();
550 scenery.cur_elev = fgTileMgrCurElev( FG_Longitude, FG_Latitude,
553 // initialize the transient per-material fragment lists
554 material_mgr.init_transient_material_lists();
557 // traverse the potentially viewable tile list
558 for ( i = 0; i < (tile_diameter * tile_diameter); i++ ) {
560 // fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index);
561 t = c->get_tile(index);
563 // calculate tile offset
564 t->SetOffset( scenery.center );
566 // Course (tile based) culling
567 if ( viewable(t->offset, t->bounding_radius) ) {
568 // at least a portion of this tile could be viewable
570 // Calculate the model_view transformation matrix for this tile
571 // This is equivalent to doing a glTranslatef(x, y, z);
572 t->UpdateViewMatrix( v->MODEL_VIEW );
575 // xglTranslatef(t->offset.x, t->offset.y, t->offset.z);
577 // traverse fragment list for tile
578 current = t->fragment_list.begin();
579 last = t->fragment_list.end();
581 for ( ; current != last; ++current ) {
582 frag_ptr = &(*current);
584 if ( frag_ptr->display_list >= 0 ) {
585 // Fine (fragment based) culling
586 frag_offset = frag_ptr->center - scenery.center;
588 if ( viewable(frag_offset, frag_ptr->bounding_radius*2) ) {
589 // add to transient per-material property fragment list
590 // frag_ptr->tile_offset.x = t->offset.x;
591 // frag_ptr->tile_offset.y = t->offset.y;
592 // frag_ptr->tile_offset.z = t->offset.z;
594 mtl_ptr = frag_ptr->material_ptr;
595 // printf(" lookup = %s\n", mtl_ptr->texture_name);
596 if ( ! mtl_ptr->append_sort_list( frag_ptr ) ) {
597 fgPrintf( FG_TERRAIN, FG_ALERT,
598 "Overran material sorting array\n" );
601 // xglCallList(frag_ptr->display_list);
604 // printf("Culled a fragment %.2f %.2f %.2f %.2f\n",
605 // frag_ptr->center.x, frag_ptr->center.y,
606 // frag_ptr->center.z, frag_ptr->bounding_radius);
614 culled += t->fragment_list.size();
618 if ( (drawn + culled) > 0 ) {
619 v->vfc_ratio = (double)culled / (double)(drawn + culled);
623 // printf("drawn = %d culled = %d saved = %.2f\n", drawn, culled,
627 // traverse the transient per-material fragment lists and render
628 // out all fragments for each material property.
630 material_mgr.render_fragments();
636 // Revision 1.41 1998/10/18 01:17:23 curt
639 // Revision 1.40 1998/10/17 01:34:28 curt
642 // Revision 1.39 1998/10/16 00:55:50 curt
643 // Converted to Point3D class.
645 // Revision 1.38 1998/09/17 18:36:18 curt
646 // Tweaks and optimizations by Norman Vine.
648 // Revision 1.37 1998/09/15 01:36:45 curt
649 // cleaned up my fragment.num_faces hack :-) to use the STL (no need in
650 // duplicating work.)
651 // Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
652 // removed some unneeded stuff from fgTileMgrCurElev()
654 // Revision 1.36 1998/09/14 12:45:26 curt
657 // Revision 1.35 1998/09/10 19:07:16 curt
658 // /Simulator/Objects/fragment.hxx
659 // Nested fgFACE inside fgFRAGMENT since its not used anywhere else.
661 // ./Simulator/Objects/material.cxx
662 // ./Simulator/Objects/material.hxx
663 // Made fgMATERIAL and fgMATERIAL_MGR bona fide classes with private
664 // data members - that should keep the rabble happy :)
666 // ./Simulator/Scenery/tilemgr.cxx
667 // In viewable() delay evaluation of eye[0] and eye[1] in until they're
669 // Change to fgTileMgrRender() to call fgMATERIAL_MGR::render_fragments()
672 // ./Include/fg_stl_config.h
673 // ./Include/auto_ptr.hxx
674 // Added support for g++ 2.7.
675 // Further changes to other files are forthcoming.
677 // Brief summary of changes required for g++ 2.7.
678 // operator->() not supported by iterators: use (*i).x instead of i->x
679 // default template arguments not supported,
680 // <functional> doesn't have mem_fun_ref() needed by callbacks.
681 // some std include files have different names.
682 // template member functions not supported.
684 // Revision 1.34 1998/09/09 20:58:09 curt
685 // Tweaks to loop constructs with STL usage.
687 // Revision 1.33 1998/09/08 15:05:10 curt
688 // Optimization by Norman Vine.
690 // Revision 1.32 1998/08/25 16:52:44 curt
691 // material.cxx material.hxx obj.cxx obj.hxx texload.c texload.h moved to
694 // Revision 1.31 1998/08/24 20:11:40 curt
697 // Revision 1.30 1998/08/22 14:49:59 curt
698 // Attempting to iron out seg faults and crashes.
699 // Did some shuffling to fix a initialization order problem between view
700 // position, scenery elevation.
702 // Revision 1.29 1998/08/20 15:12:06 curt
703 // Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate
704 // the need for "void" pointers and casts.
705 // Quick hack to count the number of scenery polygons that are being drawn.
707 // Revision 1.28 1998/08/12 21:13:06 curt
708 // material.cxx: don't load textures if they are disabled
709 // obj.cxx: optimizations from Norman Vine
710 // tile.cxx: minor tweaks
711 // tile.hxx: addition of num_faces
712 // tilemgr.cxx: minor tweaks
714 // Revision 1.27 1998/07/24 21:42:09 curt
715 // material.cxx: whups, double method declaration with no definition.
716 // obj.cxx: tweaks to avoid errors in SGI's CC.
717 // tile.cxx: optimizations by Norman Vine.
718 // tilemgr.cxx: optimizations by Norman Vine.
720 // Revision 1.26 1998/07/20 12:51:26 curt
721 // Added far clip plane to fragment clipping calculations and tie this to
722 // weather->visibility. This way you can increase framerates by increasing
723 // for and lowering visibility.
725 // Revision 1.25 1998/07/13 21:02:01 curt
726 // Wrote access functions for current fgOPTIONS.
728 // Revision 1.24 1998/07/12 03:18:29 curt
729 // Added ground collision detection. This involved:
730 // - saving the entire vertex list for each tile with the tile records.
731 // - saving the face list for each fragment with the fragment records.
732 // - code to intersect the current vertical line with the proper face in
733 // an efficient manner as possible.
734 // Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
736 // Revision 1.23 1998/07/08 14:47:23 curt
737 // Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
738 // polare3d.h renamed to polar3d.hxx
739 // fg{Cartesian,Polar}Point3d consolodated.
740 // Added some initial support for calculating local current ground elevation.
742 // Revision 1.22 1998/07/04 00:54:31 curt
743 // Added automatic mipmap generation.
745 // When rendering fragments, use saved model view matrix from associated tile
746 // rather than recalculating it with push() translate() pop().
748 // Revision 1.21 1998/06/27 16:54:59 curt
749 // Check for GL_VERSION_1_1 or GL_EXT_texture_object to decide whether to use
750 // "EXT" versions of texture management routines.
752 // Revision 1.20 1998/06/17 21:36:42 curt
753 // Load and manage multiple textures defined in the Materials library.
754 // Boost max material fagments for each material property to 800.
755 // Multiple texture support when rendering.
757 // Revision 1.19 1998/06/08 17:57:54 curt
758 // Working first pass at material proporty sorting.
760 // Revision 1.18 1998/06/06 01:09:32 curt
761 // I goofed on the log message in the last commit ... now fixed.
763 // Revision 1.17 1998/06/06 01:07:18 curt
764 // Increased per material fragment list size from 100 to 400.
765 // Now correctly draw viewable fragments in per material order.
767 // Revision 1.16 1998/06/05 22:39:55 curt
768 // Working on sorting by, and rendering by material properties.
770 // Revision 1.15 1998/06/03 00:47:51 curt
771 // No .h for STL includes.
772 // Minor view culling optimizations.
774 // Revision 1.14 1998/06/01 17:56:20 curt
775 // Incremental additions to material.cxx (not fully functional)
776 // Tweaked vfc_ratio math to avoid divide by zero.
778 // Revision 1.13 1998/05/24 02:49:10 curt
779 // Implimented fragment level view frustum culling.
781 // Revision 1.12 1998/05/23 14:09:23 curt
782 // Added tile.cxx and tile.hxx.
783 // Working on rewriting the tile management system so a tile is just a list
784 // fragments, and the fragment record contains the display list for that fragment.
786 // Revision 1.11 1998/05/20 20:53:55 curt
787 // Moved global ref point and radius (bounding sphere info, and offset) to
788 // data file rather than calculating it on the fly.
789 // Fixed polygon winding problem in scenery generation stage rather than
790 // compensating for it on the fly.
791 // Made a fgTILECACHE class.
793 // Revision 1.10 1998/05/17 16:59:34 curt
794 // Frist pass at view frustum culling now operational.
796 // Revision 1.9 1998/05/16 13:09:58 curt
797 // Beginning to add support for view frustum culling.
798 // Added some temporary code to calculate bouding radius, until the
799 // scenery generation tools and scenery can be updated.
801 // Revision 1.8 1998/05/07 23:15:21 curt
802 // Fixed a glTexImage2D() usage bug where width and height were mis-swapped.
803 // Added support for --tile-radius=n option.
805 // Revision 1.7 1998/05/06 03:16:42 curt
806 // Added an option to control square tile radius.
808 // Revision 1.6 1998/05/02 01:52:18 curt
809 // Playing around with texture coordinates.
811 // Revision 1.5 1998/04/30 12:35:32 curt
812 // Added a command line rendering option specify smooth/flat shading.
814 // Revision 1.4 1998/04/27 03:30:14 curt
815 // Minor transformation adjustments to try to keep scenery tiles closer to
816 // (0, 0, 0) GLfloats run out of precision at the distances we need to model
817 // the earth, but we can do a bunch of pre-transformations using double math
818 // and then cast to GLfloat once everything is close in where we have less
819 // precision problems.
821 // Revision 1.3 1998/04/25 22:06:32 curt
822 // Edited cvs log messages in source files ... bad bad bad!
824 // Revision 1.2 1998/04/24 00:51:09 curt
825 // Wrapped "#include <config.h>" in "#ifdef HAVE_CONFIG_H"
826 // Tweaked the scenery file extentions to be "file.obj" (uncompressed)
827 // or "file.obz" (compressed.)
829 // Revision 1.1 1998/04/22 13:22:48 curt
830 // C++ - ifing the code a bit.
832 // Revision 1.25 1998/04/18 04:14:07 curt
833 // Moved fg_debug.c to it's own library.
835 // Revision 1.24 1998/04/14 02:23:18 curt
836 // Code reorganizations. Added a Lib/ directory for more general libraries.
838 // Revision 1.23 1998/04/08 23:30:08 curt
839 // Adopted Gnu automake/autoconf system.
841 // Revision 1.22 1998/04/03 22:11:38 curt
842 // Converting to Gnu autoconf system.
844 // Revision 1.21 1998/03/23 21:23:05 curt
845 // Debugging output tweaks.
847 // Revision 1.20 1998/03/14 00:30:51 curt
848 // Beginning initial terrain texturing experiments.
850 // Revision 1.19 1998/02/20 00:16:25 curt
851 // Thursday's tweaks.
853 // Revision 1.18 1998/02/19 13:05:54 curt
854 // Incorporated some HUD tweaks from Michelle America.
855 // Tweaked the sky's sunset/rise colors.
856 // Other misc. tweaks.
858 // Revision 1.17 1998/02/16 13:39:46 curt
859 // Miscellaneous weekend tweaks. Fixed? a cache problem that caused whole
860 // tiles to occasionally be missing.
862 // Revision 1.16 1998/02/12 21:59:53 curt
863 // Incorporated code changes contributed by Charlie Hotchkiss
864 // <chotchkiss@namg.us.anritsu.com>
866 // Revision 1.14 1998/02/09 21:30:19 curt
867 // Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.
869 // Revision 1.13 1998/02/07 15:29:46 curt
870 // Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
871 // <chotchkiss@namg.us.anritsu.com>
873 // Revision 1.12 1998/02/01 03:39:55 curt
876 // Revision 1.11 1998/01/31 00:43:27 curt
877 // Added MetroWorks patches from Carmen Volpe.
879 // Revision 1.10 1998/01/29 00:51:40 curt
880 // First pass at tile cache, dynamic tile loading and tile unloading now works.
882 // Revision 1.9 1998/01/27 03:26:44 curt
883 // Playing with new fgPrintf command.
885 // Revision 1.8 1998/01/27 00:48:04 curt
886 // Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
887 // system and commandline/config file processing code.
889 // Revision 1.7 1998/01/26 15:55:25 curt
890 // Progressing on building dynamic scenery system.
892 // Revision 1.6 1998/01/24 00:03:30 curt
895 // Revision 1.5 1998/01/19 19:27:18 curt
896 // Merged in make system changes from Bob Kuehne <rpk@sgi.com>
897 // This should simplify things tremendously.
899 // Revision 1.4 1998/01/19 18:40:38 curt
900 // Tons of little changes to clean up the code and to remove fatal errors
901 // when building with the c++ compiler.
903 // Revision 1.3 1998/01/13 00:23:11 curt
904 // Initial changes to support loading and management of scenery tiles. Note,
905 // there's still a fair amount of work left to be done.
907 // Revision 1.2 1998/01/08 02:22:27 curt
908 // Continue working on basic features.
910 // Revision 1.1 1998/01/07 23:50:51 curt
911 // "area" renamed to "tile"
913 // Revision 1.2 1998/01/07 03:29:29 curt
914 // Given an arbitrary lat/lon, we can now:
915 // generate a unique index for the chunk containing the lat/lon
916 // generate a path name to the chunk file
917 // build a list of the indexes of all the nearby areas.
919 // Revision 1.1 1998/01/07 02:05:48 curt