]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/viewmgr.cxx
Add the Sound Manager before any other subsystem that uses it. This makes sure the...
[flightgear.git] / src / Main / viewmgr.cxx
index 17610d6b4fc7cd306368dd30d4eae8653aa9bda0..20db9476ba6b0660cd263a75cd2f629e594e5ae7 100644 (file)
 #  include "config.h"
 #endif
 
-#include <string.h>            // strcmp
+#include "viewmgr.hxx"
 
-#include <plib/sg.h>
+#include <string.h>            // strcmp
 
 #include <simgear/compiler.h>
-
+#include <simgear/sound/soundmgr_openal.hxx>
 #include <Model/acmodel.hxx>
-
-#include "viewmgr.hxx"
-
+#include <Main/viewer.hxx>
+#include <Main/fg_props.hxx>
 
 // Constructor
 FGViewMgr::FGViewMgr( void ) :
@@ -44,6 +43,7 @@ FGViewMgr::FGViewMgr( void ) :
   config_list(fgGetNode("/sim", true)->getChildren("view")),
   current(0)
 {
+    smgr = (SGSoundMgr *)globals->get_subsystem("soundmgr");
 }
 
 // Destructor
@@ -295,6 +295,12 @@ FGViewMgr::update (double dt)
   do_axes();
   view->update(dt);
   abs_viewer_position = loop_view->getViewPosition();
+
+  // update audio listener values
+  // set the viewer posotion in Cartesian coordinates in meters
+  smgr->set_position(abs_viewer_position);
+  smgr->set_orientation(loop_view->getViewOrientation());
+  smgr->set_velocity(SGVec3f(0,0,0)); // TODO: in meters per second
 }
 
 void
@@ -343,7 +349,71 @@ FGViewMgr::copyToCurrent()
                 get_current_view()->getInternal());
 }
 
+void FGViewMgr::clear()
+{
+  views.clear();
+}
+
+FGViewer*
+FGViewMgr::get_current_view()
+{
+       if ( current < (int)views.size() ) {
+           return views[current];
+       } else {
+           return NULL;
+       }
+}
+
+const FGViewer*
+FGViewMgr::get_current_view() const
+{
+       if ( current < (int)views.size() ) {
+           return views[current];
+       } else {
+           return NULL;
+       }
+}
+
+
+FGViewer*
+FGViewMgr::get_view( int i )
+{
+       if ( i < 0 ) { i = 0; }
+       if ( i >= (int)views.size() ) { i = views.size() - 1; }
+       return views[i];
+}
+
+const FGViewer*
+FGViewMgr::get_view( int i ) const
+{
+       if ( i < 0 ) { i = 0; }
+       if ( i >= (int)views.size() ) { i = views.size() - 1; }
+       return views[i];
+}
+
+FGViewer*
+FGViewMgr::next_view()
+{
+       setView((current+1 < (int)views.size()) ? (current + 1) : 0);
+       view_number->fireValueChanged();
+       return views[current];
+}
+
+FGViewer*
+FGViewMgr::prev_view()
+{
+       setView((0 < current) ? (current - 1) : (views.size() - 1));
+       view_number->fireValueChanged();
+       return views[current];
+}
 
+void
+FGViewMgr::add_view( FGViewer * v )
+{
+  views.push_back(v);
+  v->init();
+}
+    
 double
 FGViewMgr::getViewHeadingOffset_deg () const
 {