]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewer.cxx
Merge branch 'jt/runway' into next
[flightgear.git] / src / Main / viewer.cxx
index f91cb7f5b5582b24459593ac7904ed035b4bd3cf..f2ffd56c9d57a5fae327aae613bc7e6fc6068f45 100644 (file)
@@ -37,7 +37,6 @@
 
 #include <simgear/debug/logstream.hxx>
 #include <simgear/constants.h>
-#include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/scene/model/location.hxx>
@@ -50,6 +49,9 @@
 
 #include "viewer.hxx"
 
+#include "CameraGroup.hxx"
+
+using namespace flightgear;
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGViewer.
@@ -81,7 +83,8 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
     _damp_heading(0),
     _scaling_type(FG_SCALING_MAX),
     _location(0),
-    _target_location(0)
+    _target_location(0),
+    _cameraGroup(CameraGroup::getDefault())
 {
     _absolute_view_pos = SGVec3d(0, 0, 0);
     _type = Type;
@@ -402,14 +405,6 @@ FGViewer::setOrientationOffsets (double roll_offset_deg, double pitch_offset_deg
   _heading_offset_deg = heading_offset_deg;
 }
 
-double *
-FGViewer::get_absolute_view_pos () 
-{
-  if (_dirty)
-    recalc();
-  return _absolute_view_pos.data();
-}
-
 // recalc() is done every time one of the setters is called (making the 
 // cached data "dirty") on the next "get".  It calculates all the outputs 
 // for viewer.
@@ -422,12 +417,9 @@ FGViewer::recalc ()
     recalcLookAt();
   }
 
-  SGVec3d center = globals->get_scenery()->get_center();
-  _view_pos = toVec3f(_absolute_view_pos - center);
-
   SGGeod geodEyePoint = SGGeod::fromCart(_absolute_view_pos);
   geodEyePoint.setElevationM(0);
-  _zero_elev = toVec3f(SGVec3d::fromGeod(geodEyePoint) - center);
+  _zero_elev = SGVec3d::fromGeod(geodEyePoint);
   
   SGQuatd hlOr = SGQuatd::fromLonLat(geodEyePoint);
   _surface_south = toVec3f(hlOr.backTransform(-SGVec3d::e1()));
@@ -561,7 +553,7 @@ FGViewer::recalcLookAt ()
                                  _roll_offset_deg);
 
   // Offsets to the eye position
-  SGVec3d eyeOff(-_offset_m.z(), _offset_m.y(), -_offset_m.x());
+  SGVec3d eyeOff(-_offset_m.z(), _offset_m.x(), -_offset_m.y());
   SGQuatd ec2eye = geodEyeHlOr*geodEyeOr;
   SGVec3d eyeCart = SGVec3d::fromGeod(geodEyePos);
   eyeCart += (ec2eye*eyeOffsetOr).backTransform(eyeOff);
@@ -775,5 +767,7 @@ FGViewer::update (double dt)
       }
     }
   }
-
+  recalc();
+  _cameraGroup->update(_absolute_view_pos.osg(), mViewOrientation.osg());
+  _cameraGroup->setCameraParameters(get_v_fov(), get_aspect_ratio());
 }