+
+ /**
+ * Get the orientation vector of this sound.
+ * This is in the same coordinate system as OpenGL; y=up, z=back, x=right
+ * @return Orientaton vector
+ */
+ SGVec3f& get_orientation() { return _orivec; }
+
+ /**
+ * Get the inner angle of the audio cone.
+ * @return Inner angle in degrees
+ */
+ float get_innerangle() { return _inner_angle; }
+
+ /**
+ * Get the outer angle of the audio cone.
+ * @return Outer angle in degrees
+ */
+ float get_outerangle() { return _outer_angle; }
+
+ /**
+ * Get the remaining gain at the edge of the outer cone.
+ * @return Gain
+ */
+ float get_outergain() { return _outer_gain; }
+
+ /**
+ * Set the velocity vector (in meters per second) of this sound.
+ * This is in the local frame coordinate system; x=north, y=east, z=down
+ * @param Velocity vector
+ */
+ inline void set_velocity( const SGVec3f& vel ) {
+ _velocity = vel; _changed = true;
+ }
+
+ /**
+ * Get velocity vector (in meters per second) of this sound.
+ * This is in the same coordinate system as OpenGL; y=up, z=back, x=right
+ * @return Velocity vector
+ */
+ SGVec3f& get_velocity() { return _velocity; }
+
+
+ /**
+ * Set reference distance (in meters) of this sound.
+ * This is the distance where the gain will be half.
+ * @param dist Reference distance
+ */
+ inline void set_reference_dist( float dist ) {
+ _reference_dist = dist; _static_changed = true;
+ }
+
+ /**
+ * Get reference distance ((in meters) of this sound.
+ * This is the distance where the gain will be half.
+ * @return Reference distance
+ */
+ inline float get_reference_dist() { return _reference_dist; }
+
+
+ /**
+ * Set maximum distance (in meters) of this sound.
+ * This is the distance where this sound is no longer audible.
+ * @param dist Maximum distance
+ */
+ inline void set_max_dist( float dist ) {
+ _max_dist = dist; _static_changed = true;
+ }
+
+ /**
+ * Get maximum distance (in meters) of this sound.
+ * This is the distance where this sound is no longer audible.
+ * @return dist Maximum distance
+ */
+ inline float get_max_dist() { return _max_dist; }
+
+ /**
+ * Get the reference name of this audio sample.
+ * @return Sample name
+ */
+ inline std::string get_sample_name() const { return _refname; }
+
+ inline virtual bool is_queue() const { return false; }
+
+ void update_pos_and_orientation();
+
+private:
+
+ // Position of the source sound.
+ SGVec3d _absolute_pos; // absolute position
+ SGVec3d _relative_pos; // position relative to the base position
+ SGVec3d _direction; // orientation offset
+ SGVec3f _velocity; // Velocity of the source sound.
+
+ // The position and orientation of this sound
+ SGQuatd _orientation; // base orientation
+ SGVec3f _orivec; // orientation vector for OpenAL
+ SGVec3d _base_pos; // base position
+
+ SGQuatd _rotation;
+
+ std::string _refname; // name or file path
+ unsigned char* _data;
+
+ // configuration values
+ int _format;
+ size_t _size;
+ int _freq;
+
+ // Buffers hold sound data.
+ bool _valid_buffer;
+ unsigned int _buffer;
+
+ // Sources are points emitting sound.
+ bool _valid_source;
+ unsigned int _source;
+
+ // The orientation of this sound (direction and cut-off angles)
+ float _inner_angle;
+ float _outer_angle;
+ float _outer_gain;
+
+ float _pitch;
+ float _volume;
+ float _master_volume;
+ float _reference_dist;
+ float _max_dist;
+ bool _loop;
+
+ bool _playing;
+ bool _changed;
+ bool _static_changed;
+ bool _is_file;
+
+ string random_string();