1
0
Fork 0

Changes by NHV to allow the sim to be reset.

This commit is contained in:
curt 1999-04-27 15:52:32 +00:00
parent 397f6de896
commit 78757ea9dd
9 changed files with 133 additions and 36 deletions

View file

@ -176,14 +176,14 @@ void GLUTkey(unsigned char k, int x, int y) {
FG_LOG( FG_INPUT, FG_DEBUG, "" );
switch (k) {
case 50: // numeric keypad 2
if( fgAPAltitudeEnabled() ) {
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
fgAPAltitudeAdjust( 100 );
} else {
controls.move_elevator(-0.05);
}
return;
case 56: // numeric keypad 8
if( fgAPAltitudeEnabled() ) {
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
fgAPAltitudeAdjust( -100 );
} else {
controls.move_elevator(0.05);
@ -352,7 +352,7 @@ void GLUTspecialkey(int k, int x, int y) {
return;
case GLUT_KEY_F9: // F9 toggles textures on and off...
if ( material_mgr.get_textures_loaded() ) {
if ( material_mgr.loaded() ) {
current_options.get_textures() ?
current_options.set_textures(false) :
current_options.set_textures(true);
@ -370,14 +370,14 @@ void GLUTspecialkey(int k, int x, int y) {
//exit(1);
return;
case GLUT_KEY_UP:
if( fgAPAltitudeEnabled() ) {
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
fgAPAltitudeAdjust( -100 );
} else {
controls.move_elevator(0.05);
}
return;
case GLUT_KEY_DOWN:
if( fgAPAltitudeEnabled() ) {
if( fgAPAltitudeEnabled() || fgAPTerrainFollowEnabled() ) {
fgAPAltitudeAdjust( 100 );
} else {
controls.move_elevator(-0.05);

View file

@ -417,3 +417,90 @@ int fgInitSubsystems( void )
return(1);
}
void fgReInitSubsystems( void )
{
FGInterface *f = current_aircraft.fdm_state;
// fgLIGHT *l = &cur_light_params;
// fgTIME *t = &cur_time_params;
FGView *v = &current_view;
fgInitPosition();
if( fgTileMgrInit() ) {
// Load the local scenery data
fgTileMgrUpdate();
} else {
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Tile Manager initialization!" );
exit(-1);
}
fgFDMSetGroundElevation( current_options.get_flight_model(),
scenery.cur_elev );
// Reset our altitude if we are below ground
FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << f->get_Altitude() );
FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " <<
f->get_Runway_altitude() );
if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
}
double sea_level_radius_meters;
double lat_geoc;
// Set the FG variables first
fgGeodToGeoc( f->get_Latitude(), f->get_Altitude(),
&sea_level_radius_meters, &lat_geoc);
f->set_Geocentric_Position( lat_geoc, f->get_Longitude(),
f->get_Altitude() +
(sea_level_radius_meters * METER_TO_FEET) );
f->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
f->set_sin_cos_longitude(f->get_Longitude());
f->set_sin_cos_latitude(f->get_Latitude());
f->set_sin_lat_geocentric(sin(lat_geoc));
f->set_cos_lat_geocentric(cos(lat_geoc));
// The following section sets up the flight model EOM parameters
// and should really be read in from one or more files.
// Initial Velocity
f->set_Velocities_Local( 0.0, 0.0, 0.0 );
// Initial Orientation
f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
current_options.get_pitch() * DEG_TO_RAD,
current_options.get_heading() * DEG_TO_RAD );
// Initial Angular Body rates
f->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
f->set_Earth_position_angle( 0.0 );
// Mass properties and geometry values
f->set_Inertias( 8.547270E+01,
1.048000E+03, 3.000000E+03, 3.530000E+03, 0.000000E+00 );
// CG position w.r.t. ref. point
f->set_CG_Position( 0.0, 0.0, 0.0 );
// Initialize view parameters
FG_LOG( FG_GENERAL, FG_DEBUG, "Before v->init()");
v->Init();
FG_LOG( FG_GENERAL, FG_DEBUG, "After v->init()");
v->UpdateViewMath(f);
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << v->get_abs_view_pos());
v->UpdateWorldToEye(f);
fgFDMInit( current_options.get_flight_model(), cur_fdm_state,
1.0 / DEFAULT_MODEL_HZ );
scenery.cur_elev = f->get_Runway_altitude() * FEET_TO_METER;
if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
}
controls.reset_all();
fgAPReset();
}

View file

@ -41,6 +41,10 @@ int fgInitGeneral ( void );
int fgInitSubsystems( void );
// Reset
void fgReInitSubsystems( void );
#endif // _FG_INIT_H

View file

@ -212,6 +212,7 @@ public:
}
// Update functions
inline void set_airport_id( const string id ) { airport_id = id; }
inline void set_hud_status( bool status ) { hud_status = status; }
inline void set_fov( double amount ) { fov = amount; }
inline void set_textures( bool status ) { textures = status; }

View file

@ -133,7 +133,7 @@ void FGView::UpdateFOV( const fgOPTIONS& o ) {
void FGView::LookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
GLdouble centerx, GLdouble centery, GLdouble centerz,
GLdouble upx, GLdouble upy, GLdouble upz ) {
GLdouble *m;
GLfloat *m;
GLdouble x[3], y[3], z[3];
GLdouble mag;
@ -208,7 +208,7 @@ void FGView::LookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
m[15] = 1.0 /* m[3] * -eyex + m[7] * -eyey + m[11] * -eyez + m[15] */;
// xglMultMatrixd( m );
xglLoadMatrixd( m );
xglLoadMatrixf( m );
}
@ -279,7 +279,7 @@ void FGView::UpdateViewParams( void ) {
// GLdouble centerx, GLdouble centery, GLdouble centerz,
// GLdouble upx, GLdouble upy, GLdouble upz )
{
GLdouble *m;
GLfloat *m;
GLdouble x[3], y[3], z[3];
// GLdouble mag;
@ -369,7 +369,7 @@ void FGView::UpdateViewParams( void ) {
m[15] = 1.0 /* m[3] * -view_pos.x() + m[7] * -view_pos.y() + m[11] * -view_pos.z() + m[15] */;
// xglMultMatrixd( m );
xglLoadMatrixd( m );
xglLoadMatrixf( m );
}
#endif // FG_VIEW_INLINE_OPTIMIZATIONS

View file

@ -150,7 +150,7 @@ public:
MAT3mat WORLD_TO_EYE;
// Current model view matrix;
GLdouble MODEL_VIEW[16];
GLfloat MODEL_VIEW[16];
public:
@ -242,7 +242,7 @@ public:
inline double *get_surface_east() { return surface_east; }
inline double *get_local_up() { return local_up; }
inline const MAT3mat *get_WORLD_TO_EYE() const { return &WORLD_TO_EYE; }
inline GLdouble *get_MODEL_VIEW() { return MODEL_VIEW; }
inline GLfloat *get_MODEL_VIEW() { return MODEL_VIEW; }
};

View file

@ -76,7 +76,7 @@ public:
Point3D center;
double bounding_radius;
Point3D offset;
GLdouble model_view[16];
GLfloat model_view[16];
// this tile's official location in the world
FGBucket tile_bucket;
@ -122,16 +122,18 @@ public:
offset = center - off;
}
// Return this tile's offset
inline Point3D GetOffset( void ) const { return offset; }
// Calculate the model_view transformation matrix for this tile
inline void
UpdateViewMatrix(GLdouble *MODEL_VIEW)
UpdateViewMatrix(GLfloat *MODEL_VIEW)
{
#if defined( USE_MEM ) || defined( WIN32 )
memcpy( model_view, MODEL_VIEW, 16*sizeof(GLdouble) );
memcpy( model_view, MODEL_VIEW, 16*sizeof(GLfloat) );
#else
bcopy( MODEL_VIEW, model_view, 16*sizeof(GLdouble) );
bcopy( MODEL_VIEW, model_view, 16*sizeof(GLfloat) );
#endif
// This is equivalent to doing a glTranslatef(x, y, z);
@ -158,5 +160,3 @@ private:
#endif // _TILE_HXX

View file

@ -61,6 +61,10 @@ fgTILECACHE::init( void )
FG_LOG( FG_TERRAIN, FG_INFO, "Initializing the tile cache." );
for ( i = 0; i < FG_TILE_CACHE_SIZE; i++ ) {
if ( tile_cache[i].used ) {
entry_free(i);
tile_cache[i].tile_bucket.make_bad();
}
tile_cache[i].used = 0;
}
}

View file

@ -56,8 +56,8 @@
// to test clipping speedup in fgTileMgrRender()
#if defined ( USE_FAST_FOV_CLIP )
// #define TEST_FOV_CLIP
// #define TEST_ELEV
// #define TEST_FOV_CLIP
// #define TEST_ELEV
#endif
@ -81,7 +81,9 @@ int fgTileMgrInit( void ) {
FG_LOG( FG_TERRAIN, FG_INFO, "Initializing Tile Manager subsystem." );
// load default material library
material_mgr.load_lib();
if ( ! material_mgr.loaded() ) {
material_mgr.load_lib();
}
return 1;
}
@ -362,6 +364,7 @@ int fgTileMgrUpdate( void ) {
// wipe/initialize tile cache
c->init();
p_last.make_bad();
// build the local area list and update cache
for ( j = 0; j < tile_diameter; j++ ) {
@ -471,9 +474,9 @@ static int viewable( const Point3D& cp, double radius ) {
int viewable = 1; // start by assuming it's viewable
double x1, y1;
/********************************/
/********************************/
#if defined( USE_FAST_FOV_CLIP ) // views.hxx
/********************************/
/********************************/
MAT3vec eye;
double *mat;
@ -490,9 +493,9 @@ static int viewable( const Point3D& cp, double radius ) {
// Check near and far clip plane
if( ( eye[2] > radius ) ||
( eye[2] + radius + current_weather.get_visibility() < 0) )
{
return(0);
}
{
return(0);
}
eye[0] = (x*mat[0] + y*mat[4] + z*mat[8] + mat[12])
* current_view.get_slope_x();
@ -500,9 +503,9 @@ static int viewable( const Point3D& cp, double radius ) {
// check right and left clip plane (from eye perspective)
x1 = radius * current_view.get_fov_x_clip();
if( (eye[2] > -(eye[0]+x1)) || (eye[2] > (eye[0]-x1)) )
{
return(0);
}
{
return(0);
}
eye[1] = (x*mat[1] + y*mat[5] + z*mat[9] + mat[13])
* current_view.get_slope_y();
@ -510,13 +513,13 @@ static int viewable( const Point3D& cp, double radius ) {
// check bottom and top clip plane (from eye perspective)
y1 = radius * current_view.get_fov_y_clip();
if( (eye[2] > -(eye[1]+y1)) || (eye[2] > (eye[1]-y1)) )
{
return(0);
}
{
return(0);
}
/********************************/
/********************************/
#else // DO NOT USE_FAST_FOV_CLIP
/********************************/
/********************************/
fgVIEW *v;
MAT3hvec world, eye;
@ -628,7 +631,7 @@ inrange( const double radius, const Point3D& center, const Point3D& vp,
static void
update_tile_geometry( fgTILE *t, GLdouble *MODEL_VIEW)
{
GLdouble *m;
GLfloat *m;
double x, y, z;
// calculate tile offset
@ -759,5 +762,3 @@ void fgTileMgrRender( void ) {
material_mgr.render_fragments();
xglPopMatrix();
}