#if 0
if (length(position) > 20000)
- printf("source and listener distance greater than 20km!\n");
+ printf("%s source and listener distance greater than 20km!\n",
+ _refname.c_str());
if (isNaN(toVec3f(position).data())) printf("NaN in source position\n");
if (isNaN(orientation.data())) printf("NaN in source orientation\n");
if (isNaN(velocity.data())) printf("NaN in source velocity\n");
_absolute_pos(SGVec3d::zeros()),
_offset_pos(SGVec3d::zeros()),
_base_pos(SGVec3d::zeros()),
+ _geod_pos(SGGeod::fromCart(SGVec3d::zeros())),
_velocity(SGVec3d::zeros()),
_orientation(SGQuatd::zeros()),
_devname(NULL)
alListenerf( AL_GAIN, _volume );
alListenerfv( AL_ORIENTATION, _at_up_vec );
// alListenerfv( AL_POSITION, toVec3f(_absolute_pos).data() );
- alListenerfv( AL_VELOCITY, _velocity.data() );
+
+ SGQuatd hlOr = SGQuatd::fromLonLat( _geod_pos );
+ SGVec3d velocity = SGVec3d::zeros();
+ if ( _velocity[0] || _velocity[1] || _velocity[2] ) {
+ velocity = hlOr.backTransform(_velocity*SG_FEET_TO_METER);
+ }
+ alListenerfv( AL_VELOCITY, toVec3f(velocity).data() );
// alDopplerVelocity(340.3); // TODO: altitude dependent
testForALError("update");
_changed = false;
* Set the Cartesian position of the sound manager.
* @param pos OpenAL listener position
*/
- void set_position( const SGVec3d& pos ) {
- _base_pos = pos; _changed = true;
+ void set_position( const SGVec3d& pos, const SGGeod& pos_geod ) {
+ _base_pos = pos; _geod_pos = pos_geod; _changed = true;
}
void set_position_offset( const SGVec3d& pos ) {
* This is the horizontal local frame; x=north, y=east, z=down
* @param Velocity vector
*/
- void set_velocity( const SGVec3f& vel ) {
+ void set_velocity( const SGVec3d& vel ) {
_velocity = vel; _changed = true;
}
* 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 _velocity; }
+ inline SGVec3f get_velocity() { return toVec3f(_velocity); }
/**
* Set the orientation of the sound manager
SGVec3d _absolute_pos;
SGVec3d _offset_pos;
SGVec3d _base_pos;
+ SGGeod _geod_pos;
// Velocity of the listener.
- SGVec3f _velocity;
+ SGVec3d _velocity;
// Orientation of the listener.
// first 3 elements are "at" vector, second 3 are "up" vector