Changeset 9918 for code/branches/presentationHS13/src
- Timestamp:
- Dec 16, 2013, 3:43:45 PM (11 years ago)
- Location:
- code/branches/presentationHS13
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS13
- Property svn:mergeinfo changed
/code/branches/sfxThilo (added) merged: 9691,9720,9889,9913
- Property svn:mergeinfo changed
-
code/branches/presentationHS13/src/modules/pong/Pong.cc
r9667 r9918 47 47 #include "PongBot.h" 48 48 #include "PongAI.h" 49 49 50 namespace orxonox 50 51 { … … 117 118 } 118 119 } 120 119 121 } 120 122 -
code/branches/presentationHS13/src/modules/pong/PongBall.cc
r9667 r9918 40 40 41 41 #include "PongBat.h" 42 43 #include "sound/WorldSound.h" 44 #include "core/XMLPort.h" 42 45 43 46 namespace orxonox … … 66 69 67 70 this->registerVariables(); 71 72 //initialize sound 73 if (GameMode::isMaster()) 74 { 75 this->defScoreSound_ = new WorldSound(this->getContext()); 76 this->defScoreSound_->setVolume(1.0f); 77 this->defBatSound_ = new WorldSound(this->getContext()); 78 this->defBatSound_->setVolume(0.4f); 79 this->defBoundarySound_ = new WorldSound(this->getContext()); 80 this->defBoundarySound_->setVolume(0.5f); 81 } 82 else 83 { 84 this->defScoreSound_ = 0; 85 this->defBatSound_ = 0; 86 this->defBoundarySound_ = 0; 87 } 68 88 } 69 89 … … 81 101 delete[] this->batID_; 82 102 } 103 } 104 105 //xml port for loading sounds 106 void PongBall::XMLPort(Element& xmlelement, XMLPort::Mode mode) 107 { 108 SUPER(PongBall, XMLPort, xmlelement, mode); 109 XMLPortParam(PongBall, "defScoreSound", setDefScoreSound, getDefScoreSound, xmlelement, mode); 110 XMLPortParam(PongBall, "defBatSound", setDefBatSound, getDefBatSound, xmlelement, mode); 111 XMLPortParam(PongBall, "defBoundarySound", setDefBoundarySound, getDefBoundarySound, xmlelement, mode); 83 112 } 84 113 … … 117 146 if (position.z > this->fieldHeight_ / 2 || position.z < -this->fieldHeight_ / 2) 118 147 { 119 // Its velocity in z-direction is inverted (i.e. it bounces off). 148 defBoundarySound_->play(); //play boundary sound 149 // Its velocity in z-direction is inverted (i.e. it bounces off). 120 150 velocity.z = -velocity.z; 121 151 // And its position is set as to not overstep the boundary it has just crossed. … … 142 172 if (fabs(distance) <= 1) // If the bat is there to parry. 143 173 { 144 // Set the ball to be exactly at the boundary. 174 defBatSound_->play(); //play bat sound 175 // Set the ball to be exactly at the boundary. 145 176 position.x = this->fieldWidth_ / 2; 146 177 // Invert its velocity in x-direction (i.e. it bounces off). … … 155 186 else if (GameMode::isMaster() && position.x > this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 156 187 { 188 defScoreSound_->play();//play score sound 157 189 if (this->getGametype() && this->bat_[0]) 158 190 { … … 169 201 if (fabs(distance) <= 1) // If the bat is there to parry. 170 202 { 171 // Set the ball to be exactly at the boundary. 203 defBatSound_->play(); //play bat sound 204 // Set the ball to be exactly at the boundary. 172 205 position.x = -this->fieldWidth_ / 2; 173 206 // Invert its velocity in x-direction (i.e. it bounces off). … … 182 215 else if (GameMode::isMaster() && position.x < -this->fieldWidth_ / 2 * (1 + this->relMercyOffset_)) 183 216 { 217 defScoreSound_->play();//play score sound 184 218 if (this->getGametype() && this->bat_[1]) 185 219 { … … 262 296 this->bat_[1] = orxonox_cast<PongBat*>(Synchronisable::getSynchronisable(this->batID_[1])); 263 297 } 298 299 void PongBall::setDefScoreSound(const std::string &pongSound) 300 { 301 if( defScoreSound_ ) 302 defScoreSound_->setSource(pongSound); 303 else 304 assert(0); // This should never happen, because soundpointer is only available on master 305 } 306 307 const std::string& PongBall::getDefScoreSound() 308 { 309 if( defScoreSound_ ) 310 return defScoreSound_->getSource(); 311 else 312 assert(0); 313 return BLANKSTRING; 314 } 315 316 void PongBall::setDefBatSound(const std::string &pongSound) 317 { 318 if( defBatSound_ ) 319 defBatSound_->setSource(pongSound); 320 else 321 assert(0); // This should never happen, because soundpointer is only available on master 322 } 323 324 const std::string& PongBall::getDefBatSound() 325 { 326 if( defBatSound_ ) 327 return defBatSound_->getSource(); 328 else 329 assert(0); 330 return BLANKSTRING; 331 } 332 333 void PongBall::setDefBoundarySound(const std::string &pongSound) 334 { 335 if( defBoundarySound_ ) 336 defBoundarySound_->setSource(pongSound); 337 else 338 assert(0); // This should never happen, because soundpointer is only available on master 339 } 340 341 const std::string& PongBall::getDefBoundarySound() 342 { 343 if( defBoundarySound_ ) 344 return defBoundarySound_->getSource(); 345 else 346 assert(0); 347 return BLANKSTRING; 348 } 264 349 } -
code/branches/presentationHS13/src/modules/pong/PongBall.h
r9667 r9918 42 42 #include "worldentities/MovableEntity.h" 43 43 44 44 45 namespace orxonox 45 46 { … … 63 64 64 65 virtual void tick(float dt); 66 67 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 65 68 66 69 /** … … 123 126 static const float MAX_REL_Z_VELOCITY; 124 127 128 void setDefScoreSound(const std::string& engineSound); 129 const std::string& getDefScoreSound(); 130 void setDefBatSound(const std::string& engineSound); 131 const std::string& getDefBatSound(); 132 void setDefBoundarySound(const std::string& engineSound); 133 const std::string& getDefBoundarySound(); 134 125 135 private: 126 136 void registerVariables(); … … 135 145 unsigned int* batID_; //!< The object IDs of the bats, to be able to synchronize them over the network. 136 146 float relMercyOffset_; //!< Offset, that makes the player not loose, when, in all fairness, he would have. 147 WorldSound* defScoreSound_; 148 WorldSound* defBatSound_; 149 WorldSound* defBoundarySound_; 137 150 }; 138 151 } -
code/branches/presentationHS13/src/modules/pong/PongScore.cc
r9667 r9918 41 41 42 42 #include "Pong.h" 43 #include "sound/WorldSound.h" ///////////////////////////// 43 44 44 45 namespace orxonox -
code/branches/presentationHS13/src/modules/pong/PongScore.h
r9667 r9918 124 124 WeakPtr<PlayerInfo> player1_; //!< Store information about left player permanently. 125 125 WeakPtr<PlayerInfo> player2_; //!< Same for the right player. To end the game properly. 126 WorldSound* scoreSound_; 127 126 128 }; 127 129 } -
code/branches/presentationHS13/src/orxonox/MoodManager.h
r9667 r9918 51 51 52 52 private: 53 virtual voidmoodChanged(const std::string& mood) = 0;53 virtual bool moodChanged(const std::string& mood) = 0; 54 54 55 55 static void changedMood(const std::string& mood); -
code/branches/presentationHS13/src/orxonox/gamestates/GSMainMenu.cc
r9667 r9918 85 85 { 86 86 if (GameMode::playsSound()) 87 this->ambient_->destroy(); 87 this->ambient_->destroy(); //CHECK Thilo destroy ?preDestroy()? !!!!!!! 88 88 89 89 InputManager::getInstance().destroyState("MainMenuHackery"); -
code/branches/presentationHS13/src/orxonox/items/MultiStateEngine.cc
r9667 r9918 61 61 this->defEngineSndNormal_->setLooping(true); 62 62 this->defEngineSndBoost_->setLooping(true); 63 this->defEngineSndNormal_->setVolume(0.8f); 64 this->defEngineSndBoost_->setVolume(0.5f); 63 65 this->lua_ = new LuaState(); 64 66 } -
code/branches/presentationHS13/src/orxonox/sound/AmbientSound.cc
r8861 r9918 79 79 } 80 80 81 voidAmbientSound::setAmbientSource(const std::string& source)81 bool AmbientSound::setAmbientSource(const std::string& source) 82 82 { 83 83 this->ambientSource_ = source; 84 this->moodChanged(MoodManager::getInstance().getMood());84 return(this->moodChanged(MoodManager::getInstance().getMood())); 85 85 } 86 86 87 voidAmbientSound::moodChanged(const std::string& mood)87 bool AmbientSound::moodChanged(const std::string& mood) 88 88 { 89 89 if (GameMode::playsSound()) … … 95 95 orxout(user_info) << "Loading ambient sound " << path << "..." << endl; // TODO: make this output internal if we implement sound streaming 96 96 this->setSource(path); 97 98 // all went fine 99 return true; 97 100 } 98 101 else 99 102 { 100 103 orxout(internal_warning, context::sound) << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << endl; 104 105 // everything went southways 106 return false; 101 107 } 102 108 } 109 return false; 103 110 } 104 111 -
code/branches/presentationHS13/src/orxonox/sound/AmbientSound.h
r7856 r9918 54 54 void pause(); 55 55 56 voidsetAmbientSource(const std::string& source);56 bool setAmbientSource(const std::string& source); 57 57 inline const std::string& getAmbientSource() const 58 58 { return this->ambientSource_; } … … 68 68 void preDestroy(); 69 69 float getRealVolume(); 70 voidmoodChanged(const std::string& mood);70 bool moodChanged(const std::string& mood); 71 71 inline void ambientSourceChanged() 72 72 { this->setAmbientSource(this->ambientSource_); } -
code/branches/presentationHS13/src/orxonox/sound/BaseSound.cc
r9667 r9918 47 47 BaseSound::BaseSound() 48 48 : bPooling_(false) 49 , volume_( 1.0)49 , volume_(0.7) 50 50 , bLooping_(false) 51 51 , state_(Stopped) -
code/branches/presentationHS13/src/orxonox/sound/SoundManager.cc
r9667 r9918 218 218 .description("Defines the overall volume.") 219 219 .callback(this, &SoundManager::checkSoundVolumeValidity); 220 SetConfigValueAlias(volume_[SoundType::Music], "ambientVolume_", 1.0f)220 SetConfigValueAlias(volume_[SoundType::Music], "ambientVolume_", 0.7f) 221 221 .description("Defines the ambient volume.") 222 222 .callback(this, &SoundManager::checkAmbientVolumeValidity); -
code/branches/presentationHS13/src/orxonox/sound/WorldAmbientSound.cc
r9667 r9918 33 33 #include "core/XMLPort.h" 34 34 #include "AmbientSound.h" 35 #include "core/command/ConsoleCommand.h" 36 #include <exception> 37 35 38 36 39 namespace orxonox 37 40 { 41 SetConsoleCommand("WorldAmbientSound", "nextsong", &WorldAmbientSound::nextSong); 42 38 43 RegisterClass(WorldAmbientSound); 39 44 … … 44 49 this->ambientSound_ = new AmbientSound(); 45 50 this->registerVariables(); 51 soundList_.push_back("Earth.ogg"); 52 soundList_.push_back("Jupiter.ogg"); 53 soundList_.push_back("Mars.ogg"); 54 soundList_.push_back("allgorythm-lift_up.ogg"); 55 soundList_.push_back("allgorythm-resonance_blaster.ogg"); 56 soundList_.push_back("AlphaCentauri.ogg"); 57 soundList_.push_back("Asteroid_rocks.ogg"); 58 soundList_.push_back("Ganymede.ogg"); 59 soundList_.push_back("luke_grey_-_hypermode.ogg"); 60 46 61 } 47 48 62 WorldAmbientSound::~WorldAmbientSound() 49 63 { … … 51 65 { 52 66 this->ambientSound_->destroy(); 67 WorldAmbientSound::soundList_.clear(); 53 68 } 54 69 } … … 94 109 this->ambientSound_->stop(); 95 110 } 111 112 void WorldAmbientSound::nextSong() 113 { 114 115 //HACK: Assuption - there is only one WorldAmbientSound in a level and only one level is used. 116 for (ObjectList<WorldAmbientSound>::iterator it = ObjectList<WorldAmbientSound>::begin(); 117 it != ObjectList<WorldAmbientSound>::end(); ++it) 118 { 119 while(it->ambientSound_->setAmbientSource(WorldAmbientSound::soundList_[WorldAmbientSound::soundNumber_]) == false){ 120 WorldAmbientSound::soundNumber_ = (WorldAmbientSound::soundNumber_ + 1) % WorldAmbientSound::soundList_.size(); 121 } 122 WorldAmbientSound::soundNumber_ = (WorldAmbientSound::soundNumber_ + 1) % WorldAmbientSound::soundList_.size(); 123 } 124 } 96 125 } -
code/branches/presentationHS13/src/orxonox/sound/WorldAmbientSound.h
r9667 r9918 34 34 #include "core/BaseObject.h" 35 35 #include "network/synchronisable/Synchronisable.h" 36 #include <string> 37 #include <vector> 38 36 39 37 40 namespace orxonox … … 54 57 void play(); 55 58 59 //This function changes the current ambient song. 60 //You can call nextSong() active in the level 61 //by pressing the key 'M'. 62 static void nextSong(); 63 56 64 private: 57 65 void registerVariables(); 58 66 67 //Vector with the diffrent available level sounds. 68 //The sound names are pushed in the WorldAmbientSound-constructor. 69 static std::vector<std::string> soundList_; 70 71 // This value will be initialized below, don't make this into 72 // a const, since we want to change it in nextSong(). 73 static int soundNumber_; 74 75 59 76 AmbientSound* ambientSound_; 60 77 }; 78 79 // This is an initialization for the soundnumber variable. Since it is 80 // static, we have to initialize it this way. 81 int WorldAmbientSound::soundNumber_ = 0; 82 std::vector<std::string> WorldAmbientSound::soundList_; 83 61 84 } 62 85 -
code/branches/presentationHS13/src/orxonox/sound/WorldSound.cc
r9667 r9918 81 81 alSourcef(this->audioSource_, AL_REFERENCE_DISTANCE, refDist); 82 82 // TODO: 500 is very magical here. Derive something better 83 alSourcef(this->audioSource_, AL_MAX_DISTANCE, refDist * 500);83 alSourcef(this->audioSource_, AL_MAX_DISTANCE, refDist * 20); 84 84 } 85 85 this->tick(0); // update position, orientation and velocity -
code/branches/presentationHS13/src/orxonox/weaponsystem/WeaponMode.cc
r9667 r9918 79 79 this->defSndWpnFire_ = new WorldSound(this->getContext()); 80 80 this->defSndWpnFire_->setLooping(false); 81 this->defSndWpnFire_->setVolume(0.8f); 81 82 this->bSoundAttached_ = false; 82 83 } -
code/branches/presentationHS13/src/orxonox/worldentities/pawns/Pawn.cc
r9900 r9918 46 46 #include "weaponsystem/WeaponPack.h" 47 47 #include "weaponsystem/WeaponSet.h" 48 #include "sound/WorldSound.h" 48 49 49 50 #include "controllers/FormationController.h" … … 100 101 101 102 this->setSyncMode(ObjectDirection::Bidirectional); // needed to synchronise e.g. aimposition 103 104 if (GameMode::isMaster()) 105 { 106 this->explosionSound_ = new WorldSound(this->getContext()); 107 this->explosionSound_->setVolume(1.0f); 108 } 109 else 110 { 111 this->explosionSound_ = 0; 112 } 102 113 } 103 114 … … 109 120 this->weaponSystem_->destroy(); 110 121 } 122 111 123 } 112 124 … … 135 147 XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f); 136 148 149 XMLPortParam(Pawn, "explosionSound", setExplosionSound, getExplosionSound, xmlelement, mode); 150 137 151 XMLPortParam ( RadarViewable, "radarname", setRadarName, getRadarName, xmlelement, mode ); 138 152 } 153 139 154 140 155 void Pawn::registerVariables() … … 290 305 void Pawn::kill() 291 306 { 292 307 this->damage(this->health_); 293 308 this->death(); 294 309 } … … 314 329 if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) 315 330 { 316 // Set bAlive_ to false and wait for PawnManager to do the destruction 331 explosionSound_->play(); 332 // Set bAlive_ to false and wait for PawnManager to do the destruction 317 333 this->bAlive_ = false; 318 334 … … 532 548 533 549 550 void Pawn::setExplosionSound(const std::string &explosionSound) 551 { 552 if(explosionSound_ ) 553 explosionSound_->setSource(explosionSound); 554 else 555 assert(0); // This should never happen, because soundpointer is only available on master 556 } 557 558 const std::string& Pawn::getExplosionSound() 559 { 560 if( explosionSound_ ) 561 return explosionSound_->getSource(); 562 else 563 assert(0); 564 return BLANKSTRING; 565 } 566 534 567 535 568 } -
code/branches/presentationHS13/src/orxonox/worldentities/pawns/Pawn.h
r9667 r9918 36 36 #include "interfaces/RadarViewable.h" 37 37 #include "worldentities/ControllableEntity.h" 38 38 39 39 40 namespace orxonox // tolua_export … … 178 179 virtual void changedVisibility(); 179 180 181 void setExplosionSound(const std::string& engineSound); 182 const std::string& getExplosionSound(); 183 180 184 protected: 181 185 virtual void preDestroy(); … … 231 235 232 236 Vector3 aimPosition_; 237 238 WorldSound* explosionSound_; 239 233 240 }; // tolua_export 234 241 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.