Home | nevrax.com |
|
env_sound_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_ENV_SOUND_USER_H 00027 #define NL_ENV_SOUND_USER_H 00028 00029 #include "nel/misc/types_nl.h" 00030 #include "nel/sound/u_env_sound.h" 00031 #include "source_user.h" 00032 #include <vector> 00033 00034 00035 namespace NLSOUND { 00036 00037 00038 class CListenerUser; 00039 class IPlayable; 00040 class IBoundingShape; 00041 00042 00043 // Number of environment channels 00044 #define MAX_ENV_CHANNELS 3 00045 #define AMBIANT_CH1 0 00046 #define AMBIANT_CH2 1 00047 #define SPARSE_CH 2 00048 00049 00082 class CEnvSoundUser : public UEnvSound 00083 { 00084 public: 00085 00087 CEnvSoundUser(); 00088 00090 virtual ~CEnvSoundUser(); 00091 00092 00094 //void serial( NLMISC::IStream& s ); 00096 //static void serialFileHeader( NLMISC::IStream& s ); 00098 //static uint32 load( CEnvSoundUser* &envSoundTreeRoot, NLMISC::IStream& s ); 00099 00100 00102 virtual void getPos( NLMISC::CVector& pos ) const; 00104 virtual void setPos( const NLMISC::CVector& pos ); 00106 virtual void selectEnv( const char *tag, bool children_too=false ) ; 00108 virtual std::vector<UEnvSound*>& getChildren(); 00109 00110 00112 void recompute(); 00114 void update(); 00115 00116 00118 virtual void play( bool children_too=false ); 00120 virtual void stop( bool children_too=false ); 00122 bool mustPlay() const { return _Play; } 00123 00124 00126 void setProperties( bool transition, IBoundingShape *bshape ); 00128 void addChild( CEnvSoundUser *child ); 00132 void addEnvTag( IPlayable *source, const std::string& tag="" ); 00134 //static void save( CEnvSoundUser *envSoundTreeRoot, NLMISC::IStream& s ); 00136 IBoundingShape *getBoundingShape() { return _BoundingShape; } 00138 IPlayable *getSource() { return _Source; } 00140 CEnvSoundUser *getParent() { return _Parent; } 00141 00142 protected: 00143 00144 // Return true if the envsound is a leaf in the hierarchy tree 00145 //bool isLeaf() const { return _Children.empty(); } 00146 00148 bool isRoot() const { return _Parent==NULL; } 00149 00150 // Enable/disable the source and set general gain if enabled, and reset the source mark (recursive) 00151 void applySourcesMarks(); 00152 00154 CEnvSoundUser *findCurrentEnv( const NLMISC::CVector& listenerpos ); 00155 00159 void markSources( const NLMISC::CVector& listenerpos, float gain ); 00160 00162 uint32 getCount() const; 00163 00165 void playSub( bool children_too=false ); 00166 00168 void stopSub( bool children_too=false ); 00169 00170 00171 private: 00172 00173 // Must play or not 00174 bool _Play; 00175 00176 // Current sound source (3D source or ambiant source) and all possible sources 00177 IPlayable *_Source; 00178 std::vector<IPlayable*> _SrcBank; 00179 std::vector<std::string> _Tags; 00180 00181 // Area 00182 IBoundingShape *_BoundingShape; 00183 00184 // Transition shape ? 00185 bool _Transition; 00186 00187 // Hierarchy 00188 CEnvSoundUser *_Parent; 00189 std::vector<CEnvSoundUser*> _Children; 00190 00191 // Playing preparation 00192 bool _Mark; 00193 float _Gain; 00194 00195 }; 00196 00197 00198 } // NLSOUND 00199 00200 00201 #endif // NL_ENV_SOUND_USER_H 00202 00203 /* End of env_sound_user.h */ |