Changeset 6307 for code/branches/presentation2/src
- Timestamp:
- Dec 9, 2009, 10:09:27 PM (15 years ago)
- Location:
- code/branches/presentation2/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
r6245 r6307 41 41 #include "worldentities/WorldEntity.h" 42 42 #include "worldentities/pawns/Pawn.h" 43 44 #include "sound/WorldSound.h"45 43 46 44 namespace orxonox -
code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.cc
r6245 r6307 36 36 #include "worldentities/pawns/Pawn.h" 37 37 38 #include "sound/WorldSound.h"39 40 38 namespace orxonox 41 39 { -
code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.cc
r6285 r6307 38 38 #include "worldentities/pawns/Pawn.h" 39 39 40 #include "sound/WorldSound.h"41 42 40 namespace orxonox 43 41 { -
code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
r6203 r6307 42 42 43 43 AmbientSound::AmbientSound(BaseObject* creator) 44 : BaseObject(creator) 44 : BaseObject(creator), Synchronisable(creator) 45 45 { 46 46 RegisterObject(AmbientSound); … … 48 48 // Ambient sounds always fade in 49 49 this->setVolume(0); 50 this->registerVariables(); 50 51 } 51 52 52 53 AmbientSound::~AmbientSound() 53 54 { 55 } 56 57 void AmbientSound::registerVariables() 58 { 59 registerVariable(volume_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::volumeChanged)); 60 // registerVariable(source_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::sourceChanged)); 61 registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged)); 62 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::loopingChanged)); 63 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::pitchChanged)); 64 registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient); 54 65 } 55 66 -
code/branches/presentation2/src/orxonox/sound/AmbientSound.h
r6186 r6307 35 35 #include "core/BaseObject.h" 36 36 #include "sound/BaseSound.h" 37 #include "network/synchronisable/Synchronisable.h" 37 38 38 39 namespace orxonox … … 43 44 * 44 45 */ 45 class _OrxonoxExport AmbientSound : public BaseSound, public BaseObject 46 class _OrxonoxExport AmbientSound : public BaseSound, public BaseObject, public Synchronisable 46 47 { 47 48 friend class SoundManager; … … 63 64 virtual void setAmbientSource(const std::string& source); 64 65 const std::string& getAmbientSource() const { return this->ambientSource_; } 66 inline void ambientSourceChanged(){ this->setAmbientSource(this->ambientSource_); } 65 67 66 68 private: … … 68 70 void doStop(); 69 71 void doPause(); 72 73 void registerVariables(); 70 74 71 75 std::string ambientSource_; //!< Analogous to source_, but mood independent -
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
r6285 r6307 46 46 , bPooling_(false) 47 47 , volume_(1.0) 48 , bLoop _(false)48 , bLooping_(false) 49 49 , state_(Stopped) 50 50 , pitch_ (1.0) … … 151 151 void BaseSound::setLooping(bool val) 152 152 { 153 this->bLoop _ = val;153 this->bLooping_ = val; 154 154 if (GameMode::playsSound() && alIsSource(this->audioSource_)) 155 155 alSourcei(this->audioSource_, AL_LOOPING, (val ? AL_TRUE : AL_FALSE)); … … 204 204 if (ALuint error = alGetError()) 205 205 { 206 COUT(1) << "Sound Error: Could not load file \"" << source << "\": " << SoundManager::getALErrorString << std::endl;206 COUT(1) << "Sound Error: Could not load file \"" << source << "\": " << SoundManager::getALErrorString(error) << std::endl; 207 207 return; 208 208 } -
code/branches/presentation2/src/orxonox/sound/BaseSound.h
r6255 r6307 68 68 virtual void setSource(const std::string& source); 69 69 virtual const std::string& getSource() const { return this->source_; } 70 inline void sourceChanged(){ this->setSource(this->source_); } 70 71 71 72 void setVolume(float vol); 72 73 float getVolume() const { return this->volume_; } 74 inline void volumeChanged(){ this->setVolume(this->volume_); } 73 75 74 76 virtual float getVolumeGain(); 75 77 void updateVolume(void); 76 78 77 bool getLooping() const { return this->bLoop _; }79 bool getLooping() const { return this->bLooping_; } 78 80 void setLooping(bool val); 81 inline void loopingChanged(){ this->setLooping(this->bLooping_); } 79 82 80 83 float getPitch() const { return this->pitch_; } 81 84 void setPitch(float pitch); 85 inline void pitchChanged(){ this->setPitch(this->pitch_); } 82 86 83 87 //ALuint getALAudioSource(void); 84 88 85 89 protected: 86 ALint getSourceState() const;87 88 ALuint audioSource_;89 bool bPooling_;90 shared_ptr<SoundBuffer> soundBuffer_;91 92 private:93 90 enum State 94 91 { … … 97 94 Paused 98 95 }; 96 ALint getSourceState() const; 99 97 98 ALuint audioSource_; 99 bool bPooling_; 100 shared_ptr<SoundBuffer> soundBuffer_; 100 101 std::string source_; 101 102 float volume_; 102 bool bLoop _;103 bool bLooping_; 103 104 State state_; 104 105 float pitch_; 106 107 private: 105 108 DataStreamPtr dataStream_; 106 109 }; -
code/branches/presentation2/src/orxonox/sound/WorldSound.cc
r6269 r6307 36 36 #include "core/XMLPort.h" 37 37 #include "SoundManager.h" 38 #include <core/ConsoleCommandCompilation.h> 38 39 39 40 namespace orxonox … … 47 48 // WorldSound buffers should be pooled when they're not used anymore 48 49 this->bPooling_ = true; 50 this->registerVariables(); 49 51 } 50 52 51 53 WorldSound::~WorldSound() 52 54 { 55 } 56 57 void WorldSound::registerVariables() 58 { 59 registerVariable(volume_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::volumeChanged)); 60 registerVariable(source_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::sourceChanged)); 61 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::loopingChanged)); 62 registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient); 63 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<BaseSound>(static_cast<BaseSound*>(this), &BaseSound::pitchChanged)); 53 64 } 54 65 -
code/branches/presentation2/src/orxonox/sound/WorldSound.h
r6186 r6307 57 57 58 58 private: 59 void registerVariables(); 59 60 }; 60 61 } -
code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
r6265 r6307 71 71 this->muzzleOrientation_ = Quaternion::IDENTITY; 72 72 73 this->defSndWpnFire_ = new WorldSound(this); 74 this->defSndWpnFire_->setLooping(false); 75 this->bSoundAttached_ = false; 73 if( GameMode::isMaster() ) 74 { 75 this->defSndWpnFire_ = new WorldSound(this); 76 this->defSndWpnFire_->setLooping(false); 77 this->bSoundAttached_ = false; 78 } 79 else 80 this->defSndWpnFire_ = 0; 76 81 } 77 82 … … 80 85 if(this->isInitialized()) 81 86 { 82 delete this->defSndWpnFire_; 87 if( this->defSndWpnFire_ ) 88 delete this->defSndWpnFire_; 83 89 } 84 90 } … … 106 112 { 107 113 (*reloadTime) = this->reloadTime_; 108 if( !this->bSoundAttached_ )114 if( !this->bSoundAttached_ && GameMode::isMaster() ) 109 115 { 110 116 assert(this->getWeapon() && this->getWeapon()->getWeaponSlot()); … … 130 136 this->reloadTimer_.startTimer(); 131 137 132 if( !(this->defSndWpnFire_->isPlaying()))138 if( this->defSndWpnFire_ && !(this->defSndWpnFire_->isPlaying())) 133 139 { 134 140 this->defSndWpnFire_->play(); … … 222 228 void WeaponMode::reloaded() 223 229 { 224 if( this->defSndWpnFire_->isPlaying())230 if( this->defSndWpnFire_ && this->defSndWpnFire_->isPlaying()) 225 231 { 226 232 this->defSndWpnFire_->stop(); … … 257 263 void WeaponMode::setDefaultSound(const std::string& soundPath) 258 264 { 259 this->defSndWpnFire_->setSource(soundPath); 265 if( this->defSndWpnFire_ ) 266 this->defSndWpnFire_->setSource(soundPath); 260 267 } 261 268 262 269 const std::string& WeaponMode::getDefaultSound() 263 270 { 264 return this->defSndWpnFire_->getSource(); 271 if( this->defSndWpnFire_ ) 272 return this->defSndWpnFire_->getSource(); 273 else 274 return std::string(); 265 275 } 266 276 }
Note: See TracChangeset
for help on using the changeset viewer.