]> git.mxchange.org Git - simgear.git/blobdiff - simgear/sound/soundmgr_openal.hxx
make the relative positions fixed against the body again.
[simgear.git] / simgear / sound / soundmgr_openal.hxx
index 1c05024db8709ed9a94f802c20fb55297374eb70..ecfd2637f87ed41adffa4f505afc4e713640a5bc 100644 (file)
 # include <OpenAL/al.h>
 # include <OpenAL/alc.h>
 # include <OpenAL/alut.h>
+#elif defined(OPENALSDK)
+# include <al.h>
+# include <alc.h>
+# include <AL/alut.h> 
 #else
 # include <AL/al.h>
 # include <AL/alc.h>
@@ -94,8 +98,7 @@ public:
     void init();
     void bind();
     void unbind();
-    void update(double dt) {};
-    void update_late(double dt);
+    void update(double dt);
     
     void suspend();
     void resume();
@@ -112,13 +115,13 @@ public:
     /**
      * Set the sound manager to a  working condition.
      */
-    inline void activate() { _active = true; }
+    void activate();
 
     /**
      * Test is the sound manager is in an active and working condition.
      * @return true is the sound manager is active
      */
-    inline bool is_active() const { return (_working && _active); }
+    inline bool is_active() const { return _active; }
 
     /**
      * Register a sample group to the sound manager.
@@ -150,13 +153,15 @@ public:
     SGSampleGroup *find( const string& refname, bool create = false );
 
     /**
-     * Set the position of the sound manager.
-     * This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
+     * Set the Cartesian position of the sound manager.
      * @param pos OpenAL listener position
      */
     void set_position( const SGVec3d& pos ) {
-        _position = -pos;
-        _changed = true;
+        _base_pos = pos; _changed = true;
+    }
+
+    void set_position_offset( const SGVec3d& pos ) {
+        _offset_pos = pos; _changed = true;
     }
 
     /**
@@ -164,16 +169,15 @@ public:
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right
      * @return OpenAL listener position
      */
-    SGVec3f get_position() { return toVec3f(_position); }
+    SGVec3d& get_position() { return _absolute_pos; }
 
     /**
-     * Set the velocity vector of the sound manager
-     * This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
-     * @param vel Velocity vector of the OpenAL listener
+     * Set the velocity vector (in meters per second) of the sound manager
+     * This is the horizontal local frame; x=north, y=east, z=down
+     * @param Velocity vector
      */
-    void set_velocity( SGVec3d& dir ) {
-        _velocity = dir;
-        _changed = true;
+    void set_velocity( const SGVec3f& vel ) {
+        _velocity = vel; _changed = true;
     }
 
     /**
@@ -181,13 +185,15 @@ public:
      * This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
      * @return Velocity vector of the OpenAL listener
      */
-    inline SGVec3f get_velocity() { return toVec3f(_velocity); }
+    inline SGVec3f& get_velocity() { return _velocity; }
 
     /**
      * Set the orientation of the sound manager
      * @param ori Quaternation containing the orientation information
      */
-    void set_orientation( SGQuatd ori );
+    void set_orientation( const SGQuatd& ori ) {
+        _orientation = ori; _changed = true;
+    }
 
     /**
      * Get the orientation of the sound manager
@@ -278,10 +284,12 @@ private:
     ALCcontext *_context;
 
     // Position of the listener.
-    SGVec3d _position;
+    SGVec3d _absolute_pos;
+    SGVec3d _offset_pos;
+    SGVec3d _base_pos;
 
     // Velocity of the listener.
-    SGVec3d _velocity;
+    SGVec3f _velocity;
 
     // Orientation of the listener. 
     // first 3 elements are "at" vector, second 3 are "up" vector
@@ -301,6 +309,7 @@ private:
     bool testForALUTError(string s);
     bool testForError(void *p, string s);
 
+    void update_pos_and_orientation();
     void update_sample_config( SGSampleGroup *sound );
 };