Changeset 6382 for code/branches/presentation2
- Timestamp:
- Dec 19, 2009, 12:18:41 AM (15 years ago)
- Location:
- code/branches/presentation2
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2/data/levels/presentationHS09b.oxw
r6363 r6382 25 25 26 26 27 <AmbientSound ambientSource="Mars.ogg" loop ="true" play="true" />27 <AmbientSound ambientSource="Mars.ogg" looping="true" playOnLoad="true" /> 28 28 29 29 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" /> … … 258 258 259 259 260 <AmbientSound ambientSource="Earth.ogg" loop ="true" play="false">260 <AmbientSound ambientSource="Earth.ogg" looping="true" playOnLoad="false"> 261 261 <events> 262 262 <activity> -
code/branches/presentation2/data/levels/sound.oxw
r6248 r6382 18 18 > 19 19 20 <AmbientSound ambientSource="Earth.ogg" loop ="true" play="true" />21 <AmbientSound ambientSource="Mars.ogg" loop ="true" play="false">20 <AmbientSound ambientSource="Earth.ogg" looping="true" playOnLoad="true" /> 21 <AmbientSound ambientSource="Mars.ogg" looping="true"> 22 22 <events> 23 23 <activity> … … 30 30 </events> 31 31 </AmbientSound> 32 <AmbientSound ambientSource="Jupiter.ogg" loop ="true" play="false">32 <AmbientSound ambientSource="Jupiter.ogg" looping="true"> 33 33 <events> 34 34 <activity> -
code/branches/presentation2/data/levels/templates/spaceship_HXY.oxt
r6363 r6382 69 69 > 70 70 <EffectContainer condition="idle"> 71 <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" loop =1 active=false/>71 <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/> 72 72 </EffectContainer> 73 73 <EffectContainer condition="not idle"> -
code/branches/presentation2/data/levels/templates/spaceship_Transporter.oxt
r6363 r6382 69 69 > 70 70 <EffectContainer condition="idle"> 71 <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" loop =1 active=false/>71 <WorldSound mainstate="activity" source="sounds/Engine_idle.ogg" looping=1 active=false/> 72 72 </EffectContainer> 73 73 <EffectContainer condition="not idle"> -
code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
r6370 r6382 42 42 43 43 AmbientSound::AmbientSound(BaseObject* creator) 44 : BaseObject(creator), Synchronisable(creator) 44 : BaseObject(creator) 45 , Synchronisable(creator) 46 , bPlayOnLoad_(false) 45 47 { 46 48 RegisterObject(AmbientSound); … … 49 51 this->setVolume(0); 50 52 this->registerVariables(); 51 }52 53 AmbientSound::~AmbientSound()54 {55 53 } 56 54 … … 67 65 { 68 66 registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged)); 69 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));70 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));71 registerVariable( (int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::stateChanged));67 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged)); 68 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged)); 69 registerVariable(bPlayOnLoad_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::playOnLoadChanged)); 72 70 } 73 71 … … 76 74 SUPER(AmbientSound, XMLPort, xmlelement, mode); 77 75 BaseSound::XMLPortExtern(xmlelement, mode); 78 XMLPortParam(AmbientSound, "ambientsource", setAmbientSource, getAmbientSource, xmlelement, mode); 76 XMLPortParam(AmbientSound, "ambientSource", setAmbientSource, getAmbientSource, xmlelement, mode); 77 XMLPortParam(AmbientSound, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode); 79 78 } 80 79 … … 88 87 { 89 88 if (GameMode::playsSound()) 90 {91 89 SoundManager::getInstance().registerAmbientSound(this); 92 }93 else94 BaseSound::play();95 }96 97 void AmbientSound::doPlay()98 {99 BaseSound::play();100 90 } 101 91 … … 103 93 { 104 94 if (GameMode::playsSound()) 105 {106 95 SoundManager::getInstance().unregisterAmbientSound(this); 107 }108 else109 BaseSound::stop();110 }111 112 void AmbientSound::doStop()113 {114 BaseSound::stop();115 96 } 116 97 … … 118 99 { 119 100 if (GameMode::playsSound()) 120 {121 101 SoundManager::getInstance().pauseAmbientSound(this); 122 }123 else124 BaseSound::pause();125 102 } 126 103 … … 129 106 assert(GameMode::playsSound()); 130 107 return SoundManager::getInstance().getRealVolume(SoundType::Music); 131 }132 133 void AmbientSound::doPause()134 {135 BaseSound::pause();136 108 } 137 109 … … 150 122 } 151 123 124 void AmbientSound::setPlayOnLoad(bool val) 125 { 126 this->bPlayOnLoad_ = val; 127 if (val) 128 this->play(); 129 } 130 152 131 void AmbientSound::changedActivity() 153 132 { -
code/branches/presentation2/src/orxonox/sound/AmbientSound.h
r6370 r6382 50 50 public: 51 51 AmbientSound(BaseObject* creator); 52 ~AmbientSound();53 52 54 53 void XMLPort(Element& xmlelement, XMLPort::Mode mode); … … 61 60 62 61 void setAmbientSource(const std::string& source); 63 const std::string& getAmbientSource() const { return this->ambientSource_; } 64 inline void ambientSourceChanged(){ this->setAmbientSource(this->ambientSource_); } 62 inline const std::string& getAmbientSource() const 63 { return this->ambientSource_; } 64 65 void setPlayOnLoad(bool val); 66 bool getPlayOnLoad() const 67 { return this->bPlayOnLoad_; } 68 69 protected: 70 ~AmbientSound() { } 65 71 66 72 private: 67 virtual void preDestroy(); 68 void doPlay(); 69 void doStop(); 70 void doPause(); 73 void preDestroy(); 71 74 void registerVariables(); 72 75 float getRealVolume(); 76 inline void ambientSourceChanged() 77 { this->setAmbientSource(this->ambientSource_); } 78 inline void playOnLoadChanged() 79 { this->setPlayOnLoad(this->bPlayOnLoad_); } 73 80 74 81 std::string ambientSource_; //!< Analogous to source_, but mood independent 82 bool bPlayOnLoad_; //!< Play the sound immediately when loaded 75 83 }; 76 84 } -
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
r6372 r6382 64 64 void BaseSound::XMLPortExtern(Element& xmlelement, XMLPort::Mode mode) 65 65 { 66 XMLPortParam(BaseSound, "volume", setVolume, getVolume, xmlelement, mode);67 XMLPortParam(BaseSound, "loop ",setLooping, getLooping, xmlelement, mode);68 XMLPortParam(BaseSound, "p lay", setPlaying, isPlaying,xmlelement, mode);69 XMLPortParam(BaseSound, "source", setSource, getSource, xmlelement, mode);70 } 71 72 void BaseSound:: play()66 XMLPortParam(BaseSound, "volume", setVolume, getVolume, xmlelement, mode); 67 XMLPortParam(BaseSound, "looping", setLooping, getLooping, xmlelement, mode); 68 XMLPortParam(BaseSound, "pitch", setPitch, getPitch, xmlelement, mode); 69 XMLPortParam(BaseSound, "source", setSource, getSource, xmlelement, mode); 70 } 71 72 void BaseSound::doPlay() 73 73 { 74 74 this->state_ = Playing; … … 76 76 { 77 77 if (!alIsSource(this->audioSource_)) 78 { 78 79 this->audioSource_ = SoundManager::getInstance().getSoundSource(); 79 if (!alIsSource(this->audioSource_)) 80 return; 81 this->initialiseSource(); 80 if (!alIsSource(this->audioSource_)) 81 return; 82 this->initialiseSource(); 83 } 82 84 83 85 alSourcePlay(this->audioSource_); … … 87 89 } 88 90 89 void BaseSound:: stop()91 void BaseSound::doStop() 90 92 { 91 93 this->state_ = Stopped; … … 103 105 } 104 106 105 void BaseSound:: pause()107 void BaseSound::doPause() 106 108 { 107 109 if (this->isStopped()) … … 242 244 State state = this->state_; // save 243 245 if (this->isPlaying() || this->isPaused()) 244 BaseSound::play();246 doPlay(); 245 247 if (state == Paused) 246 248 { 247 249 this->state_ = Paused; 248 BaseSound::pause();250 doPause(); 249 251 } 250 252 } -
code/branches/presentation2/src/orxonox/sound/BaseSound.h
r6370 r6382 51 51 public: 52 52 BaseSound(); 53 virtual ~BaseSound();54 53 55 54 void XMLPortExtern(Element& xmlelement, XMLPort::Mode mode); 56 55 57 virtual void play() ;58 virtual void stop() ;59 virtual void pause() ;56 virtual void play() { this->doPlay(); } 57 virtual void stop() { this->doStop(); } 58 virtual void pause() { this->doPause(); } 60 59 61 60 bool isPlaying() const { return this->state_ == Playing; } 62 61 bool isPaused() const { return this->state_ == Paused; } 63 62 bool isStopped() const { return this->state_ == Stopped; } 64 65 void setPlaying(bool val)66 { val ? this->play() : this->stop(); }67 63 68 64 virtual void setSource(const std::string& source); … … 90 86 Paused 91 87 }; 88 89 virtual ~BaseSound(); 90 91 void doPlay(); 92 void doStop(); 93 void doPause(); 92 94 93 95 // network callbacks -
code/branches/presentation2/src/orxonox/sound/WorldSound.cc
r6372 r6382 51 51 this->registerVariables(); 52 52 } 53 54 WorldSound::~WorldSound()55 {56 }57 53 58 54 void WorldSound::registerVariables() 59 55 { 60 registerVariable(volume_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::volumeChanged));61 registerVariable(source_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::sourceChanged));56 registerVariable(volume_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::volumeChanged)); 57 registerVariable(source_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::sourceChanged)); 62 58 registerVariable(bLooping_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::loopingChanged)); 59 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::pitchChanged)); 63 60 registerVariable((int&)(BaseSound::state_), ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::stateChanged)); 64 registerVariable(pitch_, ObjectDirection::ToClient, new NetworkCallback<WorldSound>(this, &WorldSound::pitchChanged));65 61 } 66 62 … … 125 121 float WorldSound::getRealVolume() 126 122 { 123 assert(GameMode::playsSound()); 127 124 return SoundManager::getInstance().getRealVolume(SoundType::Effects); 128 125 } -
code/branches/presentation2/src/orxonox/sound/WorldSound.h
r6370 r6382 46 46 public: 47 47 WorldSound(BaseObject* creator); 48 ~WorldSound();49 48 50 49 void XMLPort(Element& xmlelement, XMLPort::Mode mode); … … 53 52 54 53 void tick(float dt); 54 55 protected: 56 ~WorldSound() {} 55 57 56 58 private:
Note: See TracChangeset
for help on using the changeset viewer.