]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewer_rph.cxx
- removed references to FGSoundMgr
[flightgear.git] / src / Main / viewer_rph.cxx
index 04d131ca75a0a9ef5e574873e1c29e7ae2d83bfc..e8ab87b628401fd337a76bca9fb2d0079fa5a8eb 100644 (file)
@@ -35,6 +35,7 @@
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
+#include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/vector.hxx>
 
 #include <Scenery/scenery.hxx>
@@ -139,6 +140,7 @@ inline static void fgMakeLOCAL( sgMat4 dst, const double Theta,
 #endif
 
 
+#if 0
 // convert sgMat4 to MAT3 and print
 static void print_sgMat4( sgMat4 &in) {
     int i, j;
@@ -149,6 +151,7 @@ static void print_sgMat4( sgMat4 &in) {
        cout << endl;
     }
 }
+#endif
 
 
 // Update the view parameters
@@ -157,21 +160,24 @@ void FGViewerRPH::update() {
     sgVec3 minus_z, forward;
     sgMat4 VIEWo;
 
+    // convert to geocentric coordinates
+    double geoc_lat;
+    sgGeodToGeoc( geod_view_pos[1], geod_view_pos[2],
+                 &sea_level_radius, &geoc_lat );
+
     // calculate the cartesion coords of the current lat/lon/0 elev
-    Point3D p = Point3D( geod_view_pos[0], 
-                        geod_view_pos[1], 
-                        sea_level_radius );
+    Point3D p = Point3D( geod_view_pos[0], geoc_lat, sea_level_radius );
 
-    tmp = sgPolarToCart3d(p) - scenery.center;
+    tmp = sgPolarToCart3d(p) - scenery.get_center();
     sgSetVec3( zero_elev, tmp[0], tmp[1], tmp[2] );
 
     // 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[2] > (scenery.cur_elev + 0.5 * METER_TO_FEET) ) {
+    if ( geod_view_pos[2] > (scenery.get_cur_elev() + 0.5 * SG_METER_TO_FEET) ) {
        p.setz( p.radius() + geod_view_pos[2] );
     } else {
-       p.setz( p.radius() + scenery.cur_elev + 0.5 * METER_TO_FEET );
+       p.setz( p.radius() + scenery.get_cur_elev() + 0.5 * SG_METER_TO_FEET );
     }
 
     tmp = sgPolarToCart3d(p);
@@ -179,18 +185,21 @@ void FGViewerRPH::update() {
 
     // view_pos = abs_view_pos - scenery.center;
     sgdVec3 sc;
-    sgdSetVec3( sc, scenery.center.x(), scenery.center.y(), scenery.center.z());
+    sgdSetVec3( sc,
+               scenery.get_center().x(),
+               scenery.get_center().y(),
+               scenery.get_center().z() );
     sgdVec3 vp;
     sgdSubVec3( vp, abs_view_pos, sc );
     sgSetVec3( view_pos, vp );
 
-    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 = "
+    SG_LOG( SG_VIEW, SG_DEBUG, "sea level radius = " << sea_level_radius );
+    SG_LOG( SG_VIEW, SG_DEBUG, "Polar view pos = " << p );
+    SG_LOG( SG_VIEW, SG_DEBUG, "Absolute view pos = "
            << abs_view_pos[0] << ","
            << abs_view_pos[1] << ","
            << abs_view_pos[2] );
-    FG_LOG( FG_VIEW, FG_DEBUG, "(RPH) Relative view pos = "
+    SG_LOG( SG_VIEW, SG_DEBUG, "(RPH) Relative view pos = "
            << view_pos[0] << "," << view_pos[1] << "," << view_pos[2] );
 
     // code to calculate LOCAL matrix calculated from Phi, Theta, and
@@ -206,12 +215,12 @@ void FGViewerRPH::update() {
     sgVec3 rollvec;
     sgSetVec3( rollvec, 0.0, 0.0, 1.0 );
     sgMat4 PHI;                // roll
-    sgMakeRotMat4( PHI, rph[0] * RAD_TO_DEG, rollvec );
+    sgMakeRotMat4( PHI, rph[0] * SGD_RADIANS_TO_DEGREES, rollvec );
 
     sgVec3 pitchvec;
     sgSetVec3( pitchvec, 0.0, 1.0, 0.0 );
     sgMat4 THETA;              // pitch
-    sgMakeRotMat4( THETA, rph[1] * RAD_TO_DEG, pitchvec );
+    sgMakeRotMat4( THETA, rph[1] * SGD_RADIANS_TO_DEGREES, pitchvec );
 
     // ROT = PHI * THETA
     sgMat4 ROT;
@@ -222,7 +231,7 @@ void FGViewerRPH::update() {
     sgVec3 yawvec;
     sgSetVec3( yawvec, 1.0, 0.0, 0.0 );
     sgMat4 PSI;                // heading
-    sgMakeRotMat4( PSI, -rph[2] * RAD_TO_DEG, yawvec );
+    sgMakeRotMat4( PSI, -rph[2] * SGD_RADIANS_TO_DEGREES, yawvec );
 
     // LOCAL = ROT * PSI
     // sgMultMat4( LOCAL, ROT, PSI );
@@ -235,9 +244,9 @@ void FGViewerRPH::update() {
     // print_sgMat4( LOCAL );
        
     sgMakeRotMat4( UP, 
-                  geod_view_pos[0] * RAD_TO_DEG,
+                  geod_view_pos[0] * SGD_RADIANS_TO_DEGREES,
                   0.0,
-                  -geod_view_pos[1] * RAD_TO_DEG );
+                  -geod_view_pos[1] * SGD_RADIANS_TO_DEGREES );
 
     sgSetVec3( world_up, UP[0][0], UP[0][1], UP[0][2] );
     // sgXformVec3( world_up, UP );
@@ -272,11 +281,11 @@ void FGViewerRPH::update() {
     sgXformVec3( pilot_offset_world, pilot_offset_world, VIEWo );
 
     // generate the view offset matrix
-    sgMakeRotMat4( VIEW_OFFSET, view_offset * RAD_TO_DEG, view_up );
+    sgMakeRotMat4( VIEW_OFFSET, view_offset * SGD_RADIANS_TO_DEGREES, view_up );
     // cout << "VIEW_OFFSET matrix" << endl;
     // print_sgMat4( VIEW_OFFSET );
     sgXformVec3( view_forward, forward, VIEW_OFFSET );
-    FG_LOG( FG_VIEW, FG_DEBUG, "(RPH) view forward = "
+    SG_LOG( SG_VIEW, SG_DEBUG, "(RPH) view forward = "
            << view_forward[0] << "," << view_forward[1] << ","
            << view_forward[2] );
        
@@ -326,7 +335,7 @@ void FGViewerRPH::update() {
     sgNegateVec3(world_down, world_up);
     sgVectorProductVec3(surface_east, surface_south, world_down);
 #else
-    sgMakeRotMat4( TMP, SGD_PI_2 * RAD_TO_DEG, world_up );
+    sgMakeRotMat4( TMP, SGD_PI_2 * SGD_RADIANS_TO_DEGREES, world_up );
     // cout << "sgMat4 TMP" << endl;
     // print_sgMat4( TMP );
     sgXformVec3(surface_east, surface_south, TMP);