proper listener velocity calculation, this has no effect yet but is required when other models start emitting sounds.
This commit is contained in:
@@ -361,7 +361,8 @@ void SGSampleGroup::update_sample_config( SGSoundSample *sample ) {
|
||||
|
||||
#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");
|
||||
|
||||
@@ -66,6 +66,7 @@ SGSoundMgr::SGSoundMgr() :
|
||||
_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)
|
||||
@@ -264,7 +265,13 @@ if (isNaN(_velocity.data())) printf("NaN in listener velocity\n");
|
||||
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;
|
||||
|
||||
@@ -156,8 +156,8 @@ public:
|
||||
* 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 ) {
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ 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 _velocity; }
|
||||
inline SGVec3f get_velocity() { return toVec3f(_velocity); }
|
||||
|
||||
/**
|
||||
* Set the orientation of the sound manager
|
||||
@@ -287,9 +287,10 @@ private:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user