]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewer.cxx
- implement progress information (enabled by default; can be turned off via
[flightgear.git] / src / Main / viewer.cxx
index b39b1414451097894138aa7c5307a24f39fa32b9..6615f78b0ba726ce3aac7ebee83f5b61db3c1bb6 100644 (file)
@@ -176,7 +176,8 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
                     double damp_roll, double damp_pitch, double damp_heading,
                     double x_offset_m, double y_offset_m, double z_offset_m,
                     double heading_offset_deg, double pitch_offset_deg,
-                    double roll_offset_deg, double fov_deg,
+                    double roll_offset_deg,
+                    double fov_deg, double aspect_ratio_multiplier,
                     double target_x_offset_m, double target_y_offset_m,
                     double target_z_offset_m, double near_m, bool internal ):
     _dirty(true),
@@ -225,6 +226,7 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
     } else {
       _fov_deg = 55;
     }
+    _aspect_ratio_multiplier = aspect_ratio_multiplier;
     _target_x_offset_m = target_x_offset_m;
     _target_y_offset_m = target_y_offset_m;
     _target_z_offset_m = target_z_offset_m;
@@ -540,14 +542,15 @@ FGViewer::getZeroElevViewPos ()
 void
 FGViewer::updateFromModelLocation (SGLocation * location)
 {
-  sgCopyMat4(LOCAL, location->getCachedTransformMatrix());
+  Point3D center = globals->get_scenery()->get_next_center();
+  sgCopyMat4(LOCAL, location->getTransformMatrix(center));
 }
 
 void
 FGViewer::updateAtModelLocation (SGLocation * location)
 {
-  sgCopyMat4(ATLOCAL, 
-             location->getCachedTransformMatrix());
+  Point3D center = globals->get_scenery()->get_next_center();
+  sgCopyMat4(ATLOCAL, location->getTransformMatrix(center));
 }
 
 void
@@ -558,8 +561,20 @@ FGViewer::recalcOurOwnLocation (SGLocation * location, double lon_deg, double la
   dampEyeData(roll_deg, pitch_deg, heading_deg);
   location->setPosition( lon_deg, lat_deg, alt_ft );
   location->setOrientation( roll_deg, pitch_deg, heading_deg );
-  sgCopyMat4(LOCAL,
-             location->getTransformMatrix(globals->get_scenery()->get_center()));
+  Point3D center = globals->get_scenery()->get_next_center();
+  sgCopyMat4(LOCAL, location->getTransformMatrix(center));
+}
+
+void
+FGViewer::set_scenery_center(const Point3D& center)
+{
+  _location->set_tile_center(center);
+  _location->getTransformMatrix(center);
+  if (_type == FG_LOOKAT) {
+    _target_location->set_tile_center(center);
+    _target_location->getTransformMatrix(center);
+  }
+  set_dirty();
 }
 
 // recalc() is done every time one of the setters is called (making the 
@@ -668,10 +683,11 @@ FGViewer::recalcLookAt ()
           _target_roll_deg, _target_pitch_deg, _target_heading_deg );
   }
   // calculate the "at" target object positon relative to eye or view's tile center...
+  Point3D center = globals->get_scenery()->get_next_center();
   sgdVec3 dVec3;
-  sgdSetVec3(dVec3,  _location->get_tile_center()[0], _location->get_tile_center()[1], _location->get_tile_center()[2]);
+  sgdSetVec3(dVec3, center[0], center[1], center[2]);
   sgdSubVec3(dVec3,
-             _target_location->get_absolute_view_pos(globals->get_scenery()->get_center()),
+             _target_location->get_absolute_view_pos(center),
              dVec3 );
   sgSetVec3(at_pos, dVec3[0], dVec3[1], dVec3[2]);
 
@@ -737,10 +753,10 @@ void
 FGViewer::copyLocationData()
 {
   // Get our friendly vectors from the eye location...
+  sgdCopyVec3(_absolute_view_pos,
+              _location->get_absolute_view_pos(globals->get_scenery()->get_next_center()));
   sgCopyVec3(_zero_elev_view_pos,  _location->get_zero_elev());
   sgCopyVec3(_relative_view_pos, _location->get_view_pos());
-  sgdCopyVec3(_absolute_view_pos,
-              _location->get_absolute_view_pos(globals->get_scenery()->get_center()));
   sgCopyMat4(UP, _location->getCachedUpMatrix());
   sgCopyVec3(_world_up, _location->get_world_up());
   // these are the vectors that the sun and moon code like to get...
@@ -840,8 +856,10 @@ FGViewer::get_h_fov()
            return _fov_deg;
        } else {
            // v_fov == fov
-           return atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS) / _aspect_ratio) *
-               SG_RADIANS_TO_DEGREES * 2;
+           return
+                atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
+                     / (_aspect_ratio*_aspect_ratio_multiplier))
+                * SG_RADIANS_TO_DEGREES * 2;
        }
     default:
        assert(false);
@@ -856,13 +874,17 @@ FGViewer::get_v_fov()
 {
     switch (_scaling_type) {
     case FG_SCALING_WIDTH:  // h_fov == fov
-       return atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS) * _aspect_ratio) *
-           SG_RADIANS_TO_DEGREES * 2;
+       return 
+            atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
+                 * (_aspect_ratio*_aspect_ratio_multiplier))
+            * SG_RADIANS_TO_DEGREES * 2;
     case FG_SCALING_MAX:
        if (_aspect_ratio < 1.0) {
            // h_fov == fov
-           return atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS) * _aspect_ratio) *
-               SG_RADIANS_TO_DEGREES * 2;
+           return
+                atan(tan(_fov_deg/2 * SG_DEGREES_TO_RADIANS)
+                     * (_aspect_ratio*_aspect_ratio_multiplier))
+                * SG_RADIANS_TO_DEGREES * 2;
        } else {
            // v_fov == fov
            return _fov_deg;