forked from teamnwah/openmw-tes3coop
Be more consistent with the vector orientations given the sound handler
This commit is contained in:
parent
cbeff4657f
commit
7160d20db3
4 changed files with 18 additions and 12 deletions
|
@ -368,7 +368,7 @@ Sound* OpenAL_Output::PlaySound(const std::string &fname, std::auto_ptr<Sound_De
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound* OpenAL_Output::PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
Sound* OpenAL_Output::PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
||||||
MWWorld::Ptr ptr, float volume, float pitch,
|
const float *pos, float volume, float pitch,
|
||||||
float min, float max, bool loop)
|
float min, float max, bool loop)
|
||||||
{
|
{
|
||||||
throwALerror();
|
throwALerror();
|
||||||
|
@ -393,7 +393,6 @@ Sound* OpenAL_Output::PlaySound3D(const std::string &fname, std::auto_ptr<Sound_
|
||||||
}
|
}
|
||||||
|
|
||||||
std::auto_ptr<OpenAL_Sound> sound(new OpenAL_Sound(src, buf));
|
std::auto_ptr<OpenAL_Sound> sound(new OpenAL_Sound(src, buf));
|
||||||
const float *pos = ptr.getCellRef().pos.pos;
|
|
||||||
alSource3f(src, AL_POSITION, pos[0], pos[2], -pos[1]);
|
alSource3f(src, AL_POSITION, pos[0], pos[2], -pos[1]);
|
||||||
alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
alSource3f(src, AL_DIRECTION, 0.0f, 0.0f, 0.0f);
|
||||||
alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
alSource3f(src, AL_VELOCITY, 0.0f, 0.0f, 0.0f);
|
||||||
|
@ -430,10 +429,14 @@ Sound* OpenAL_Output::StreamSound(const std::string &fname, std::auto_ptr<Sound_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void OpenAL_Output::UpdateListener(float pos[3], float atdir[3], float updir[3])
|
void OpenAL_Output::UpdateListener(const float *pos, const float *atdir, const float *updir)
|
||||||
{
|
{
|
||||||
float orient[6] = { atdir[0], atdir[1], atdir[2], updir[0], updir[1], updir[2] };
|
float orient[6] = {
|
||||||
alListenerfv(AL_POSITION, pos);
|
atdir[0], atdir[2], -atdir[1],
|
||||||
|
updir[0], updir[2], -updir[1]
|
||||||
|
};
|
||||||
|
|
||||||
|
alListener3f(AL_POSITION, pos[0], pos[2], -pos[1]);
|
||||||
alListenerfv(AL_ORIENTATION, orient);
|
alListenerfv(AL_ORIENTATION, orient);
|
||||||
throwALerror();
|
throwALerror();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,13 +25,13 @@ namespace MWSound
|
||||||
virtual Sound *PlaySound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
virtual Sound *PlaySound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
||||||
float volume, float pitch, bool loop);
|
float volume, float pitch, bool loop);
|
||||||
virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
||||||
MWWorld::Ptr ptr, float volume, float pitch,
|
const float *pos, float volume, float pitch,
|
||||||
float min, float max, bool loop);
|
float min, float max, bool loop);
|
||||||
|
|
||||||
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
||||||
float volume, float pitch);
|
float volume, float pitch);
|
||||||
|
|
||||||
virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]);
|
virtual void UpdateListener(const float *pos, const float *atdir, const float *updir);
|
||||||
|
|
||||||
OpenAL_Output(SoundManager &mgr);
|
OpenAL_Output(SoundManager &mgr);
|
||||||
virtual ~OpenAL_Output();
|
virtual ~OpenAL_Output();
|
||||||
|
|
|
@ -22,13 +22,12 @@ namespace MWSound
|
||||||
virtual Sound *PlaySound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
virtual Sound *PlaySound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
||||||
float volume, float pitch, bool loop) = 0;
|
float volume, float pitch, bool loop) = 0;
|
||||||
virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
virtual Sound *PlaySound3D(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
||||||
MWWorld::Ptr ptr, float volume, float pitch,
|
const float *pos, float volume, float pitch,
|
||||||
float min, float max, bool loop) = 0;
|
float min, float max, bool loop) = 0;
|
||||||
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
virtual Sound *StreamSound(const std::string &fname, std::auto_ptr<Sound_Decoder> decoder,
|
||||||
float volume, float pitch) = 0;
|
float volume, float pitch) = 0;
|
||||||
|
|
||||||
// FIXME: This should take an MWWorld::Ptr that represents the in-world camera
|
virtual void UpdateListener(const float *pos, const float *atdir, const float *updir) = 0;
|
||||||
virtual void UpdateListener(float pos[3], float atdir[3], float updir[3]) = 0;
|
|
||||||
|
|
||||||
Sound_Output(SoundManager &mgr) : mgr(mgr) { }
|
Sound_Output(SoundManager &mgr) : mgr(mgr) { }
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -125,8 +125,9 @@ namespace MWSound
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Sound *sound;
|
Sound *sound;
|
||||||
|
const float *pos = ptr.getCellRef().pos.pos;
|
||||||
std::auto_ptr<Sound_Decoder> decoder(new DEFAULT_DECODER);
|
std::auto_ptr<Sound_Decoder> decoder(new DEFAULT_DECODER);
|
||||||
sound = Output->PlaySound3D(file, decoder, ptr, volume, pitch, min, max, loop);
|
sound = Output->PlaySound3D(file, decoder, pos, volume, pitch, min, max, loop);
|
||||||
if(untracked)
|
if(untracked)
|
||||||
LooseSounds[id] = SoundPtr(sound);
|
LooseSounds[id] = SoundPtr(sound);
|
||||||
else
|
else
|
||||||
|
@ -444,7 +445,10 @@ namespace MWSound
|
||||||
nDir = cam->getRealDirection();
|
nDir = cam->getRealDirection();
|
||||||
nUp = cam->getRealUp();
|
nUp = cam->getRealUp();
|
||||||
|
|
||||||
Output->UpdateListener(&nPos[0], &nDir[0], &nUp[0]);
|
float pos[3] = { nPos[0], -nPos[2], nPos[1] };
|
||||||
|
float at[3] = { nDir[0], -nDir[2], nDir[1] };
|
||||||
|
float up[3] = { nUp[0], -nUp[2], nUp[1] };
|
||||||
|
Output->UpdateListener(pos, at, up);
|
||||||
|
|
||||||
|
|
||||||
IDMap::iterator snditer = LooseSounds.begin();
|
IDMap::iterator snditer = LooseSounds.begin();
|
||||||
|
|
Loading…
Reference in a new issue