1998-05-20 20:53:53 +00:00
|
|
|
// tilemgr.cxx -- routines to handle dynamic management of scenery tiles
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started January 1998.
|
|
|
|
//
|
|
|
|
// 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)
|
1998-01-07 23:50:01 +00:00
|
|
|
|
|
|
|
|
1998-04-24 00:51:07 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
1998-04-03 22:09:02 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_WINDOWS_H
|
1998-01-07 23:50:01 +00:00
|
|
|
# include <windows.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <GL/glut.h>
|
1998-01-19 19:26:51 +00:00
|
|
|
#include <XGL/xgl.h>
|
1998-01-07 23:50:01 +00:00
|
|
|
|
1998-05-23 14:09:20 +00:00
|
|
|
#include <Aircraft/aircraft.h>
|
|
|
|
|
1998-04-14 02:23:04 +00:00
|
|
|
#include <Bucket/bucketutils.h>
|
1998-04-18 04:13:51 +00:00
|
|
|
#include <Debug/fg_debug.h>
|
1998-01-27 00:47:41 +00:00
|
|
|
#include <Include/fg_constants.h>
|
|
|
|
#include <Include/fg_types.h>
|
1998-05-06 03:16:42 +00:00
|
|
|
#include <Main/options.hxx>
|
1998-05-16 13:09:57 +00:00
|
|
|
#include <Main/views.hxx>
|
1998-07-08 14:47:20 +00:00
|
|
|
#include <Math/fg_geodesy.h>
|
1998-05-16 13:09:57 +00:00
|
|
|
#include <Math/mat3.h>
|
1998-07-08 14:47:20 +00:00
|
|
|
#include <Math/polar3d.hxx>
|
|
|
|
#include <Math/vector.hxx>
|
1998-08-25 16:52:38 +00:00
|
|
|
#include <Objects/material.hxx>
|
|
|
|
#include <Objects/obj.hxx>
|
1998-07-20 12:51:26 +00:00
|
|
|
#include <Weather/weather.h>
|
1998-01-07 23:50:01 +00:00
|
|
|
|
1998-06-05 22:39:53 +00:00
|
|
|
#include "scenery.hxx"
|
|
|
|
#include "tilecache.hxx"
|
|
|
|
|
1998-01-07 23:50:01 +00:00
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
// to test clipping speedup in fgTileMgrRender()
|
|
|
|
#if defined ( USE_FAST_FOV_CLIP )
|
|
|
|
// #define TEST_FOV_CLIP
|
|
|
|
// #define TEST_ELEV
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
#define FG_LOCAL_X_Y 81 // max(o->tile_diameter) ** 2
|
1998-01-24 00:03:27 +00:00
|
|
|
|
1998-08-12 21:13:03 +00:00
|
|
|
#define FG_SQUARE( X ) ( (X) * (X) )
|
1998-07-24 21:42:06 +00:00
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
|
|
|
|
#else
|
|
|
|
# define FG_MEM_COPY(to,from,n) bcopy(from, to, n)
|
|
|
|
#endif
|
1998-01-24 00:03:27 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// closest (potentially viewable) tiles, centered on current tile.
|
|
|
|
// This is an array of pointers to cache indexes.
|
1998-01-24 00:03:27 +00:00
|
|
|
int tiles[FG_LOCAL_X_Y];
|
|
|
|
|
1998-01-07 23:50:01 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// Initialize the Tile Manager subsystem
|
1998-02-12 21:58:27 +00:00
|
|
|
int fgTileMgrInit( void ) {
|
1998-01-27 03:26:41 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem.\n");
|
1998-06-05 22:39:53 +00:00
|
|
|
|
|
|
|
// load default material library
|
|
|
|
material_mgr.load_lib();
|
|
|
|
|
1998-02-12 21:58:27 +00:00
|
|
|
return 1;
|
1998-01-07 23:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// load a tile
|
1998-07-04 00:54:28 +00:00
|
|
|
void fgTileMgrLoadTile( fgBUCKET *p, int *index) {
|
1998-05-20 20:53:53 +00:00
|
|
|
fgTILECACHE *c;
|
|
|
|
|
|
|
|
c = &global_tile_cache;
|
|
|
|
|
1998-01-27 03:26:41 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_DEBUG, "Updating for bucket %d %d %d %d\n",
|
1998-01-26 15:55:24 +00:00
|
|
|
p->lon, p->lat, p->x, p->y);
|
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// if not in cache, load tile into the next available slot
|
1998-09-14 12:45:23 +00:00
|
|
|
if ( (*index = c->exists(p)) < 0 ) {
|
|
|
|
*index = c->next_avail();
|
|
|
|
c->fill_in(*index, p);
|
1998-01-29 00:51:38 +00:00
|
|
|
}
|
|
|
|
|
1998-01-27 03:26:41 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_DEBUG, "Selected cache index of %d\n", *index);
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// given the current lon/lat, fill in the array of local chunks. If
|
|
|
|
// the chunk isn't already in the cache, then read it from disk.
|
1998-02-12 21:58:27 +00:00
|
|
|
int fgTileMgrUpdate( void ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
fgTILECACHE *c;
|
1998-02-07 15:29:31 +00:00
|
|
|
fgFLIGHT *f;
|
1998-07-04 00:54:28 +00:00
|
|
|
fgBUCKET p1, p2;
|
|
|
|
static fgBUCKET p_last = {-1000, 0, 0, 0};
|
1998-07-13 21:00:09 +00:00
|
|
|
int tile_diameter;
|
1998-01-24 00:03:27 +00:00
|
|
|
int i, j, dw, dh;
|
1998-01-07 23:50:01 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
c = &global_tile_cache;
|
1998-02-07 15:29:31 +00:00
|
|
|
f = current_aircraft.flight;
|
1998-07-13 21:00:09 +00:00
|
|
|
|
|
|
|
tile_diameter = current_options.get_tile_diameter();
|
1998-01-07 23:50:01 +00:00
|
|
|
|
1998-01-24 00:03:27 +00:00
|
|
|
fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p1);
|
1998-07-13 21:00:09 +00:00
|
|
|
dw = tile_diameter / 2;
|
|
|
|
dh = tile_diameter / 2;
|
1998-01-08 02:22:26 +00:00
|
|
|
|
1998-02-12 21:58:27 +00:00
|
|
|
if ( (p1.lon == p_last.lon) && (p1.lat == p_last.lat) &&
|
1998-01-24 00:03:27 +00:00
|
|
|
(p1.x == p_last.x) && (p1.y == p_last.y) ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
// same bucket as last time
|
1998-01-27 03:26:41 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_DEBUG, "Same bucket as last time\n");
|
1998-01-26 15:55:24 +00:00
|
|
|
} else if ( p_last.lon == -1000 ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
// First time through, initialize the system and load all
|
|
|
|
// relavant tiles
|
1998-01-19 18:40:15 +00:00
|
|
|
|
1998-05-07 23:15:20 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, " First time through ... ");
|
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, " Updating Tile list for %d,%d %d,%d\n",
|
1998-02-12 21:58:27 +00:00
|
|
|
p1.lon, p1.lat, p1.x, p1.y);
|
1998-05-07 23:15:20 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
|
1998-07-13 21:00:09 +00:00
|
|
|
tile_diameter * tile_diameter);
|
1998-01-13 00:23:08 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// wipe/initialize tile cache
|
1998-09-14 12:45:23 +00:00
|
|
|
c->init();
|
1998-01-13 00:23:08 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// build the local area list and update cache
|
1998-07-13 21:00:09 +00:00
|
|
|
for ( j = 0; j < tile_diameter; j++ ) {
|
|
|
|
for ( i = 0; i < tile_diameter; i++ ) {
|
1998-01-24 00:03:27 +00:00
|
|
|
fgBucketOffset(&p1, &p2, i - dw, j - dh);
|
1998-07-13 21:00:09 +00:00
|
|
|
fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + i]);
|
1998-01-24 00:03:27 +00:00
|
|
|
}
|
1998-01-13 00:23:08 +00:00
|
|
|
}
|
1998-01-26 15:55:24 +00:00
|
|
|
} else {
|
1998-05-20 20:53:53 +00:00
|
|
|
// We've moved to a new bucket, we need to scroll our
|
|
|
|
// structures, and load in the new tiles
|
1998-01-26 15:55:24 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// CURRENTLY THIS ASSUMES WE CAN ONLY MOVE TO ADJACENT TILES.
|
|
|
|
// AT ULTRA HIGH SPEEDS THIS ASSUMPTION MAY NOT BE VALID IF
|
|
|
|
// THE AIRCRAFT CAN SKIP A TILE IN A SINGLE ITERATION.
|
1998-01-26 15:55:24 +00:00
|
|
|
|
1998-05-07 23:15:20 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, "Updating Tile list for %d,%d %d,%d\n",
|
|
|
|
p1.lon, p1.lat, p1.x, p1.y);
|
|
|
|
|
1998-02-12 21:58:27 +00:00
|
|
|
if ( (p1.lon > p_last.lon) ||
|
1998-01-27 00:47:41 +00:00
|
|
|
( (p1.lon == p_last.lon) && (p1.x > p_last.x) ) ) {
|
1998-05-07 23:15:20 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
|
1998-07-13 21:00:09 +00:00
|
|
|
tile_diameter);
|
|
|
|
for ( j = 0; j < tile_diameter; j++ ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
// scrolling East
|
1998-07-13 21:00:09 +00:00
|
|
|
for ( i = 0; i < tile_diameter - 1; i++ ) {
|
|
|
|
tiles[(j*tile_diameter) + i] =
|
|
|
|
tiles[(j*tile_diameter) + i + 1];
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
1998-05-20 20:53:53 +00:00
|
|
|
// load in new column
|
1998-01-26 15:55:24 +00:00
|
|
|
fgBucketOffset(&p_last, &p2, dw + 1, j - dh);
|
1998-07-13 21:00:09 +00:00
|
|
|
fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) +
|
|
|
|
tile_diameter - 1]);
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
1998-02-12 21:58:27 +00:00
|
|
|
} else if ( (p1.lon < p_last.lon) ||
|
1998-01-27 00:47:41 +00:00
|
|
|
( (p1.lon == p_last.lon) && (p1.x < p_last.x) ) ) {
|
1998-05-07 23:15:20 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
|
1998-07-13 21:00:09 +00:00
|
|
|
tile_diameter);
|
|
|
|
for ( j = 0; j < tile_diameter; j++ ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
// scrolling West
|
1998-07-13 21:00:09 +00:00
|
|
|
for ( i = tile_diameter - 1; i > 0; i-- ) {
|
|
|
|
tiles[(j*tile_diameter) + i] =
|
|
|
|
tiles[(j*tile_diameter) + i - 1];
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
1998-05-20 20:53:53 +00:00
|
|
|
// load in new column
|
1998-01-26 15:55:24 +00:00
|
|
|
fgBucketOffset(&p_last, &p2, -dw - 1, j - dh);
|
1998-07-13 21:00:09 +00:00
|
|
|
fgTileMgrLoadTile(&p2, &tiles[(j*tile_diameter) + 0]);
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-02-12 21:58:27 +00:00
|
|
|
if ( (p1.lat > p_last.lat) ||
|
1998-01-27 00:47:41 +00:00
|
|
|
( (p1.lat == p_last.lat) && (p1.y > p_last.y) ) ) {
|
1998-05-07 23:15:20 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
|
1998-07-13 21:00:09 +00:00
|
|
|
tile_diameter);
|
|
|
|
for ( i = 0; i < tile_diameter; i++ ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
// scrolling North
|
1998-07-13 21:00:09 +00:00
|
|
|
for ( j = 0; j < tile_diameter - 1; j++ ) {
|
|
|
|
tiles[(j * tile_diameter) + i] =
|
|
|
|
tiles[((j+1) * tile_diameter) + i];
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
1998-05-20 20:53:53 +00:00
|
|
|
// load in new column
|
1998-01-26 15:55:24 +00:00
|
|
|
fgBucketOffset(&p_last, &p2, i - dw, dh + 1);
|
1998-07-13 21:00:09 +00:00
|
|
|
fgTileMgrLoadTile(&p2, &tiles[((tile_diameter-1) *
|
|
|
|
tile_diameter) + i]);
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
1998-02-12 21:58:27 +00:00
|
|
|
} else if ( (p1.lat < p_last.lat) ||
|
1998-01-27 00:47:41 +00:00
|
|
|
( (p1.lat == p_last.lat) && (p1.y < p_last.y) ) ) {
|
1998-05-07 23:15:20 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_INFO, " Loading %d tiles\n",
|
1998-07-13 21:00:09 +00:00
|
|
|
tile_diameter);
|
|
|
|
for ( i = 0; i < tile_diameter; i++ ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
// scrolling South
|
1998-07-13 21:00:09 +00:00
|
|
|
for ( j = tile_diameter - 1; j > 0; j-- ) {
|
|
|
|
tiles[(j * tile_diameter) + i] =
|
|
|
|
tiles[((j-1) * tile_diameter) + i];
|
1998-01-26 15:55:24 +00:00
|
|
|
}
|
1998-05-20 20:53:53 +00:00
|
|
|
// load in new column
|
1998-01-26 15:55:24 +00:00
|
|
|
fgBucketOffset(&p_last, &p2, i - dw, -dh - 1);
|
|
|
|
fgTileMgrLoadTile(&p2, &tiles[0 + i]);
|
|
|
|
}
|
1998-02-12 21:58:27 +00:00
|
|
|
}
|
1998-01-13 00:23:08 +00:00
|
|
|
}
|
1998-01-26 15:55:24 +00:00
|
|
|
p_last.lon = p1.lon;
|
|
|
|
p_last.lat = p1.lat;
|
|
|
|
p_last.x = p1.x;
|
|
|
|
p_last.y = p1.y;
|
1998-02-12 21:58:27 +00:00
|
|
|
return 1;
|
1998-01-13 00:23:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-07-08 14:47:20 +00:00
|
|
|
// Calculate shortest distance from point to line
|
1998-07-24 21:42:06 +00:00
|
|
|
static double point_line_dist_squared( fgPoint3d *tc, fgPoint3d *vp,
|
|
|
|
MAT3vec d )
|
|
|
|
{
|
1998-07-08 14:47:20 +00:00
|
|
|
MAT3vec p, p0;
|
|
|
|
double dist;
|
|
|
|
|
|
|
|
p[0] = tc->x; p[1] = tc->y; p[2] = tc->z;
|
|
|
|
p0[0] = vp->x; p0[1] = vp->y; p0[2] = vp->z;
|
|
|
|
|
1998-07-24 21:42:06 +00:00
|
|
|
dist = fgPointLineSquared(p, p0, d);
|
1998-07-08 14:47:20 +00:00
|
|
|
|
|
|
|
// printf("dist = %.2f\n", dist);
|
|
|
|
|
|
|
|
return(dist);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-16 13:09:57 +00:00
|
|
|
// Calculate if point/radius is inside view frustum
|
1998-07-08 14:47:20 +00:00
|
|
|
static int viewable( fgPoint3d *cp, double radius ) {
|
1998-09-08 15:05:10 +00:00
|
|
|
int viewable = 1; // start by assuming it's viewable
|
|
|
|
double x1, y1;
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
#if defined( USE_FAST_FOV_CLIP ) // views.hxx
|
|
|
|
/********************************/
|
|
|
|
|
|
|
|
MAT3vec eye;
|
|
|
|
double *mat;
|
|
|
|
double x, y, z;
|
|
|
|
|
|
|
|
x = cp->x;
|
|
|
|
y = cp->y;
|
|
|
|
z = cp->z;
|
|
|
|
|
|
|
|
mat = (double *)(current_view.WORLD_TO_EYE);
|
|
|
|
|
|
|
|
eye[2] = x*mat[2] + y*mat[6] + z*mat[10] + mat[14];
|
|
|
|
|
|
|
|
// Check near and far clip plane
|
|
|
|
if( ( eye[2] > radius ) ||
|
|
|
|
( eye[2] + radius + current_weather.visibility < 0) )
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1998-09-10 19:07:09 +00:00
|
|
|
eye[0] = (x*mat[0] + y*mat[4] + z*mat[8] + mat[12]) * current_view.slope_x;
|
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
// check right and left clip plane (from eye perspective)
|
|
|
|
x1 = radius * current_view.fov_x_clip;
|
|
|
|
if( (eye[2] > -(eye[0]+x1)) || (eye[2] > (eye[0]-x1)) )
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1998-09-10 19:07:09 +00:00
|
|
|
eye[1] = (x*mat[1] + y*mat[5] + z*mat[9] + mat[13]) * current_view.slope_y;
|
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
// check bottom and top clip plane (from eye perspective)
|
|
|
|
y1 = radius * current_view.fov_y_clip;
|
|
|
|
if( (eye[2] > -(eye[1]+y1)) || (eye[2] > (eye[1]-y1)) )
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/********************************/
|
|
|
|
#else // DO NOT USE_FAST_FOV_CLIP
|
|
|
|
/********************************/
|
|
|
|
|
1998-05-16 13:09:57 +00:00
|
|
|
fgVIEW *v;
|
|
|
|
MAT3hvec world, eye;
|
1998-09-08 15:05:10 +00:00
|
|
|
double x0, slope;
|
1998-05-16 13:09:57 +00:00
|
|
|
|
|
|
|
v = ¤t_view;
|
|
|
|
|
|
|
|
MAT3_SET_HVEC(world, cp->x, cp->y, cp->z, 1.0);
|
1998-09-10 19:07:09 +00:00
|
|
|
// MAT3mult_vec(eye, world, v->WORLD_TO_EYE);
|
1998-05-16 13:09:57 +00:00
|
|
|
// printf( "\nworld -> eye = %.2f %.2f %.2f radius = %.2f\n",
|
|
|
|
// eye[0], eye[1], eye[2], radius);
|
1998-05-17 16:59:34 +00:00
|
|
|
|
1998-09-10 19:07:09 +00:00
|
|
|
// Use lazy evaluation for calculating eye hvec.
|
|
|
|
#define vec world
|
|
|
|
#define mat v->WORLD_TO_EYE
|
|
|
|
eye[2] = vec[0]*mat[0][2]+vec[1]*mat[1][2]+vec[2]*mat[2][2]+mat[3][2];
|
|
|
|
|
1998-05-17 16:59:34 +00:00
|
|
|
// Check near clip plane
|
1998-09-10 19:07:09 +00:00
|
|
|
if ( eye[2] > radius ) {
|
1998-05-17 16:59:34 +00:00
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1998-07-20 12:51:26 +00:00
|
|
|
// Check far clip plane
|
|
|
|
if ( eye[2] + radius < -current_weather.visibility ) {
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
1998-05-17 16:59:34 +00:00
|
|
|
// check right clip plane (from eye perspective)
|
|
|
|
// y = m * (x - x0) = equation of a line intercepting X axis at x0
|
|
|
|
x1 = v->cos_fov_x * radius;
|
|
|
|
y1 = v->sin_fov_x * radius;
|
1998-06-03 00:47:50 +00:00
|
|
|
slope = v->slope_x;
|
1998-09-10 19:07:09 +00:00
|
|
|
eye[0] = vec[0]*mat[0][0]+vec[1]*mat[1][0]+vec[2]*mat[2][0]+mat[3][0];
|
1998-05-17 16:59:34 +00:00
|
|
|
|
1998-09-10 19:07:09 +00:00
|
|
|
if ( eye[2] > ((slope * (eye[0] - x1)) + y1) ) {
|
|
|
|
return( false );
|
1998-05-17 16:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check left clip plane (from eye perspective)
|
1998-09-10 19:07:09 +00:00
|
|
|
if ( eye[2] > -((slope * (eye[0] + x1)) - y1) ) {
|
|
|
|
return( false );
|
1998-05-17 16:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check bottom clip plane (from eye perspective)
|
|
|
|
x1 = -(v->cos_fov_y) * radius;
|
|
|
|
y1 = v->sin_fov_y * radius;
|
1998-06-03 00:47:50 +00:00
|
|
|
slope = v->slope_y;
|
1998-09-10 19:07:09 +00:00
|
|
|
eye[1] = vec[0]*mat[0][1]+vec[1]*mat[1][1]+vec[2]*mat[2][1]+mat[3][1];
|
|
|
|
#undef vec
|
|
|
|
#undef mat
|
1998-05-17 16:59:34 +00:00
|
|
|
|
1998-09-10 19:07:09 +00:00
|
|
|
if ( eye[2] > ((slope * (eye[1] - x1)) + y1) ) {
|
|
|
|
return( false );
|
1998-05-17 16:59:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check top clip plane (from eye perspective)
|
1998-09-10 19:07:09 +00:00
|
|
|
if ( eye[2] > -((slope * (eye[1] + x1)) - y1) ) {
|
|
|
|
return( false );
|
1998-05-16 13:09:57 +00:00
|
|
|
}
|
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
#endif // defined( USE_FAST_FOV_CLIP )
|
|
|
|
|
1998-05-16 13:09:57 +00:00
|
|
|
return(viewable);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
// NEW
|
|
|
|
|
|
|
|
// inrange() IS THIS POINT WITHIN POSSIBLE VIEWING RANGE ?
|
|
|
|
// calculate distance from vertical tangent line at
|
|
|
|
// current position to center of object.
|
|
|
|
// this is equivalent to
|
|
|
|
// dist = point_line_dist_squared( &(t->center), &(v->abs_view_pos),
|
|
|
|
// v->local_up );
|
|
|
|
// if ( dist < FG_SQUARE(t->bounding_radius) ) {
|
|
|
|
//
|
|
|
|
// the compiler should inline this for us
|
|
|
|
|
|
|
|
static int
|
|
|
|
inrange( const double radius, const fgPoint3d *center, const fgPoint3d *vp,
|
|
|
|
const MAT3vec up)
|
|
|
|
{
|
|
|
|
MAT3vec u, u1, v;
|
|
|
|
// double tmp;
|
|
|
|
|
|
|
|
// u = p - p0
|
|
|
|
u[0] = center->x - vp->x;
|
|
|
|
u[1] = center->y - vp->y;
|
|
|
|
u[2] = center->z - vp->z;
|
|
|
|
|
|
|
|
// calculate the projection, u1, of u along d.
|
|
|
|
// u1 = ( dot_prod(u, d) / dot_prod(d, d) ) * d;
|
|
|
|
|
|
|
|
MAT3_SCALE_VEC(u1, up,
|
|
|
|
(MAT3_DOT_PRODUCT(u, up) / MAT3_DOT_PRODUCT(up, up)) );
|
|
|
|
|
|
|
|
// v = u - u1 = vector from closest point on line, p1, to the
|
|
|
|
// original point, p.
|
|
|
|
MAT3_SUB_VEC(v, u, u1);
|
|
|
|
|
|
|
|
return( FG_SQUARE(radius) >= MAT3_DOT_PRODUCT(v, v));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-08-22 14:49:55 +00:00
|
|
|
// Determine scenery altitude. Normally this just happens when we
|
|
|
|
// render the scene, but we'd also like to be able to do this
|
|
|
|
// explicitely. lat & lon are in radians. abs_view_pos in meters.
|
|
|
|
// Returns result in meters.
|
|
|
|
double fgTileMgrCurElev( double lon, double lat, fgPoint3d *abs_view_pos ) {
|
|
|
|
fgTILECACHE *c;
|
|
|
|
fgTILE *t;
|
|
|
|
// fgVIEW *v;
|
|
|
|
fgFRAGMENT *frag_ptr;
|
|
|
|
fgBUCKET p;
|
|
|
|
fgPoint3d earth_center, result;
|
|
|
|
fgPoint3d pp;
|
|
|
|
MAT3vec local_up;
|
|
|
|
list < fgFRAGMENT > :: iterator current;
|
|
|
|
list < fgFRAGMENT > :: iterator last;
|
|
|
|
double dist, min_dist, lat_geod, alt, sea_level_r;
|
1998-09-15 01:35:03 +00:00
|
|
|
// double x, y, z;
|
1998-08-22 14:49:55 +00:00
|
|
|
int index, tile_diameter, i;
|
|
|
|
|
|
|
|
c = &global_tile_cache;
|
|
|
|
// v = ¤t_view;
|
|
|
|
|
|
|
|
local_up[0] = abs_view_pos->x;
|
|
|
|
local_up[1] = abs_view_pos->y;
|
|
|
|
local_up[2] = abs_view_pos->z;
|
|
|
|
|
|
|
|
// Find current translation offset
|
|
|
|
fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
|
1998-09-14 12:45:23 +00:00
|
|
|
index = c->exists(&p);
|
|
|
|
t = c->get_tile(index);
|
1998-08-22 14:49:55 +00:00
|
|
|
|
1998-09-15 01:35:03 +00:00
|
|
|
// scenery.next_center.x = t->center.x;
|
|
|
|
// scenery.next_center.y = t->center.y;
|
|
|
|
// scenery.next_center.z = t->center.z;
|
|
|
|
|
1998-08-22 14:49:55 +00:00
|
|
|
earth_center.x = 0.0;
|
|
|
|
earth_center.y = 0.0;
|
|
|
|
earth_center.z = 0.0;
|
|
|
|
|
|
|
|
fgPrintf( FG_TERRAIN, FG_DEBUG,
|
|
|
|
"Pos = (%.2f, %.2f) Current bucket = %d %d %d %d Index = %ld\n",
|
|
|
|
lon * RAD_TO_DEG, lat * RAD_TO_DEG,
|
|
|
|
p.lon, p.lat, p.x, p.y, fgBucketGenIndex(&p) );
|
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
// calculate tile offset
|
1998-09-15 01:35:03 +00:00
|
|
|
// x = (t->offset.x = t->center.x - scenery.center.x);
|
|
|
|
// y = (t->offset.y = t->center.y - scenery.center.y);
|
|
|
|
// z = (t->offset.z = t->center.z - scenery.center.z);
|
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
// calc current terrain elevation calculate distance from
|
|
|
|
// vertical tangent line at current position to center of
|
|
|
|
// tile.
|
1998-08-22 14:49:55 +00:00
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
/* printf("distance squared = %.2f, bounding radius = %.2f\n",
|
|
|
|
point_line_dist_squared(&(t->offset), &(v->view_pos),
|
|
|
|
v->local_up), t->bounding_radius); */
|
1998-08-22 14:49:55 +00:00
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
dist = point_line_dist_squared( &(t->center), abs_view_pos,
|
1998-08-22 14:49:55 +00:00
|
|
|
local_up );
|
1998-09-08 15:05:10 +00:00
|
|
|
if ( dist < FG_SQUARE(t->bounding_radius) ) {
|
|
|
|
|
|
|
|
// traverse fragment list for tile
|
|
|
|
current = t->fragment_list.begin();
|
|
|
|
last = t->fragment_list.end();
|
|
|
|
|
1998-09-09 20:58:09 +00:00
|
|
|
for ( ; current != last; ++current ) {
|
1998-09-08 15:05:10 +00:00
|
|
|
frag_ptr = &(*current);
|
|
|
|
/* printf("distance squared = %.2f, bounding radius = %.2f\n",
|
|
|
|
point_line_dist_squared( &(frag_ptr->center),
|
|
|
|
&abs_view_pos), local_up),
|
|
|
|
frag_ptr->bounding_radius); */
|
|
|
|
|
|
|
|
dist = point_line_dist_squared( &(frag_ptr->center),
|
|
|
|
abs_view_pos, local_up);
|
|
|
|
if ( dist <= FG_SQUARE(frag_ptr->bounding_radius) ) {
|
|
|
|
if ( frag_ptr->intersect( abs_view_pos,
|
|
|
|
&earth_center, 0, &result ) ) {
|
|
|
|
// compute geocentric coordinates of tile center
|
|
|
|
pp = fgCartToPolar3d(result);
|
|
|
|
// convert to geodetic coordinates
|
|
|
|
fgGeocToGeod(pp.lat, pp.radius, &lat_geod,
|
|
|
|
&alt, &sea_level_r);
|
|
|
|
// printf("alt = %.2f\n", alt);
|
|
|
|
// exit since we found an intersection
|
|
|
|
return(alt);
|
1998-08-22 14:49:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("no terrain intersection found\n");
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
// NEW for legibility
|
|
|
|
|
|
|
|
// update this tile's geometry for current view
|
|
|
|
// The Compiler should inline this
|
|
|
|
static void
|
|
|
|
update_tile_geometry( fgTILE *t, GLdouble *MODEL_VIEW)
|
|
|
|
{
|
|
|
|
GLdouble *m;
|
|
|
|
double x, y, z;
|
|
|
|
|
|
|
|
// calculate tile offset
|
|
|
|
x = (t->offset.x = t->center.x - scenery.center.x);
|
|
|
|
y = (t->offset.y = t->center.y - scenery.center.y);
|
|
|
|
z = (t->offset.z = t->center.z - scenery.center.z);
|
|
|
|
|
|
|
|
m = t->model_view;
|
|
|
|
|
|
|
|
// Calculate the model_view transformation matrix for this tile
|
|
|
|
FG_MEM_COPY( m, MODEL_VIEW, 16*sizeof(GLdouble) );
|
|
|
|
|
|
|
|
// This is equivalent to doing a glTranslatef(x, y, z);
|
|
|
|
m[12] += (m[0]*x + m[4]*y + m[8] *z);
|
|
|
|
m[13] += (m[1]*x + m[5]*y + m[9] *z);
|
|
|
|
m[14] += (m[2]*x + m[6]*y + m[10]*z);
|
|
|
|
// m[15] += (m[3]*x + m[7]*y + m[11]*z);
|
|
|
|
// m[3] m7[] m[11] are 0.0 see LookAt() in views.cxx
|
|
|
|
// so m[15] is unchanged
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// Render the local tiles
|
1998-01-19 18:40:15 +00:00
|
|
|
void fgTileMgrRender( void ) {
|
1998-05-20 20:53:53 +00:00
|
|
|
fgTILECACHE *c;
|
1998-02-09 21:30:18 +00:00
|
|
|
fgFLIGHT *f;
|
1998-07-12 03:18:27 +00:00
|
|
|
fgTILE *t, *last_tile_ptr;
|
1998-05-17 16:59:34 +00:00
|
|
|
fgVIEW *v;
|
1998-07-04 00:54:28 +00:00
|
|
|
fgBUCKET p;
|
1998-07-12 03:18:27 +00:00
|
|
|
fgPoint3d frag_offset, pp;
|
|
|
|
fgPoint3d earth_center, result;
|
1998-06-06 01:07:17 +00:00
|
|
|
fgFRAGMENT *frag_ptr;
|
1998-06-05 22:39:53 +00:00
|
|
|
fgMATERIAL *mtl_ptr;
|
1998-07-04 00:54:28 +00:00
|
|
|
GLdouble *m;
|
1998-07-08 14:47:20 +00:00
|
|
|
double dist, min_dist, lat_geod, alt, sea_level_r;
|
1998-07-04 00:54:28 +00:00
|
|
|
double x, y, z;
|
1998-05-23 14:09:20 +00:00
|
|
|
list < fgFRAGMENT > :: iterator current;
|
|
|
|
list < fgFRAGMENT > :: iterator last;
|
1998-07-04 00:54:28 +00:00
|
|
|
int i, j, size;
|
1998-07-13 21:00:09 +00:00
|
|
|
int tile_diameter, textures;
|
1998-01-24 00:03:27 +00:00
|
|
|
int index;
|
1998-05-16 13:09:57 +00:00
|
|
|
int culled = 0;
|
|
|
|
int drawn = 0;
|
1998-08-20 15:12:03 +00:00
|
|
|
int total_faces = 0;
|
1998-01-13 00:23:08 +00:00
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
c = &global_tile_cache;
|
1998-02-09 21:30:18 +00:00
|
|
|
f = current_aircraft.flight;
|
1998-05-17 16:59:34 +00:00
|
|
|
v = ¤t_view;
|
1998-02-09 21:30:18 +00:00
|
|
|
|
1998-07-13 21:00:09 +00:00
|
|
|
tile_diameter = current_options.get_tile_diameter();
|
|
|
|
textures = current_options.get_textures();
|
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// Find current translation offset
|
1998-02-09 21:30:18 +00:00
|
|
|
fgBucketFind(FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG, &p);
|
1998-09-14 12:45:23 +00:00
|
|
|
index = c->exists(&p);
|
|
|
|
t = c->get_tile(index);
|
1998-02-09 21:30:18 +00:00
|
|
|
|
1998-07-12 03:18:27 +00:00
|
|
|
scenery.next_center.x = t->center.x;
|
|
|
|
scenery.next_center.y = t->center.y;
|
|
|
|
scenery.next_center.z = t->center.z;
|
|
|
|
|
|
|
|
earth_center.x = 0.0;
|
|
|
|
earth_center.y = 0.0;
|
|
|
|
earth_center.z = 0.0;
|
|
|
|
|
1998-05-06 03:16:42 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_DEBUG,
|
1998-05-07 23:15:20 +00:00
|
|
|
"Pos = (%.2f, %.2f) Current bucket = %d %d %d %d Index = %ld\n",
|
1998-05-06 03:16:42 +00:00
|
|
|
FG_Longitude * RAD_TO_DEG, FG_Latitude * RAD_TO_DEG,
|
|
|
|
p.lon, p.lat, p.x, p.y, fgBucketGenIndex(&p) );
|
1998-02-11 02:50:34 +00:00
|
|
|
|
1998-06-05 22:39:53 +00:00
|
|
|
// initialize the transient per-material fragment lists
|
|
|
|
material_mgr.init_transient_material_lists();
|
1998-07-08 14:47:20 +00:00
|
|
|
min_dist = 100000.0;
|
1998-06-05 22:39:53 +00:00
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
scenery.cur_elev = fgTileMgrCurElev( FG_Longitude, FG_Latitude,
|
|
|
|
&(v->abs_view_pos) );
|
|
|
|
|
1998-06-06 01:07:17 +00:00
|
|
|
// Pass 1
|
1998-06-05 22:39:53 +00:00
|
|
|
// traverse the potentially viewable tile list
|
1998-07-13 21:00:09 +00:00
|
|
|
for ( i = 0; i < (tile_diameter * tile_diameter); i++ ) {
|
1998-01-24 00:03:27 +00:00
|
|
|
index = tiles[i];
|
1998-05-20 20:53:53 +00:00
|
|
|
// fgPrintf( FG_TERRAIN, FG_DEBUG, "Index = %d\n", index);
|
1998-09-14 12:45:23 +00:00
|
|
|
t = c->get_tile(index);
|
1998-05-23 14:09:20 +00:00
|
|
|
|
|
|
|
// calculate tile offset
|
1998-07-20 12:51:26 +00:00
|
|
|
x = (t->offset.x = t->center.x - scenery.center.x);
|
|
|
|
y = (t->offset.y = t->center.y - scenery.center.y);
|
|
|
|
z = (t->offset.z = t->center.z - scenery.center.z);
|
1998-07-04 00:54:28 +00:00
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
#if defined( TEST_FOV_CLIP )
|
|
|
|
if( viewable(&(t->offset), t->bounding_radius) !=
|
|
|
|
viewable2(&(t->offset), t->bounding_radius) )
|
|
|
|
{
|
|
|
|
printf("FOV PROBLEM\n");
|
|
|
|
exit(10);
|
1998-07-08 14:47:20 +00:00
|
|
|
}
|
1998-09-08 15:05:10 +00:00
|
|
|
#endif // defined( TEST_FOV_CLIP )
|
1998-07-08 14:47:20 +00:00
|
|
|
|
1998-05-24 02:49:09 +00:00
|
|
|
// Course (tile based) culling
|
1998-06-06 01:07:17 +00:00
|
|
|
if ( viewable(&(t->offset), t->bounding_radius) ) {
|
1998-07-04 00:54:28 +00:00
|
|
|
// at least a portion of this tile could be viewable
|
1998-05-23 14:09:20 +00:00
|
|
|
|
1998-09-15 01:35:03 +00:00
|
|
|
m = t->model_view;
|
|
|
|
for ( j = 0; j < 16; j++ ) {
|
|
|
|
m[j] = v->MODEL_VIEW[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
// Calculate the model_view transformation matrix for this tile
|
|
|
|
// This is equivalent to doing a glTranslatef(x, y, z);
|
|
|
|
m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
|
|
|
|
m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
|
|
|
|
m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
|
|
|
|
m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
|
|
|
|
|
1998-06-06 01:07:17 +00:00
|
|
|
// xglPushMatrix();
|
|
|
|
// xglTranslatef(t->offset.x, t->offset.y, t->offset.z);
|
1998-05-23 14:09:20 +00:00
|
|
|
|
|
|
|
// traverse fragment list for tile
|
|
|
|
current = t->fragment_list.begin();
|
|
|
|
last = t->fragment_list.end();
|
|
|
|
|
1998-09-09 20:58:09 +00:00
|
|
|
for ( ; current != last; ++current ) {
|
1998-06-06 01:07:17 +00:00
|
|
|
frag_ptr = &(*current);
|
|
|
|
|
|
|
|
if ( frag_ptr->display_list >= 0 ) {
|
1998-05-24 02:49:09 +00:00
|
|
|
// Fine (fragment based) culling
|
1998-06-06 01:07:17 +00:00
|
|
|
frag_offset.x = frag_ptr->center.x - scenery.center.x;
|
|
|
|
frag_offset.y = frag_ptr->center.y - scenery.center.y;
|
|
|
|
frag_offset.z = frag_ptr->center.z - scenery.center.z;
|
1998-05-24 02:49:09 +00:00
|
|
|
|
1998-09-08 15:05:10 +00:00
|
|
|
#if defined( TEST_FOV_CLIP )
|
|
|
|
radius = frag_ptr->bounding_radius*2;
|
|
|
|
if ( viewable(&frag_offset, radius) !=
|
|
|
|
viewable2(&frag_offset, radius) ) {
|
|
|
|
printf("FOV PROBLEM\n");
|
|
|
|
exit(10);
|
|
|
|
}
|
|
|
|
#endif // defined( TEST_FOV_CLIP )
|
|
|
|
|
1998-06-06 01:07:17 +00:00
|
|
|
if ( viewable(&frag_offset, frag_ptr->bounding_radius*2) ) {
|
1998-06-05 22:39:53 +00:00
|
|
|
// add to transient per-material property fragment list
|
1998-07-04 00:54:28 +00:00
|
|
|
// frag_ptr->tile_offset.x = t->offset.x;
|
|
|
|
// frag_ptr->tile_offset.y = t->offset.y;
|
|
|
|
// frag_ptr->tile_offset.z = t->offset.z;
|
1998-06-08 17:57:54 +00:00
|
|
|
|
1998-08-20 15:12:03 +00:00
|
|
|
mtl_ptr = frag_ptr->material_ptr;
|
1998-06-05 22:39:53 +00:00
|
|
|
// printf(" lookup = %s\n", mtl_ptr->texture_name);
|
1998-09-10 19:07:09 +00:00
|
|
|
if ( ! mtl_ptr->append_sort_list( frag_ptr ) ) {
|
1998-06-06 01:07:17 +00:00
|
|
|
fgPrintf( FG_TERRAIN, FG_ALERT,
|
|
|
|
"Overran material sorting array\n" );
|
1998-06-05 22:39:53 +00:00
|
|
|
}
|
|
|
|
|
1998-06-06 01:07:17 +00:00
|
|
|
// xglCallList(frag_ptr->display_list);
|
1998-05-24 02:49:09 +00:00
|
|
|
drawn++;
|
|
|
|
} else {
|
|
|
|
// printf("Culled a fragment %.2f %.2f %.2f %.2f\n",
|
1998-06-06 01:07:17 +00:00
|
|
|
// frag_ptr->center.x, frag_ptr->center.y,
|
|
|
|
// frag_ptr->center.z, frag_ptr->bounding_radius);
|
1998-05-24 02:49:09 +00:00
|
|
|
culled++;
|
|
|
|
}
|
1998-05-23 14:09:20 +00:00
|
|
|
}
|
1998-05-16 13:09:57 +00:00
|
|
|
}
|
1998-05-23 14:09:20 +00:00
|
|
|
|
1998-06-06 01:07:17 +00:00
|
|
|
// xglPopMatrix();
|
1998-05-24 02:49:09 +00:00
|
|
|
} else {
|
|
|
|
culled += t->fragment_list.size();
|
1998-02-01 03:39:53 +00:00
|
|
|
}
|
1998-01-13 00:23:08 +00:00
|
|
|
}
|
1998-05-16 13:09:57 +00:00
|
|
|
|
1998-06-01 17:56:20 +00:00
|
|
|
if ( (drawn + culled) > 0 ) {
|
|
|
|
v->vfc_ratio = (double)culled / (double)(drawn + culled);
|
|
|
|
} else {
|
|
|
|
v->vfc_ratio = 0.0;
|
|
|
|
}
|
1998-05-17 16:59:34 +00:00
|
|
|
// printf("drawn = %d culled = %d saved = %.2f\n", drawn, culled,
|
|
|
|
// v->vfc_ratio);
|
1998-06-05 22:39:53 +00:00
|
|
|
|
1998-06-06 01:07:17 +00:00
|
|
|
// Pass 2
|
1998-06-05 22:39:53 +00:00
|
|
|
// traverse the transient per-material fragment lists and render
|
|
|
|
// out all fragments for each material property.
|
1998-06-08 17:57:54 +00:00
|
|
|
xglPushMatrix();
|
1998-09-10 19:07:09 +00:00
|
|
|
material_mgr.render_fragments();
|
1998-07-04 00:54:28 +00:00
|
|
|
xglPopMatrix();
|
1998-01-07 23:50:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-05-20 20:53:53 +00:00
|
|
|
// $Log$
|
1998-09-15 01:35:03 +00:00
|
|
|
// Revision 1.37 1998/09/15 01:36:45 curt
|
|
|
|
// cleaned up my fragment.num_faces hack :-) to use the STL (no need in
|
|
|
|
// duplicating work.)
|
|
|
|
// Tweaked fgTileMgrRender() do not calc tile matrix unless necessary.
|
|
|
|
// removed some unneeded stuff from fgTileMgrCurElev()
|
|
|
|
//
|
1998-09-14 12:45:23 +00:00
|
|
|
// Revision 1.36 1998/09/14 12:45:26 curt
|
|
|
|
// minor tweaks.
|
|
|
|
//
|
1998-09-10 19:07:09 +00:00
|
|
|
// Revision 1.35 1998/09/10 19:07:16 curt
|
|
|
|
// /Simulator/Objects/fragment.hxx
|
|
|
|
// Nested fgFACE inside fgFRAGMENT since its not used anywhere else.
|
|
|
|
//
|
|
|
|
// ./Simulator/Objects/material.cxx
|
|
|
|
// ./Simulator/Objects/material.hxx
|
|
|
|
// Made fgMATERIAL and fgMATERIAL_MGR bona fide classes with private
|
|
|
|
// data members - that should keep the rabble happy :)
|
|
|
|
//
|
|
|
|
// ./Simulator/Scenery/tilemgr.cxx
|
|
|
|
// In viewable() delay evaluation of eye[0] and eye[1] in until they're
|
|
|
|
// actually needed.
|
|
|
|
// Change to fgTileMgrRender() to call fgMATERIAL_MGR::render_fragments()
|
|
|
|
// method.
|
|
|
|
//
|
|
|
|
// ./Include/fg_stl_config.h
|
|
|
|
// ./Include/auto_ptr.hxx
|
|
|
|
// Added support for g++ 2.7.
|
|
|
|
// Further changes to other files are forthcoming.
|
|
|
|
//
|
|
|
|
// Brief summary of changes required for g++ 2.7.
|
|
|
|
// operator->() not supported by iterators: use (*i).x instead of i->x
|
|
|
|
// default template arguments not supported,
|
|
|
|
// <functional> doesn't have mem_fun_ref() needed by callbacks.
|
|
|
|
// some std include files have different names.
|
|
|
|
// template member functions not supported.
|
|
|
|
//
|
1998-09-09 20:58:09 +00:00
|
|
|
// Revision 1.34 1998/09/09 20:58:09 curt
|
|
|
|
// Tweaks to loop constructs with STL usage.
|
|
|
|
//
|
1998-09-08 15:05:10 +00:00
|
|
|
// Revision 1.33 1998/09/08 15:05:10 curt
|
|
|
|
// Optimization by Norman Vine.
|
|
|
|
//
|
1998-08-25 16:52:38 +00:00
|
|
|
// Revision 1.32 1998/08/25 16:52:44 curt
|
|
|
|
// material.cxx material.hxx obj.cxx obj.hxx texload.c texload.h moved to
|
|
|
|
// ../Objects
|
|
|
|
//
|
1998-08-24 20:11:39 +00:00
|
|
|
// Revision 1.31 1998/08/24 20:11:40 curt
|
|
|
|
// Tweaks ...
|
|
|
|
//
|
|
|
|
// Revision 1.30 1998/08/22 14:49:59 curt
|
1998-08-22 14:49:55 +00:00
|
|
|
// Attempting to iron out seg faults and crashes.
|
|
|
|
// Did some shuffling to fix a initialization order problem between view
|
|
|
|
// position, scenery elevation.
|
|
|
|
//
|
1998-08-20 15:12:03 +00:00
|
|
|
// Revision 1.29 1998/08/20 15:12:06 curt
|
|
|
|
// Used a forward declaration of classes fgTILE and fgMATERIAL to eliminate
|
|
|
|
// the need for "void" pointers and casts.
|
|
|
|
// Quick hack to count the number of scenery polygons that are being drawn.
|
|
|
|
//
|
1998-08-12 21:13:03 +00:00
|
|
|
// Revision 1.28 1998/08/12 21:13:06 curt
|
|
|
|
// material.cxx: don't load textures if they are disabled
|
|
|
|
// obj.cxx: optimizations from Norman Vine
|
|
|
|
// tile.cxx: minor tweaks
|
|
|
|
// tile.hxx: addition of num_faces
|
|
|
|
// tilemgr.cxx: minor tweaks
|
|
|
|
//
|
1998-07-24 21:42:06 +00:00
|
|
|
// Revision 1.27 1998/07/24 21:42:09 curt
|
|
|
|
// material.cxx: whups, double method declaration with no definition.
|
|
|
|
// obj.cxx: tweaks to avoid errors in SGI's CC.
|
|
|
|
// tile.cxx: optimizations by Norman Vine.
|
|
|
|
// tilemgr.cxx: optimizations by Norman Vine.
|
|
|
|
//
|
1998-07-20 12:51:26 +00:00
|
|
|
// Revision 1.26 1998/07/20 12:51:26 curt
|
|
|
|
// Added far clip plane to fragment clipping calculations and tie this to
|
|
|
|
// weather->visibility. This way you can increase framerates by increasing
|
|
|
|
// for and lowering visibility.
|
|
|
|
//
|
1998-07-13 21:00:09 +00:00
|
|
|
// Revision 1.25 1998/07/13 21:02:01 curt
|
|
|
|
// Wrote access functions for current fgOPTIONS.
|
|
|
|
//
|
1998-07-12 03:18:27 +00:00
|
|
|
// Revision 1.24 1998/07/12 03:18:29 curt
|
|
|
|
// Added ground collision detection. This involved:
|
|
|
|
// - saving the entire vertex list for each tile with the tile records.
|
|
|
|
// - saving the face list for each fragment with the fragment records.
|
|
|
|
// - code to intersect the current vertical line with the proper face in
|
|
|
|
// an efficient manner as possible.
|
|
|
|
// Fixed a bug where the tiles weren't being shifted to "near" (0,0,0)
|
|
|
|
//
|
1998-07-08 14:47:20 +00:00
|
|
|
// Revision 1.23 1998/07/08 14:47:23 curt
|
|
|
|
// Fix GL_MODULATE vs. GL_DECAL problem introduced by splash screen.
|
|
|
|
// polare3d.h renamed to polar3d.hxx
|
|
|
|
// fg{Cartesian,Polar}Point3d consolodated.
|
|
|
|
// Added some initial support for calculating local current ground elevation.
|
|
|
|
//
|
1998-07-04 00:54:28 +00:00
|
|
|
// Revision 1.22 1998/07/04 00:54:31 curt
|
|
|
|
// Added automatic mipmap generation.
|
|
|
|
//
|
|
|
|
// When rendering fragments, use saved model view matrix from associated tile
|
|
|
|
// rather than recalculating it with push() translate() pop().
|
|
|
|
//
|
1998-06-27 16:54:59 +00:00
|
|
|
// Revision 1.21 1998/06/27 16:54:59 curt
|
|
|
|
// Check for GL_VERSION_1_1 or GL_EXT_texture_object to decide whether to use
|
|
|
|
// "EXT" versions of texture management routines.
|
|
|
|
//
|
1998-06-17 21:36:39 +00:00
|
|
|
// Revision 1.20 1998/06/17 21:36:42 curt
|
|
|
|
// Load and manage multiple textures defined in the Materials library.
|
|
|
|
// Boost max material fagments for each material property to 800.
|
|
|
|
// Multiple texture support when rendering.
|
|
|
|
//
|
1998-06-08 17:57:54 +00:00
|
|
|
// Revision 1.19 1998/06/08 17:57:54 curt
|
|
|
|
// Working first pass at material proporty sorting.
|
|
|
|
//
|
1998-06-06 01:09:31 +00:00
|
|
|
// Revision 1.18 1998/06/06 01:09:32 curt
|
|
|
|
// I goofed on the log message in the last commit ... now fixed.
|
|
|
|
//
|
1998-06-06 01:07:17 +00:00
|
|
|
// Revision 1.17 1998/06/06 01:07:18 curt
|
|
|
|
// Increased per material fragment list size from 100 to 400.
|
1998-06-06 01:09:31 +00:00
|
|
|
// Now correctly draw viewable fragments in per material order.
|
1998-06-06 01:07:17 +00:00
|
|
|
//
|
1998-06-05 22:39:53 +00:00
|
|
|
// Revision 1.16 1998/06/05 22:39:55 curt
|
|
|
|
// Working on sorting by, and rendering by material properties.
|
|
|
|
//
|
1998-06-03 00:47:50 +00:00
|
|
|
// Revision 1.15 1998/06/03 00:47:51 curt
|
|
|
|
// No .h for STL includes.
|
|
|
|
// Minor view culling optimizations.
|
|
|
|
//
|
1998-06-01 17:56:20 +00:00
|
|
|
// Revision 1.14 1998/06/01 17:56:20 curt
|
|
|
|
// Incremental additions to material.cxx (not fully functional)
|
|
|
|
// Tweaked vfc_ratio math to avoid divide by zero.
|
|
|
|
//
|
1998-05-24 02:49:09 +00:00
|
|
|
// Revision 1.13 1998/05/24 02:49:10 curt
|
|
|
|
// Implimented fragment level view frustum culling.
|
|
|
|
//
|
1998-05-23 14:09:20 +00:00
|
|
|
// Revision 1.12 1998/05/23 14:09:23 curt
|
|
|
|
// Added tile.cxx and tile.hxx.
|
|
|
|
// Working on rewriting the tile management system so a tile is just a list
|
|
|
|
// fragments, and the fragment record contains the display list for that fragment.
|
|
|
|
//
|
1998-05-20 20:53:53 +00:00
|
|
|
// Revision 1.11 1998/05/20 20:53:55 curt
|
|
|
|
// Moved global ref point and radius (bounding sphere info, and offset) to
|
|
|
|
// data file rather than calculating it on the fly.
|
|
|
|
// Fixed polygon winding problem in scenery generation stage rather than
|
|
|
|
// compensating for it on the fly.
|
|
|
|
// Made a fgTILECACHE class.
|
|
|
|
//
|
|
|
|
// Revision 1.10 1998/05/17 16:59:34 curt
|
|
|
|
// Frist pass at view frustum culling now operational.
|
|
|
|
//
|
|
|
|
// Revision 1.9 1998/05/16 13:09:58 curt
|
|
|
|
// Beginning to add support for view frustum culling.
|
|
|
|
// Added some temporary code to calculate bouding radius, until the
|
|
|
|
// scenery generation tools and scenery can be updated.
|
|
|
|
//
|
|
|
|
// Revision 1.8 1998/05/07 23:15:21 curt
|
|
|
|
// Fixed a glTexImage2D() usage bug where width and height were mis-swapped.
|
|
|
|
// Added support for --tile-radius=n option.
|
|
|
|
//
|
|
|
|
// Revision 1.7 1998/05/06 03:16:42 curt
|
|
|
|
// Added an option to control square tile radius.
|
|
|
|
//
|
|
|
|
// Revision 1.6 1998/05/02 01:52:18 curt
|
|
|
|
// Playing around with texture coordinates.
|
|
|
|
//
|
|
|
|
// 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!
|
|
|
|
//
|
|
|
|
// Revision 1.2 1998/04/24 00:51:09 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.1 1998/04/22 13:22:48 curt
|
|
|
|
// C++ - ifing the code a bit.
|
|
|
|
//
|
|
|
|
// Revision 1.25 1998/04/18 04:14:07 curt
|
|
|
|
// Moved fg_debug.c to it's own library.
|
|
|
|
//
|
|
|
|
// Revision 1.24 1998/04/14 02:23:18 curt
|
|
|
|
// Code reorganizations. Added a Lib/ directory for more general libraries.
|
|
|
|
//
|
|
|
|
// Revision 1.23 1998/04/08 23:30:08 curt
|
|
|
|
// Adopted Gnu automake/autoconf system.
|
|
|
|
//
|
|
|
|
// Revision 1.22 1998/04/03 22:11:38 curt
|
|
|
|
// Converting to Gnu autoconf system.
|
|
|
|
//
|
|
|
|
// Revision 1.21 1998/03/23 21:23:05 curt
|
|
|
|
// Debugging output tweaks.
|
|
|
|
//
|
|
|
|
// Revision 1.20 1998/03/14 00:30:51 curt
|
|
|
|
// Beginning initial terrain texturing experiments.
|
|
|
|
//
|
|
|
|
// Revision 1.19 1998/02/20 00:16:25 curt
|
|
|
|
// Thursday's tweaks.
|
|
|
|
//
|
|
|
|
// Revision 1.18 1998/02/19 13:05:54 curt
|
|
|
|
// Incorporated some HUD tweaks from Michelle America.
|
|
|
|
// Tweaked the sky's sunset/rise colors.
|
|
|
|
// Other misc. tweaks.
|
|
|
|
//
|
|
|
|
// Revision 1.17 1998/02/16 13:39:46 curt
|
|
|
|
// Miscellaneous weekend tweaks. Fixed? a cache problem that caused whole
|
|
|
|
// tiles to occasionally be missing.
|
|
|
|
//
|
|
|
|
// Revision 1.16 1998/02/12 21:59:53 curt
|
|
|
|
// Incorporated code changes contributed by Charlie Hotchkiss
|
|
|
|
// <chotchkiss@namg.us.anritsu.com>
|
|
|
|
//
|
|
|
|
// Revision 1.14 1998/02/09 21:30:19 curt
|
|
|
|
// Fixed a nagging problem with terrain tiles not "quite" matching up perfectly.
|
|
|
|
//
|
|
|
|
// Revision 1.13 1998/02/07 15:29:46 curt
|
|
|
|
// Incorporated HUD changes and struct/typedef changes from Charlie Hotchkiss
|
|
|
|
// <chotchkiss@namg.us.anritsu.com>
|
|
|
|
//
|
|
|
|
// Revision 1.12 1998/02/01 03:39:55 curt
|
|
|
|
// Minor tweaks.
|
|
|
|
//
|
|
|
|
// Revision 1.11 1998/01/31 00:43:27 curt
|
|
|
|
// Added MetroWorks patches from Carmen Volpe.
|
|
|
|
//
|
|
|
|
// Revision 1.10 1998/01/29 00:51:40 curt
|
|
|
|
// First pass at tile cache, dynamic tile loading and tile unloading now works.
|
|
|
|
//
|
|
|
|
// Revision 1.9 1998/01/27 03:26:44 curt
|
|
|
|
// Playing with new fgPrintf command.
|
|
|
|
//
|
|
|
|
// Revision 1.8 1998/01/27 00:48:04 curt
|
|
|
|
// Incorporated Paul Bleisch's <pbleisch@acm.org> new debug message
|
|
|
|
// system and commandline/config file processing code.
|
|
|
|
//
|
|
|
|
// Revision 1.7 1998/01/26 15:55:25 curt
|
|
|
|
// Progressing on building dynamic scenery system.
|
|
|
|
//
|
|
|
|
// Revision 1.6 1998/01/24 00:03:30 curt
|
|
|
|
// Initial revision.
|
|
|
|
//
|
|
|
|
// Revision 1.5 1998/01/19 19:27:18 curt
|
|
|
|
// Merged in make system changes from Bob Kuehne <rpk@sgi.com>
|
|
|
|
// This should simplify things tremendously.
|
|
|
|
//
|
|
|
|
// Revision 1.4 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.3 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.2 1998/01/08 02:22:27 curt
|
|
|
|
// Continue working on basic features.
|
|
|
|
//
|
|
|
|
// Revision 1.1 1998/01/07 23:50:51 curt
|
|
|
|
// "area" renamed to "tile"
|
|
|
|
//
|
|
|
|
// Revision 1.2 1998/01/07 03:29:29 curt
|
|
|
|
// Given an arbitrary lat/lon, we can now:
|
|
|
|
// generate a unique index for the chunk containing the lat/lon
|
|
|
|
// generate a path name to the chunk file
|
|
|
|
// build a list of the indexes of all the nearby areas.
|
|
|
|
//
|
|
|
|
// Revision 1.1 1998/01/07 02:05:48 curt
|
|
|
|
// Initial revision.
|