X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FSound.cc;h=4cb291300850dec5c29e38a1808c42a986287789;hp=460f7bb24a1054d2a18e0e579f08e8386320e06c;hb=ca0f7bdfba63140dca0bd20586d31980f3938eb2;hpb=33842c860fe18ca8cf087905992885687434320c diff --git a/src/Moof/Sound.cc b/src/Moof/Sound.cc index 460f7bb..4cb2913 100644 --- a/src/Moof/Sound.cc +++ b/src/Moof/Sound.cc @@ -457,6 +457,8 @@ struct Sound::Impl { // don't let the music die! update(); + // TODO - might be nice to also allow using threads for streaming rather + // than a timer, probably as a compile-time option } }; @@ -522,13 +524,13 @@ bool Sound::isPlaying() const return impl_->isPlaying(); } -void Sound::setPosition(Vector3 position) +void Sound::setPosition(const Vector3& position) { float p[3] = {position[0], position[1], position[2]}; alSourcefv(impl_->source_, AL_POSITION, p); } -void Sound::setVelocity(Vector3 velocity) +void Sound::setVelocity(const Vector3& velocity) { float v[3] = {velocity[0], velocity[1], velocity[2]}; alSourcefv(impl_->source_, AL_VELOCITY, v); @@ -551,6 +553,31 @@ void Sound::setLooping(bool looping) } +void Sound::setListenerPosition(const Vector3& position) +{ + alListener3f(AL_POSITION, float(position[0]), float(position[1]), + float(position[2])); +} + +void Sound::setListenerVelocity(const Vector3& velocity) +{ + alListener3f(AL_VELOCITY, float(velocity[0]), float(velocity[1]), + float(velocity[2])); +} + +void Sound::setListenerOrientation(const Vector3& forward, const Vector3& up) +{ + float vec[6]; + vec[0] = float(forward[0]); + vec[1] = float(forward[1]); + vec[2] = float(forward[2]); + vec[3] = float(up[0]); + vec[4] = float(up[1]); + vec[5] = float(up[2]); + alListenerfv(AL_ORIENTATION, vec); +} + + std::string Sound::getPath(const std::string& name) { std::string path = Resource::getPath("sounds/" + name + ".ogg");