_absolute_pos(SGVec3d::zeros()),
_relative_pos(SGVec3d::zeros()),
_direction(SGVec3d::zeros()),
- _velocity(SGVec3d::zeros()),
+ _velocity(SGVec3f::zeros()),
_orientation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
- _base_pos(SGGeod::fromDeg(0,0)),
+ _base_pos(SGVec3d::zeros()),
+ _rotation(SGQuatd::zeros()),
_refname(random_string()),
_data(NULL),
_format(AL_FORMAT_MONO8),
_absolute_pos(SGVec3d::zeros()),
_relative_pos(SGVec3d::zeros()),
_direction(SGVec3d::zeros()),
- _velocity(SGVec3d::zeros()),
+ _velocity(SGVec3f::zeros()),
_orientation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
- _base_pos(SGGeod::fromDeg(0,0)),
+ _base_pos(SGVec3d::zeros()),
+ _rotation(SGQuatd::zeros()),
_refname(file),
_data(NULL),
_format(AL_FORMAT_MONO8),
_absolute_pos(SGVec3d::zeros()),
_relative_pos(SGVec3d::zeros()),
_direction(SGVec3d::zeros()),
- _velocity(SGVec3d::zeros()),
+ _velocity(SGVec3f::zeros()),
_orientation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
- _base_pos(SGGeod::fromDeg(0,0)),
+ _base_pos(SGVec3d::zeros()),
+ _rotation(SGQuatd::zeros()),
_refname(random_string()),
_format(format),
_size(len),
_absolute_pos(SGVec3d::zeros()),
_relative_pos(SGVec3d::zeros()),
_direction(SGVec3d::zeros()),
- _velocity(SGVec3d::zeros()),
+ _velocity(SGVec3f::zeros()),
_orientation(SGQuatd::zeros()),
_orivec(SGVec3f::zeros()),
- _base_pos(SGGeod::fromDeg(0,0)),
+ _base_pos(SGVec3d::zeros()),
+ _rotation(SGQuatd::zeros()),
_refname(random_string()),
_format(format),
_size(len),
// destructor
SGSoundSample::~SGSoundSample() {
- if (_data) free(_data);
+ if ( _data != NULL ) free(_data);
}
-void SGSoundSample::update_absolute_position() {
- // The rotation rotating from the earth centerd frame to
- // the horizontal local frame
- SGQuatd hlOr = SGQuatd::fromLonLat(_base_pos);
+void SGSoundSample::update_pos_and_orientation() {
- // Compute the sounds orientation and position
- // wrt the earth centered frame - that is global coorinates
- SGQuatd sc2body = hlOr*_orientation;
-
- // This is rotates the x-forward, y-right, z-down coordinate system where
- // simulation runs into the OpenGL camera system with x-right, y-up, z-back.
- SGQuatd q(-0.5, -0.5, 0.5, 0.5);
-
- // The cartesian position of the base sound coordinate
- SGVec3d position = SGVec3d::fromGeod(_base_pos);
-
- _absolute_pos = position;
- if ( !(_relative_pos[0] == 0 && _relative_pos[1] == 0 &&
- _relative_pos[2] == 0) )
- {
- _absolute_pos += (sc2body*q).backTransform(_relative_pos);
+ _absolute_pos = _base_pos;
+ if (_relative_pos[0] || _relative_pos[1] || _relative_pos[2] ) {
+ _absolute_pos += _rotation.rotate( _relative_pos );
}
- if ( !(_direction[0] == 0 && _direction[1] == 0 && _direction[2] == 0) ) {
- _orivec = toVec3f((sc2body*q).backTransform(toVec3d(_direction)));
+
+ _orivec = SGVec3f::zeros();
+ if ( _direction[0] || _direction[1] || _direction[2] ) {
+ _orivec = toVec3f( _rotation.rotate( _direction ) );
}
}