}
}
-// ste the source orientation of all managed sounds
+// set the source position of all managed sounds
void SGSampleGroup::set_position( SGGeod pos ) {
sample_map_iterator sample_current = _samples.begin();
}
-// ste the source orientation of all managed sounds
+// set the source orientation of all managed sounds
void SGSampleGroup::set_orientation( SGQuatd ori ) {
if (_orientation != ori) {
alSourcefv( source, AL_DIRECTION, _smgr->get_direction().data() );
alSourcefv( source, AL_VELOCITY, _smgr->get_velocity().data() );
} else {
- alSourcefv( source, AL_POSITION, sample->get_position());
+ alSourcefv( source, AL_POSITION, sample->get_position() );
alSourcefv( source, AL_DIRECTION, sample->get_orientation() );
alSourcefv( source, AL_VELOCITY, sample->get_velocity() );
}
*/
void set_orientation( SGQuatd ori );
- inline void tie_to_listener() { _tied_to_listener = true; }
+ void tie_to_listener() { _tied_to_listener = true; }
- inline void activate() { _active = true; }
+ void activate() { _active = true; }
protected:
SGSoundMgr *_smgr;
_playing(false),
_changed(true),
_static_changed(true),
- _is_file(false)
+ _is_file(false),
+ _orivec(SGVec3f::zeros())
{
}
_playing(false),
_changed(true),
_static_changed(true),
- _is_file(true)
+ _is_file(true),
+ _orivec(SGVec3f::zeros())
{
SGPath samplepath( path );
if ( strlen(file) ) {
_playing(false),
_changed(true),
_static_changed(true),
- _is_file(false)
+ _is_file(false),
+ _orivec(SGVec3f::zeros())
{
_sample_name = "unknown, data supplied by caller";
SG_LOG( SG_GENERAL, SG_DEBUG, "In memory sounds sample" );
_changed = true;
}
-float *SGSoundSample::get_orientation() {
- SGQuatd orient = SGQuatd::fromLonLat(_base_pos) * _orientation;
- SGVec3d orivec = -orient.rotate(_direction);
- return toVec3f(orivec).data();
-}
-
void SGSoundSample::set_relative_position( SGVec3f pos ) {
_relative_pos = pos;
update_absolute_position();
}
void SGSoundSample::update_absolute_position() {
+ SGQuatd orient = SGQuatd::fromLonLat(_base_pos) * _orientation;
+ _orivec = -toVec3f(orient.rotate(_direction));
+
_absolute_pos = -SGVec3d::fromGeod(_base_pos);
// TODO: add relative position
}
bool _static_changed;
bool _is_file;
+ SGVec3f _orivec;
void update_absolute_position();
public:
* Get the orientation of the sound source, the inner or outer angle
* or outer gain.
*/
- float *get_orientation();
-
- inline float get_innerangle() { return _inner_angle; }
- inline float get_outerangle() { return _outer_angle; }
- inline float get_outergain() { return _outer_gain; }
+ float *get_orientation() { return _orivec.data(); }
+ float get_innerangle() { return _inner_angle; }
+ float get_outerangle() { return _outer_angle; }
+ float get_outergain() { return _outer_gain; }
/**
* Set velocity of the sound source (uses same coordinate system as opengl)
return false;
}
+ if (_working) sgrp->activate();
_sample_groups[refname] = sgrp;
return true;
ALboolean loop;
alutLoadWAVFile( fname, &format, &data, &size, &freq, &loop );
# endif
- ALenum error = alutGetError();
- if ( error != ALUT_ERROR_NO_ERROR ) {
+ ALenum error = alGetError();
+ if ( error != AL_NO_ERROR ) {
string msg = "Failed to load wav file: ";
msg.append(alutGetErrorString(error));
throw sg_io_exception(msg.c_str(), sg_location(samplepath));