_tied_to_listener(false),
_velocity(SGVec3d::zeros()),
_orientation(SGQuatd::zeros()),
- _position(SGVec3d::zeros()),
- _pos_offs(SGVec3d::zeros()),
_position_geod(SGGeod())
{
_samples.clear();
_tied_to_listener(false),
_velocity(SGVec3d::zeros()),
_orientation(SGQuatd::zeros()),
- _position(SGVec3d::zeros()),
- _pos_offs(SGVec3d::zeros()),
_position_geod(SGGeod())
{
_smgr->add(this, refname);
SGVec3d position = SGVec3d::fromGeod( _position_geod );
SGVec3d pos_offs = SGVec3d::fromGeod( _smgr->get_position_geod() );
- if (_position != position || _pos_offs != pos_offs) {
- _position = position;
- _pos_offs = pos_offs;
-
- sample_map_iterator sample_current = _samples.begin();
- sample_map_iterator sample_end = _samples.end();
- for ( ; sample_current != sample_end; ++sample_current ) {
- SGSoundSample *sample = sample_current->second;
- sample->set_position( _position );
- sample->set_position_offset( _pos_offs );
- }
- }
-
// The rotation rotating from the earth centerd frame to
// the horizontal local frame
SGQuatd hlOr = SGQuatd::fromLonLat(_position_geod);
sample_map_iterator sample_end = _samples.end();
for ( ; sample_current != sample_end; ++sample_current ) {
SGSoundSample *sample = sample_current->second;
+ sample->set_position( position - pos_offs );
sample->set_orientation( _orientation );
sample->set_rotation( sc2body );
}
SGVec3f _velocity;
SGQuatd _orientation;
- SGVec3d _position;
- SGVec3d _pos_offs;
-
SGGeod _position_geod;
sample_map _samples;
_rotation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
_base_pos(SGVec3d::zeros()),
- _base_offs(SGVec3d::zeros()),
_refname(random_string()),
_data(NULL),
_format(AL_FORMAT_MONO8),
_rotation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
_base_pos(SGVec3d::zeros()),
- _base_offs(SGVec3d::zeros()),
_refname(file),
_data(NULL),
_format(AL_FORMAT_MONO8),
_rotation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
_base_pos(SGVec3d::zeros()),
- _base_offs(SGVec3d::zeros()),
_refname(random_string()),
_format(format),
_size(len),
_rotation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
_base_pos(SGVec3d::zeros()),
- _base_offs(SGVec3d::zeros()),
_refname(random_string()),
_format(format),
_size(len),
void SGSoundSample::update_pos_and_orientation() {
- _absolute_pos = _base_pos - _base_offs;
+ _absolute_pos = _base_pos;
if ( _relative_pos[0] || _relative_pos[1] || _relative_pos[2] ) {
_absolute_pos += _rotation.backTransform(_relative_pos);
}
_base_pos = pos; _changed = true;
}
- /**
- * Set the base position offset in Cartesian coordinates
- * @param offs offset in Cartesian coordinates
- */
- inline void set_position_offset( const SGVec3d& offs ) {
- _base_offs = offs; _changed = true;
- }
-
/**
* Get the absolute position of this sound.
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
SGQuatd _rotation; // rotation vector for relative offsets
SGVec3f _orivec; // orientation vector for OpenAL
SGVec3d _base_pos; // base position
- SGVec3d _base_offs; // base offset position
std::string _refname; // name or file path
unsigned char* _data;