What do you know, the real problem turned out to be the distance attenuation function..
This commit is contained in:
@@ -324,11 +324,11 @@ void SGSampleGroup::set_volume( float vol )
|
|||||||
void SGSampleGroup::update_pos_and_orientation() {
|
void SGSampleGroup::update_pos_and_orientation() {
|
||||||
|
|
||||||
SGVec3d position = SGVec3d::fromGeod(_base_pos) - _smgr->get_position();
|
SGVec3d position = SGVec3d::fromGeod(_base_pos) - _smgr->get_position();
|
||||||
SGQuatd hlOr = SGQuatd::fromLonLat(_base_pos) * _orientation;
|
SGQuatd ec2body= SGQuatd::fromLonLat(_base_pos) * _orientation;
|
||||||
|
|
||||||
SGVec3f velocity = SGVec3f::zeros();
|
SGVec3f velocity = SGVec3f::zeros();
|
||||||
if ( _velocity[0] || _velocity[1] || _velocity[2] ) {
|
if ( _velocity[0] || _velocity[1] || _velocity[2] ) {
|
||||||
velocity = toVec3f( hlOr.backTransform(_velocity*SG_FEET_TO_METER) );
|
velocity = toVec3f( ec2body.backTransform(_velocity*SG_FEET_TO_METER) );
|
||||||
}
|
}
|
||||||
|
|
||||||
sample_map_iterator sample_current = _samples.begin();
|
sample_map_iterator sample_current = _samples.begin();
|
||||||
@@ -337,7 +337,7 @@ void SGSampleGroup::update_pos_and_orientation() {
|
|||||||
SGSoundSample *sample = sample_current->second;
|
SGSoundSample *sample = sample_current->second;
|
||||||
sample->set_master_volume( _volume );
|
sample->set_master_volume( _volume );
|
||||||
sample->set_orientation( _orientation );
|
sample->set_orientation( _orientation );
|
||||||
sample->set_rotation( hlOr );
|
sample->set_rotation( ec2body );
|
||||||
sample->set_position( position );
|
sample->set_position( position );
|
||||||
sample->set_velocity( velocity );
|
sample->set_velocity( velocity );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -197,12 +197,9 @@ SGSoundSample::~SGSoundSample() {
|
|||||||
|
|
||||||
void SGSoundSample::update_pos_and_orientation() {
|
void SGSoundSample::update_pos_and_orientation() {
|
||||||
|
|
||||||
_absolute_pos = _base_pos;
|
// position is in basic view, no need to rotate
|
||||||
#if 0
|
// (proper alignment is set in xmlsound)
|
||||||
if ( _relative_pos[0] || _relative_pos[1] || _relative_pos[2] ) {
|
_absolute_pos = _base_pos + _relative_pos;
|
||||||
_absolute_pos += _rotation.backTransform( _relative_pos );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_orivec = SGVec3f::zeros();
|
_orivec = SGVec3f::zeros();
|
||||||
if ( _direction[0] || _direction[1] || _direction[2] ) {
|
if ( _direction[0] || _direction[1] || _direction[2] ) {
|
||||||
|
|||||||
@@ -337,8 +337,8 @@ public:
|
|||||||
_orientation = ori; _changed = true;
|
_orientation = ori; _changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void set_rotation( const SGQuatd& hlOr ) {
|
inline void set_rotation( const SGQuatd& ec2body ) {
|
||||||
_rotation = hlOr; _changed = true;
|
_rotation = ec2body; _changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -133,11 +133,13 @@ void SGSoundMgr::init() {
|
|||||||
alDopplerFactor(1.0);
|
alDopplerFactor(1.0);
|
||||||
alDopplerVelocity(340.3); // speed of sound in meters per second.
|
alDopplerVelocity(340.3); // speed of sound in meters per second.
|
||||||
|
|
||||||
|
#if 0
|
||||||
if ( alIsExtensionPresent((const ALchar*)"EXT_exponent_distance") ) {
|
if ( alIsExtensionPresent((const ALchar*)"EXT_exponent_distance") ) {
|
||||||
alDistanceModel(AL_EXPONENT_DISTANCE);
|
alDistanceModel(AL_EXPONENT_DISTANCE);
|
||||||
} else {
|
} else {
|
||||||
alDistanceModel(AL_INVERSE_DISTANCE);
|
alDistanceModel(AL_INVERSE_DISTANCE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
testForALError("listener initialization");
|
testForALError("listener initialization");
|
||||||
|
|
||||||
@@ -263,7 +265,6 @@ if (isNaN(_at_up_vec)) printf("NaN in listener orientation\n");
|
|||||||
if (isNaN(toVec3f(_absolute_pos).data())) printf("NaN in listener position\n");
|
if (isNaN(toVec3f(_absolute_pos).data())) printf("NaN in listener position\n");
|
||||||
if (isNaN(_velocity.data())) printf("NaN in listener velocity\n");
|
if (isNaN(_velocity.data())) printf("NaN in listener velocity\n");
|
||||||
#endif
|
#endif
|
||||||
update_pos_and_orientation();
|
|
||||||
alListenerf( AL_GAIN, _volume );
|
alListenerf( AL_GAIN, _volume );
|
||||||
alListenerfv( AL_ORIENTATION, _at_up_vec );
|
alListenerfv( AL_ORIENTATION, _at_up_vec );
|
||||||
// alListenerfv( AL_POSITION, toVec3f(_absolute_pos).data() );
|
// alListenerfv( AL_POSITION, toVec3f(_absolute_pos).data() );
|
||||||
|
|||||||
@@ -235,9 +235,9 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
|
|||||||
SGVec3f offset_pos = SGVec3f::zeros();
|
SGVec3f offset_pos = SGVec3f::zeros();
|
||||||
SGPropertyNode_ptr prop = node->getChild("position");
|
SGPropertyNode_ptr prop = node->getChild("position");
|
||||||
if ( prop != NULL ) {
|
if ( prop != NULL ) {
|
||||||
offset_pos[0] = prop->getDoubleValue("z", 0.0);
|
offset_pos[0] = -prop->getDoubleValue("x", 0.0);
|
||||||
offset_pos[1] = prop->getDoubleValue("y", 0.0);
|
offset_pos[1] = -prop->getDoubleValue("y", 0.0);
|
||||||
offset_pos[2] = prop->getDoubleValue("x", 0.0);
|
offset_pos[2] = -prop->getDoubleValue("z", 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -249,9 +249,9 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
|
|||||||
float outer_gain = 0.0;
|
float outer_gain = 0.0;
|
||||||
prop = node->getChild("orientation");
|
prop = node->getChild("orientation");
|
||||||
if ( prop != NULL ) {
|
if ( prop != NULL ) {
|
||||||
dir = SGVec3f(prop->getFloatValue("z", 0.0),
|
dir = SGVec3f(-prop->getFloatValue("x", 0.0),
|
||||||
prop->getFloatValue("y", 0.0),
|
-prop->getFloatValue("y", 0.0),
|
||||||
prop->getFloatValue("x", 0.0));
|
-prop->getFloatValue("z", 0.0));
|
||||||
inner = prop->getFloatValue("inner-angle", 360.0);
|
inner = prop->getFloatValue("inner-angle", 360.0);
|
||||||
outer = prop->getFloatValue("outer-angle", 360.0);
|
outer = prop->getFloatValue("outer-angle", 360.0);
|
||||||
outer_gain = prop->getFloatValue("outer-gain", 0.0);
|
outer_gain = prop->getFloatValue("outer-gain", 0.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user