00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_BACKGROUND_SOUND_MANAGER_H
00027 #define NL_BACKGROUND_SOUND_MANAGER_H
00028
00029 #include "nel/misc/types_nl.h"
00030 #include "background_sound.h"
00031 #include <vector>
00032 #include <set>
00033
00034
00035 namespace NLLIGO
00036 {
00037 class CPrimRegion;
00038 }
00039
00040 namespace NLSOUND {
00041
00042
00043 class CListenerUser;
00044 class IPlayable;
00045 class IBoundingShape;
00046
00048 const uint32 BACKGROUND_LAYER = 3;
00049
00050
00074 class CBackgroundSoundManager
00075 {
00076 public:
00079 void loadSoundsFromRegion(const NLLIGO::CPrimRegion ®ion);
00082 void loadEffecsFromRegion(const NLLIGO::CPrimRegion ®ion);
00085 void loadSamplesFromRegion(const NLLIGO::CPrimRegion ®ion);
00086
00092 void load (const std::string &continent);
00093
00096 void unload ();
00097
00099 void play();
00101 void stop();
00102
00104 void setListenerPosition (const NLMISC::CVector &listenerPosition);
00105
00107 void updateBackgroundStatus();
00108
00109
00110
00111
00113 const std::vector<NLMISC::CVector> &getZone(uint32 zone, bool *isPath = 0);
00114
00116 NLMISC::CVector getZoneSourcePos(uint32 zone);
00117
00119 const UAudioMixer::TBackgroundFlags &getBackgroundFlags();
00121 void setBackgroundFlags(const UAudioMixer::TBackgroundFlags &backgroundFlags);
00122
00123 private:
00124
00125
00126 friend class CAudioMixerUser;
00127
00129 CBackgroundSoundManager();
00131 virtual ~CBackgroundSoundManager();
00132
00134 void addSound(const std::string &soundName, const std::vector<NLLIGO::CPrimVector> &points, bool isPath);
00135
00137 template <class CharType>
00138 std::vector<std::basic_string<CharType> > split(const std::basic_string<CharType> &str, CharType splitTag)
00139 {
00140 std::vector<std::basic_string<CharType> > splitted;
00141 std::basic_string<CharType>::size_type pos = 0, nextPos = 0, size = 0;
00142
00143 while ((nextPos = str.find(splitTag, nextPos)) != std::basic_string<CharType>::npos)
00144 {
00145 size = nextPos - pos;
00146 if (size > 0)
00147 splitted.push_back(std::basic_string<CharType>(str, pos, nextPos - pos));
00148
00149 nextPos += 1;
00150 pos = nextPos;
00151 }
00152
00153 size = nextPos - pos;
00154 if (pos != str.size())
00155 splitted.push_back(std::basic_string<CharType>(str, pos, str.size() - pos));
00156
00157 return splitted;
00158 }
00159
00160
00162 bool _Playing;
00163
00165 UAudioMixer::TBackgroundFlags _BackgroundFlags;
00166
00168 NLMISC::CVector _LastPosition;
00169
00171
00172
00174 struct TBanksData
00175 {
00177 std::vector<std::string> Banks;
00179 NLMISC::CVector MinBox;
00181 NLMISC::CVector MaxBox;
00183 std::vector<NLMISC::CVector> Points;
00184 };
00186 std::vector<TBanksData> _Banks;
00188 std::set<std::string> _LoadedBanks;
00190
00191
00193
00195
00196 {
00198 std::string SoundName;
00200 CSound *Sound;
00202 USource *Source;
00203
00205 NLMISC::CVector MinBox;
00207 NLMISC::CVector MaxBox;
00209 float Surface;
00211 float MaxDist;
00213 bool IsPath;
00215 std::vector<NLMISC::CVector> Points;
00217 bool Selected;
00218 };
00220 std::vector<TSoundData> _Layers[BACKGROUND_LAYER];
00221
00222 struct TSoundStatus
00223 {
00225 TSoundData &SoundData;
00227 NLMISC::CVector Position;
00231 float Gain;
00233 float Distance;
00235 TSoundStatus(TSoundData &sd, NLMISC::CVector position, float gain, float distance)
00236 : SoundData(sd), Position(position), Gain(gain), Distance(distance)
00237 {}
00238 };
00240 };
00241
00242
00243 }
00244
00245
00246 #endif // NL_BACKGROUND_SOUND_MANAGER_H
00247
00248