Game Development Reference
In-Depth Information
class ReverbArea : public VisualizerObject
{
public:
ReverbArea( ReverbEffect * reverb, const PolyMesh & mesh) :
VisualizerObject( VO_REVERB ),
m_active( false ), m_reverb( reverb ),
m_area( mesh )
{}
virtual ~ReverbArea() {}
// Reverb function called once per frame.
// Looks to see if the listener is inside the
// reverb area and if so applies the reverb to sounds.
void update()
{
if (m_area.isPointInside(SoundSystem::getListenerPos())
{
m_active = true;
SoundSystem::applyReverb( m_reverb );
}
else
{
m_active = false;
}
}
// Called once per frame by the VisualizerManager.
virtual void draw()
{
COLOR col = RED;
if ( m_active )
{
col = GREEN;
}
GPU::debugDrawAreaMesh( col, m_area );
// If reverb name rendering is enabled then render
// the name of the reverb effect in the middle of the
// area.
if ( VisualizerManager::renderReverbAreaNames() )
{
Vector text_pos = m_area.getCentrePoint();
GPU::renderText( m_event->m_name, text_pos() );
}
}
protected:
ReverbEffect * m_reverb;
bool m_active;
const PolyMesh & m_area;
};
Listing 11.6. Sample ReverbArea class.
Classes which manage sound geometry should similarly inherit from
VisualizerObject. For example, reverb areas or trigger areas managing the loading
and unloading of sound packs. Listing 11.6 shows a pseudocode demonstration of
this for reverb areas.
Search WWH ::




Custom Search