// Tell GL we are about to modify the projection parameters
xglMatrixMode(GL_PROJECTION);
xglLoadIdentity();
- gluPerspective(o->fov, v->win_ratio, 10.0, 100000.0);
+ if ( FG_Altitude * FEET_TO_METER - scenery.cur_elev > 10.0 ) {
+ gluPerspective(o->fov, v->win_ratio, 10.0, 100000.0);
+ } else {
+ gluPerspective(o->fov, v->win_ratio, 1.0, 100000.0);
+ // printf("Near ground, minimizing near clip plane\n");
+ }
// }
xglMatrixMode(GL_MODELVIEW);
// Update all Visuals (redraws anything graphics related)
static void fgRenderFrame( void ) {
+ fgFLIGHT *f;
fgLIGHT *l;
fgOPTIONS *o;
fgTIME *t;
GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 };
+ f = current_aircraft.flight;
l = &cur_light_params;
o = ¤t_options;
t = &cur_time_params;
// initializations and are running the main loop, so this will
// now work without seg faulting the system.
+ // printf("Ground = %.2f Altitude = %.2f\n", scenery.cur_elev,
+ // FG_Altitude * FEET_TO_METER);
+
// this is just a temporary hack, to make me understand Pui
timerText -> setLabel (ctime (&t->cur_time));
// end of hack
// What should we do when we have nothing else to do? Let's get ready
// for the next move and update the display?
static void fgMainLoop( void ) {
- fgAIRCRAFT *a;
fgFLIGHT *f;
fgGENERAL *g;
fgTIME *t;
static int remainder = 0;
int elapsed, multi_loop;
- double cur_elev;
int i;
double accum;
// double joy_x, joy_y;
// int joy_b1, joy_b2;
- a = ¤t_aircraft;
- f = a->flight;
+ f = current_aircraft.flight;
g = &general;
t = &cur_time_params;
fgPrintf( FG_ALL, FG_DEBUG, "Running Main Loop\n");
fgPrintf( FG_ALL, FG_DEBUG, "======= ==== ====\n");
+ // Fix elevation. I'm just sticking this here for now, it should
+ // probably move eventually
+
+ /* printf("Before - ground = %.2f runway = %.2f alt = %.2f\n",
+ scenery.cur_elev,
+ FG_Runway_altitude * FEET_TO_METER,
+ FG_Altitude * FEET_TO_METER); */
+
+ if ( scenery.cur_elev > -9990 ) {
+ if ( FG_Altitude * FEET_TO_METER <
+ (scenery.cur_elev + 3.758099 * FEET_TO_METER - 1.0) ) {
+ // now set aircraft altitude above ground
+ printf("Current Altitude = %.2f < %.2f forcing to %.2f\n",
+ FG_Altitude * FEET_TO_METER,
+ scenery.cur_elev + 3.758099 * FEET_TO_METER - 1.0,
+ scenery.cur_elev + 3.758099 * FEET_TO_METER);
+ fgFlightModelSetAltitude( FG_LARCSIM, f,
+ scenery.cur_elev +
+ 3.758099 * FEET_TO_METER);
+
+ fgPrintf( FG_ALL, FG_BULK,
+ "<*> resetting altitude to %.0f meters\n",
+ FG_Altitude * FEET_TO_METER);
+ }
+ FG_Runway_altitude = scenery.cur_elev * METER_TO_FEET;
+ }
+
+ /* printf("Adjustment - ground = %.2f runway = %.2f alt = %.2f\n",
+ scenery.cur_elev,
+ FG_Runway_altitude * FEET_TO_METER,
+ FG_Altitude * FEET_TO_METER); */
+
// update "time"
fgTimeUpdate(f, t);
"Model iterations needed = %d, new remainder = %d\n",
multi_loop, remainder);
+ /* printf("right before fm - ground = %.2f runway = %.2f alt = %.2f\n",
+ scenery.cur_elev,
+ FG_Runway_altitude * FEET_TO_METER,
+ FG_Altitude * FEET_TO_METER); */
+
// Run flight model
if ( ! use_signals ) {
// flight model
fgUpdateTimeDepCalcs(multi_loop);
}
- // I'm just sticking this here for now, it should probably move
- // eventually
- /* cur_elev = mesh_altitude(FG_Longitude * RAD_TO_ARCSEC,
- FG_Latitude * RAD_TO_ARCSEC); */
- // there is no ground collision detection really, so for now I
- // just hard code the ground elevation to be 0 */
- cur_elev = 0;
-
- // printf("Ground elevation is %.2f meters here.\n", cur_elev);
- // FG_Runway_altitude = cur_elev * METER_TO_FEET;
-
- if ( FG_Altitude * FEET_TO_METER < cur_elev + 3.758099) {
- // set this here, otherwise if we set runway height above our
- // current height we get a really nasty bounce.
- FG_Runway_altitude = FG_Altitude - 3.758099;
-
- // now set aircraft altitude above ground
- FG_Altitude = cur_elev * METER_TO_FEET + 3.758099;
- fgPrintf( FG_ALL, FG_BULK, "<*> resetting altitude to %.0f meters\n",
- FG_Altitude * FEET_TO_METER);
- }
+ /* printf("After fm - ground = %.2f runway = %.2f alt = %.2f\n",
+ scenery.cur_elev,
+ FG_Runway_altitude * FEET_TO_METER,
+ FG_Altitude * FEET_TO_METER); */
- fgAircraftOutputCurrent(a);
+ // fgAircraftOutputCurrent(a);
// see if we need to load any new scenery tiles
fgTileMgrUpdate();
// $Log$
+// Revision 1.33 1998/07/12 03:14:42 curt
+// Added ground collision detection.
+// Did some serious horsing around to be able to "hug" the ground properly
+// and still be able to take off.
+// Set the near clip plane to 1.0 meters when less than 10 meters above the
+// ground.
+// Did some serious horsing around getting the initial airplane position to be
+// correct based on rendered terrain elevation.
+// Added a little cheat/hack that will prevent the view position from ever
+// dropping below the terrain, even when the flight model doesn't quite
+// put you as high as you'd like.
+//
// Revision 1.32 1998/07/08 14:45:07 curt
// polar3d.h renamed to polar3d.hxx
// vector.h renamed to vector.hxx
} else {
FG_Longitude = ( a.longitude ) * DEG_TO_RAD;
FG_Latitude = ( a.latitude ) * DEG_TO_RAD;
- FG_Runway_altitude = ( a.elevation + 200 );
+ FG_Runway_altitude = ( a.elevation );
FG_Altitude = FG_Runway_altitude + 3.758099;
}
}
// gear, its initialization call should located in this routine.
// Returns non-zero if a problem encountered.
int fgInitSubsystems( void ) {
- double cur_elev;
-
fgFLIGHT *f;
fgLIGHT *l;
fgTIME *t;
fgPrintf( FG_GENERAL, FG_EXIT, "Error in Scenery initialization!\n" );
}
-
if( fgTileMgrInit() ) {
// Load the local scenery data
fgTileMgrUpdate();
// I'm just sticking this here for now, it should probably move
// eventually
- cur_elev = FG_Runway_altitude * FEET_TO_METER;
- if ( cur_elev > -9990.0 ) {
- FG_Runway_altitude = cur_elev * METER_TO_FEET;
- }
+ scenery.cur_elev = FG_Runway_altitude * FEET_TO_METER;
- if ( FG_Altitude < FG_Runway_altitude ) {
- FG_Altitude = FG_Runway_altitude + 3.758099;
- }
+ if ( FG_Altitude < FG_Runway_altitude + 3.758099) {
+ FG_Altitude = FG_Runway_altitude + 3.758099;
+ }
- fgPrintf( FG_GENERAL, FG_INFO,
- "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
- FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
- FG_Altitude * FEET_TO_METER);
+ fgPrintf( FG_GENERAL, FG_INFO,
+ "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
+ FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
+ FG_Altitude * FEET_TO_METER);
// end of thing that I just stuck in that I should probably move
// Initialize the flight model subsystem data structures base on
fgFlightModelInit( FG_LARCSIM, f, 1.0 / DEFAULT_MODEL_HZ );
+ // I'm just sticking this here for now, it should probably move
+ // eventually
+ scenery.cur_elev = FG_Runway_altitude * FEET_TO_METER;
+
+ if ( FG_Altitude < FG_Runway_altitude + 3.758099) {
+ FG_Altitude = FG_Runway_altitude + 3.758099;
+ }
+
+ fgPrintf( FG_GENERAL, FG_INFO,
+ "Updated position (after elevation adj): (%.4f, %.4f, %.2f)\n",
+ FG_Latitude * RAD_TO_DEG, FG_Longitude * RAD_TO_DEG,
+ FG_Altitude * FEET_TO_METER);
+ // end of thing that I just stuck in that I should probably move
+
// Joystick support
if (fgJoystickInit(0) ) {
// Joystick initialized ok.
// $Log$
+// Revision 1.23 1998/07/12 03:14:43 curt
+// Added ground collision detection.
+// Did some serious horsing around to be able to "hug" the ground properly
+// and still be able to take off.
+// Set the near clip plane to 1.0 meters when less than 10 meters above the
+// ground.
+// Did some serious horsing around getting the initial airplane position to be
+// correct based on rendered terrain elevation.
+// Added a little cheat/hack that will prevent the view position from ever
+// dropping below the terrain, even when the flight model doesn't quite
+// put you as high as you'd like.
+//
// Revision 1.22 1998/07/04 00:52:25 curt
// Add my own version of gluLookAt() (which is nearly identical to the
// Mesa/glu version.) But, by calculating the Model View matrix our selves
scenery.center.y = scenery.next_center.y;
scenery.center.z = scenery.next_center.z;
+ // printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x,
+ // scenery.center.y, scenery.center.z);
+
// calculate the cartesion coords of the current lat/lon/0 elev
p.lon = FG_Longitude;
p.lat = FG_Lat_geocentric;
cur_zero_elev.z -= scenery.center.z;
// calculate view position in current FG view coordinate system
- // p.lon & p.lat are already defined earlier
- p.radius = FG_Radius_to_vehicle * FEET_TO_METER + 1.0;
+ // p.lon & p.lat are already defined earlier, p.radius was set to
+ // the sea level radius, so now we add in our altitude.
+ if ( FG_Altitude * FEET_TO_METER >
+ (scenery.cur_elev + 3.758099 * METER_TO_FEET) ) {
+ p.radius += FG_Altitude * FEET_TO_METER;
+ } else {
+ p.radius += scenery.cur_elev + 3.758099 * METER_TO_FEET;
+ }
abs_view_pos = fgPolarToCart3d(p);
// $Log$
+// Revision 1.15 1998/07/12 03:14:43 curt
+// Added ground collision detection.
+// Did some serious horsing around to be able to "hug" the ground properly
+// and still be able to take off.
+// Set the near clip plane to 1.0 meters when less than 10 meters above the
+// ground.
+// Did some serious horsing around getting the initial airplane position to be
+// correct based on rendered terrain elevation.
+// Added a little cheat/hack that will prevent the view position from ever
+// dropping below the terrain, even when the flight model doesn't quite
+// put you as high as you'd like.
+//
// Revision 1.14 1998/07/08 14:45:08 curt
// polar3d.h renamed to polar3d.hxx
// vector.h renamed to vector.hxx