Add some support for sound emitters on tracks
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@9430 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
5d8324813f
commit
a4b954f2ea
@ -225,7 +225,7 @@ void SFXOpenAL::position(const Vec3 &position)
|
||||
return;
|
||||
if (!m_ok)
|
||||
{
|
||||
fprintf(stderr, "WARNING, position called on non-ok SFX\n");
|
||||
fprintf(stderr, "WARNING, position called on non-ok SFX <%s>\n", m_soundBuffer->getFileName().c_str());
|
||||
return;
|
||||
}
|
||||
if (!m_positional)
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "tracks/track_object.hpp"
|
||||
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
@ -40,6 +42,7 @@ TrackObject::TrackObject(const XMLNode &xml_node)
|
||||
m_init_scale = core::vector3df(1,1,1);
|
||||
m_enabled = true;
|
||||
m_is_looped = false;
|
||||
m_sound = NULL;
|
||||
|
||||
xml_node.get("xyz", &m_init_xyz );
|
||||
xml_node.get("hpr", &m_init_hpr );
|
||||
@ -48,9 +51,26 @@ TrackObject::TrackObject(const XMLNode &xml_node)
|
||||
xml_node.get("looped", &m_is_looped );
|
||||
std::string model_name;
|
||||
xml_node.get("model", &model_name );
|
||||
std::string sound;
|
||||
xml_node.get("sound", &sound );
|
||||
|
||||
// Some animated objects (billboards) don't use this scene node
|
||||
if(model_name=="")
|
||||
if (sound.size() > 0)
|
||||
{
|
||||
m_sound = sfx_manager->createSoundSource(sound);
|
||||
if (m_sound != NULL)
|
||||
{
|
||||
m_sound->position(m_init_xyz);
|
||||
m_sound->setLoop(true);
|
||||
m_sound->play();
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "[TrackObject] Sound emitter object could not be created\n");
|
||||
}
|
||||
}
|
||||
|
||||
// Some animated objects (billboards, sound emitters) don't use this scene node
|
||||
if (model_name == "")
|
||||
{
|
||||
m_node = NULL;
|
||||
m_mesh = NULL;
|
||||
@ -112,6 +132,12 @@ TrackObject::~TrackObject()
|
||||
if(m_mesh->getReferenceCount()==1)
|
||||
irr_driver->removeMeshFromCache(m_mesh);
|
||||
}
|
||||
|
||||
if (m_sound)
|
||||
{
|
||||
sfx_manager->deleteSFX(m_sound);
|
||||
}
|
||||
|
||||
} // ~TrackObject
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -33,6 +33,7 @@ using namespace irr;
|
||||
|
||||
|
||||
class XMLNode;
|
||||
class SFXBase;
|
||||
|
||||
/**
|
||||
* \ingroup tracks
|
||||
@ -79,6 +80,9 @@ protected:
|
||||
|
||||
/** The initial scale of the object. */
|
||||
core::vector3df m_init_scale;
|
||||
|
||||
/** If a sound is attached to this objectt and/or this is a sound emitter object */
|
||||
SFXBase* m_sound;
|
||||
|
||||
public:
|
||||
TrackObject(const XMLNode &xml_node);
|
||||
|
@ -59,6 +59,10 @@ void TrackObjectManager::add(const XMLNode &xml_node)
|
||||
{
|
||||
m_all_objects.push_back(new BillboardAnimation(xml_node));
|
||||
}
|
||||
else if(type=="sfx-emitter")
|
||||
{
|
||||
m_all_objects.push_back(new TrackObject(xml_node));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Unknown track object: '%s' - ignored.\n",
|
||||
@ -179,6 +183,9 @@ void TrackObjectManager::enableFog(bool enable)
|
||||
TrackObject* curr;
|
||||
for_in (curr, m_all_objects)
|
||||
{
|
||||
adjustForFog(curr->getNode(), enable);
|
||||
if (curr->getNode() != NULL)
|
||||
{
|
||||
adjustForFog(curr->getNode(), enable);
|
||||
}
|
||||
}
|
||||
} // enableFog
|
||||
|
Loading…
Reference in New Issue
Block a user