Allow per-track sounds for emitters

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9431 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-08-06 20:37:54 +00:00
parent a4b954f2ea
commit a44adb6e6c
4 changed files with 37 additions and 12 deletions

View File

@@ -48,16 +48,20 @@ public:
virtual bool init() = 0;
virtual void position(const Vec3 &position) = 0;
virtual void setLoop(bool status) = 0;
virtual void play() = 0;
virtual void stop() = 0;
virtual void pause() = 0;
virtual void resume() = 0;
virtual void speed(float factor) = 0;
virtual void volume(float gain) = 0;
virtual void setLoop(bool status) = 0;
virtual void play() = 0;
virtual void stop() = 0;
virtual void pause() = 0;
virtual void resume() = 0;
virtual void speed(float factor) = 0;
virtual void volume(float gain) = 0;
virtual SFXManager::SFXStatus
getStatus() = 0;
virtual void onSoundEnabledBack() = 0;
getStatus() = 0;
virtual void onSoundEnabledBack() = 0;
virtual void setRolloff(float rolloff) = 0;
virtual const SFXBuffer* getBuffer() const = 0;
}; // SfxBase

View File

@@ -280,4 +280,11 @@ void SFXOpenAL::onSoundEnabledBack()
}
}
//-----------------------------------------------------------------------------
void SFXOpenAL::setRolloff(float rolloff)
{
alSourcef (m_soundSource, AL_ROLLOFF_FACTOR, rolloff);
}
#endif //if HAVE_OGGVORBIS

View File

@@ -71,8 +71,9 @@ public:
virtual void volume(float gain);
virtual SFXManager::SFXStatus getStatus();
virtual void onSoundEnabledBack();
const SFXBuffer* getBuffer() const { return m_soundBuffer; }
virtual void setRolloff(float rolloff);
virtual const SFXBuffer* getBuffer() const { return m_soundBuffer; }
}; // SFXOpenAL

View File

@@ -20,6 +20,7 @@
#include "tracks/track_object.hpp"
#include "audio/sfx_base.hpp"
#include "audio/sfx_buffer.hpp"
#include "audio/sfx_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "io/file_manager.hpp"
@@ -56,7 +57,18 @@ TrackObject::TrackObject(const XMLNode &xml_node)
if (sound.size() > 0)
{
m_sound = sfx_manager->createSoundSource(sound);
float rolloff = 0.5;
xml_node.get("rolloff", &rolloff );
float volume = 1.0;
xml_node.get("volume", &volume );
SFXBuffer* buffer = new SFXBuffer(file_manager->getModelFile(sound),
true /* positional */,
rolloff,
volume);
buffer->load();
m_sound = sfx_manager->createSoundSource(buffer);
if (m_sound != NULL)
{
m_sound->position(m_init_xyz);
@@ -135,6 +147,7 @@ TrackObject::~TrackObject()
if (m_sound)
{
delete m_sound->getBuffer();
sfx_manager->deleteSFX(m_sound);
}