not working right, but this will hopefully be fixed soon.
# End Source File\r
# Begin Source File\r
\r
+SOURCE=.\src\FDM\LaRCsimIC.cxx\r
+\r
+!IF "$(CFG)" == "FlightGear - Win32 Release"\r
+\r
+# PROP Intermediate_Dir "Release\Lib_Flight"\r
+\r
+!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"\r
+\r
+# PROP Intermediate_Dir "Debug\Lib_Flight"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\src\FDM\MagicCarpet.cxx\r
\r
!IF "$(CFG)" == "FlightGear - Win32 Release"\r
extern FGInterface cur_view_fdm;
GLubyte *hiResScreenCapture( int multiplier )
{
- float oldfov = globals->get_options()->get_fov();
- float fov = oldfov / multiplier;
- FGViewer *v = globals->get_current_view();
- globals->get_options()->set_fov(fov);
- v->force_update_fov_math();
+ float oldfov = globals->get_options()->get_fov();
+ float fov = oldfov / multiplier;
+ 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( );
- if (b1) delete( b1 );
- // New empty (mostly) bitmap
- b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
- int x,y;
- for ( y = 0; y < multiplier; y++ )
- {
- for ( x = 0; x < multiplier; x++ )
- {
- fgReshape( cur_width, cur_height );
- // pan to tile
- rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
- fgRenderFrame();
- // restore view
- GlBitmap b2;
- b1->copyBitmap( &b2, cur_width*x, cur_height*y );
- }
+ if (b1) delete( b1 );
+ // New empty (mostly) bitmap
+ b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
+ int x,y;
+ for ( y = 0; y < multiplier; y++ ) {
+ for ( x = 0; x < multiplier; x++ ) {
+ fgReshape( cur_width, cur_height );
+ // pan to tile
+ rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
+ fgRenderFrame();
+ // restore view
+ GlBitmap b2;
+ b1->copyBitmap( &b2, cur_width*x, cur_height*y );
}
- globals->get_current_view()->UpdateViewParams(cur_view_fdm);
- globals->get_options()->set_fov(oldfov);
- v->force_update_fov_math();
- return b1->getBitmap();
+ }
+ globals->get_current_view()->UpdateViewParams(cur_view_fdm);
+ globals->get_options()->set_fov(oldfov);
+ return b1->getBitmap();
}
#endif
// Set current_options lon/lat given an airport id
bool fgSetPosFromAirportID( const string& id ) {
FGAirport a;
- double lon, lat;
+ // double lon, lat;
FG_LOG( FG_GENERAL, FG_INFO,
"Attempting to set starting position from airport code " << id );
// Initialize view parameters
FG_LOG( FG_GENERAL, FG_DEBUG, "Before current_view.init()");
- globals->get_current_view()->Init();
- globals->get_pilot_view()->Init();
+ globals->get_current_view()->init();
+ // globals->get_pilot_view()->Init();
FG_LOG( FG_GENERAL, FG_DEBUG, "After current_view.init()");
- globals->get_current_view()->UpdateViewMath(*cur_fdm_state);
- globals->get_pilot_view()->UpdateViewMath(*cur_fdm_state);
+
+ globals->get_current_view()->
+ set_geod_view_pos( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Lat_geocentric(),
+ cur_fdm_state->get_Altitude() *
+ FEET_TO_METER );
+ globals->get_current_view()->
+ 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(),
+ cur_fdm_state->get_Theta(),
+ cur_fdm_state->get_Phi() );
+
+ // 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 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 );
+ // 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()");
- globals->get_current_view()->UpdateViewMath(*cur_fdm_state);
- globals->get_pilot_view()->UpdateViewMath(*cur_fdm_state);
+
+ globals->get_current_view()->
+ set_geod_view_pos( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Lat_geocentric(),
+ cur_fdm_state->get_Altitude() *
+ FEET_TO_METER );
+ globals->get_current_view()->
+ 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(),
+ cur_fdm_state->get_Theta(),
+ cur_fdm_state->get_Phi() );
+
+ // 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());
FGOptions *options;
// viewers
- FGViewer *pilot_view;
+ // FGViewer *pilot_view;
FGViewer *current_view;
public:
inline FGOptions *get_options() const { return options; }
inline void set_options( FGOptions *o ) { options = o; }
- inline FGViewer *get_pilot_view() const { return pilot_view; }
- inline void set_pilot_view( FGViewer *v ) { pilot_view = v; }
+ // inline FGViewer *get_pilot_view() const { return pilot_view; }
+ // inline void set_pilot_view( FGViewer *v ) { pilot_view = v; }
inline FGViewer *get_current_view() const { return current_view; }
inline void set_current_view( FGViewer *v ) { current_view = v; }
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(-25.0, 25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(-25.0, 25.0, 1.0);
v->set_view_offset( FG_PI * 0.75 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(-25.0, 0.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(-25.0, 0.0, 1.0);
v->set_view_offset( FG_PI );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(-25.0, -25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(-25.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.25 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(0.0, 25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(0.0, 25.0, 1.0);
v->set_view_offset( FG_PI * 0.50 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(0.0, -25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(0.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.50 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(25.0, 25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(25.0, 25.0, 1.0);
v->set_view_offset( FG_PI * 0.25 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(25.0, 0.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(25.0, 0.0, 1.0);
v->set_view_offset( 0.00 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(25.0, -25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(25.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.75 );
}
return;
fov = FG_FOV_MAX;
}
globals->get_options()->set_fov(fov);
- v->force_update_fov_math();
+ // v->force_update_fov_math();
return;
case 90: // Z key
#ifndef FG_OLD_WEATHER
globals->get_options()->set_view_mode( FGOptions::FG_VIEW_FOLLOW );
v->set_goal_view_offset( FG_PI * 1.75 );
v->set_view_offset( FG_PI * 1.75 );
- globals->get_pilot_view()->set_pilot_offset(25.0, -25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(25.0, -25.0, 1.0);
}
fgReshape( globals->get_options()->get_xsize(),
globals->get_options()->get_ysize() );
fov = FG_FOV_MIN;
}
globals->get_options()->set_fov(fov);
- v->force_update_fov_math();
+ // v->force_update_fov_math();
return;
case 122: // z key
#ifndef FG_OLD_WEATHER
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW)
{
- globals->get_pilot_view()->set_pilot_offset(-25.0, 25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(-25.0, 25.0, 1.0);
v->set_view_offset( FG_PI * 0.75 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(-25.0, 0.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(-25.0, 0.0, 1.0);
v->set_view_offset( FG_PI );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW)
{
- globals->get_pilot_view()->set_pilot_offset(-25.0, -25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(-25.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.25 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(0.0, 25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(0.0, 25.0, 1.0);
v->set_view_offset( FG_PI * 0.50 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(0.0, -25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(0.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.50 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(25.0, 25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(25.0, 25.0, 1.0);
v->set_view_offset( FG_PI * 0.25 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(25.0, 0.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(25.0, 0.0, 1.0);
v->set_view_offset( 0.00 );
}
return;
if ( globals->get_options()->get_view_mode() ==
FGOptions::FG_VIEW_FOLLOW )
{
- globals->get_pilot_view()->set_pilot_offset(25.0, -25.0, 1.0);
+ globals->get_current_view()->set_pilot_offset(25.0, -25.0, 1.0);
v->set_view_offset( FG_PI * 1.75 );
}
return;
fgLIGHT *l = &cur_light_params;
static double last_visibility = -9999;
- double angle;
+ // double angle;
// GLfloat black[4] = { 0.0, 0.0, 0.0, 1.0 };
// GLfloat white[4] = { 1.0, 1.0, 1.0, 1.0 };
// GLfloat terrain_color[4] = { 0.54, 0.44, 0.29, 1.0 };
// timerText -> setLabel (ctime (&t->cur_time));
// end of hack
+ // calculate our current position in cartesian space
+ scenery.center = scenery.next_center;
+ // printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x(),
+ // scenery.center.y(), scenery.center.z());
+
+ globals->get_current_view()->
+ set_geod_view_pos( cur_fdm_state->get_Longitude(),
+ cur_fdm_state->get_Lat_geocentric(),
+ cur_fdm_state->get_Altitude() *
+ FEET_TO_METER );
+ globals->get_current_view()->
+ 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(),
+ cur_fdm_state->get_Theta(),
+ cur_fdm_state->get_Phi() );
+
// update view volume parameters
// cout << "before pilot_view update" << endl;
- if ( globals->get_options()->get_view_mode()
- == FGOptions::FG_VIEW_FOLLOW )
+ if ( globals->get_options()->get_view_mode() ==
+ FGOptions::FG_VIEW_FOLLOW )
{
- float * offset = globals->get_pilot_view()->get_pilot_offset();
+ float * offset = globals->get_current_view()->get_pilot_offset();
globals->get_current_view()->set_pilot_offset( offset[0],
offset[1],
offset[2] );
} else {
globals->get_current_view()->set_pilot_offset(0.0, 0.0, 0.0);
}
- globals->get_pilot_view()->UpdateViewParams(*cur_fdm_state);
- // cout << "after pilot_view update" << endl;
- globals->get_current_view()->UpdateViewParams(cur_view_fdm);
+
+ if ( ! fgPanelVisible() ) {
+ xglViewport( 0, 0 ,
+ (GLint)(globals->get_options()->get_xsize()),
+ (GLint)(globals->get_options()->get_ysize()) );
+ } else {
+ int view_h =
+ int( (current_panel->getViewHeight() -
+ current_panel->getYOffset())
+ * (globals->get_options()->get_ysize() / 768.0) );
+ glViewport( 0,
+ (GLint)(globals->get_options()->get_ysize() - view_h),
+ (GLint)(globals->get_options()->get_xsize()),
+ (GLint)(view_h) );
+ }
// set the sun position
glLightfv( GL_LIGHT0, GL_POSITION, l->sun_vec );
// glMatrixMode( GL_PROJECTION );
// glLoadIdentity();
float fov = globals->get_options()->get_fov();
- // ssgSetFOV(fov * current_view.get_win_ratio(), fov);
- ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
+ ssgSetFOV(fov, fov * globals->get_options()->get_win_ratio());
double agl = current_aircraft.fdm_state->get_Altitude() * FEET_TO_METER
- scenery.cur_elev;
sgMat4 sgTRANS;
sgMakeTransMat4( sgTRANS,
- globals->get_pilot_view()->get_view_pos().x(),
- globals->get_pilot_view()->get_view_pos().y(),
- globals->get_pilot_view()->get_view_pos().z() );
+ 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 ownship_up;
sgSetVec3( ownship_up, 0.0, 0.0, 1.0);
// sgTUX = ( sgROT * pilot_view.VIEW_ROT ) * sgTRANS
sgMat4 sgTUX;
sgCopyMat4( sgTUX, sgROT );
- sgPostMultMat4( sgTUX, globals->get_pilot_view()->get_VIEW_ROT() );
+ sgPostMultMat4( sgTUX, globals->get_current_view()->get_VIEW_ROT() );
sgPostMultMat4( sgTUX, sgTRANS );
sgCoord tuxpos;
// Handle new window size or exposure
void fgReshape( int width, int height ) {
if ( ! fgPanelVisible() || idle_state != 1000 ) {
- globals->get_current_view()->set_win_ratio( (float)height /
- (float)width );
+ globals->get_options()->set_win_ratio( (float)height /
+ (float)width );
glViewport(0, 0 , (GLint)(width), (GLint)(height) );
} else {
int view_h =
int((current_panel->getViewHeight() - current_panel->getYOffset())
* (height / 768.0)) + 1;
- globals->get_current_view()->set_win_ratio( (float)view_h /
- (float)width );
+ globals->get_options()->set_win_ratio( (float)view_h /
+ (float)width );
glViewport(0, (GLint)(height - view_h),
(GLint)(width), (GLint)(view_h) );
}
globals->get_options()->set_xsize( width );
globals->get_options()->set_ysize( height );
- globals->get_current_view()->force_update_fov_math();
-
- // set these fov to be the same as in fgRenderFrame()
- // float x_fov = globals->get_options()->get_fov();
- // float y_fov = x_fov * 1.0 / current_view.get_win_ratio();
- // ssgSetFOV( x_fov, y_fov );
- // glViewport ( 0, 0, width, height );
float fov = globals->get_options()->get_fov();
- // ssgSetFOV(fov * current_view.get_win_ratio(), fov);
- ssgSetFOV(fov, fov * globals->get_current_view()->get_win_ratio());
+ ssgSetFOV(fov, fov * globals->get_options()->get_win_ratio());
fgHUDReshape();
// yes we've finished all our initializations and are running
// the main loop, so this will now work without seg faulting
// the system.
- globals->get_current_view()->UpdateViewParams(cur_view_fdm);
+ // globals->get_current_view()->UpdateViewParams();
}
}
globals->set_options( options );
FGViewer *pv = new FGViewer;
- globals->set_pilot_view( pv );
- FGViewer *cv = new FGViewer;
- globals->set_current_view( cv );
+ globals->set_current_view( pv );
+ // FGViewer *cv = new FGViewer;
+ // globals->set_current_view( cv );
// Scan the config file(s) and command line options to see if
// fg_root was specified (ignore all other options for now)
// $$$ end - added VS Renganathan, 15 Oct 2K
void fgLoadDCS(void) {
- double obj_lat,obj_lon,obj_alt;
- int i = 1;
string obj_filename;
FGPath tile_path( globals->get_options()->get_fg_root());
void fgUpdateDCS (void) {
- double eye_lat,eye_lon,eye_alt;
+ // double eye_lat,eye_lon,eye_alt;
static double obj_lat=15.377603*DEG_TO_RAD;
static double obj_lon= 73.816436*DEG_TO_RAD;
static double obj_alt=0.15;
- static double obj_head;
+ // static double obj_head;
double sl_radius,obj_latgc;
- float nresultmat[4][4];
- sgMat4 Trans,rothead,rotlon,rot180,rotlat,resultmat1,resultmat2,resultmat3;
+ // float nresultmat[4][4];
double bz[3];
obj_lat = obj_lat + 0.0000001;
bool textures; // Textures enabled/disabled
bool wireframe; // Wireframe mode enabled/disabled
int xsize, ysize; // window size derived from geometry string
+ double win_ratio; // ratio of x and y fov's; fov(y) = fov(x) * win_ratio
int bpp; // bits per pixel
fgViewMode view_mode; // view mode
double default_view_offset; // default forward view offset (for use by
inline bool get_wireframe() const { return wireframe; }
inline int get_xsize() const { return xsize; }
inline int get_ysize() const { return ysize; }
+ inline double get_win_ratio() const { return win_ratio; }
inline int get_bpp() const { return bpp; }
inline fgViewMode get_view_mode() const { return view_mode; }
inline double get_default_view_offset() const {
void toggle_panel();
inline void set_xsize( int x ) { xsize = x; }
inline void set_ysize( int y ) { ysize = y; }
+ inline void set_win_ratio( double r ) { win_ratio = r; }
inline void set_view_mode (fgViewMode value) { view_mode = value; }
inline void set_tile_radius (int value) { tile_radius = value; }
inline void set_tile_diameter (int value) { tile_diameter = value; }
// Constructor
-FGViewer::FGViewer( void ) {
+FGViewer::FGViewer( void )
+{
}
+
#define USE_FAST_VIEWROT
#ifdef USE_FAST_VIEWROT
// VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
}
#endif
+
// Initialize a view structure
-void FGViewer::Init( void ) {
+void FGViewer::init( void ) {
+ dirty = true;
+
FG_LOG( FG_VIEW, FG_INFO, "Initializing View parameters" );
- view_offset = goal_view_offset = globals->get_options()->get_default_view_offset();
+ view_offset = goal_view_offset =
+ globals->get_options()->get_default_view_offset();
sgSetVec3( pilot_offset, 0.0, 0.0, 0.0 );
- set_win_ratio( globals->get_options()->get_xsize() /
- globals->get_options()->get_ysize() );
+ globals->get_options()->set_win_ratio( globals->get_options()->get_xsize() /
+ globals->get_options()->get_ysize()
+ );
#ifndef USE_FAST_VIEWROT
// This never changes -- NHV
LARC_TO_SSG[3][2] = 0.0;
LARC_TO_SSG[3][3] = 1.0;
#endif // USE_FAST_VIEWROT
-
- force_update_fov_math();
}
#endif
-// Update the view volume, position, and orientation
-void FGViewer::UpdateViewParams( const FGInterface& f ) {
- UpdateViewMath(f);
-
- if ( ! fgPanelVisible() ) {
- xglViewport( 0, 0 ,
- (GLint)(globals->get_options()->get_xsize()),
- (GLint)(globals->get_options()->get_ysize()) );
- } else {
- int view_h =
- int((current_panel->getViewHeight() - current_panel->getYOffset())
- * (globals->get_options()->get_ysize() / 768.0));
- glViewport( 0, (GLint)(globals->get_options()->get_ysize() - view_h),
- (GLint)(globals->get_options()->get_xsize()),
- (GLint)(view_h) );
- }
-}
-
-
// convert sgMat4 to MAT3 and print
static void print_sgMat4( sgMat4 &in) {
int i, j;
// Update the view parameters
-void FGViewer::UpdateViewMath( const FGInterface& f ) {
+void FGViewer::update() {
- Point3D p;
- sgVec3 v0, minus_z, sgvec, forward;
- sgMat4 VIEWo, TMP;
-
- if ( update_fov ) {
- ssgSetFOV( globals->get_options()->get_fov(),
- globals->get_options()->get_fov() * win_ratio );
- update_fov = false;
- }
-
- scenery.center = scenery.next_center;
-
- // printf("scenery center = %.2f %.2f %.2f\n", scenery.center.x,
- // scenery.center.y, scenery.center.z);
+ sgVec3 v0, minus_z, forward;
+ sgMat4 VIEWo;
// 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 );
+ Point3D p = Point3D( geod_view_pos.lon(),
+ geod_view_pos.lat(),
+ 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 ( f.get_Altitude() * FEET_TO_METER >
- (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
- p.setz( p.radius() + f.get_Altitude() * FEET_TO_METER );
+ if ( geod_view_pos.elev() > (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
+ p.setz( p.radius() + geod_view_pos.elev() );
} else {
p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
}
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 );
#ifdef USE_FAST_LOCAL
- fgMakeLOCAL( LOCAL, f.get_Theta(), f.get_Phi(), -f.get_Psi() );
+ fgMakeLOCAL( LOCAL, hpr[1], hpr[2], -hpr[0] );
#else // USE_TEXT_BOOK_METHOD
sgVec3 rollvec;
sgSetVec3( rollvec, 0.0, 0.0, 1.0 );
sgMat4 PHI; // roll
- sgMakeRotMat4( PHI, f.get_Phi() * RAD_TO_DEG, rollvec );
+ sgMakeRotMat4( PHI, hpr[2] * RAD_TO_DEG, rollvec );
sgVec3 pitchvec;
sgSetVec3( pitchvec, 0.0, 1.0, 0.0 );
sgMat4 THETA; // pitch
- sgMakeRotMat4( THETA, f.get_Theta() * RAD_TO_DEG, pitchvec );
+ sgMakeRotMat4( THETA, hpr[1] * RAD_TO_DEG, pitchvec );
// ROT = PHI * THETA
sgMat4 ROT;
sgVec3 yawvec;
sgSetVec3( yawvec, 1.0, 0.0, 0.0 );
- sgMat4 PSI; // pitch
- sgMakeRotMat4( PSI, -f.get_Psi() * RAD_TO_DEG, yawvec );
+ sgMat4 PSI; // heading
+ sgMakeRotMat4( PSI, -hpr[0] * RAD_TO_DEG, yawvec );
// LOCAL = ROT * PSI
// sgMultMat4( LOCAL, ROT, PSI );
sgCopyMat4( LOCAL, ROT );
sgPostMultMat4( LOCAL, PSI );
-#endif // YIKES
+#endif // USE_FAST_LOCAL
// cout << "LOCAL matrix" << endl;
// print_sgMat4( LOCAL );
sgMakeRotMat4( UP,
- f.get_Longitude() * RAD_TO_DEG,
+ geod_view_pos.lon() * RAD_TO_DEG,
0.0,
- -f.get_Latitude() * RAD_TO_DEG );
+ -geod_view_pos.lat() * RAD_TO_DEG );
sgSetVec3( local_up, UP[0][0], UP[0][1], UP[0][2] );
// sgXformVec3( local_up, UP );
// << surface_east[1] << "," << surface_east[2] << endl;
// cout << "Should be close to zero = "
// << sgScalarProductVec3(surface_south, surface_east) << endl;
+
+ dirty = false;
}
private:
+ // flag forcing a recalc of derived view parameters
+ bool dirty;
+
// the current view offset angle from forward (rotated about the
// view_up vector)
double view_offset;
// the goal view offset angle (used for smooth view changes)
double goal_view_offset;
- // flag forcing update of fov related stuff
- bool update_fov;
-
- // fov of view is specified in the X direction, win_ratio is used to
- // calculate the fov in the Y direction. fov(y) = fov(x) * win_ratio
- double win_ratio;
+ // geodetic view position
+ Point3D geod_view_pos;
- // width & height of window
- // int winWidth, winHeight;
+ // radius to sea level from center of the earth (m)
+ double sea_level_radius;
// absolute view position in earth coordinates
Point3D abs_view_pos;
// Distances in meters of course.
sgVec3 pilot_offset;
+ // view orientation (heading, pitch, roll)
+ sgVec3 hpr;
+
// cartesion coordinates of current lon/lat if at sea level
// translated to scenery.center
Point3D cur_zero_elev;
// the vector pointing straight out the nose of the aircraft
sgVec3 view_forward;
- // Transformation matrix for eye coordinates to aircraft coordinates
- // sgMat4 AIRCRAFT;
-
// Transformation matrix for the view direction offset relative to
// the AIRCRAFT matrix
sgMat4 VIEW_OFFSET;
// sg versions of our friendly matrices
sgMat4 LOCAL, UP, VIEW_ROT, TRANS, VIEW, LARC_TO_SSG;
+ // Update the view volume, position, and orientation
+ void update();
+
public:
// Constructor
~FGViewer( void );
// Initialize a view class
- void Init( void );
-
- // Update the view volume, position, and orientation
- 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( const FGInterface& f );
-
- // Update the field of view coefficients
- void UpdateFOV( const FGOptions *o );
+ void init( void );
// Transform a vector from world coordinates to the local plane
void CurrentNormalInLocalPlane(sgVec3 dst, sgVec3 src);
+ //////////////////////////////////////////////////////////////////////
+ // setter functions
+ //////////////////////////////////////////////////////////////////////
+ inline void set_geod_view_pos( double lon, double lat, double alt ) {
+ // data should be in radians and meters asl
+ dirty = true;
+ // cout << "set_geod_view_pos = " << lon << ", " << lat << ", " << alt
+ // << endl;
+ geod_view_pos = Point3D( 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 ) {
+ // data should be in radians
+ dirty = true;
+ sgSetVec3( hpr, h, p, r );
+ }
+ inline void set_pilot_offset( float x, float y, float z ) {
+ dirty = true;
+ sgSetVec3( pilot_offset, x, y, z );
+ }
+ inline void set_view_offset( double a ) {
+ dirty = true;
+ view_offset = a;
+ }
+ inline void inc_view_offset( double amt ) {
+ dirty = true;
+ view_offset += amt;
+ }
+ inline void set_goal_view_offset( double a) {
+ dirty = true;
+ goal_view_offset = a;
+ }
+
+ //////////////////////////////////////////////////////////////////////
// accessor functions
+ //////////////////////////////////////////////////////////////////////
inline double get_view_offset() const { return view_offset; }
- inline void set_view_offset( double a ) { view_offset = a; }
- inline void inc_view_offset( double amt ) { view_offset += amt; }
inline double get_goal_view_offset() const { return goal_view_offset; }
- inline void set_goal_view_offset( double a) { goal_view_offset = a; }
- inline double get_win_ratio() const { return win_ratio; }
- inline void set_win_ratio( double r ) { win_ratio = r; }
- // inline int get_winWidth() const { return winWidth; }
- // inline void set_winWidth( int w ) { winWidth = w; }
- // inline int get_winHeight() const { return winHeight; }
- // inline void set_winHeight( int h ) { winHeight = h; }
- inline Point3D get_abs_view_pos() const { return abs_view_pos; }
- inline Point3D get_view_pos() const { return view_pos; }
inline float *get_pilot_offset() { return pilot_offset; }
- inline void set_pilot_offset( float x, float y, float z ) {
- sgSetVec3( pilot_offset, x, y, z );
+ inline double get_sea_level_radius() const { return sea_level_radius; }
+ inline float *get_hpr() { return hpr; }
+
+ //////////////////////////////////////////////////////////////////////
+ // derived values accessor functions
+ //////////////////////////////////////////////////////////////////////
+ inline Point3D get_abs_view_pos() {
+ if ( dirty ) { update(); }
+ return abs_view_pos;
+ }
+ inline Point3D get_view_pos() {
+ if ( dirty ) { update(); }
+ return view_pos;
+ }
+ inline Point3D get_cur_zero_elev() {
+ if ( dirty ) { update(); }
+ return cur_zero_elev;
+ }
+ inline float *get_surface_south() {
+ if ( dirty ) { update(); }
+ return surface_south;
}
- inline Point3D get_cur_zero_elev() const { return cur_zero_elev; }
+ inline float *get_surface_east() {
+ if ( dirty ) { update(); }
+ return surface_east;
+ }
+ inline float *get_local_up() {
+ if ( dirty ) { update(); }
+ return local_up;
+ }
+ inline float *get_view_forward() {
+ if ( dirty ) { update(); }
+ return view_forward;
+ }
+ inline const sgVec4 *get_VIEW() {
+ if ( dirty ) { update(); }
+ return VIEW;
+ }
+ inline const sgVec4 *get_VIEW_ROT() {
+ if ( dirty ) { update(); }
+ return VIEW_ROT;
+ }
+
+ //////////////////////////////////////////////////////////////////////
+ // need to fix these
+ //////////////////////////////////////////////////////////////////////
inline float *get_to_sun() { return to_sun; }
inline void set_to_sun( float x, float y, float z ) {
sgSetVec3( to_sun, x, y, z );
inline void set_surface_to_moon( float x, float y, float z) {
sgSetVec3( surface_to_moon, x, y, z );
}
- inline float *get_surface_south() { return surface_south; }
- inline float *get_surface_east() { return surface_east; }
- inline float *get_local_up() { return local_up; }
- inline float *get_view_forward() { return view_forward; }
-
- inline const sgVec4 *get_VIEW() { return VIEW; }
- inline const sgVec4 *get_VIEW_ROT() { return VIEW_ROT; }
};
+
#endif // _VIEWER_HXX