proper orientation(?) and comment out relative position and direction code since it messes with OpenAL in such a way that volume doesn't work properly anymore
This commit is contained in:
parent
c89db53ebf
commit
6ccad91537
@ -46,7 +46,7 @@ SGSoundSample::SGSoundSample() :
|
||||
_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)),
|
||||
@ -80,7 +80,7 @@ SGSoundSample::SGSoundSample( const char *path, const char *file ) :
|
||||
_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)),
|
||||
@ -120,7 +120,7 @@ SGSoundSample::SGSoundSample( const unsigned char** data,
|
||||
_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)),
|
||||
@ -155,7 +155,7 @@ SGSoundSample::SGSoundSample( void** data, int len, int freq, int format ) :
|
||||
_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)),
|
||||
@ -204,15 +204,17 @@ void SGSoundSample::update_pos_and_orientation() {
|
||||
// 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
|
||||
// The cartesian position of the sounds base location
|
||||
SGVec3d position = SGVec3d::fromGeod(_base_pos);
|
||||
|
||||
_absolute_pos = position;
|
||||
#if 0
|
||||
if ( _relative_pos[0] || _relative_pos[1] || _relative_pos[2] ) {
|
||||
_absolute_pos += (sc2body*q).backTransform(_relative_pos);
|
||||
}
|
||||
#endif
|
||||
if ( _direction[0] || _direction[1] || _direction[2] ) {
|
||||
_orivec = toVec3f((sc2body*q).backTransform(toVec3d(_direction)));
|
||||
_orivec = toVec3f( (sc2body*q).backTransform(_direction) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ public:
|
||||
* @param dir Sound emission direction
|
||||
*/
|
||||
inline void set_direction( const SGVec3f& dir ) {
|
||||
_direction = dir; _changed = true;
|
||||
_direction = toVec3d(dir); _changed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -359,7 +359,6 @@ public:
|
||||
* @return Orientaton vector
|
||||
*/
|
||||
SGVec3f& get_orientation() { return _orivec; }
|
||||
SGVec3f& get_direction() { return _direction; }
|
||||
|
||||
/**
|
||||
* Get the inner angle of the audio cone.
|
||||
@ -442,7 +441,7 @@ private:
|
||||
// Position of the source sound.
|
||||
SGVec3d _absolute_pos; // absolute position
|
||||
SGVec3d _relative_pos; // position relative to the base position
|
||||
SGVec3f _direction; // orientation offset
|
||||
SGVec3d _direction; // orientation offset
|
||||
SGVec3f _velocity; // Velocity of the source sound.
|
||||
|
||||
// The position and orientation of this sound
|
||||
|
@ -477,7 +477,12 @@ void SGSoundMgr::update_pos_and_orientation() {
|
||||
// simulation runs into the OpenGL camera system with x-right, y-up, z-back.
|
||||
SGQuatd q(-0.5, -0.5, 0.5, 0.5);
|
||||
|
||||
_absolute_pos = position + (lc2body*q).backTransform( _position_offs );
|
||||
_absolute_pos = position;
|
||||
#if 0
|
||||
if (_position_offs[0] || _position_offs[1] || _position_offs[2] ) {
|
||||
_absolute_pos += (lc2body*q).backTransform( _position_offs );
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Description: ORIENTATION is a pair of 3-tuples representing the
|
||||
@ -489,8 +494,8 @@ void SGSoundMgr::update_pos_and_orientation() {
|
||||
* behavior is undefined.
|
||||
* This is in the same coordinate system as OpenGL; y=up, z=back, x=right.
|
||||
*/
|
||||
SGQuatd lViewOrientation = lc2body*_orient_offs*q;
|
||||
SGVec3d sgv_up = lViewOrientation.rotate(SGVec3d::e2());
|
||||
SGQuatd lViewOrientation = hlOr*_orient_offs*q;
|
||||
SGVec3d sgv_up = -lViewOrientation.rotate(SGVec3d::e2());
|
||||
SGVec3d sgv_at = lViewOrientation.rotate(SGVec3d::e3());
|
||||
_at_up_vec[0] = sgv_at[0];
|
||||
_at_up_vec[1] = sgv_at[1];
|
||||
|
@ -229,9 +229,9 @@ SGXmlSound::init(SGPropertyNode *root, SGPropertyNode *node,
|
||||
SGVec3f offset_pos = SGVec3f::zeros();
|
||||
SGPropertyNode_ptr prop = node->getChild("position");
|
||||
if ( prop != NULL ) {
|
||||
offset_pos[0] = prop->getDoubleValue("x", 0.0);
|
||||
offset_pos[1] = -prop->getDoubleValue("y", 0.0);
|
||||
offset_pos[2] = prop->getDoubleValue("z", 0.0);
|
||||
offset_pos[0] = prop->getDoubleValue("y", 0.0);
|
||||
offset_pos[1] = prop->getDoubleValue("z", 0.0);
|
||||
offset_pos[2] = prop->getDoubleValue("x", 0.0);
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user