FGViewer *v = globals->get_current_view();
globals->get_options()->set_fov(fov);
fgInitVisuals();
- int cur_width = globals->get_current_view()->get_winWidth( );
- int cur_height = globals->get_current_view()->get_winHeight( );
+ int cur_width = globals->get_options()->get_xsize( );
+ int cur_height = globals->get_options()->get_ysize( );
if (b1) delete( b1 );
// New empty (mostly) bitmap
b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
mainMenuBar->hide();
CGlPrinter p( CGlPrinter::PRINT_BITMAP );
- int cur_width = globals->get_current_view()->get_winWidth( );
- int cur_height = globals->get_current_view()->get_winHeight( );
+ int cur_width = globals->get_options()->get_xsize( );
+ int cur_height = globals->get_options()->get_ysize( );
p.Begin( "FlightGear", cur_width*3, cur_height*3 );
p.End( hiResScreenCapture(3) );
<< (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 current_view.UpdateViewMath()
- // routine doesn't get hosed.
-
+ // We need to calculate a few sea_level_radius here so we can pass
+ // the correct value to the view class
double sea_level_radius_meters;
double lat_geoc;
- // Set the FG variables first
- sgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(),
+ sgGeodToGeoc( cur_fdm_state->get_Latitude(),
+ cur_fdm_state->get_Altitude(),
&sea_level_radius_meters, &lat_geoc);
- /* 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) );
- */
- cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
-
- /* cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
- cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
-
- cur_fdm_state->set_sin_lat_geocentric(sin(lat_geoc));
- cur_fdm_state->set_cos_lat_geocentric(cos(lat_geoc)); */
-
+ cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters *
+ METER_TO_FEET );
// The following section sets up the flight model EOM parameters
// and should really be read in from one or more files.
// Initial Velocity
- //cur_fdm_state->set_Velocities_Local( globals->get_options()->get_uBody(),
- // globals->get_options()->get_vBody(),
- // globals->get_options()->get_wBody());
fgVelocityInit();
// Initial Orientation
- cur_fdm_state->set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
- globals->get_options()->get_pitch() * DEG_TO_RAD,
- globals->get_options()->get_heading() * DEG_TO_RAD );
-
- // Initial Angular Body rates
- //cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
-
- //cur_fdm_state->set_Earth_position_angle( 0.0 );
-
- // Mass properties and geometry values
- //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
- //cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
+ cur_fdm_state->
+ set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
+ globals->get_options()->get_pitch() * DEG_TO_RAD,
+ globals->get_options()->get_heading() * DEG_TO_RAD );
// Initialize the event manager
global_events.Init();
set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
FEET_TO_METER );
globals->get_current_view()->
- set_hpr( cur_fdm_state->get_Psi(),
+ set_rph( cur_fdm_state->get_Phi(),
cur_fdm_state->get_Theta(),
- cur_fdm_state->get_Phi() );
+ cur_fdm_state->get_Psi() );
- // globals->get_current_view()->UpdateViewMath();
- // globals->get_pilot_view()->UpdateViewMath();
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = "
<< globals->get_current_view()->get_abs_view_pos());
- // current_view.UpdateWorldToEye(f);
-
- // Initialize the planetary subsystem
- // global_events.Register( "fgPlanetsInit()", fgPlanetsInit,
- // fgEVENT::FG_EVENT_READY, 600000);
-
- // Initialize the sun's position
- // global_events.Register( "fgSunInit()", fgSunInit,
- // fgEVENT::FG_EVENT_READY, 30000 );
-
- // Intialize the moon's position
- // global_events.Register( "fgMoonInit()", fgMoonInit,
- // fgEVENT::FG_EVENT_READY, 600000 );
// fgUpdateSunPos() needs a few position and view parameters set
// so it can calculate local relative sun angle and a few other
// Initialize the underlying radio stack model
current_radiostack = new FGRadioStack;
-// current_radiostack->set_nav1_freq( 117.30 );
-// current_radiostack->set_nav1_alt_freq( 110.30 );
-// current_radiostack->set_nav1_sel_radial( 119.0 );
-
-// current_radiostack->set_nav2_freq( 111.80 );
-// current_radiostack->set_nav2_alt_freq( 115.70 );
-// current_radiostack->set_nav2_sel_radial( 029.0 );
-
-// current_radiostack->set_adf_freq( 266.0 );
-
-#if 0
- // This block of settings are Alex's defaults for San Diego
- current_radiostack->set_nav1_freq( 111.70 );
- current_radiostack->set_nav1_alt_freq( 115.30 );
- current_radiostack->set_nav1_sel_radial( 280.0 );
- current_radiostack->set_nav2_freq( 117.80 );
- current_radiostack->set_nav2_alt_freq( 114.00 );
- current_radiostack->set_nav2_sel_radial( 68.0 );
- current_radiostack->set_adf_freq( 210.0 );
- // End of Alex's custom settings
-#endif
-
current_radiostack->search( cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
cur_fdm_state->get_Altitude() * FEET_TO_METER );
// Initialize the flight model subsystem data structures base on
// above values
- // fgFDMInit( globals->get_options()->get_flight_model(), cur_fdm_state,
- // 1.0 / globals->get_options()->get_model_hz() );
if ( cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() ) ) {
// fdm init successful
} else {
exit(-1);
}
- // I'm just sticking this here for now, it should probably move
- // eventually
+ // *ABCD* I'm just sticking this here for now, it should probably
+ // move eventually
scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
- 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 );
+ 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,
<< (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
+ // *ABCD* end of thing that I just stuck in that I should probably
+ // move
// Joystick support
- if ( fgJoystickInit() ) {
- // Joystick initialized ok.
- } else {
+ if ( ! fgJoystickInit() ) {
FG_LOG( FG_GENERAL, FG_ALERT, "Error in Joystick initialization!" );
}
"Panels/Default/default.xml");
current_panel = fgReadPanel(panel_path);
if (current_panel == 0) {
- FG_LOG(FG_INPUT, FG_ALERT,
- "Error reading new panel from " << panel_path);
+ FG_LOG( FG_INPUT, FG_ALERT,
+ "Error reading new panel from " << panel_path );
+ } else {
+ FG_LOG( FG_INPUT, FG_INFO, "Loaded new panel from " << panel_path );
}
- FG_LOG(FG_INPUT, FG_INFO, "Loaded new panel from " << panel_path);
// Initialize the BFI
FGBFI::init();
scenery.cur_elev );
// Reset our altitude if we are below ground
- FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = " << cur_fdm_state->get_Altitude() );
- FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = " <<
- cur_fdm_state->get_Runway_altitude() );
+ FG_LOG( FG_GENERAL, FG_DEBUG, "Current altitude = "
+ << cur_fdm_state->get_Altitude() );
+ FG_LOG( FG_GENERAL, FG_DEBUG, "Current runway altitude = "
+ << cur_fdm_state->get_Runway_altitude() );
- 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 );
+ 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
sgGeodToGeoc( cur_fdm_state->get_Latitude(), cur_fdm_state->get_Altitude(),
&sea_level_radius_meters, &lat_geoc);
- /* 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) );
- */
- cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters * METER_TO_FEET );
-
- //cur_fdm_state->set_sin_cos_longitude(cur_fdm_state->get_Longitude());
- //cur_fdm_state->set_sin_cos_latitude(cur_fdm_state->get_Latitude());
+ cur_fdm_state->set_Sea_level_radius( sea_level_radius_meters *
+ METER_TO_FEET );
- //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
- //cur_fdm_state->set_Velocities_Local( globals->get_options()->get_uBody(),
- // globals->get_options()->get_vBody(),
- // globals->get_options()->get_wBody());
fgVelocityInit();
// Initial Orientation
- cur_fdm_state->set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
- globals->get_options()->get_pitch() * DEG_TO_RAD,
- globals->get_options()->get_heading() * DEG_TO_RAD );
-
- // Initial Angular Body rates
- //cur_fdm_state->set_Omega_Body( 7.206685E-05, 0.0, 9.492658E-05 );
-
- //cur_fdm_state->set_Earth_position_angle( 0.0 );
-
- // Mass properties and geometry values
- //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
- //cur_fdm_state->set_CG_Position( 0.0, 0.0, 0.0 );
+ cur_fdm_state->
+ set_Euler_Angles( globals->get_options()->get_roll() * DEG_TO_RAD,
+ globals->get_options()->get_pitch() * DEG_TO_RAD,
+ globals->get_options()->get_heading() * DEG_TO_RAD );
// Initialize view parameters
globals->get_current_view()->set_view_offset( 0.0 );
globals->get_current_view()->set_goal_view_offset( 0.0 );
- // globals->get_pilot_view()->set_view_offset( 0.0 );
- // globals->get_pilot_view()->set_goal_view_offset( 0.0 );
FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
FEET_TO_METER );
globals->get_current_view()->
- set_hpr( cur_fdm_state->get_Psi(),
+ set_rph( cur_fdm_state->get_Phi(),
cur_fdm_state->get_Theta(),
- cur_fdm_state->get_Phi() );
+ cur_fdm_state->get_Psi() );
- // globals->get_current_view()->UpdateViewMath();
- // globals->get_pilot_view()->UpdateViewMath();
FG_LOG( FG_GENERAL, FG_DEBUG, " abs_view_pos = "
<< globals->get_current_view()->get_abs_view_pos());
- // fgFDMInit( globals->get_options()->get_flight_model(), cur_fdm_state,
- // 1.0 / globals->get_options()->get_model_hz() );
cur_fdm_state->init( 1.0 / globals->get_options()->get_model_hz() );
scenery.cur_elev = cur_fdm_state->get_Runway_altitude() * FEET_TO_METER;
- 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 );
+ 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();
// Handle keyboard events
void GLUTkey(unsigned char k, int x, int y) {
FGInterface *f;
- SGTime *t;
FGViewer *v;
float fov, tmp;
static bool winding_ccw = true;
set_sea_level_radius( cur_fdm_state->get_Sea_level_radius() *
FEET_TO_METER );
globals->get_current_view()->
- set_hpr( cur_fdm_state->get_Psi(),
+ set_rph( cur_fdm_state->get_Phi(),
cur_fdm_state->get_Theta(),
- cur_fdm_state->get_Phi() );
+ cur_fdm_state->get_Psi() );
// update view volume parameters
// cout << "before pilot_view update" << endl;
// update the sky dome
if ( globals->get_options()->get_skyblend() ) {
- sgVec3 view_pos;
- sgSetVec3( view_pos,
- globals->get_current_view()->get_view_pos().x(),
- globals->get_current_view()->get_view_pos().y(),
- globals->get_current_view()->get_view_pos().z() );
-
sgVec3 zero_elev;
sgSetVec3( zero_elev,
globals->get_current_view()->get_cur_zero_elev().x(),
<< " moon ra = " << globals->get_ephem()->getMoonRightAscension()
<< " moon dec = " << globals->get_ephem()->getMoonDeclination() << endl; */
- thesky->reposition( view_pos, zero_elev,
+ thesky->reposition( globals->get_current_view()->get_view_pos(),
+ zero_elev,
globals->get_current_view()->get_local_up(),
cur_fdm_state->get_Longitude(),
cur_fdm_state->get_Latitude(),
sgMat4 sgTRANS;
sgMakeTransMat4( sgTRANS,
- globals->get_current_view()->get_view_pos().x(),
- globals->get_current_view()->get_view_pos().y(),
- globals->get_current_view()->get_view_pos().z() );
+ globals->get_current_view()->get_view_pos() );
sgVec3 ownship_up;
sgSetVec3( ownship_up, 0.0, 0.0, 1.0);
// Update the view parameters
void FGViewer::update() {
- sgVec3 v0, minus_z, forward;
+ sgVec3 minus_z, forward;
sgMat4 VIEWo;
// calculate the cartesion coords of the current lat/lon/0 elev
- Point3D p = Point3D( geod_view_pos.lon(),
- geod_view_pos.lat(),
+ Point3D p = Point3D( geod_view_pos[0],
+ geod_view_pos[1],
sea_level_radius );
cur_zero_elev = sgPolarToCart3d(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 ( geod_view_pos.elev() > (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
- p.setz( p.radius() + geod_view_pos.elev() );
+ if ( geod_view_pos[2] > (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
+ p.setz( p.radius() + geod_view_pos[2] );
} else {
p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
}
- abs_view_pos = sgPolarToCart3d(p);
-
- view_pos = abs_view_pos - scenery.center;
+ Point3D tmp = sgPolarToCart3d(p);
+ sgdSetVec3( abs_view_pos, tmp[0], tmp[1], tmp[2] );
+
+ sgdVec3 sc;
+ sgdSetVec3( sc, scenery.center.x(), scenery.center.y(), scenery.center.z());
+ sgdVec3 vp;
+ sgdSubVec3( vp, abs_view_pos, sc );
+ sgSetVec3( view_pos, vp );
+ // view_pos = abs_view_pos - scenery.center;
FG_LOG( FG_VIEW, FG_DEBUG, "sea level radius = " << sea_level_radius );
FG_LOG( FG_VIEW, FG_DEBUG, "Polar view pos = " << p );
- FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = " << abs_view_pos );
- FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = " << view_pos );
+ FG_LOG( FG_VIEW, FG_DEBUG, "Absolute view pos = "
+ << abs_view_pos[0] << ","
+ << abs_view_pos[1] << ","
+ << abs_view_pos[2] );
+ FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = "
+ << view_pos[0] << "," << view_pos[1] << "," << view_pos[2] );
// code to calculate LOCAL matrix calculated from Phi, Theta, and
// Psi (roll, pitch, yaw) in case we aren't running LaRCsim as our
#ifdef USE_FAST_LOCAL
- fgMakeLOCAL( LOCAL, hpr[1], hpr[2], -hpr[0] );
+ fgMakeLOCAL( LOCAL, rph[1], rph[0], -rph[2] );
#else // USE_TEXT_BOOK_METHOD
sgVec3 rollvec;
sgSetVec3( rollvec, 0.0, 0.0, 1.0 );
sgMat4 PHI; // roll
- sgMakeRotMat4( PHI, hpr[2] * RAD_TO_DEG, rollvec );
+ sgMakeRotMat4( PHI, rph[0] * RAD_TO_DEG, rollvec );
sgVec3 pitchvec;
sgSetVec3( pitchvec, 0.0, 1.0, 0.0 );
sgMat4 THETA; // pitch
- sgMakeRotMat4( THETA, hpr[1] * RAD_TO_DEG, pitchvec );
+ sgMakeRotMat4( THETA, rph[1] * RAD_TO_DEG, pitchvec );
// ROT = PHI * THETA
sgMat4 ROT;
sgVec3 yawvec;
sgSetVec3( yawvec, 1.0, 0.0, 0.0 );
sgMat4 PSI; // heading
- sgMakeRotMat4( PSI, -hpr[0] * RAD_TO_DEG, yawvec );
+ sgMakeRotMat4( PSI, -rph[2] * RAD_TO_DEG, yawvec );
// LOCAL = ROT * PSI
// sgMultMat4( LOCAL, ROT, PSI );
// print_sgMat4( LOCAL );
sgMakeRotMat4( UP,
- geod_view_pos.lon() * RAD_TO_DEG,
+ geod_view_pos[0] * RAD_TO_DEG,
0.0,
- -geod_view_pos.lat() * RAD_TO_DEG );
+ -geod_view_pos[1] * RAD_TO_DEG );
sgSetVec3( local_up, UP[0][0], UP[0][1], UP[0][2] );
// sgXformVec3( local_up, UP );
// print_sgMat4( VIEW_ROT );
sgVec3 trans_vec;
- sgSetVec3( trans_vec,
- view_pos.x() + pilot_offset_world[0],
- view_pos.y() + pilot_offset_world[1],
- view_pos.z() + pilot_offset_world[2] );
+ sgAddVec3( trans_vec, view_pos, pilot_offset_world );
// VIEW = VIEW_ROT * TRANS
sgCopyMat4( VIEW, VIEW_ROT );
sgPreMultMat4( VIEW, quat_mat);
// !!!!!!!!!! testing
- // make a vector to the current view position
- sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
-
// Given a vector pointing straight down (-Z), map into onto the
// local plane representing "horizontal". This should give us the
// local direction for moving "south".
sgSetVec3( minus_z, 0.0, 0.0, -1.0 );
- sgmap_vec_onto_cur_surface_plane(local_up, v0, minus_z, surface_south);
+ sgmap_vec_onto_cur_surface_plane(local_up, view_pos, minus_z,
+ surface_south);
sgNormalizeVec3(surface_south);
// cout << "Surface direction directly south " << surface_south[0] << ","
// << surface_south[1] << "," << surface_south[2] << endl;
double goal_view_offset;
// geodetic view position
- Point3D geod_view_pos;
+ sgdVec3 geod_view_pos;
// radius to sea level from center of the earth (m)
double sea_level_radius;
// absolute view position in earth coordinates
- Point3D abs_view_pos;
+ sgdVec3 abs_view_pos;
// view position in opengl world coordinates (this is the
// abs_view_pos translated to scenery.center)
- Point3D view_pos;
+ sgVec3 view_pos;
// pilot offset from center of gravity. The X axis is positive
// out the tail, Y is out the right wing, and Z is positive up.
// Distances in meters of course.
sgVec3 pilot_offset;
- // view orientation (heading, pitch, roll)
- sgVec3 hpr;
+ // view orientation (roll, pitch, heading)
+ sgVec3 rph;
// cartesion coordinates of current lon/lat if at sea level
// translated to scenery.center
dirty = true;
// cout << "set_geod_view_pos = " << lon << ", " << lat << ", " << alt
// << endl;
- geod_view_pos = Point3D( lon, lat, alt );
+ sgdSetVec3( geod_view_pos, lon, lat, alt );
}
inline void set_sea_level_radius( double r ) {
// data should be in meters from the center of the earth
dirty = true;
sea_level_radius = r;
}
- inline void set_hpr( double h, double p, double r ) {
+ inline void set_rph( double r, double p, double h ) {
// data should be in radians
dirty = true;
- sgSetVec3( hpr, h, p, r );
+ sgSetVec3( rph, r, p, h );
}
inline void set_pilot_offset( float x, float y, float z ) {
dirty = true;
inline double get_goal_view_offset() const { return goal_view_offset; }
inline float *get_pilot_offset() { return pilot_offset; }
inline double get_sea_level_radius() const { return sea_level_radius; }
- inline float *get_hpr() { return hpr; }
+ inline float *get_rph() { return rph; }
//////////////////////////////////////////////////////////////////////
// derived values accessor functions
//////////////////////////////////////////////////////////////////////
- inline Point3D get_abs_view_pos() {
+ inline double *get_abs_view_pos() {
if ( dirty ) { update(); }
return abs_view_pos;
}
- inline Point3D get_view_pos() {
+ inline float *get_view_pos() {
if ( dirty ) { update(); }
return view_pos;
}
FGTileCache::next_avail( void )
{
// Point3D delta;
- Point3D abs_view_pos;
+ sgdVec3 abs_view_pos;
int i;
// float max, med, min, tmp;
float dist, max_dist;
return(i);
} else if ( tile_cache[i].is_loaded() || tile_cache[i].is_cached() ) {
// calculate approximate distance from view point
- abs_view_pos = globals->get_current_view()->get_abs_view_pos();
+ sgdCopyVec3( abs_view_pos,
+ globals->get_current_view()->get_abs_view_pos() );
- FG_LOG( FG_TERRAIN, FG_DEBUG,
- "DIST Abs view pos = " << abs_view_pos );
+ FG_LOG( FG_TERRAIN, FG_DEBUG, "DIST Abs view pos = "
+ << abs_view_pos[0] << ","
+ << abs_view_pos[1] << ","
+ << abs_view_pos[2] );
FG_LOG( FG_TERRAIN, FG_DEBUG,
" ref point = " << tile_cache[i].center );
dist = max + (med + min) / 4;
*/
- dist = tile_cache[i].center.distance3D( abs_view_pos );
+ sgdVec3 center;
+ sgdSetVec3( center,
+ tile_cache[i].center[0],
+ tile_cache[i].center[1],
+ tile_cache[i].center[2] );
+ dist = sgdDistanceVec3( center, abs_view_pos );
FG_LOG( FG_TERRAIN, FG_DEBUG, " distance = " << dist );
// meters.
bool
-FGTileMgr::current_elev_ssg( const Point3D& abs_view_pos,
- const Point3D& view_pos )
+FGTileMgr::current_elev_ssg( sgdVec3 abs_view_pos,
+ sgVec3 view_pos )
{
sgdVec3 orig, dir;
- sgdSetVec3(orig, view_pos.x(), view_pos.y(), view_pos.z() );
- sgdSetVec3(dir, abs_view_pos.x(), abs_view_pos.y(), abs_view_pos.z() );
+ sgdSetVec3(orig, view_pos );
+ sgdCopyVec3(dir, abs_view_pos );
hit_list.Intersect( terrain, orig, dir );
if ( scenery.center == Point3D(0.0) ) {
// initializing
// cout << "initializing ... " << endl;
+ sgdVec3 tmp_abs_view_pos;
+ sgVec3 tmp_view_pos;
+
Point3D geod_pos = Point3D( longitude * DEG_TO_RAD,
latitude * DEG_TO_RAD,
0.0);
- Point3D tmp_abs_view_pos = sgGeodToCart( geod_pos );
- scenery.center = tmp_abs_view_pos;
+ Point3D tmp = sgGeodToCart( geod_pos );
+ scenery.center = tmp;
+ sgdSetVec3( tmp_abs_view_pos, tmp.x(), tmp.y(), tmp.z() );
+
// cout << "abs_view_pos = " << tmp_abs_view_pos << endl;
prep_ssg_nodes();
- current_elev_ssg( tmp_abs_view_pos,
- Point3D( 0.0 ) );
+ sgSetVec3( tmp_view_pos, 0.0, 0.0, 0.0 );
+ current_elev_ssg( tmp_abs_view_pos, tmp_view_pos );
} else {
// cout << "abs view pos = " << current_view.abs_view_pos
// << " view pos = " << current_view.view_pos << endl;
const sgdVec3 p, const sgdVec3 dir,
FGHitList *list );
- bool current_elev_ssg( const Point3D& abs_view_pos,
- const Point3D& view_pos );
+ bool current_elev_ssg( sgdVec3 abs_view_pos,
+ sgVec3 view_pos );
// Prepare the ssg nodes ... for each tile, set it's proper
// transform and update it's range selector based on current
-// moonpos.cxx (basically, this is a slightly modified version of the 'sunpos.cxx' file, adapted from XEarth)
-
+// moonpos.cxx (basically, this is a slightly modified version of the
+// 'sunpos.cxx' file, adapted from XEarth)
+//
// kirk johnson
// july 1993
//
void fgUpdateMoonPos( void ) {
fgLIGHT *l;
FGViewer *v;
- sgVec3 nup, nmoon, v0, surface_to_moon;
+ sgVec3 nup, nmoon, surface_to_moon;
Point3D p, rel_moonpos;
double dot, east_dot;
double moon_gd_lat, sl_radius;
<< l->moon_angle << endl;
// calculate vector to moon's position on the earth's surface
- rel_moonpos = l->fg_moonpos - (v->get_view_pos() + scenery.center);
+ Point3D vp( v->get_view_pos()[0],
+ v->get_view_pos()[1],
+ v->get_view_pos()[1] );
+ rel_moonpos = l->fg_moonpos - ( vp + scenery.center );
v->set_to_moon( rel_moonpos.x(), rel_moonpos.y(), rel_moonpos.z() );
// printf( "Vector to moon = %.2f %.2f %.2f\n",
// v->to_moon[0], v->to_moon[1], v->to_moon[2]);
- // make a vector to the current view position
- Point3D view_pos = v->get_view_pos();
- sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
-
// Given a vector from the view position to the point on the
// earth's surface the moon is directly over, map into onto the
// local plane representing "horizontal".
- sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v0,
+ sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v->get_view_pos(),
v->get_to_moon(), surface_to_moon );
sgNormalizeVec3(surface_to_moon);
v->set_surface_to_moon( surface_to_moon[0], surface_to_moon[1],
void fgUpdateSunPos( void ) {
fgLIGHT *l;
FGViewer *v;
- sgVec3 nup, nsun, v0, surface_to_sun;
+ sgVec3 nup, nsun, surface_to_sun;
Point3D p, rel_sunpos;
double dot, east_dot;
double sun_gd_lat, sl_radius;
cout << "sun angle relative to current location = " << l->sun_angle << endl;
// calculate vector to sun's position on the earth's surface
- rel_sunpos = l->fg_sunpos - (v->get_view_pos() + scenery.center);
+ Point3D vp( v->get_view_pos()[0],
+ v->get_view_pos()[1],
+ v->get_view_pos()[1] );
+ rel_sunpos = l->fg_sunpos - ( vp + scenery.center );
v->set_to_sun( rel_sunpos.x(), rel_sunpos.y(), rel_sunpos.z() );
// printf( "Vector to sun = %.2f %.2f %.2f\n",
// v->to_sun[0], v->to_sun[1], v->to_sun[2]);
- // make a vector to the current view position
- Point3D view_pos = v->get_view_pos();
- sgSetVec3( v0, view_pos.x(), view_pos.y(), view_pos.z() );
-
// Given a vector from the view position to the point on the
// earth's surface the sun is directly over, map into onto the
// local plane representing "horizontal".
- sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v0, v->get_to_sun(),
- surface_to_sun );
+ sgmap_vec_onto_cur_surface_plane( v->get_local_up(), v->get_view_pos(),
+ v->get_to_sun(), surface_to_sun );
sgNormalizeVec3(surface_to_sun);
v->set_surface_to_sun( surface_to_sun[0], surface_to_sun[1],
surface_to_sun[2] );