void SGSampleGroup::update_pos_and_orientation() {
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();
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();
SGSoundSample *sample = sample_current->second;
sample->set_master_volume( _volume );
sample->set_orientation( _orientation );
- sample->set_rotation( hlOr );
+ sample->set_rotation( ec2body );
sample->set_position( position );
sample->set_velocity( velocity );
}
void SGSoundSample::update_pos_and_orientation() {
- _absolute_pos = _base_pos;
-#if 0
- if ( _relative_pos[0] || _relative_pos[1] || _relative_pos[2] ) {
- _absolute_pos += _rotation.backTransform( _relative_pos );
- }
-#endif
+ // position is in basic view, no need to rotate
+ // (proper alignment is set in xmlsound)
+ _absolute_pos = _base_pos + _relative_pos;
_orivec = SGVec3f::zeros();
if ( _direction[0] || _direction[1] || _direction[2] ) {
_orientation = ori; _changed = true;
}
- inline void set_rotation( const SGQuatd& hlOr ) {
- _rotation = hlOr; _changed = true;
+ inline void set_rotation( const SGQuatd& ec2body ) {
+ _rotation = ec2body; _changed = true;
}
/**
alDopplerFactor(1.0);
alDopplerVelocity(340.3); // speed of sound in meters per second.
+#if 0
if ( alIsExtensionPresent((const ALchar*)"EXT_exponent_distance") ) {
alDistanceModel(AL_EXPONENT_DISTANCE);
} else {
alDistanceModel(AL_INVERSE_DISTANCE);
}
+#endif
testForALError("listener initialization");
if (isNaN(toVec3f(_absolute_pos).data())) printf("NaN in listener position\n");
if (isNaN(_velocity.data())) printf("NaN in listener velocity\n");
#endif
- update_pos_and_orientation();
alListenerf( AL_GAIN, _volume );
alListenerfv( AL_ORIENTATION, _at_up_vec );
// alListenerfv( AL_POSITION, toVec3f(_absolute_pos).data() );
SGVec3f offset_pos = SGVec3f::zeros();
SGPropertyNode_ptr prop = node->getChild("position");
if ( prop != NULL ) {
- offset_pos[0] = prop->getDoubleValue("z", 0.0);
- offset_pos[1] = prop->getDoubleValue("y", 0.0);
- offset_pos[2] = prop->getDoubleValue("x", 0.0);
+ offset_pos[0] = -prop->getDoubleValue("x", 0.0);
+ offset_pos[1] = -prop->getDoubleValue("y", 0.0);
+ offset_pos[2] = -prop->getDoubleValue("z", 0.0);
}
//
float outer_gain = 0.0;
prop = node->getChild("orientation");
if ( prop != NULL ) {
- dir = SGVec3f(prop->getFloatValue("z", 0.0),
- prop->getFloatValue("y", 0.0),
- prop->getFloatValue("x", 0.0));
+ dir = SGVec3f(-prop->getFloatValue("x", 0.0),
+ -prop->getFloatValue("y", 0.0),
+ -prop->getFloatValue("z", 0.0));
inner = prop->getFloatValue("inner-angle", 360.0);
outer = prop->getFloatValue("outer-angle", 360.0);
outer_gain = prop->getFloatValue("outer-gain", 0.0);