Fiddling around with views, fdm data passing and management to try to be
more sensible so we can do a more reasonable external view.
This commit is contained in:
parent
1d1bd0a2ff
commit
1b45c9ee54
9 changed files with 223 additions and 193 deletions
|
@ -38,7 +38,7 @@
|
|||
|
||||
// Define a structure containing all the parameters for an aircraft
|
||||
typedef struct{
|
||||
FGInterface *fdm_state;
|
||||
FGInterface *fdm_state;
|
||||
FGControls *controls;
|
||||
} fgAIRCRAFT ;
|
||||
|
||||
|
|
|
@ -81,10 +81,17 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <Include/compiler.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
#include <Time/timestamp.hxx>
|
||||
|
||||
FG_USING_STD(list);
|
||||
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This library requires C++
|
||||
#endif
|
||||
|
@ -839,6 +846,11 @@ public:
|
|||
};
|
||||
|
||||
|
||||
typedef list < FGInterface > fdm_state_list;
|
||||
typedef fdm_state_list::iterator fdm_state_list_iterator;
|
||||
typedef fdm_state_list::const_iterator const_fdm_state_list_iterator;
|
||||
|
||||
|
||||
extern FGInterface cur_fdm_state;
|
||||
|
||||
|
||||
|
|
|
@ -218,7 +218,6 @@ bool fgInitGeneral( void ) {
|
|||
bool fgInitSubsystems( void ) {
|
||||
FGTime::cur_time_params = new FGTime();
|
||||
|
||||
FGInterface *f; // assigned later
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
FGView *v = ¤t_view;
|
||||
|
@ -229,7 +228,6 @@ bool fgInitSubsystems( void ) {
|
|||
// allocates structures so must happen before any of the flight
|
||||
// model or control parameters are set
|
||||
fgAircraftInit(); // In the future this might not be the case.
|
||||
f = current_aircraft.fdm_state;
|
||||
|
||||
// set the initial position
|
||||
fgInitPosition();
|
||||
|
@ -265,13 +263,13 @@ bool fgInitSubsystems( void ) {
|
|||
// now handled inside of the fgTileMgrUpdate()
|
||||
|
||||
/*
|
||||
geod_pos = Point3D( f->get_Longitude(), f->get_Latitude(), 0.0);
|
||||
geod_pos = Point3D( cur_fdm_state.get_Longitude(), cur_fdm_state.get_Latitude(), 0.0);
|
||||
tmp_abs_view_pos = fgGeodToCart(geod_pos);
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_DEBUG,
|
||||
"Initial abs_view_pos = " << tmp_abs_view_pos );
|
||||
scenery.cur_elev =
|
||||
fgTileMgrCurElev( f->get_Longitude(), f->get_Latitude(),
|
||||
fgTileMgrCurElev( cur_fdm_state.get_Longitude(), cur_fdm_state.get_Latitude(),
|
||||
tmp_abs_view_pos );
|
||||
FG_LOG( FG_GENERAL, FG_DEBUG,
|
||||
"Altitude after update " << scenery.cur_elev );
|
||||
|
@ -281,19 +279,19 @@ bool fgInitSubsystems( void ) {
|
|||
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 altitude = " << cur_fdm_state.get_Altitude() );
|
||||
FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " <<
|
||||
f->get_Runway_altitude() );
|
||||
cur_fdm_state.get_Runway_altitude() );
|
||||
|
||||
if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
|
||||
f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
|
||||
if ( cur_fdm_state.get_Altitude() < cur_fdm_state.get_Runway_altitude() + 3.758099) {
|
||||
cur_fdm_state.set_Altitude( cur_fdm_state.get_Runway_altitude() + 3.758099 );
|
||||
}
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Updated position (after elevation adj): ("
|
||||
<< (f->get_Latitude() * RAD_TO_DEG) << ", "
|
||||
<< (f->get_Longitude() * RAD_TO_DEG) << ", "
|
||||
<< (f->get_Altitude() * FEET_TO_METER) << ")" );
|
||||
<< (cur_fdm_state.get_Latitude() * RAD_TO_DEG) << ", "
|
||||
<< (cur_fdm_state.get_Longitude() * RAD_TO_DEG) << ", "
|
||||
<< (cur_fdm_state.get_Altitude() * FEET_TO_METER) << ")" );
|
||||
|
||||
// We need to calculate a few more values here that would normally
|
||||
// be calculated by the FDM so that the v->UpdateViewMath()
|
||||
|
@ -302,43 +300,43 @@ bool fgInitSubsystems( void ) {
|
|||
double sea_level_radius_meters;
|
||||
double lat_geoc;
|
||||
// Set the FG variables first
|
||||
fgGeodToGeoc( f->get_Latitude(), f->get_Altitude(),
|
||||
fgGeodToGeoc( cur_fdm_state.get_Latitude(), cur_fdm_state.get_Altitude(),
|
||||
&sea_level_radius_meters, &lat_geoc);
|
||||
f->set_Geocentric_Position( lat_geoc, f->get_Longitude(),
|
||||
f->get_Altitude() +
|
||||
cur_fdm_state.set_Geocentric_Position( lat_geoc, cur_fdm_state.get_Longitude(),
|
||||
cur_fdm_state.get_Altitude() +
|
||||
(sea_level_radius_meters * METER_TO_FEET) );
|
||||
f->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
|
||||
cur_fdm_state.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());
|
||||
cur_fdm_state.set_sin_cos_longitude(cur_fdm_state.get_Longitude());
|
||||
cur_fdm_state.set_sin_cos_latitude(cur_fdm_state.get_Latitude());
|
||||
|
||||
f->set_sin_lat_geocentric(sin(lat_geoc));
|
||||
f->set_cos_lat_geocentric(cos(lat_geoc));
|
||||
cur_fdm_state.set_sin_lat_geocentric(sin(lat_geoc));
|
||||
cur_fdm_state.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( current_options.get_uBody(),
|
||||
cur_fdm_state.set_Velocities_Local( current_options.get_uBody(),
|
||||
current_options.get_vBody(),
|
||||
current_options.get_wBody());
|
||||
|
||||
// Initial Orientation
|
||||
f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
|
||||
cur_fdm_state.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 );
|
||||
cur_fdm_state.set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
|
||||
|
||||
f->set_Earth_position_angle( 0.0 );
|
||||
cur_fdm_state.set_Earth_position_angle( 0.0 );
|
||||
|
||||
// Mass properties and geometry values
|
||||
f->set_Inertias( 8.547270E+01,
|
||||
cur_fdm_state.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 );
|
||||
cur_fdm_state.set_CG_Position( 0.0, 0.0, 0.0 );
|
||||
|
||||
// Initialize the event manager
|
||||
global_events.Init();
|
||||
|
@ -350,14 +348,14 @@ bool fgInitSubsystems( void ) {
|
|||
fgEVENT::FG_EVENT_READY, 60000 );
|
||||
|
||||
// Initialize the time dependent variables
|
||||
t->init(f);
|
||||
t->update(f);
|
||||
t->init(cur_fdm_state);
|
||||
t->update(cur_fdm_state);
|
||||
|
||||
// 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);
|
||||
v->UpdateViewMath(cur_fdm_state);
|
||||
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = " << v->get_abs_view_pos());
|
||||
// v->UpdateWorldToEye(f);
|
||||
|
||||
|
@ -448,17 +446,17 @@ bool fgInitSubsystems( void ) {
|
|||
|
||||
// I'm just sticking this here for now, it should probably move
|
||||
// eventually
|
||||
scenery.cur_elev = f->get_Runway_altitude() * FEET_TO_METER;
|
||||
scenery.cur_elev = cur_fdm_state.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 );
|
||||
if ( cur_fdm_state.get_Altitude() < cur_fdm_state.get_Runway_altitude() + 3.758099) {
|
||||
cur_fdm_state.set_Altitude( cur_fdm_state.get_Runway_altitude() + 3.758099 );
|
||||
}
|
||||
|
||||
FG_LOG( FG_GENERAL, FG_INFO,
|
||||
"Updated position (after elevation adj): ("
|
||||
<< (f->get_Latitude() * RAD_TO_DEG) << ", "
|
||||
<< (f->get_Longitude() * RAD_TO_DEG) << ", "
|
||||
<< (f->get_Altitude() * FEET_TO_METER) << ")" );
|
||||
<< (cur_fdm_state.get_Latitude() * RAD_TO_DEG) << ", "
|
||||
<< (cur_fdm_state.get_Longitude() * RAD_TO_DEG) << ", "
|
||||
<< (cur_fdm_state.get_Altitude() * FEET_TO_METER) << ")" );
|
||||
// end of thing that I just stuck in that I should probably move
|
||||
|
||||
// Joystick support
|
||||
|
@ -484,7 +482,6 @@ bool fgInitSubsystems( void ) {
|
|||
|
||||
void fgReInitSubsystems( void )
|
||||
{
|
||||
FGInterface *f = current_aircraft.fdm_state;
|
||||
FGView *v = ¤t_view;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
|
||||
|
@ -505,69 +502,69 @@ void fgReInitSubsystems( void )
|
|||
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 altitude = " << cur_fdm_state.get_Altitude() );
|
||||
FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " <<
|
||||
f->get_Runway_altitude() );
|
||||
cur_fdm_state.get_Runway_altitude() );
|
||||
|
||||
if ( f->get_Altitude() < f->get_Runway_altitude() + 3.758099) {
|
||||
f->set_Altitude( f->get_Runway_altitude() + 3.758099 );
|
||||
if ( cur_fdm_state.get_Altitude() < cur_fdm_state.get_Runway_altitude() + 3.758099) {
|
||||
cur_fdm_state.set_Altitude( cur_fdm_state.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(),
|
||||
fgGeodToGeoc( cur_fdm_state.get_Latitude(), cur_fdm_state.get_Altitude(),
|
||||
&sea_level_radius_meters, &lat_geoc);
|
||||
f->set_Geocentric_Position( lat_geoc, f->get_Longitude(),
|
||||
f->get_Altitude() +
|
||||
cur_fdm_state.set_Geocentric_Position( lat_geoc, cur_fdm_state.get_Longitude(),
|
||||
cur_fdm_state.get_Altitude() +
|
||||
(sea_level_radius_meters * METER_TO_FEET) );
|
||||
f->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
|
||||
cur_fdm_state.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());
|
||||
cur_fdm_state.set_sin_cos_longitude(cur_fdm_state.get_Longitude());
|
||||
cur_fdm_state.set_sin_cos_latitude(cur_fdm_state.get_Latitude());
|
||||
|
||||
f->set_sin_lat_geocentric(sin(lat_geoc));
|
||||
f->set_cos_lat_geocentric(cos(lat_geoc));
|
||||
cur_fdm_state.set_sin_lat_geocentric(sin(lat_geoc));
|
||||
cur_fdm_state.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( current_options.get_uBody(),
|
||||
cur_fdm_state.set_Velocities_Local( current_options.get_uBody(),
|
||||
current_options.get_vBody(),
|
||||
current_options.get_wBody());
|
||||
|
||||
// Initial Orientation
|
||||
f->set_Euler_Angles( current_options.get_roll() * DEG_TO_RAD,
|
||||
cur_fdm_state.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 );
|
||||
cur_fdm_state.set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
|
||||
|
||||
f->set_Earth_position_angle( 0.0 );
|
||||
cur_fdm_state.set_Earth_position_angle( 0.0 );
|
||||
|
||||
// Mass properties and geometry values
|
||||
f->set_Inertias( 8.547270E+01,
|
||||
cur_fdm_state.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 );
|
||||
cur_fdm_state.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);
|
||||
v->UpdateViewMath(cur_fdm_state);
|
||||
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 / current_options.get_model_hz() );
|
||||
|
||||
scenery.cur_elev = f->get_Runway_altitude() * FEET_TO_METER;
|
||||
scenery.cur_elev = cur_fdm_state.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 );
|
||||
if ( cur_fdm_state.get_Altitude() < cur_fdm_state.get_Runway_altitude() + 3.758099) {
|
||||
cur_fdm_state.set_Altitude( cur_fdm_state.get_Runway_altitude() + 3.758099 );
|
||||
}
|
||||
|
||||
controls.reset_all();
|
||||
|
|
|
@ -301,7 +301,7 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
local_update_sky_and_lighting_params();
|
||||
return;
|
||||
case 118: // v key
|
||||
v->cycle_view_mode();
|
||||
current_options.cycle_view_mode();
|
||||
return;
|
||||
case 120: // x key
|
||||
fov = current_options.get_fov();
|
||||
|
|
|
@ -224,7 +224,7 @@ static void fgInitVisuals( void ) {
|
|||
static void fgRenderFrame( void ) {
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
FGView *v = ¤t_view;
|
||||
// FGView *v = ¤t_view;
|
||||
|
||||
double angle;
|
||||
// GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
|
@ -251,7 +251,7 @@ static void fgRenderFrame( void ) {
|
|||
// end of hack
|
||||
|
||||
// update view volume parameters
|
||||
v->UpdateViewParams();
|
||||
current_view.UpdateViewParams(cur_fdm_state);
|
||||
|
||||
// set the sun position
|
||||
xglLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
|
||||
|
@ -285,7 +285,7 @@ static void fgRenderFrame( void ) {
|
|||
xglMatrixMode(GL_MODELVIEW);
|
||||
xglLoadIdentity();
|
||||
sgMat4 vm_tmp, view_mat;
|
||||
sgTransposeNegateMat4 ( vm_tmp, v->sgVIEW ) ;
|
||||
sgTransposeNegateMat4 ( vm_tmp, current_view.sgVIEW ) ;
|
||||
sgCopyMat4( view_mat, copy_of_ssgOpenGLAxisSwapMatrix ) ;
|
||||
sgPreMultMat4( view_mat, vm_tmp ) ;
|
||||
xglLoadMatrixf( (float *)view_mat );
|
||||
|
@ -303,7 +303,7 @@ static void fgRenderFrame( void ) {
|
|||
// setup transformation for drawing astronomical objects
|
||||
xglPushMatrix();
|
||||
// Translate to view position
|
||||
Point3D view_pos = v->get_view_pos();
|
||||
Point3D view_pos = current_view.get_view_pos();
|
||||
xglTranslatef( view_pos.x(), view_pos.y(), view_pos.z() );
|
||||
// Rotate based on gst (sidereal time)
|
||||
// note: constant should be 15.041085, Curt thought it was 15
|
||||
|
@ -376,22 +376,25 @@ static void fgRenderFrame( void ) {
|
|||
ssgSetNearFar( 0.5f, 100000.0f );
|
||||
}
|
||||
|
||||
sgMat4 sgVIEW;
|
||||
// sgMat4 sgVIEW;
|
||||
// while ( current_view.follow.size() > 25 ) {
|
||||
// current_view.follow.pop_front();
|
||||
// }
|
||||
|
||||
while ( current_view.follow.size() > 400 ) {
|
||||
current_view.follow.pop_front();
|
||||
}
|
||||
|
||||
if ( current_view.view_mode == FGView::FG_VIEW_FIRST_PERSON ) {
|
||||
if ( current_options.get_view_mode() ==
|
||||
fgOPTIONS::FG_VIEW_FIRST_PERSON )
|
||||
{
|
||||
// select current view matrix
|
||||
sgCopyMat4( sgVIEW, current_view.sgVIEW );
|
||||
// sgCopyMat4( sgVIEW, current_view.sgVIEW );
|
||||
|
||||
// disable TuX
|
||||
penguin_sel->select(0);
|
||||
} else if ( current_view.view_mode == FGView::FG_VIEW_FOLLOW ) {
|
||||
} else if ( current_options.get_view_mode() ==
|
||||
fgOPTIONS::FG_VIEW_FOLLOW )
|
||||
{
|
||||
// select view matrix from front of view matrix queue
|
||||
FGMat4Wrapper tmp = current_view.follow.front();
|
||||
sgCopyMat4( sgVIEW, tmp.m );
|
||||
// FGMat4Wrapper tmp = current_view.follow.front();
|
||||
// sgCopyMat4( sgVIEW, tmp.m );
|
||||
|
||||
// enable TuX and set up his position and orientation
|
||||
penguin_sel->select(1);
|
||||
|
@ -418,7 +421,7 @@ static void fgRenderFrame( void ) {
|
|||
penguin_pos->setTransform( &tuxpos );
|
||||
}
|
||||
|
||||
ssgSetCamera( sgVIEW );
|
||||
ssgSetCamera( current_view.sgVIEW );
|
||||
|
||||
// position tile nodes and update range selectors
|
||||
global_tile_mgr.prep_ssg_nodes();
|
||||
|
@ -455,10 +458,11 @@ static void fgRenderFrame( void ) {
|
|||
|
||||
// Update internal time dependent calculations (i.e. flight model)
|
||||
void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
|
||||
FGInterface *f = current_aircraft.fdm_state;
|
||||
static fdm_state_list fdm_list;
|
||||
FGInterface fdm_state;
|
||||
fgLIGHT *l = &cur_light_params;
|
||||
FGTime *t = FGTime::cur_time_params;
|
||||
FGView *v = ¤t_view;
|
||||
// FGView *v = ¤t_view;
|
||||
int i;
|
||||
|
||||
// update the flight model
|
||||
|
@ -466,50 +470,71 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
|
|||
multi_loop = 1;
|
||||
}
|
||||
|
||||
fdm_state = cur_fdm_state;
|
||||
|
||||
if ( !t->getPause() ) {
|
||||
// run Autopilot system
|
||||
fgAPRun();
|
||||
|
||||
// printf("updating flight model x %d\n", multi_loop);
|
||||
fgFDMUpdate( current_options.get_flight_model(),
|
||||
cur_fdm_state,
|
||||
fdm_state,
|
||||
multi_loop * current_options.get_speed_up(),
|
||||
remainder );
|
||||
} else {
|
||||
fgFDMUpdate( current_options.get_flight_model(),
|
||||
cur_fdm_state, 0, remainder );
|
||||
fdm_state, 0, remainder );
|
||||
}
|
||||
|
||||
fdm_list.push_back( fdm_state );
|
||||
while ( fdm_list.size() > 25 ) {
|
||||
fdm_list.pop_front();
|
||||
}
|
||||
|
||||
if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FIRST_PERSON ) {
|
||||
cur_fdm_state = fdm_state;
|
||||
} else if ( current_options.get_view_mode() == fgOPTIONS::FG_VIEW_FOLLOW ) {
|
||||
cur_fdm_state = fdm_list.front();
|
||||
}
|
||||
|
||||
// update the view angle
|
||||
for ( i = 0; i < multi_loop; i++ ) {
|
||||
if ( fabs(v->get_goal_view_offset() - v->get_view_offset()) < 0.05 ) {
|
||||
v->set_view_offset( v->get_goal_view_offset() );
|
||||
if ( fabs(current_view.get_goal_view_offset() -
|
||||
current_view.get_view_offset()) < 0.05 )
|
||||
{
|
||||
current_view.set_view_offset( current_view.get_goal_view_offset() );
|
||||
break;
|
||||
} else {
|
||||
// move v->view_offset towards v->goal_view_offset
|
||||
if ( v->get_goal_view_offset() > v->get_view_offset() ) {
|
||||
if ( v->get_goal_view_offset() - v->get_view_offset() < FG_PI ){
|
||||
v->inc_view_offset( 0.01 );
|
||||
// move current_view.view_offset towards current_view.goal_view_offset
|
||||
if ( current_view.get_goal_view_offset() >
|
||||
current_view.get_view_offset() )
|
||||
{
|
||||
if ( current_view.get_goal_view_offset() -
|
||||
current_view.get_view_offset() < FG_PI )
|
||||
{
|
||||
current_view.inc_view_offset( 0.01 );
|
||||
} else {
|
||||
v->inc_view_offset( -0.01 );
|
||||
current_view.inc_view_offset( -0.01 );
|
||||
}
|
||||
} else {
|
||||
if ( v->get_view_offset() - v->get_goal_view_offset() < FG_PI ){
|
||||
v->inc_view_offset( -0.01 );
|
||||
if ( current_view.get_view_offset() -
|
||||
current_view.get_goal_view_offset() < FG_PI )
|
||||
{
|
||||
current_view.inc_view_offset( -0.01 );
|
||||
} else {
|
||||
v->inc_view_offset( 0.01 );
|
||||
current_view.inc_view_offset( 0.01 );
|
||||
}
|
||||
}
|
||||
if ( v->get_view_offset() > FG_2PI ) {
|
||||
v->inc_view_offset( -FG_2PI );
|
||||
} else if ( v->get_view_offset() < 0 ) {
|
||||
v->inc_view_offset( FG_2PI );
|
||||
if ( current_view.get_view_offset() > FG_2PI ) {
|
||||
current_view.inc_view_offset( -FG_2PI );
|
||||
} else if ( current_view.get_view_offset() < 0 ) {
|
||||
current_view.inc_view_offset( FG_2PI );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double tmp = -(l->sun_rotation + FG_PI)
|
||||
- (f->get_Psi() - v->get_view_offset() );
|
||||
- (cur_fdm_state.get_Psi() - current_view.get_view_offset() );
|
||||
while ( tmp < 0.0 ) {
|
||||
tmp += FG_2PI;
|
||||
}
|
||||
|
@ -517,7 +542,7 @@ void fgUpdateTimeDepCalcs(int multi_loop, int remainder) {
|
|||
tmp -= FG_2PI;
|
||||
}
|
||||
/* printf("Psi = %.2f, viewoffset = %.2f sunrot = %.2f rottosun = %.2f\n",
|
||||
FG_Psi * RAD_TO_DEG, v->view_offset * RAD_TO_DEG,
|
||||
FG_Psi * RAD_TO_DEG, current_view.view_offset * RAD_TO_DEG,
|
||||
-(l->sun_rotation+FG_PI) * RAD_TO_DEG, tmp * RAD_TO_DEG); */
|
||||
l->UpdateAdjFog();
|
||||
}
|
||||
|
@ -540,7 +565,6 @@ static const double alt_adjust_m = alt_adjust_ft * FEET_TO_METER;
|
|||
// 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 ) {
|
||||
FGInterface *f;
|
||||
FGTime *t;
|
||||
static long remainder = 0;
|
||||
long elapsed, multi_loop;
|
||||
|
@ -552,7 +576,6 @@ static void fgMainLoop( void ) {
|
|||
static int frames = 0;
|
||||
#endif // FANCY_FRAME_COUNTER
|
||||
|
||||
f = current_aircraft.fdm_state;
|
||||
t = FGTime::cur_time_params;
|
||||
|
||||
FG_LOG( FG_ALL, FG_DEBUG, "Running Main Loop");
|
||||
|
@ -578,15 +601,15 @@ static void fgMainLoop( void ) {
|
|||
|
||||
/* printf("Before - ground = %.2f runway = %.2f alt = %.2f\n",
|
||||
scenery.cur_elev,
|
||||
f->get_Runway_altitude() * FEET_TO_METER,
|
||||
f->get_Altitude() * FEET_TO_METER); */
|
||||
cur_fdm_state.get_Runway_altitude() * FEET_TO_METER,
|
||||
cur_fdm_state.get_Altitude() * FEET_TO_METER); */
|
||||
|
||||
if ( scenery.cur_elev > -9990 ) {
|
||||
if ( f->get_Altitude() * FEET_TO_METER <
|
||||
if ( cur_fdm_state.get_Altitude() * FEET_TO_METER <
|
||||
(scenery.cur_elev + alt_adjust_m - 3.0) ) {
|
||||
// now set aircraft altitude above ground
|
||||
printf("Current Altitude = %.2f < %.2f forcing to %.2f\n",
|
||||
f->get_Altitude() * FEET_TO_METER,
|
||||
cur_fdm_state.get_Altitude() * FEET_TO_METER,
|
||||
scenery.cur_elev + alt_adjust_m - 3.0,
|
||||
scenery.cur_elev + alt_adjust_m );
|
||||
fgFDMForceAltitude( current_options.get_flight_model(),
|
||||
|
@ -594,7 +617,7 @@ static void fgMainLoop( void ) {
|
|||
|
||||
FG_LOG( FG_ALL, FG_DEBUG,
|
||||
"<*> resetting altitude to "
|
||||
<< f->get_Altitude() * FEET_TO_METER << " meters" );
|
||||
<< cur_fdm_state.get_Altitude() * FEET_TO_METER << " meters" );
|
||||
}
|
||||
fgFDMSetGroundElevation( current_options.get_flight_model(),
|
||||
scenery.cur_elev ); // meters
|
||||
|
@ -602,11 +625,11 @@ static void fgMainLoop( void ) {
|
|||
|
||||
/* printf("Adjustment - ground = %.2f runway = %.2f alt = %.2f\n",
|
||||
scenery.cur_elev,
|
||||
f->get_Runway_altitude() * FEET_TO_METER,
|
||||
f->get_Altitude() * FEET_TO_METER); */
|
||||
cur_fdm_state.get_Runway_altitude() * FEET_TO_METER,
|
||||
cur_fdm_state.get_Altitude() * FEET_TO_METER); */
|
||||
|
||||
// update "time"
|
||||
t->update(f);
|
||||
t->update(cur_fdm_state);
|
||||
|
||||
// Get elapsed time (in usec) for this past frame
|
||||
elapsed = fgGetTimeInterval();
|
||||
|
@ -695,16 +718,16 @@ static void fgMainLoop( void ) {
|
|||
|
||||
double pitch = log((controls.get_throttle(0) * 14.0) + 1.0);
|
||||
//fprintf(stderr, "pitch1: %f ", pitch);
|
||||
if (controls.get_throttle(0) > 0.0 || f->v_rel_wind > 40.0) {
|
||||
//fprintf(stderr, "rel_wind: %f ", f->v_rel_wind);
|
||||
if (controls.get_throttle(0) > 0.0 || cur_fdm_state.v_rel_wind > 40.0) {
|
||||
//fprintf(stderr, "rel_wind: %f ", cur_fdm_state.v_rel_wind);
|
||||
// only add relative wind and AoA if prop is moving
|
||||
// or we're really flying at idle throttle
|
||||
if (pitch < 5.4) { // this needs tuning
|
||||
// prop tips not breaking sound barrier
|
||||
pitch += log(f->v_rel_wind + 0.8)/2;
|
||||
pitch += log(cur_fdm_state.v_rel_wind + 0.8)/2;
|
||||
} else {
|
||||
// prop tips breaking sound barrier
|
||||
pitch += log(f->v_rel_wind + 0.8)/10;
|
||||
pitch += log(cur_fdm_state.v_rel_wind + 0.8)/10;
|
||||
}
|
||||
//fprintf(stderr, "pitch2: %f ", pitch);
|
||||
//fprintf(stderr, "AoA: %f ", FG_Gamma_vert_rad);
|
||||
|
@ -712,7 +735,7 @@ static void fgMainLoop( void ) {
|
|||
// Angle of Attack next... -x^3(e^x) is my best guess Just
|
||||
// need to calculate some reasonable scaling factor and
|
||||
// then clamp it on the positive aoa (neg adj) side
|
||||
double aoa = f->get_Gamma_vert_rad() * 2.2;
|
||||
double aoa = cur_fdm_state.get_Gamma_vert_rad() * 2.2;
|
||||
double tmp = 3.0;
|
||||
double aoa_adj = pow(-aoa, tmp) * pow(M_E, aoa);
|
||||
if (aoa_adj < -0.8) aoa_adj = -0.8;
|
||||
|
@ -726,7 +749,7 @@ static void fgMainLoop( void ) {
|
|||
//fprintf(stderr, "pitch4: %f\n", pitch);
|
||||
|
||||
double volume = controls.get_throttle(0) * 1.15 + 0.3 +
|
||||
log(f->v_rel_wind + 1.0)/14.0;
|
||||
log(cur_fdm_state.v_rel_wind + 1.0)/14.0;
|
||||
// fprintf(stderr, "volume: %f\n", volume);
|
||||
|
||||
pitch_envelope.setStep ( 0, 0.01, pitch );
|
||||
|
@ -920,7 +943,7 @@ void fgReshape( int width, int height ) {
|
|||
// yes we've finished all our initializations and are running
|
||||
// the main loop, so this will now work without seg faulting
|
||||
// the system.
|
||||
current_view.UpdateViewParams();
|
||||
current_view.UpdateViewParams(cur_fdm_state);
|
||||
if ( current_options.get_panel_status() ) {
|
||||
FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
|
||||
}
|
||||
|
|
|
@ -174,6 +174,7 @@ fgOPTIONS::fgOPTIONS() :
|
|||
wireframe(0),
|
||||
xsize(640),
|
||||
ysize(480),
|
||||
view_mode(FG_VIEW_FIRST_PERSON),
|
||||
|
||||
// Scenery options
|
||||
tile_diameter(5),
|
||||
|
|
|
@ -104,6 +104,12 @@ public:
|
|||
FG_MOUSE = 2
|
||||
};
|
||||
|
||||
enum fgViewMode
|
||||
{
|
||||
FG_VIEW_FIRST_PERSON = 0,
|
||||
FG_VIEW_FOLLOW = 1
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
// The flight gear "root" directory
|
||||
|
@ -148,6 +154,7 @@ private:
|
|||
bool textures; // Textures enabled/disabled
|
||||
bool wireframe; // Wireframe mode enabled/disabled
|
||||
int xsize, ysize; // window size derived from geometry string
|
||||
fgViewMode view_mode; // view mode
|
||||
|
||||
// Scenery options
|
||||
int tile_radius; // Square radius of rendered tiles (around center
|
||||
|
@ -231,6 +238,7 @@ public:
|
|||
inline bool get_wireframe() const { return wireframe; }
|
||||
inline int get_xsize() const { return xsize; }
|
||||
inline int get_ysize() const { return ysize; }
|
||||
inline fgViewMode get_view_mode() const { return view_mode; }
|
||||
inline int get_tile_radius() const { return tile_radius; }
|
||||
inline int get_tile_diameter() const { return tile_diameter; }
|
||||
|
||||
|
@ -262,8 +270,16 @@ public:
|
|||
}
|
||||
}
|
||||
void toggle_panel();
|
||||
inline void set_xsize( int x ) { xsize= x; }
|
||||
inline void set_ysize( int y ) { xsize= y; }
|
||||
inline void set_xsize( int x ) { xsize = x; }
|
||||
inline void set_ysize( int y ) { ysize = y; }
|
||||
inline void cycle_view_mode() {
|
||||
if ( view_mode == FG_VIEW_FIRST_PERSON ) {
|
||||
view_mode = FG_VIEW_FOLLOW;
|
||||
} else if ( view_mode == FG_VIEW_FOLLOW ) {
|
||||
view_mode = FG_VIEW_FIRST_PERSON;
|
||||
}
|
||||
}
|
||||
|
||||
inline void set_net_id( const string id ) { net_id = id; }
|
||||
|
||||
private:
|
||||
|
|
|
@ -62,7 +62,12 @@ static int panel_hist = 0;
|
|||
static const bool use_larcsim_local_to_body = false;
|
||||
|
||||
|
||||
// This is a record containing current view parameters
|
||||
// This is a record containing current view parameters for the current
|
||||
// aircraft position
|
||||
FGView pilot_view;
|
||||
|
||||
// This is a record containing current view parameters for the current
|
||||
// view position
|
||||
FGView current_view;
|
||||
|
||||
|
||||
|
@ -75,7 +80,6 @@ FGView::FGView( void ) {
|
|||
void FGView::Init( void ) {
|
||||
FG_LOG( FG_VIEW, FG_INFO, "Initializing View parameters" );
|
||||
|
||||
view_mode = FG_VIEW_FIRST_PERSON;
|
||||
view_offset = 0.0;
|
||||
goal_view_offset = 0.0;
|
||||
|
||||
|
@ -131,20 +135,8 @@ void FGView::UpdateFOV( const fgOPTIONS& o ) {
|
|||
}
|
||||
|
||||
|
||||
// Cycle view mode
|
||||
void FGView::cycle_view_mode() {
|
||||
if ( view_mode == FG_VIEW_FIRST_PERSON ) {
|
||||
view_mode = FG_VIEW_FOLLOW;
|
||||
} else if ( view_mode == FG_VIEW_FOLLOW ) {
|
||||
view_mode = FG_VIEW_FIRST_PERSON;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update the view volume, position, and orientation
|
||||
void FGView::UpdateViewParams( void ) {
|
||||
FGInterface *f = current_aircraft.fdm_state;
|
||||
|
||||
void FGView::UpdateViewParams( const FGInterface& f ) {
|
||||
UpdateViewMath(f);
|
||||
|
||||
if ((current_options.get_panel_status() != panel_hist) && (current_options.get_panel_status()))
|
||||
|
@ -281,7 +273,7 @@ void getRotMatrix(double* out, MAT3vec vec, double radians)
|
|||
|
||||
|
||||
// Update the view parameters
|
||||
void FGView::UpdateViewMath( FGInterface *f ) {
|
||||
void FGView::UpdateViewMath( const FGInterface& f ) {
|
||||
Point3D p;
|
||||
MAT3vec vec, forward, v0, minus_z;
|
||||
MAT3mat R, TMP, UP, LOCAL, VIEW;
|
||||
|
@ -300,18 +292,18 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
// scenery.center.y, scenery.center.z);
|
||||
|
||||
// calculate the cartesion coords of the current lat/lon/0 elev
|
||||
p = Point3D( f->get_Longitude(),
|
||||
f->get_Lat_geocentric(),
|
||||
f->get_Sea_level_radius() * FEET_TO_METER );
|
||||
p = Point3D( f.get_Longitude(),
|
||||
f.get_Lat_geocentric(),
|
||||
f.get_Sea_level_radius() * FEET_TO_METER );
|
||||
|
||||
cur_zero_elev = fgPolarToCart3d(p) - scenery.center;
|
||||
|
||||
// calculate view position in current FG view coordinate system
|
||||
// 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 ( f->get_Altitude() * FEET_TO_METER >
|
||||
if ( f.get_Altitude() * FEET_TO_METER >
|
||||
(scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
|
||||
p.setz( p.radius() + f->get_Altitude() * FEET_TO_METER );
|
||||
p.setz( p.radius() + f.get_Altitude() * FEET_TO_METER );
|
||||
} else {
|
||||
p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
|
||||
}
|
||||
|
@ -320,26 +312,26 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
|
||||
#else // FG_VIEW_INLINE_OPTIMIZATIONS
|
||||
|
||||
double tmp_radius = f->get_Sea_level_radius() * FEET_TO_METER;
|
||||
double tmp = f->get_cos_lat_geocentric() * tmp_radius;
|
||||
double tmp_radius = f.get_Sea_level_radius() * FEET_TO_METER;
|
||||
double tmp = f.get_cos_lat_geocentric() * tmp_radius;
|
||||
|
||||
cur_zero_elev.setx(f->get_cos_longitude()*tmp - scenery.center.x());
|
||||
cur_zero_elev.sety(f->get_sin_longitude()*tmp - scenery.center.y());
|
||||
cur_zero_elev.setz(f->get_sin_lat_geocentric()*tmp_radius - scenery.center.z());
|
||||
cur_zero_elev.setx(f.get_cos_longitude()*tmp - scenery.center.x());
|
||||
cur_zero_elev.sety(f.get_sin_longitude()*tmp - scenery.center.y());
|
||||
cur_zero_elev.setz(f.get_sin_lat_geocentric()*tmp_radius - scenery.center.z());
|
||||
|
||||
// calculate view position in current FG view coordinate system
|
||||
// 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 ( f->get_Altitude() * FEET_TO_METER >
|
||||
if ( f.get_Altitude() * FEET_TO_METER >
|
||||
(scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
|
||||
tmp_radius += f->get_Altitude() * FEET_TO_METER;
|
||||
tmp_radius += f.get_Altitude() * FEET_TO_METER;
|
||||
} else {
|
||||
tmp_radius += scenery.cur_elev + 0.5 * METER_TO_FEET ;
|
||||
}
|
||||
tmp = f->get_cos_lat_geocentric() * tmp_radius;
|
||||
abs_view_pos.setx(f->get_cos_longitude()*tmp);
|
||||
abs_view_pos.sety(f->get_sin_longitude()*tmp);
|
||||
abs_view_pos.setz(f->get_sin_lat_geocentric()*tmp_radius);
|
||||
tmp = f.get_cos_lat_geocentric() * tmp_radius;
|
||||
abs_view_pos.setx(f.get_cos_longitude()*tmp);
|
||||
abs_view_pos.sety(f.get_sin_longitude()*tmp);
|
||||
abs_view_pos.setz(f.get_sin_lat_geocentric()*tmp_radius);
|
||||
|
||||
#endif // FG_VIEW_INLINE_OPTIMIZATIONS
|
||||
|
||||
|
@ -360,17 +352,17 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
// Answer (I think): The LaRCsim matrix is generated in a
|
||||
// different reference frame than we've set up for our world
|
||||
|
||||
LOCAL[0][0] = f->get_T_local_to_body_33();
|
||||
LOCAL[0][1] = -f->get_T_local_to_body_32();
|
||||
LOCAL[0][2] = -f->get_T_local_to_body_31();
|
||||
LOCAL[0][0] = f.get_T_local_to_body_33();
|
||||
LOCAL[0][1] = -f.get_T_local_to_body_32();
|
||||
LOCAL[0][2] = -f.get_T_local_to_body_31();
|
||||
LOCAL[0][3] = 0.0;
|
||||
LOCAL[1][0] = -f->get_T_local_to_body_23();
|
||||
LOCAL[1][1] = f->get_T_local_to_body_22();
|
||||
LOCAL[1][2] = f->get_T_local_to_body_21();
|
||||
LOCAL[1][0] = -f.get_T_local_to_body_23();
|
||||
LOCAL[1][1] = f.get_T_local_to_body_22();
|
||||
LOCAL[1][2] = f.get_T_local_to_body_21();
|
||||
LOCAL[1][3] = 0.0;
|
||||
LOCAL[2][0] = -f->get_T_local_to_body_13();
|
||||
LOCAL[2][1] = f->get_T_local_to_body_12();
|
||||
LOCAL[2][2] = f->get_T_local_to_body_11();
|
||||
LOCAL[2][0] = -f.get_T_local_to_body_13();
|
||||
LOCAL[2][1] = f.get_T_local_to_body_12();
|
||||
LOCAL[2][2] = f.get_T_local_to_body_11();
|
||||
LOCAL[2][3] = 0.0;
|
||||
LOCAL[3][0] = LOCAL[3][1] = LOCAL[3][2] = LOCAL[3][3] = 0.0;
|
||||
LOCAL[3][3] = 1.0;
|
||||
|
@ -411,18 +403,18 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
// flight model
|
||||
|
||||
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
||||
MAT3rotate(R, vec, f->get_Phi());
|
||||
MAT3rotate(R, vec, f.get_Phi());
|
||||
// cout << "Roll matrix" << endl;
|
||||
// MAT3print(R, stdout);
|
||||
|
||||
sgVec3 sgrollvec;
|
||||
sgSetVec3( sgrollvec, 0.0, 0.0, 1.0 );
|
||||
sgMat4 sgPHI; // roll
|
||||
sgMakeRotMat4( sgPHI, f->get_Phi() * RAD_TO_DEG, sgrollvec );
|
||||
sgMakeRotMat4( sgPHI, f.get_Phi() * RAD_TO_DEG, sgrollvec );
|
||||
|
||||
|
||||
MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
|
||||
MAT3rotate(TMP, vec, f->get_Theta());
|
||||
MAT3rotate(TMP, vec, f.get_Theta());
|
||||
// cout << "Pitch matrix" << endl;;
|
||||
// MAT3print(TMP, stdout);
|
||||
MAT3mult(R, R, TMP);
|
||||
|
@ -432,7 +424,7 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
sgVec3 sgpitchvec;
|
||||
sgSetVec3( sgpitchvec, 0.0, 1.0, 0.0 );
|
||||
sgMat4 sgTHETA; // pitch
|
||||
sgMakeRotMat4( sgTHETA, f->get_Theta() * RAD_TO_DEG,
|
||||
sgMakeRotMat4( sgTHETA, f.get_Theta() * RAD_TO_DEG,
|
||||
sgpitchvec );
|
||||
|
||||
sgMat4 sgROT;
|
||||
|
@ -440,7 +432,7 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
|
||||
|
||||
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
|
||||
MAT3rotate(TMP, vec, -f->get_Psi());
|
||||
MAT3rotate(TMP, vec, -f.get_Psi());
|
||||
// cout << "Yaw matrix" << endl;
|
||||
// MAT3print(TMP, stdout);
|
||||
MAT3mult(LOCAL, R, TMP);
|
||||
|
@ -450,7 +442,7 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
sgVec3 sgyawvec;
|
||||
sgSetVec3( sgyawvec, 1.0, 0.0, 0.0 );
|
||||
sgMat4 sgPSI; // pitch
|
||||
sgMakeRotMat4( sgPSI, -f->get_Psi() * RAD_TO_DEG, sgyawvec );
|
||||
sgMakeRotMat4( sgPSI, -f.get_Psi() * RAD_TO_DEG, sgyawvec );
|
||||
|
||||
sgMultMat4( sgLOCAL, sgROT, sgPSI );
|
||||
|
||||
|
@ -472,13 +464,13 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
// Derive the local UP transformation matrix based on *geodetic*
|
||||
// coordinates
|
||||
MAT3_SET_VEC(vec, 0.0, 0.0, 1.0);
|
||||
MAT3rotate(R, vec, f->get_Longitude()); // R = rotate about Z axis
|
||||
MAT3rotate(R, vec, f.get_Longitude()); // R = rotate about Z axis
|
||||
// printf("Longitude matrix\n");
|
||||
// MAT3print(R, stdout);
|
||||
|
||||
MAT3_SET_VEC(vec, 0.0, 1.0, 0.0);
|
||||
MAT3mult_vec(vec, vec, R);
|
||||
MAT3rotate(TMP, vec, -f->get_Latitude()); // TMP = rotate about X axis
|
||||
MAT3rotate(TMP, vec, -f.get_Latitude()); // TMP = rotate about X axis
|
||||
// printf("Latitude matrix\n");
|
||||
// MAT3print(TMP, stdout);
|
||||
|
||||
|
@ -487,9 +479,9 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
// MAT3print(UP, stdout);
|
||||
|
||||
sgMakeRotMat4( sgUP,
|
||||
f->get_Longitude() * RAD_TO_DEG,
|
||||
f.get_Longitude() * RAD_TO_DEG,
|
||||
0.0,
|
||||
-f->get_Latitude() * RAD_TO_DEG );
|
||||
-f.get_Latitude() * RAD_TO_DEG );
|
||||
/*
|
||||
cout << "FG derived UP matrix using sg routines" << endl;
|
||||
MAT3mat print;
|
||||
|
@ -551,9 +543,9 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
|
||||
sgMultMat4( sgVIEW, sgVIEW_ROT, sgTRANS );
|
||||
|
||||
FGMat4Wrapper tmp;
|
||||
sgCopyMat4( tmp.m, sgVIEW );
|
||||
follow.push_back( tmp );
|
||||
// FGMat4Wrapper tmp;
|
||||
// sgCopyMat4( tmp.m, sgVIEW );
|
||||
// follow.push_back( tmp );
|
||||
|
||||
// generate the current up, forward, and fwrd-view vectors
|
||||
MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);
|
||||
|
@ -603,10 +595,10 @@ void FGView::UpdateViewMath( FGInterface *f ) {
|
|||
#else // FG_VIEW_INLINE_OPTIMIZATIONS
|
||||
|
||||
// // Build spherical to cartesian transform matrix directly
|
||||
double cos_lat = f->get_cos_latitude(); // cos(-f->get_Latitude());
|
||||
double sin_lat = -f->get_sin_latitude(); // sin(-f->get_Latitude());
|
||||
double cos_lon = f->get_cos_longitude(); //cos(f->get_Longitude());
|
||||
double sin_lon = f->get_sin_longitude(); //sin(f->get_Longitude());
|
||||
double cos_lat = f.get_cos_latitude(); // cos(-f.get_Latitude());
|
||||
double sin_lat = -f.get_sin_latitude(); // sin(-f.get_Latitude());
|
||||
double cos_lon = f.get_cos_longitude(); //cos(f.get_Longitude());
|
||||
double sin_lon = f.get_sin_longitude(); //sin(f.get_Longitude());
|
||||
|
||||
double *mat = (double *)UP;
|
||||
|
||||
|
|
|
@ -46,14 +46,14 @@
|
|||
FG_USING_STD(list);
|
||||
|
||||
|
||||
class FGMat4Wrapper {
|
||||
public:
|
||||
sgMat4 m;
|
||||
};
|
||||
// class FGMat4Wrapper {
|
||||
// public:
|
||||
// sgMat4 m;
|
||||
// };
|
||||
|
||||
typedef list < FGMat4Wrapper > sgMat4_list;
|
||||
typedef sgMat4_list::iterator sgMat4_list_iterator;
|
||||
typedef sgMat4_list::const_iterator const_sgMat4_list_iterator;
|
||||
// typedef list < FGMat4Wrapper > sgMat4_list;
|
||||
// typedef sgMat4_list::iterator sgMat4_list_iterator;
|
||||
// typedef sgMat4_list::const_iterator const_sgMat4_list_iterator;
|
||||
|
||||
|
||||
// used in views.cxx and tilemgr.cxx
|
||||
|
@ -65,12 +65,6 @@ class FGView {
|
|||
|
||||
public:
|
||||
|
||||
enum fgViewMode
|
||||
{
|
||||
FG_VIEW_FIRST_PERSON = 0,
|
||||
FG_VIEW_FOLLOW = 1
|
||||
};
|
||||
|
||||
// the current offset from forward for viewing
|
||||
double view_offset;
|
||||
|
||||
|
@ -166,14 +160,11 @@ public:
|
|||
// Current model view matrix;
|
||||
GLfloat MODEL_VIEW[16];
|
||||
|
||||
// view mode
|
||||
fgViewMode view_mode;
|
||||
|
||||
// sg versions of our friendly matrices
|
||||
sgMat4 sgLOCAL, sgUP, sgVIEW_ROT, sgTRANS, sgVIEW, sgLARC_TO_SSG;
|
||||
|
||||
// queue of view matrices so we can have a follow view
|
||||
sgMat4_list follow;
|
||||
// sgMat4_list follow;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -187,21 +178,18 @@ public:
|
|||
void Init( void );
|
||||
|
||||
// Update the view volume, position, and orientation
|
||||
void UpdateViewParams( void );
|
||||
void UpdateViewParams( const FGInterface& f );
|
||||
|
||||
// Flag to request that UpdateFOV() be called next time
|
||||
// UpdateViewMath() is run.
|
||||
inline void force_update_fov_math() { update_fov = true; }
|
||||
|
||||
// Update the view parameters
|
||||
void UpdateViewMath( FGInterface *f );
|
||||
void UpdateViewMath( const FGInterface& f );
|
||||
|
||||
// Update the field of view coefficients
|
||||
void UpdateFOV( const fgOPTIONS& o );
|
||||
|
||||
// Cycle view mode
|
||||
void cycle_view_mode();
|
||||
|
||||
// accessor functions
|
||||
inline double get_view_offset() const { return view_offset; }
|
||||
inline void set_view_offset( double a ) { view_offset = a; }
|
||||
|
@ -261,6 +249,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
extern FGView pilot_view;
|
||||
extern FGView current_view;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue