SFXEmitter Class Reference

#include <sfxEmitter.h>

Inheritance diagram for SFXEmitter:

Inheritance graph
[legend]
List of all members.

Detailed Description

The SFXEmitter is used to place 2D or 3D sounds into a mission.

If the profile is set then the emitter plays that. If the profile is null and the filename is set then the local emitter options are used.

Note that you can call SFXEmitter.play() and SFXEmitter.stop() to control playback from script.


Public Member Functions

 SFXEmitter ()
virtual ~SFXEmitter ()
 DECLARE_CONOBJECT (SFXEmitter)
bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
void onStaticModified (const char *slotName, const char *newValue=NULL)
 Called when a static field is modified.
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream)
 Instructs this object to pack its state for transfer over the network.
void unpackUpdate (NetConnection *conn, BitStream *stream)
 Instructs this object to read state data previously packed with packUpdate.
void setTransform (const MatrixF &mat)
 Sets the Object -> World transform.
void setScale (const VectorF &scale)
 Sets the scale for the object.
bool prepRenderImage (SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState)
 Called when the SceneGraph is ready for the registration of RenderImages.
void renderObject (SceneState *state)
void play ()
 Sends network event to start playback if the emitter source is not already playing.
void stop ()
 Sends network event to stop emitter playback on all ghosted clients.

Static Public Member Functions

static void initPersistFields ()
 Register dynamic fields in a subclass of ConsoleObject.

Protected Types

 InitialUpdateMask = BIT(0)
 TransformUpdateMask = BIT(1)
 DirtyUpdateMask = BIT(2)
 SourcePlayMask = BIT(3)
 SourceStopMask = BIT(4)
 AllSourceMasks = SourcePlayMask | SourceStopMask
 Profile = BIT(0)
 Filename = BIT(2)
 Volume = BIT(4)
 IsLooping = BIT(5)
 Is3D = BIT(6)
 ReferenceDistance = BIT(7)
 MaxDistance = BIT(8)
 ConeInsideAngle = BIT(9)
 ConeOutsideAngle = BIT(10)
 ConeOutsideVolume = BIT(11)
 Transform = BIT(12)
 Channel = BIT(13)
 OutsideAmbient = BIT(14)
 AllDirtyMask = 0xFFFFFFFF
enum  UpdateMasks {
  InitialUpdateMask = BIT(0),
  TransformUpdateMask = BIT(1),
  DirtyUpdateMask = BIT(2),
  SourcePlayMask = BIT(3),
  SourceStopMask = BIT(4),
  AllSourceMasks = SourcePlayMask | SourceStopMask
}
 Network update masks. More...
enum  Dirty {
  Profile = BIT(0),
  Filename = BIT(2),
  Volume = BIT(4),
  IsLooping = BIT(5),
  Is3D = BIT(6),
  ReferenceDistance = BIT(7),
  MaxDistance = BIT(8),
  ConeInsideAngle = BIT(9),
  ConeOutsideAngle = BIT(10),
  ConeOutsideVolume = BIT(11),
  Transform = BIT(12),
  Channel = BIT(13),
  OutsideAmbient = BIT(14),
  AllDirtyMask = 0xFFFFFFFF
}
 Dirty flags used to handle sound property updates locally and across the network. More...

Protected Member Functions

bool _readDirtyFlag (BitStream *stream, U32 flag)
 Helper which reads a flag from the stream and updates the mDirty bits.
void _update ()
 Called when the emitter state has been marked dirty and the source needs to be updated.

Protected Attributes

SFXSourcemSource
 The sound source for the emitter.
SFXProfilemProfile
 The selected profile or null if the local profile should be used.
SFXProfile mLocalProfile
 A local profile object used to coax the sound system to play a custom sound.
SFXDescription mDescription
 The description used by the local profile.
bool mPlayOnAdd
 If true playback starts when the emitter is added to the scene.
BitSet32 mDirty
 The current dirty flags.

Private Types

typedef SceneObject Parent


Member Typedef Documentation

typedef SceneObject SFXEmitter::Parent [private]

Reimplemented from SceneObject.


Member Enumeration Documentation

enum SFXEmitter::UpdateMasks [protected]

Network update masks.

Enumerator:
InitialUpdateMask 
TransformUpdateMask 
DirtyUpdateMask 
SourcePlayMask 
SourceStopMask 
AllSourceMasks 

enum SFXEmitter::Dirty [protected]

Dirty flags used to handle sound property updates locally and across the network.

Enumerator:
Profile 
Filename 
Volume 
IsLooping 
Is3D 
ReferenceDistance 
MaxDistance 
ConeInsideAngle 
ConeOutsideAngle 
ConeOutsideVolume 
Transform 
Channel 
OutsideAmbient 
AllDirtyMask 


Constructor & Destructor Documentation

SFXEmitter::SFXEmitter (  ) 

virtual SFXEmitter::~SFXEmitter (  )  [virtual]


Member Function Documentation

bool SFXEmitter::_readDirtyFlag ( BitStream stream,
U32  flag 
) [protected]

Helper which reads a flag from the stream and updates the mDirty bits.

void SFXEmitter::_update (  )  [protected]

Called when the emitter state has been marked dirty and the source needs to be updated.

SFXEmitter::DECLARE_CONOBJECT ( SFXEmitter   ) 

bool SFXEmitter::onAdd (  )  [virtual]

Called when the object is added to the sim.

Reimplemented from SceneObject.

void SFXEmitter::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from SceneObject.

void SFXEmitter::onStaticModified ( const char *  slotName,
const char *  newValue = NULL 
) [virtual]

Called when a static field is modified.

Reimplemented from SimObject.

static void SFXEmitter::initPersistFields (  )  [static]

Register dynamic fields in a subclass of ConsoleObject.

See also:
addField(), addFieldV(), addDeprecatedField(), addGroup(), endGroup()

Reimplemented from SceneObject.

U32 SFXEmitter::packUpdate ( NetConnection conn,
U32  mask,
BitStream stream 
) [virtual]

Instructs this object to pack its state for transfer over the network.

Parameters:
conn Net connection being used
mask Mask indicating fields to transmit.
stream Bitstream to pack data to
Returns:
Any bits which were not dealt with. The value is stored by the networking system. Don't set bits you weren't passed.

Reimplemented from NetObject.

void SFXEmitter::unpackUpdate ( NetConnection conn,
BitStream stream 
) [virtual]

Instructs this object to read state data previously packed with packUpdate.

Parameters:
conn Net connection being used
stream stream to read from

Reimplemented from NetObject.

void SFXEmitter::setTransform ( const MatrixF mat  )  [virtual]

Sets the Object -> World transform.

Parameters:
mat New transform matrix

Reimplemented from SceneObject.

void SFXEmitter::setScale ( const VectorF scale  )  [virtual]

Sets the scale for the object.

Parameters:
scale Scaling values

Reimplemented from SceneObject.

bool SFXEmitter::prepRenderImage ( SceneState state,
const U32  stateKey,
const U32  startZone,
const bool  modifyBaseZoneState 
) [virtual]

Called when the SceneGraph is ready for the registration of RenderImages.

See also:
SceneState
Parameters:
state SceneState
stateKey State key of the current SceneState
startZone Base zone index
modifyBaseZoneState If true, the object needs to modify the zone state.

Reimplemented from SceneObject.

void SFXEmitter::renderObject ( SceneState state  ) 

void SFXEmitter::play (  ) 

Sends network event to start playback if the emitter source is not already playing.

void SFXEmitter::stop (  ) 

Sends network event to stop emitter playback on all ghosted clients.


Member Data Documentation

The sound source for the emitter.

The selected profile or null if the local profile should be used.

A local profile object used to coax the sound system to play a custom sound.

The description used by the local profile.

If true playback starts when the emitter is added to the scene.

The current dirty flags.