#define FG_SQUARE( X ) ( (X) * (X) )
-#ifdef WIN32
-# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
+#if defined(USE_MEM) || defined(WIN32)
+# define FG_MEM_COPY(to,from,n) memcpy(to, from, n)
#else
-# define FG_MEM_COPY(to,from,n) bcopy(from, to, n)
+# define FG_MEM_COPY(to,from,n) bcopy(from, to, n)
#endif
// closest (potentially viewable) tiles, centered on current tile.
// explicitely. lat & lon are in radians. abs_view_pos in meters.
// Returns result in meters.
double
-fgTileMgrCurElev( const fgBUCKET& p ) {
+fgTileMgrCurElevNEW( const fgBUCKET& p ) {
fgTILE *t;
fgFRAGMENT *frag_ptr;
- Point3D abs_view_pos = current_view.abs_view_pos;
+ Point3D abs_view_pos = current_view.get_abs_view_pos();
Point3D earth_center(0.0);
Point3D result;
MAT3vec local_up;
scenery.next_center = t->center;
- // earth_center = Point3D(0.0, 0.0, 0.0);
-
FG_LOG( FG_TERRAIN, FG_DEBUG,
"Current bucket = " << p << " Index = " << fgBucketGenIndex(&p) );
+ FG_LOG( FG_TERRAIN, FG_DEBUG,
+ "abs_view_pos = " << abs_view_pos );
// calculate tile offset
// x = (t->offset.x = t->center.x - scenery.center.x);
}
}
- cout << "no terrain intersection found\n";
+ FG_LOG( FG_TERRAIN, FG_INFO, "(new) no terrain intersection found" );
+
return 0.0;
}
// explicitely. lat & lon are in radians. abs_view_pos in meters.
// Returns result in meters.
double
-fgTileMgrCurElevOLD( double lon, double lat, const Point3D& abs_view_pos ) {
+fgTileMgrCurElev( double lon, double lat, const Point3D& abs_view_pos ) {
fgTILECACHE *c;
fgTILE *t;
// fgVIEW *v;
local_up[1] = abs_view_pos.y();
local_up[2] = abs_view_pos.z();
+ FG_LOG( FG_TERRAIN, FG_DEBUG, "Absolute view pos = " << abs_view_pos );
+
// Find current translation offset
fgBucketFind(lon * RAD_TO_DEG, lat * RAD_TO_DEG, &p);
index = c->exists(p);
scenery.next_center = t->center;
- // earth_center = Point3D(0.0, 0.0, 0.0);
-
FG_LOG( FG_TERRAIN, FG_DEBUG,
"Pos = (" << lon * RAD_TO_DEG << ", " << lat * RAD_TO_DEG
<< ") Current bucket = " << p
}
}
- cout << "no terrain intersection found\n";
+ FG_LOG( FG_TERRAIN, FG_INFO, "(old) no terrain intersection found" );
+
return 0.0;
}
// the chunk isn't already in the cache, then read it from disk.
int fgTileMgrUpdate( void ) {
fgTILECACHE *c;
- fgFLIGHT *f;
+ FGInterface *f;
fgBUCKET p1, p2;
static fgBUCKET p_last = {-1000, 0, 0, 0};
int tile_diameter;
int i, j, dw, dh;
c = &global_tile_cache;
- f = current_aircraft.flight;
+ f = current_aircraft.fdm_state;
tile_diameter = current_options.get_tile_diameter();
// First time through, initialize the system and load all
// relavant tiles
+ FG_LOG( FG_TERRAIN, FG_INFO, "Updating Tile list for " << p1 );
FG_LOG( FG_TERRAIN, FG_INFO, " First time through ... " );
FG_LOG( FG_TERRAIN, FG_INFO, " Updating Tile list for " << p1 );
FG_LOG( FG_TERRAIN, FG_INFO, " Loading "
}
// find our current elevation (feed in the current bucket to save work)
- scenery.cur_elev = fgTileMgrCurElev( p1 );
+ Point3D geod_pos = Point3D( f->get_Longitude(), f->get_Latitude(), 0.0);
+ Point3D tmp_abs_view_pos = fgGeodToCart(geod_pos);
+
+ scenery.cur_elev =
+ fgTileMgrCurElev( f->get_Longitude(), f->get_Latitude(),
+ tmp_abs_view_pos );
p_last.lon = p1.lon;
p_last.lat = p1.lat;
y = cp.y();
z = cp.z();
- mat = (double *)(current_view.WORLD_TO_EYE);
+ mat = (double *)(current_view.get_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) )
+ ( eye[2] + radius + current_weather.get_visibility() < 0) )
{
return(0);
}
- eye[0] = (x*mat[0] + y*mat[4] + z*mat[8] + mat[12]) * current_view.slope_x;
+ eye[0] = (x*mat[0] + y*mat[4] + z*mat[8] + mat[12])
+ * current_view.get_slope_x();
// check right and left clip plane (from eye perspective)
- x1 = radius * current_view.fov_x_clip;
+ x1 = radius * current_view.get_fov_x_clip();
if( (eye[2] > -(eye[0]+x1)) || (eye[2] > (eye[0]-x1)) )
{
return(0);
}
- eye[1] = (x*mat[1] + y*mat[5] + z*mat[9] + mat[13]) * current_view.slope_y;
+ eye[1] = (x*mat[1] + y*mat[5] + z*mat[9] + mat[13])
+ * current_view.get_slope_y();
// check bottom and top clip plane (from eye perspective)
- y1 = radius * current_view.fov_y_clip;
+ y1 = radius * current_view.get_fov_y_clip();
if( (eye[2] > -(eye[1]+y1)) || (eye[2] > (eye[1]-y1)) )
{
return(0);
}
// Check far clip plane
- if ( eye[2] + radius < -current_weather.visibility ) {
+ if ( eye[2] + radius < -current_weather.get_visibility() ) {
return(0);
}
// Render the local tiles
void fgTileMgrRender( void ) {
- fgFLIGHT *f;
+ FGInterface *f;
fgTILECACHE *c;
fgTILE *t;
- fgVIEW *v;
+ FGView *v;
Point3D frag_offset;
fgFRAGMENT *frag_ptr;
fgMATERIAL *mtl_ptr;
int drawn = 0;
c = &global_tile_cache;
- f = current_aircraft.flight;
+ f = current_aircraft.fdm_state;
v = ¤t_view;
tile_diameter = current_options.get_tile_diameter();
// Calculate the model_view transformation matrix for this tile
// This is equivalent to doing a glTranslatef(x, y, z);
- t->UpdateViewMatrix( v->MODEL_VIEW );
+ t->UpdateViewMatrix( v->get_MODEL_VIEW() );
// xglPushMatrix();
// xglTranslatef(t->offset.x, t->offset.y, t->offset.z);
}
if ( (drawn + culled) > 0 ) {
- v->vfc_ratio = (double)culled / (double)(drawn + culled);
+ v->set_vfc_ratio( (double)culled / (double)(drawn + culled) );
} else {
- v->vfc_ratio = 0.0;
+ v->set_vfc_ratio( 0.0 );
}
// printf("drawn = %d culled = %d saved = %.2f\n", drawn, culled,
// v->vfc_ratio);
// $Log$
+// Revision 1.53 1999/02/05 21:29:16 curt
+// Modifications to incorporate Jon S. Berndts flight model code.
+//
+// Revision 1.52 1999/01/27 04:49:48 curt
+// Fixes so that the sim can start out at an airport below sea level.
+//
+// Revision 1.51 1998/12/09 18:50:33 curt
+// Converted "class fgVIEW" to "class FGView" and updated to make data
+// members private and make required accessor functions.
+//
+// Revision 1.50 1998/12/06 13:51:25 curt
+// Turned "struct fgWEATHER" into "class FGWeather".
+//
+// Revision 1.49 1998/12/05 15:54:26 curt
+// Renamed class fgFLIGHT to class FGState as per request by JSB.
+//
+// Revision 1.48 1998/12/05 14:20:21 curt
+// Looking into a terrain intersection problem.
+//
+// Revision 1.47 1998/12/05 14:11:19 curt
+// Sun portability tweak.
+//
// Revision 1.46 1998/12/03 14:15:24 curt
// Actually set the current scenery elevation based on scenery intersection point
// rather than calculating the intesection point and throwing it away.