Home | nevrax.com |
|
source_user.hGo to the documentation of this file.00001 00007 /* Copyright, 2001 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #ifndef NL_SOURCE_USER_H 00027 #define NL_SOURCE_USER_H 00028 00029 #include "nel/misc/types_nl.h" 00030 #include "nel/sound/u_source.h" 00031 #include "nel/misc/vector.h" 00032 #include "nel/misc/time_nl.h" 00033 #include "playable.h" 00034 00035 00036 namespace NLSOUND { 00037 00038 00039 class ISource; 00040 class CTrack; 00041 class CSound; 00042 00043 00050 class CSourceUser : public USource, public IPlayable 00051 { 00052 public: 00053 00055 CSourceUser( TSoundId id=NULL, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL ); 00057 virtual ~CSourceUser(); 00058 00060 static void init() 00061 { 00062 NLMISC_REGISTER_CLASS(CSourceUser); 00063 } 00064 00065 00067 virtual void setSound( TSoundId id ); 00069 virtual TSoundId getSound() { return _Sound; } 00071 virtual void setPriority( TSoundPriority pr, bool redispatch=true ); 00073 TSoundPriority getPriority() { return _Priority; } 00074 00075 00077 00078 00079 virtual void setLooping( bool l ); 00081 virtual bool getLooping() const; 00083 virtual void play(); 00085 virtual void stop(); 00087 virtual bool isPlaying(); 00089 virtual void unregisterSpawnCallBack() { _SpawnEndCb = NULL; } 00091 00092 00094 00095 00099 virtual void setPos( const NLMISC::CVector& pos ); 00103 virtual void getPos( NLMISC::CVector& pos ) const; 00105 virtual void setVelocity( const NLMISC::CVector& vel ); 00107 virtual void getVelocity( NLMISC::CVector& vel ) const { vel = _Velocity; } 00109 virtual void setDirection( const NLMISC::CVector& dir ); 00111 virtual void getDirection( NLMISC::CVector& dir ) const { dir = _Direction; } 00118 virtual void setGain( float gain ); 00120 virtual float getGain() const { return _Gain; } 00124 virtual void setRelativeGain( float gain ); 00126 virtual float getRelativeGain() const; 00130 virtual void setPitch( float pitch ); 00132 virtual float getPitch() const { return _Pitch; } 00134 virtual void setSourceRelativeMode( bool mode ); 00136 virtual bool getSourceRelativeMode() const { return _RelativeMode; } 00137 00138 00140 void set3DPositionVector( const NLMISC::CVector *pos ) { _3DPosition = pos; } 00142 const NLMISC::CVector *getPositionP() const { return &_Position; } 00146 void enterTrack( CTrack *track ); 00148 void leaveTrack(); 00150 CTrack *getTrack() { return _Track; } 00152 bool isStopped(); 00154 bool isSpawn() const { return _Spawn; } 00156 TSpawnEndCallback getSpawnEndCallback() const { return _SpawnEndCb; } 00158 void *getCallbackUserParam(void) const { return _CbUserParam; } 00159 00160 // From IPlayable 00161 00163 virtual void enable( bool toplay, float gain ); 00165 virtual void moveTo( const NLMISC::CVector& pos ) { setPos( pos ); } 00167 virtual void serial( NLMISC::IStream& s ); 00168 00169 NLMISC_DECLARE_CLASS(CSourceUser); 00170 00171 protected: 00172 00174 void copyToTrack(); 00175 00176 private: 00177 00178 // These data are copied to a track when the source selected is for playing 00179 00180 CSound *_Sound; 00181 TSoundPriority _Priority; 00182 bool _Playing; 00183 bool _Looping; 00184 00185 NLMISC::CVector _Position; 00186 NLMISC::CVector _Velocity; 00187 NLMISC::CVector _Direction; 00188 float _Gain; 00189 float _Pitch; 00190 bool _RelativeMode; 00191 00192 // Corresponding track (if selected for playing) 00193 CTrack *_Track; 00194 00195 // Position to return, for a stereo source 00196 const NLMISC::CVector *_3DPosition; 00197 00198 // Playing start time 00199 NLMISC::TTime _PlayStart; 00200 00201 // Spawn state 00202 const bool _Spawn; 00203 TSpawnEndCallback _SpawnEndCb; 00204 void *_CbUserParam; 00205 }; 00206 00207 00208 } // NLSOUND 00209 00210 00211 #endif // NL_SOURCE_USER_H 00212 00213 /* End of source_user.h */ |