Merge pull request #1874 from John3/readmeUpdate
[Torque-3d.git] / Engine / source / sfx / fmod / sfxFMODEvent.h
blob1e4c53e005588e867565c480e3c8b99073316d6b
1 //-----------------------------------------------------------------------------
2 // Copyright (c) 2012 GarageGames, LLC
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to
6 // deal in the Software without restriction, including without limitation the
7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 // sell copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 // IN THE SOFTWARE.
21 //-----------------------------------------------------------------------------
23 #ifndef _SFXFMODEVENT_H_
24 #define _SFXFMODEVENT_H_
26 #ifndef _SFXTRACK_H_
27 #include "sfx/sfxTrack.h"
28 #endif
29 #ifndef _CONSOLETYPES_H_
30 #include "console/consoleTypes.h"
31 #endif
32 #ifndef _MPOINT2_H_
33 #include "math/mPoint2.h"
34 #endif
36 #include "fmod_event.h"
39 class SFXFMODProject;
40 class SFXFMODEventGroup;
43 /// An event in an FMOD Designer project.
44 ///
45 /// This class must not be manually instanced by the user. Instead, SFXFMODEvents
46 /// are automatically created when an SFXFMODProject is loaded.
47 ///
48 /// Be aware that as all the playback happens internally within FMOD's event system,
49 /// this bypasses the SFX layer and will thus not work with features that rely the
50 /// structures there. Namely, sound occlusion (except for FMOD's own occlusion) will
51 /// not work with FMOD events.
52 ///
53 /// The parameters of an FMOD event are automatically created and designed using the
54 /// information in the project.
55 ///
56 class SFXFMODEvent : public SFXTrack
58 public:
60 typedef SFXTrack Parent;
61 friend class SFXFMODEventGroup;
62 friend class SFXFMODEventSource;
64 protected:
66 /// Name of the event in the Designer project.
67 String mName;
69 /// Event group that this event belongs to.
70 SFXFMODEventGroup* mGroup;
72 /// Next event in the group's event chain.
73 SFXFMODEvent* mSibling;
75 /// FMOD event handle when event is open. Client-side only.
76 FMOD_EVENT* mHandle;
78 ///
79 Point2F mParameterRanges[ MaxNumParameters ];
81 ///
82 F32 mParameterValues[ MaxNumParameters ];
84 /// Group ID for client net sync.
85 S32 mGroupId;
87 ///
88 void _createParameters();
90 public:
92 ///
93 SFXFMODEvent();
95 ///
96 SFXFMODEvent( SFXFMODEventGroup* group, const String& name );
98 ///
99 SFXFMODEvent( SFXFMODEventGroup* group, FMOD_EVENT* handle );
101 ~SFXFMODEvent();
103 /// Create the event object on the FMOD device.
104 void acquire();
106 /// Release the event object on the FMOD device.
107 void release();
110 const String& getEventName() const { return mName; }
113 SFXFMODEventGroup* getEventGroup() const { return mGroup; }
116 String getQualifiedName() const;
119 bool isDataLoaded() const;
121 // SFXTrack.
122 virtual bool onAdd();
123 virtual void onRemove();
124 virtual bool preload( bool server, String& errorStr );
125 virtual void packData( BitStream* stream );
126 virtual void unpackData( BitStream* stream );
128 static void initPersistFields();
130 DECLARE_CONOBJECT( SFXFMODEvent );
131 DECLARE_CATEGORY( "SFX FMOD" );
132 DECLARE_DESCRIPTION( "An FMOD Designer event." );
135 #endif // !_SFXFMODEVENT_H_