Fix both relative and 3D sounds

actorid
Michael Papageorgiou 13 years ago
parent 97030c5dba
commit 836732096e

@ -397,6 +397,7 @@ namespace MWSound
snd->setVolume(volume);
snd->setRange(min,max);
snd->setPitch(pitch);
snd->setRelative(true);
snd->play();
if (loop)

@ -52,9 +52,9 @@ namespace Sound {
Ogre::Vector3 nPos, nDir, nUp;
nPos = camera->getPosition();
nDir = camera->getDirection();
nUp = camera->getUp();
nPos = camera->getRealPosition();
nDir = camera->getRealDirection();
nUp = camera->getRealUp();
// Don't bother the sound system needlessly
if(nDir != dir || nPos != pos || nUp != up)

@ -28,6 +28,7 @@ namespace Mangle
void setRange(float a, float b=0, float c=0)
{ client->setRange(a,b,c); }
void setStreaming(bool b) { client->setStreaming(b); }
void setRelative(bool b) { client->setRelative(b); }
// The clone() function is not implemented here, as you will
// almost certainly want to override it yourself

@ -62,6 +62,9 @@ class Sound
/// Set loop mode
virtual void setRepeat(bool) = 0;
/// If set to true the sound will not be affected by player movement
virtual void setRelative(bool) = 0;
/// Set streaming mode.
/** This may be used by implementations to optimize for very large
files. If streaming mode is off (default), most implementations

@ -197,6 +197,7 @@ class Mangle::Sound::OpenAL_Sound : public Sound
void setPos(float x, float y, float z);
void setPitch(float);
void setRepeat(bool);
void setRelative(bool);
void notifyOwnerDeath()
{ ownerAlive = false; }
@ -363,6 +364,12 @@ void OpenAL_Sound::setRepeat(bool rep)
alSourcei(inst, AL_LOOPING, rep?AL_TRUE:AL_FALSE);
}
void OpenAL_Sound::setRelative(bool rel)
{
alSourcei(inst, AL_SOURCE_RELATIVE, rel?AL_TRUE:AL_FALSE);
checkALError("setting relative");
}
SoundPtr OpenAL_Sound::clone()
{
setupBuffer();

Loading…
Cancel
Save