sfxFMODEvent.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  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. //-----------------------------------------------------------------------------
  22. #ifndef _SFXFMODEVENT_H_
  23. #define _SFXFMODEVENT_H_
  24. #ifndef _SFXTRACK_H_
  25. #include "sfx/sfxTrack.h"
  26. #endif
  27. #ifndef _CONSOLETYPES_H_
  28. #include "console/consoleTypes.h"
  29. #endif
  30. #ifndef _MPOINT2_H_
  31. #include "math/mPoint2.h"
  32. #endif
  33. #include "fmod_event.h"
  34. class SFXFMODProject;
  35. class SFXFMODEventGroup;
  36. /// An event in an FMOD Designer project.
  37. ///
  38. /// This class must not be manually instanced by the user. Instead, SFXFMODEvents
  39. /// are automatically created when an SFXFMODProject is loaded.
  40. ///
  41. /// Be aware that as all the playback happens internally within FMOD's event system,
  42. /// this bypasses the SFX layer and will thus not work with features that rely the
  43. /// structures there. Namely, sound occlusion (except for FMOD's own occlusion) will
  44. /// not work with FMOD events.
  45. ///
  46. /// The parameters of an FMOD event are automatically created and designed using the
  47. /// information in the project.
  48. ///
  49. class SFXFMODEvent : public SFXTrack
  50. {
  51. public:
  52. typedef SFXTrack Parent;
  53. friend class SFXFMODEventGroup;
  54. friend class SFXFMODEventSource;
  55. protected:
  56. /// Name of the event in the Designer project.
  57. String mName;
  58. /// Event group that this event belongs to.
  59. SFXFMODEventGroup* mGroup;
  60. /// Next event in the group's event chain.
  61. SFXFMODEvent* mSibling;
  62. /// FMOD event handle when event is open. Client-side only.
  63. FMOD_EVENT* mHandle;
  64. ///
  65. Point2F mParameterRanges[ MaxNumParameters ];
  66. ///
  67. F32 mParameterValues[ MaxNumParameters ];
  68. /// Group ID for client net sync.
  69. S32 mGroupId;
  70. ///
  71. void _createParameters();
  72. public:
  73. ///
  74. SFXFMODEvent();
  75. ///
  76. SFXFMODEvent( SFXFMODEventGroup* group, const String& name );
  77. ///
  78. SFXFMODEvent( SFXFMODEventGroup* group, FMOD_EVENT* handle );
  79. ~SFXFMODEvent();
  80. /// Create the event object on the FMOD device.
  81. void acquire();
  82. /// Release the event object on the FMOD device.
  83. void release();
  84. ///
  85. const String& getEventName() const { return mName; }
  86. ///
  87. SFXFMODEventGroup* getEventGroup() const { return mGroup; }
  88. ///
  89. String getQualifiedName() const;
  90. ///
  91. bool isDataLoaded() const;
  92. // SFXTrack.
  93. virtual bool onAdd();
  94. virtual void onRemove();
  95. virtual bool preload( bool server, String& errorStr );
  96. virtual void packData( BitStream* stream );
  97. virtual void unpackData( BitStream* stream );
  98. static void initPersistFields();
  99. DECLARE_CONOBJECT( SFXFMODEvent );
  100. DECLARE_CATEGORY( "SFX FMOD" );
  101. DECLARE_DESCRIPTION( "An FMOD Designer event." );
  102. };
  103. #endif // !_SFXFMODEVENT_H_