#include <simgear/math/polar3d.hxx>
#include <simgear/math/vector.hxx>
-#include <Aircraft/aircraft.hxx>
-#include <Cockpit/panel.hxx>
#include <Scenery/scenery.hxx>
#include "globals.hxx"
-#include "viewer.hxx"
+#include "viewer_rph.hxx"
// Constructor
FGViewerRPH::FGViewerRPH( void )
{
+ set_reverse_view_offset(false);
+#ifndef USE_FAST_VIEWROT
+ // This never changes -- NHV
+ LARC_TO_SSG[0][0] = 0.0;
+ LARC_TO_SSG[0][1] = 1.0;
+ LARC_TO_SSG[0][2] = -0.0;
+ LARC_TO_SSG[0][3] = 0.0;
+
+ LARC_TO_SSG[1][0] = 0.0;
+ LARC_TO_SSG[1][1] = 0.0;
+ LARC_TO_SSG[1][2] = 1.0;
+ LARC_TO_SSG[1][3] = 0.0;
+
+ LARC_TO_SSG[2][0] = 1.0;
+ LARC_TO_SSG[2][1] = -0.0;
+ LARC_TO_SSG[2][2] = 0.0;
+ LARC_TO_SSG[2][3] = 0.0;
+
+ LARC_TO_SSG[3][0] = 0.0;
+ LARC_TO_SSG[3][1] = 0.0;
+ LARC_TO_SSG[3][2] = 0.0;
+ LARC_TO_SSG[3][3] = 1.0;
+#endif // USE_FAST_VIEWROT
}
#endif
-// Initialize a view structure
-void FGViewerRPH::init( void ) {
- set_dirty();
-
- FG_LOG( FG_VIEW, FG_INFO, "Initializing View parameters" );
-
- view_offset = goal_view_offset =
- globals->get_options()->get_default_view_offset();
- sgSetVec3( pilot_offset, 0.0, 0.0, 0.0 );
-
- 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[0][0] = 0.0;
- LARC_TO_SSG[0][1] = 1.0;
- LARC_TO_SSG[0][2] = -0.0;
- LARC_TO_SSG[0][3] = 0.0;
-
- LARC_TO_SSG[1][0] = 0.0;
- LARC_TO_SSG[1][1] = 0.0;
- LARC_TO_SSG[1][2] = 1.0;
- LARC_TO_SSG[1][3] = 0.0;
-
- LARC_TO_SSG[2][0] = 1.0;
- LARC_TO_SSG[2][1] = -0.0;
- LARC_TO_SSG[2][2] = 0.0;
- LARC_TO_SSG[2][3] = 0.0;
-
- LARC_TO_SSG[3][0] = 0.0;
- LARC_TO_SSG[3][1] = 0.0;
- LARC_TO_SSG[3][2] = 0.0;
- LARC_TO_SSG[3][3] = 1.0;
-#endif // USE_FAST_VIEWROT
-}
-
-
#define USE_FAST_LOCAL
#ifdef USE_FAST_LOCAL
inline static void fgMakeLOCAL( sgMat4 dst, const double Theta,
tmp = sgPolarToCart3d(p);
sgdSetVec3( abs_view_pos, tmp[0], tmp[1], tmp[2] );
+ // view_pos = abs_view_pos - scenery.center;
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 );
<< abs_view_pos[0] << ","
<< abs_view_pos[1] << ","
<< abs_view_pos[2] );
- FG_LOG( FG_VIEW, FG_DEBUG, "Relative view pos = "
+ FG_LOG( FG_VIEW, FG_DEBUG, "(RPH) Relative view pos = "
<< view_pos[0] << "," << view_pos[1] << "," << view_pos[2] );
// code to calculate LOCAL matrix calculated from Phi, Theta, and
0.0,
-geod_view_pos[1] * RAD_TO_DEG );
- sgSetVec3( local_up, UP[0][0], UP[0][1], UP[0][2] );
- // sgXformVec3( local_up, UP );
- // cout << "Local Up = " << local_up[0] << "," << local_up[1] << ","
- // << local_up[2] << endl;
+ sgSetVec3( world_up, UP[0][0], UP[0][1], UP[0][2] );
+ // sgXformVec3( world_up, UP );
+ // cout << "World Up = " << world_up[0] << "," << world_up[1] << ","
+ // << world_up[2] << endl;
- // Alternative method to Derive local up vector based on
+ // Alternative method to Derive world up vector based on
// *geodetic* coordinates
// alt_up = sgPolarToCart(FG_Longitude, FG_Latitude, 1.0);
// printf( " Alt Up = (%.4f, %.4f, %.4f)\n",
// cout << "VIEW_OFFSET matrix" << endl;
// print_sgMat4( VIEW_OFFSET );
sgXformVec3( view_forward, forward, VIEW_OFFSET );
- // cout << "view_forward = " << view_forward[0] << ","
- // << view_forward[1] << "," << view_forward[2] << endl;
+ FG_LOG( FG_VIEW, FG_DEBUG, "(RPH) view forward = "
+ << view_forward[0] << "," << view_forward[1] << ","
+ << view_forward[2] );
// VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
#ifdef USE_FAST_VIEWROT
// THIS IS THE EXPERIMENTAL VIEWING ANGLE SHIFTER
// THE MAJORITY OF THE WORK IS DONE IN GUI.CXX
// this in gui.cxx for now just testing
- extern float quat_mat[4][4];
- sgPreMultMat4( VIEW, quat_mat);
+ extern float GuiQuat_mat[4][4];
+ sgPreMultMat4( VIEW, GuiQuat_mat);
// !!!!!!!!!! testing
// Given a vector pointing straight down (-Z), map into onto the
// local direction for moving "south".
sgSetVec3( minus_z, 0.0, 0.0, -1.0 );
- sgmap_vec_onto_cur_surface_plane(local_up, view_pos, minus_z,
+ sgmap_vec_onto_cur_surface_plane(world_up, view_pos, minus_z,
surface_south);
sgNormalizeVec3(surface_south);
// cout << "Surface direction directly south " << surface_south[0] << ","
// now calculate the surface east vector
#define USE_FAST_SURFACE_EAST
#ifdef USE_FAST_SURFACE_EAST
- sgVec3 local_down;
- sgNegateVec3(local_down, local_up);
- sgVectorProductVec3(surface_east, surface_south, local_down);
-#else
-#define USE_LOCAL_UP
-#ifdef USE_LOCAL_UP
- sgMakeRotMat4( TMP, FG_PI_2 * RAD_TO_DEG, local_up );
+ sgVec3 world_down;
+ sgNegateVec3(world_down, world_up);
+ sgVectorProductVec3(surface_east, surface_south, world_down);
#else
- sgMakeRotMat4( TMP, FG_PI_2 * RAD_TO_DEG, view_up );
-#endif // USE_LOCAL_UP
+ sgMakeRotMat4( TMP, FG_PI_2 * RAD_TO_DEG, world_up );
// cout << "sgMat4 TMP" << endl;
// print_sgMat4( TMP );
sgXformVec3(surface_east, surface_south, TMP);