[Orxonox-commit 1399] r6117 - in code/branches/presentation2: . data/levels data/levels/templates src/libraries/core src/orxonox src/orxonox/gamestates src/orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Sun Nov 22 16:01:17 CET 2009
Author: rgrieder
Date: 2009-11-22 16:01:16 +0100 (Sun, 22 Nov 2009)
New Revision: 6117
Added:
code/branches/presentation2/data/levels/sound.oxw
code/branches/presentation2/src/orxonox/MoodManager.cc
code/branches/presentation2/src/orxonox/MoodManager.h
Modified:
code/branches/presentation2/
code/branches/presentation2/data/levels/templates/spaceship_assff.oxt
code/branches/presentation2/src/libraries/core/XMLPort.h
code/branches/presentation2/src/orxonox/CMakeLists.txt
code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc
code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.h
code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
code/branches/presentation2/src/orxonox/sound/AmbientSound.h
code/branches/presentation2/src/orxonox/sound/BaseSound.cc
code/branches/presentation2/src/orxonox/sound/BaseSound.h
code/branches/presentation2/src/orxonox/sound/SoundManager.cc
code/branches/presentation2/src/orxonox/sound/SoundManager.h
code/branches/presentation2/src/orxonox/sound/WorldSound.cc
code/branches/presentation2/src/orxonox/sound/WorldSound.h
Log:
Merged sound3 branch to presentation2.
Property changes on: code/branches/presentation2
___________________________________________________________________
Modified: svn:mergeinfo
- /code/branches/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/particles2:6050-6106,6109
/code/branches/resource2:3372-5694
/code/branches/steering:5949-6091
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
+ /code/branches/console:5941-6104
/code/branches/core5:5768-5928,6009
/code/branches/libraries:5612-5692
/code/branches/libraries2:5703-5737
/code/branches/particles2:6050-6106,6109
/code/branches/resource2:3372-5694
/code/branches/sound3:5941-6102
/code/branches/steering:5949-6091
code/branches/buildsystem:1874-2276,2278-2400
code/branches/buildsystem2:2506-2658
code/branches/buildsystem3:2662-2708
code/branches/ceguilua:1802-1808
code/branches/core3:1572-1739
code/branches/core4:3221-3224,3227,3234-3238,3242,3244-3250,3252-3254,3256,3259-3261,3264-3265,3268-3275,3277-3278,3280,3284-3285,3287,3289-3294,3305,3309-3310
code/branches/gametypes:2826-3031
code/branches/gcc43:1580
code/branches/gui:1635-1723,2795-2894
code/branches/input:1629-1636
code/branches/lodfinal:2372-2411
code/branches/map:2801-3086,3089
code/branches/miniprojects:2754-2824
code/branches/netp2:2835-2988
code/branches/netp3:2988-3082
code/branches/netp6:3214-3302
code/branches/network:2356
code/branches/network64:2210-2355
code/branches/objecthierarchy:1911-2085,2100,2110-2169
code/branches/objecthierarchy2:2171-2479
code/branches/overlay:2117-2385
code/branches/particles:2829-3085
code/branches/pch:3113-3194
code/branches/physics:1912-2055,2107-2439
code/branches/physics_merge:2436-2457
code/branches/pickups:1926-2086,2127,2827-2915
code/branches/pickups2:2107-2497,2915-3071
code/branches/presentation:2369-2652,2654-2660
code/branches/questsystem:1894-2088
code/branches/questsystem2:2107-2259
code/branches/questsystem5:2776-2905
code/branches/resource:3327-3366
code/branches/script_trigger:1295-1953,1955
code/branches/sound:2829-3010
code/branches/weapon:1925-2094
code/branches/weapon2:2107-2488
code/branches/weapons:2897-3051
code/branches/weaponsystem:2742-2890
Copied: code/branches/presentation2/data/levels/sound.oxw (from rev 6102, code/branches/sound3/data/levels/sound.oxw)
===================================================================
--- code/branches/presentation2/data/levels/sound.oxw (rev 0)
+++ code/branches/presentation2/data/levels/sound.oxw 2009-11-22 15:01:16 UTC (rev 6117)
@@ -0,0 +1,36 @@
+<?lua
+ include("stats.oxo")
+ include("hudtemplates3.oxo")
+?>
+
+<?lua
+ include("templates/spaceship_assff.oxt")
+ include("templates/spaceship_pirate.oxt")
+?>
+
+<Level
+ name = "Sample"
+ description = "Just a few tests"
+>
+ <Scene
+ ambientlight = "0.8, 0.8, 0.8"
+ skybox = "Orxonox/Starbox"
+ >
+
+ <AmbientSound ambientSource="Mars.ogg" loop="true" play="true" />
+ <AmbientSound ambientSource="Asteroid_rocks.ogg" loop="true" play="false">
+ <events>
+ <activity>
+ <DistanceTrigger position="300,100,0" distance=200 target="ControllableEntity">
+ <attached>
+ <ParticleSpawner position="0,0,0" source="Orxonox/fire3" lifetime=0 loop=0 autostart=1 />
+ </attached>
+ </DistanceTrigger>
+ </activity>
+ </events>
+ </AmbientSound>
+
+ <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" />
+ <SpawnPoint position="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
+ </Scene>
+</Level>
Modified: code/branches/presentation2/data/levels/templates/spaceship_assff.oxt
===================================================================
--- code/branches/presentation2/data/levels/templates/spaceship_assff.oxt 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/data/levels/templates/spaceship_assff.oxt 2009-11-22 15:01:16 UTC (rev 6117)
@@ -75,14 +75,17 @@
<Light mainstate=visibility position=" 8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
<Light mainstate=visibility position="-8, 0, 8" diffuse="0.3, 0.6, 1.0" specular="0.3, 0.6, 1.0" attenuation="600, 1.0, 0.007, 0.0002" type=point />
-->
+ <!--WorldSound mainstate=activity source="sounds/Engine_low.ogg" oop=1 /-->
</active>
<forward>
<Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
<Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.2, 0.65, 1.0, 1.0" width=15 length=1500 lifetime=2 elements=50 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Flares/ThrusterFlare1" />
+ <WorldSound mainstate=activity source="sounds/Engine_low.ogg" oop=1 />
</forward>
<boost>
<Backlight mainstate=activity active=false scale=0.4 name=bltest position=" 7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
<Backlight mainstate=activity active=false scale=0.4 name=bltest position="-7.6, 0, 6" colour="0.6, 0.75, 0.8, 0.7" width=40 length=1000 lifetime=1 elements=30 trailmaterial="Trail/backlighttrail" turnontime=1 turnofftime=1 material="Examples/Flare" />
+ <!--WorldSound mainstate=activity source="sounds/Engine_high.ogg" oop=1 /-->
</boost>
<brake>
<FadingBillboard mainstate=activity active=false scale=0.3 position=" 8, 0, 6" colour="0.5, 0.0, 0.0, 0.3" material="Examples/Flare" turnontime=0.5 turnofftime=0.5 />
Modified: code/branches/presentation2/src/libraries/core/XMLPort.h
===================================================================
--- code/branches/presentation2/src/libraries/core/XMLPort.h 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/libraries/core/XMLPort.h 2009-11-22 15:01:16 UTC (rev 6117)
@@ -183,7 +183,7 @@
containername = new orxonox::XMLPortClassParamContainer<objectclass>(std::string(paramname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor); \
ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
} \
- containername->port(static_cast<BaseObject*>(this), object, xmlelement, mode)
+ containername->port(dynamic_cast<BaseObject*>(this), object, xmlelement, mode)
// --------------------
// XMLPortObjectExtended
Modified: code/branches/presentation2/src/orxonox/CMakeLists.txt
===================================================================
--- code/branches/presentation2/src/orxonox/CMakeLists.txt 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/CMakeLists.txt 2009-11-22 15:01:16 UTC (rev 6117)
@@ -27,6 +27,7 @@
Level.cc
LevelManager.cc
Main.cc
+ MoodManager.cc
PawnManager.cc
PlayerManager.cc
Radar.cc
@@ -54,6 +55,7 @@
FIND_HEADER_FILES
TOLUA_FILES
LevelManager.h
+ MoodManager.h
pickup/BaseItem.h
pickup/PickupInventory.h
DEFINE_SYMBOL
Copied: code/branches/presentation2/src/orxonox/MoodManager.cc (from rev 6102, code/branches/sound3/src/orxonox/MoodManager.cc)
===================================================================
--- code/branches/presentation2/src/orxonox/MoodManager.cc (rev 0)
+++ code/branches/presentation2/src/orxonox/MoodManager.cc 2009-11-22 15:01:16 UTC (rev 6117)
@@ -0,0 +1,84 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Kevin 'youngk' Young
+ * Co-authors:
+ * ...
+ *
+ */
+
+#include "MoodManager.h"
+
+#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ScopedSingletonManager.h"
+
+namespace orxonox
+{
+ MoodManager* MoodManager::singletonPtr_s = 0;
+ ManageScopedSingleton(MoodManager, ScopeID::Root, false);
+
+ MoodManager::MoodManager()
+ {
+ RegisterRootObject(MoodManager);
+ moodOld_ = "default";
+ this->setConfigValues();
+ CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&MoodManager::setMood, this), "setMood"));
+ }
+
+ MoodManager::~MoodManager()
+ {
+ }
+
+ void MoodManager::setConfigValues()
+ {
+ SetConfigValue(mood_, "default")
+ .description("Sets the mood for the current level.")
+ .callback(this, &MoodManager::checkMoodValidity);
+ }
+
+ /**
+ * Sets the mood
+ * @note TODO: Inform dependent classes of mood change
+ */
+ void MoodManager::setMood(const std::string& mood)
+ {
+ ModifyConfigValue(mood_, set, mood);
+ }
+
+ // gets the current mood
+ const std::string& MoodManager::getMood()
+ {
+ return mood_;
+ }
+
+ void MoodManager::checkMoodValidity()
+ {
+ if(mood_ != "default" && mood_ != "dnb") // Insert new moods here
+ {
+ ResetConfigValue(mood_);
+ }
+ COUT(0) << "MoodManager: Mood now set to " << mood_ << std::endl;
+ return;
+ }
+}
Copied: code/branches/presentation2/src/orxonox/MoodManager.h (from rev 6102, code/branches/sound3/src/orxonox/MoodManager.h)
===================================================================
--- code/branches/presentation2/src/orxonox/MoodManager.h (rev 0)
+++ code/branches/presentation2/src/orxonox/MoodManager.h 2009-11-22 15:01:16 UTC (rev 6117)
@@ -0,0 +1,72 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Kevin 'youngk' Young
+ * Co-authors:
+ * ...
+ *
+ */
+
+#ifndef _MoodManager_H__
+#define _MoodManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <cassert>
+#include <list>
+#include <string>
+
+#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
+
+// tolua_begin
+namespace orxonox
+{
+ class _OrxonoxExport MoodManager
+ // tolua_end
+ : public Singleton<MoodManager>, public OrxonoxClass
+ { // tolua_export
+ friend class Singleton<MoodManager>;
+ public:
+ MoodManager();
+ ~MoodManager();
+
+ void setConfigValues();
+
+ void setMood(const std::string& mood);
+ const std::string& getMood();
+
+ static MoodManager& getInstance() { return Singleton<MoodManager>::getInstance(); } // tolua_export
+
+ private:
+
+ // config values
+ std::string mood_;
+ std::string moodOld_;
+
+ void checkMoodValidity();
+
+ static MoodManager* singletonPtr_s;
+ }; // tolua_export
+} // tolua_export
+
+#endif /* _MoodManager_H__ */
Modified: code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.cc 2009-11-22 15:01:16 UTC (rev 6117)
@@ -35,6 +35,7 @@
#include "core/input/KeyBinderManager.h"
#include "core/Game.h"
#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
#include "core/GraphicsManager.h"
#include "core/GUIManager.h"
#include "Scene.h"
@@ -48,6 +49,7 @@
: GameState(info)
, inputState_(0)
{
+ RegisterRootObject(GSMainMenu);
inputState_ = InputManager::getInstance().createInputState("mainMenu");
inputState_->setMouseMode(MouseMode::Nonexclusive);
inputState_->setHandler(GUIManager::getInstancePtr());
@@ -63,7 +65,6 @@
{
// Load sound
this->ambient_ = new AmbientSound(0);
- this->ambient_->setSource("ambient/mainmenu.wav");
}
}
@@ -90,15 +91,20 @@
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startClient), "startClient"));
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startDedicated), "startDedicated"));
CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu), "startMainMenu"));
+
+ // create command to change sound path
+ CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&GSMainMenu::setMainMenuSoundPath, this), "setMMSoundPath"));
KeyBinderManager::getInstance().setToDefault();
InputManager::getInstance().enterState("mainMenu");
if (GameMode::playsSound())
{
- this->ambient_->setLoop(true);
- this->ambient_->play();
+ this->ambient_->setLooping(true);
+ this->ambient_->play(); // works without source
}
+
+ this->setConfigValues();
}
void GSMainMenu::deactivate()
@@ -118,6 +124,31 @@
{
}
+ void GSMainMenu::setConfigValues()
+ {
+ SetConfigValue(soundPathMain_, "mainmenu.ogg")
+ .description("Contains the path to the main menu sound file.")
+ .callback(this, &GSMainMenu::reloadSound);
+ }
+
+ void GSMainMenu::reloadSound()
+ {
+ if (GameMode::playsSound())
+ {
+ this->ambient_->setAmbientSource(soundPathMain_);
+ }
+ }
+
+ const std::string& GSMainMenu::getMainMenuSoundPath()
+ {
+ return soundPathMain_;
+ }
+
+ void GSMainMenu::setMainMenuSoundPath(const std::string& path)
+ {
+ ModifyConfigValue(soundPathMain_, set, path);
+ }
+
void GSMainMenu::startStandalone()
{
// HACK - HACK
Modified: code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.h 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/gamestates/GSMainMenu.h 2009-11-22 15:01:16 UTC (rev 6117)
@@ -33,10 +33,11 @@
#include "util/OgreForwardRefs.h"
#include "core/GameState.h"
+#include "core/OrxonoxClass.h"
namespace orxonox
{
- class _OrxonoxExport GSMainMenu : public GameState
+ class _OrxonoxExport GSMainMenu : public GameState, public OrxonoxClass
{
public:
GSMainMenu(const GameStateInfo& info);
@@ -46,6 +47,11 @@
void deactivate();
void update(const Clock& time);
+ void setConfigValues();
+ void reloadSound();
+ const std::string& getMainMenuSoundPath();
+ void setMainMenuSoundPath(const std::string& path);
+
static void startStandalone();
static void startServer();
static void startClient();
@@ -60,6 +66,7 @@
// ambient sound for the main menu
AmbientSound* ambient_;
+ std::string soundPathMain_;
};
}
Modified: code/branches/presentation2/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/AmbientSound.cc 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/AmbientSound.cc 2009-11-22 15:01:16 UTC (rev 6117)
@@ -30,7 +30,11 @@
#include "core/CoreIncludes.h"
#include "core/EventIncludes.h"
+#include "core/GameMode.h"
+#include "core/Resource.h"
#include "core/XMLPort.h"
+#include "SoundManager.h"
+#include "MoodManager.h"
namespace orxonox
{
@@ -40,6 +44,9 @@
: BaseObject(creator)
{
RegisterObject(AmbientSound);
+
+ // Ambient sounds always fade in
+ this->setVolume(0);
}
AmbientSound::~AmbientSound()
@@ -49,9 +56,8 @@
void AmbientSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(AmbientSound, XMLPort, xmlelement, mode);
- XMLPortParamExtern(AmbientSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
- XMLPortParamExtern(AmbientSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
- XMLPortParamExtern(AmbientSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
+ BaseSound::XMLPortExtern(xmlelement, mode);
+ XMLPortParam(AmbientSound, "ambientsource", setAmbientSource, getAmbientSource, xmlelement, mode);
}
void AmbientSound::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -59,4 +65,67 @@
SUPER(AmbientSound, XMLEventPort, xmlelement, mode);
XMLPortEventState(AmbientSound, BaseObject, "play", play, xmlelement, mode);
}
+
+ void AmbientSound::play()
+ {
+ if (GameMode::playsSound())
+ {
+ COUT(3) << "Sound: " << this->getSource() << ": Playing" << std::endl;
+ SoundManager::getInstance().registerAmbientSound(this);
+ }
+ }
+
+ void AmbientSound::doPlay()
+ {
+ BaseSound::play();
+ }
+
+ void AmbientSound::stop()
+ {
+ if (GameMode::playsSound())
+ {
+ SoundManager::getInstance().unregisterAmbientSound(this);
+ }
+ }
+
+ void AmbientSound::doStop()
+ {
+ BaseSound::stop();
+ }
+
+ void AmbientSound::pause()
+ {
+ if (GameMode::playsSound())
+ {
+ SoundManager::getInstance().pauseAmbientSound(this);
+ }
+ }
+
+ void AmbientSound::doPause()
+ {
+ BaseSound::pause();
+ }
+
+ void AmbientSound::setAmbientSource(const std::string& source)
+ {
+ this->ambientSource_ = source;
+ if (GameMode::playsSound())
+ {
+ std::string path = "ambient/" + MoodManager::getInstance().getMood() + "/" + source;
+ shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path);
+ if (fileInfo != NULL)
+ this->setSource(path);
+ else
+ COUT(3) << "Sound: " << source << ": Not a valid name! Ambient sound will not change." << std::endl;
+ }
+ }
+
+ void AmbientSound::changedActivity()
+ {
+ SUPER(AmbientSound, changedActivity);
+ if (this->isActive())
+ this->play();
+ else
+ this->stop();
+ }
}
Modified: code/branches/presentation2/src/orxonox/sound/AmbientSound.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/AmbientSound.h 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/AmbientSound.h 2009-11-22 15:01:16 UTC (rev 6117)
@@ -21,10 +21,12 @@
*
* Author:
* Reto Grieder
+ * Kevin Young
* Co-authors:
* ...
*
*/
+
#ifndef _AmbientSound_H__
#define _AmbientSound_H__
@@ -42,14 +44,29 @@
*/
class _OrxonoxExport AmbientSound : public BaseSound, public BaseObject
{
+ friend class SoundManager;
+
public:
AmbientSound(BaseObject* creator);
virtual ~AmbientSound();
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedActivity();
+ virtual void play();
+ virtual void stop();
+ virtual void pause();
+
+ virtual void setAmbientSource(const std::string& source);
+ const std::string& getAmbientSource() const { return this->ambientSource_; }
+
private:
+ void doPlay();
+ void doStop();
+ void doPause();
+
+ std::string ambientSource_; //!< Analogous to source_, but mood independent
};
}
Modified: code/branches/presentation2/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.cc 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.cc 2009-11-22 15:01:16 UTC (rev 6117)
@@ -28,6 +28,7 @@
#include "BaseSound.h"
+#include <cassert>
#include <vector>
#include <AL/alut.h>
#include <vorbis/vorbisfile.h>
@@ -35,100 +36,115 @@
#include "core/CoreIncludes.h"
#include "core/GameMode.h"
#include "core/Resource.h"
+#include "core/XMLPort.h"
namespace orxonox
{
BaseSound::BaseSound()
: audioSource_(0)
, audioBuffer_(0)
- , bPlayOnLoad_(false)
, bLoop_(false)
+ , state_(Stopped)
{
RegisterRootObject(BaseSound);
+
+ if (GameMode::playsSound())
+ {
+ alGenSources(1, &this->audioSource_);
+ assert(this->audioSource_ != 0);
+ }
}
BaseSound::~BaseSound()
{
this->setSource("");
+ if (GameMode::playsSound())
+ alDeleteSources(1, &this->audioSource_);
}
+ void BaseSound::XMLPortExtern(Element& xmlelement, XMLPort::Mode mode)
+ {
+ XMLPortParam(BaseSound, "volume", setVolume, getVolume, xmlelement, mode);
+ XMLPortParam(BaseSound, "loop", setLooping, getLooping, xmlelement, mode);
+ XMLPortParam(BaseSound, "play", play, isPlaying, xmlelement, mode);
+ XMLPortParam(BaseSound, "source", setSource, getSource, xmlelement, mode);
+ }
+
void BaseSound::play()
{
- if (alIsSource(this->audioSource_))
+ if (!this->isPlaying() && GameMode::showsGraphics())
{
- if (this->bLoop_)
- alSourcei(this->audioSource_, AL_LOOPING, AL_TRUE);
- else
- alSourcei(this->audioSource_, AL_LOOPING, AL_FALSE);
+ this->state_ = Playing;
alSourcePlay(this->audioSource_);
if (alGetError() != AL_NO_ERROR)
- {
- COUT(2) << "Sound: OpenAL: Error playin sound " << this->audioSource_ << std::endl;
- }
+ COUT(2) << "Sound: OpenAL: Error playing sound " << this->audioSource_ << std::endl;
}
}
void BaseSound::stop()
{
- if (alIsSource(this->audioSource_))
+ this->state_ = Stopped;
+ if (GameMode::playsSound())
alSourceStop(this->audioSource_);
}
void BaseSound::pause()
{
- if (alIsSource(this->audioSource_))
+ if (this->isStopped())
+ return;
+ this->state_ = Paused;
+ if (GameMode::playsSound())
alSourcePause(this->audioSource_);
}
- bool BaseSound::isPlaying()
+ void BaseSound::setVolume(float vol)
{
+ if (vol > 1 || vol < 0)
+ {
+ COUT(2) << "Sound warning: volume out of range, cropping value." << std::endl;
+ vol = vol > 1 ? 1 : vol;
+ vol = vol < 0 ? 0 : vol;
+ }
+ this->volume_ = vol;
if (alIsSource(this->audioSource_))
- return getSourceState() == AL_PLAYING;
- return false;
+ alSourcef(this->audioSource_, AL_GAIN, vol);
}
- bool BaseSound::isPaused()
+ void BaseSound::setLooping(bool val)
{
- if (alIsSource(this->audioSource_))
- return getSourceState() == AL_PAUSED;
- return true;
+ this->bLoop_ = val;
+ if (GameMode::playsSound())
+ alSourcei(this->audioSource_, AL_LOOPING, (val ? AL_TRUE : AL_FALSE));
}
- bool BaseSound::isStopped()
- {
- if (alIsSource(this->audioSource_))
- return getSourceState() == AL_INITIAL || getSourceState() == AL_STOPPED;
- return true;
- }
-
- void BaseSound::setPlayOnLoad(bool val)
- {
- this->bPlayOnLoad_ = true;
- this->play();
- }
-
void BaseSound::setSource(const std::string& source)
{
- this->source_ = source;
- if (!GameMode::playsSound())
+ if (!GameMode::playsSound() || source == this->source_)
+ {
+ this->source_ = source;
return;
+ }
- if (source.empty() && alIsSource(this->audioSource_))
+ if (this->audioBuffer_ != 0 && alIsBuffer(this->audioBuffer_))
{
- // Unload sound
+ alSourceStop(this->audioSource_);
+ // Unload old sound first
alSourcei(this->audioSource_, AL_BUFFER, 0);
- alDeleteSources(1, &this->audioSource_);
alDeleteBuffers(1, &this->audioBuffer_);
- return;
+ this->audioBuffer_ = 0;
}
+ this->source_ = source;
+ if (source_.empty())
+ return;
+
COUT(3) << "Sound: OpenAL ALUT: loading file " << source << std::endl;
// Get DataStream from the resources
shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(source);
if (fileInfo == NULL)
{
- COUT(2) << "Warning: Sound file '" << source << "' not found" << std::endl;
+ COUT(2) << "Sound: Warning: Sound file '" << source << "' not found" << std::endl;
return;
}
dataStream_ = Resource::open(source);
@@ -146,7 +162,7 @@
if (source.find("ogg", 0) != std::string::npos)
{
COUT(2) << "Sound: Trying fallback ogg loader" << std::endl;
- this->audioBuffer_ = loadOggFile();
+ this->audioBuffer_ = this->loadOggFile();
}
if (this->audioBuffer_ == AL_NONE)
@@ -156,7 +172,6 @@
}
}
- alGenSources(1, &this->audioSource_);
alSourcei(this->audioSource_, AL_BUFFER, this->audioBuffer_);
if (alGetError() != AL_NO_ERROR)
{
@@ -165,18 +180,17 @@
}
alSource3f(this->audioSource_, AL_POSITION, 0, 0, 0);
+ alSourcef (this->audioSource_, AL_GAIN, this->volume_);
+ alSourcei (this->audioSource_, AL_LOOPING, (this->bLoop_ ? AL_TRUE : AL_FALSE));
+ if (this->isPlaying() || this->isPaused())
+ alSourcePlay(this->audioSource_);
+ if (this->isPaused())
+ alSourcePause(this->audioSource_);
- if (this->bPlayOnLoad_)
- this->play();
+ if (alGetError() != AL_NO_ERROR)
+ COUT(2) << "Sound: OpenAL: Error playing sound " << this->audioSource_ << std::endl;
}
- ALint BaseSound::getSourceState()
- {
- ALint state;
- alGetSourcei(this->audioSource_, AL_SOURCE_STATE, &state);
- return state;
- }
-
size_t readVorbis(void* ptr, size_t size, size_t nmemb, void* datasource)
{
return static_cast<Ogre::DataStream*>(datasource)->read(ptr, size * nmemb);
@@ -258,5 +272,4 @@
return buffer;
}
-
-} // namespace: orxonox
+}
Modified: code/branches/presentation2/src/orxonox/sound/BaseSound.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/BaseSound.h 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/BaseSound.h 2009-11-22 15:01:16 UTC (rev 6117)
@@ -25,13 +25,13 @@
* Reto Grieder
*
*/
+
#ifndef _BaseSound_H__
#define _BaseSound_H__
#include "OrxonoxPrereqs.h"
#include <string>
-#include <OgreSharedPtr.h>
#include <OgreDataStream.h>
#include "core/OrxonoxClass.h"
@@ -48,35 +48,46 @@
BaseSound();
virtual ~BaseSound();
- void play();
- void stop();
- void pause();
+ void XMLPortExtern(Element& xmlelement, XMLPort::Mode mode);
- bool isPlaying();
- bool isPaused();
- bool isStopped();
+ virtual void play();
+ virtual void stop();
+ virtual void pause();
- void setSource(const std::string& source);
- const std::string& getSource() { return this->source_; }
+ bool isPlaying() { return this->state_ == Playing; }
+ bool isPaused() { return this->state_ == Paused; }
+ bool isStopped() { return this->state_ == Stopped; }
- bool getPlayOnLoad() { return this->bPlayOnLoad_; }
- void setPlayOnLoad(bool val);
+ virtual void setSource(const std::string& source);
+ virtual const std::string& getSource() const { return this->source_; }
- bool getLoop() { return this->bLoop_; }
- void setLoop(bool val) { this->bLoop_ = val; }
+ void setVolume(float vol);
+ float getVolume() const { return this->volume_; }
+ bool getLooping() const { return this->bLoop_; }
+ void setLooping(bool val);
+
+ //ALuint getALAudioSource(void);
+
protected:
ALuint loadOggFile();
- ALint getSourceState();
ALuint audioSource_;
ALuint audioBuffer_;
private:
- std::string source_;
- bool bPlayOnLoad_;
- bool bLoop_;
- DataStreamPtr dataStream_;
+ enum State
+ {
+ Stopped,
+ Playing,
+ Paused
+ };
+
+ std::string source_;
+ float volume_;
+ bool bLoop_;
+ State state_;
+ DataStreamPtr dataStream_;
};
}
Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.cc 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.cc 2009-11-22 15:01:16 UTC (rev 6117)
@@ -21,6 +21,7 @@
*
* Author:
* Erwin 'vaiursch' Herrsche
+ * Kevin Young
* Co-authors:
* ...
*
@@ -29,12 +30,18 @@
#include "SoundManager.h"
#include <AL/alut.h>
+#include <utility>
#include "util/Exception.h"
#include "util/Math.h"
#include "util/ScopeGuard.h"
+#include "util/StringUtils.h"
+#include "util/Clock.h"
#include "core/GameMode.h"
#include "core/ScopedSingletonManager.h"
+#include "core/ConfigValueIncludes.h"
+#include "BaseSound.h"
+#include "AmbientSound.h"
namespace orxonox
{
@@ -43,44 +50,48 @@
SoundManager::SoundManager()
{
- if (!alutInitWithoutContext(NULL,NULL))
- ThrowException(InitialisationFailed, "OpenAL ALUT error: " << alutGetErrorString(alutGetError()));
+ RegisterRootObject(SoundManager);
+
+ if (!alutInitWithoutContext(NULL, NULL))
+ ThrowException(InitialisationFailed, "Sound: OpenAL ALUT error: " << alutGetErrorString(alutGetError()));
Loki::ScopeGuard alutExitGuard = Loki::MakeGuard(&alutExit);
- COUT(3) << "OpenAL: Opening sound device..." << std::endl;
+ COUT(3) << "Sound: OpenAL: Opening sound device..." << std::endl;
this->device_ = alcOpenDevice(NULL);
if (this->device_ == NULL)
{
- COUT(0) << "OpenaAL: Could not open sound device. Have you installed OpenAL?" << std::endl;
+ COUT(0) << "Sound: OpenaAL: Could not open sound device. Have you installed OpenAL?" << std::endl;
#ifdef ORXONOX_PLATFORM_WINDOWS
- COUT(0) << "Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl;
+ COUT(0) << "Sound: Just getting the DLL with the dependencies is not enough for Windows (esp. Windows 7)!" << std::endl;
#endif
- ThrowException(InitialisationFailed, "OpenAL error: Could not open sound device.");
+ ThrowException(InitialisationFailed, "Sound: OpenAL error: Could not open sound device.");
}
Loki::ScopeGuard closeDeviceGuard = Loki::MakeGuard(&alcCloseDevice, this->device_);
- COUT(3) << "OpenAL: Sound device opened" << std::endl;
+ COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl;
this->context_ = alcCreateContext(this->device_, NULL);
if (this->context_ == NULL)
- ThrowException(InitialisationFailed, "OpenAL error: Could not create sound context");
+ ThrowException(InitialisationFailed, "Sound: OpenAL error: Could not create sound context");
Loki::ScopeGuard desroyContextGuard = Loki::MakeGuard(&alcDestroyContext, this->context_);
if (alcMakeContextCurrent(this->context_) == AL_TRUE)
- COUT(3) << "OpenAL: Context " << this->context_ << " loaded" << std::endl;
+ COUT(3) << "Sound: OpenAL: Context " << this->context_ << " loaded" << std::endl;
COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;
const char* str = alutGetMIMETypes(ALUT_LOADER_BUFFER);
if (str == NULL)
- COUT(2) << "OpenAL ALUT error: " << alutGetErrorString(alutGetError()) << std::endl;
+ COUT(2) << "Sound: OpenAL ALUT error: " << alutGetErrorString(alutGetError()) << std::endl;
else
- COUT(4) << "OpenAL ALUT supported MIME types: " << str << std::endl;
+ COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << str << std::endl;
GameMode::setPlaysSound(true);
// Disarm guards
alutExitGuard.Dismiss();
closeDeviceGuard.Dismiss();
desroyContextGuard.Dismiss();
+
+ this->setConfigValues();
}
SoundManager::~SoundManager()
@@ -91,6 +102,29 @@
alutExit();
}
+ void SoundManager::update(const Clock& time)
+ {
+ this->processCrossFading(time.getDeltaTime());
+ }
+
+ void SoundManager::setConfigValues()
+ {
+ SetConfigValue(crossFadeStep_, 0.2f)
+ .description("Determines how fast sounds should fade, per second.")
+ .callback(this, &SoundManager::checkFadeStepValidity);
+ }
+
+ void SoundManager::checkFadeStepValidity()
+ {
+ if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
+ {
+ COUT(2) << "Sound warning: Sound step out of range, ignoring change." << std::endl;
+ ResetConfigValue(crossFadeStep_);
+ }
+ COUT(3) << "SoundManager: fade step set to " << crossFadeStep_ << std::endl;
+ return;
+ }
+
void SoundManager::setListenerPosition(const Vector3& position)
{
alListener3f(AL_POSITION, position.x, position.y, position.z);
@@ -113,4 +147,162 @@
if (error == AL_INVALID_VALUE)
COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl;
}
+
+ void SoundManager::registerAmbientSound(AmbientSound* newAmbient)
+ {
+ if (newAmbient != NULL)
+ {
+ for (AmbientList::const_iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
+ {
+ if (it->first == newAmbient)
+ {
+ COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;
+ return;
+ }
+ }
+
+ if (!this->ambientSounds_.empty())
+ {
+ this->fadeOut(ambientSounds_.front().first);
+ }
+ this->ambientSounds_.push_front(std::make_pair(newAmbient, false));
+ newAmbient->doPlay();
+ this->fadeIn(newAmbient);
+ }
+ }
+
+ void SoundManager::unregisterAmbientSound(AmbientSound* oldAmbient)
+ {
+ if (oldAmbient == NULL || ambientSounds_.empty())
+ {
+ return;
+ }
+ if (this->ambientSounds_.front().first == oldAmbient)
+ {
+ this->fadeOut(oldAmbient);
+ this->ambientSounds_.pop_front();
+ if (!this->ambientSounds_.empty())
+ {
+ if (!this->ambientSounds_.front().second) // Not paused before
+ {
+ this->ambientSounds_.front().first->doPlay();
+ }
+ this->fadeIn(this->ambientSounds_.front().first);
+ }
+ }
+ else
+ {
+ for (AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
+ {
+ if (it->first == oldAmbient)
+ {
+ this->fadeOut(oldAmbient);
+ this->ambientSounds_.erase(it);
+ break;
+ }
+ }
+ }
+ }
+
+ void SoundManager::pauseAmbientSound(AmbientSound* ambient)
+ {
+ if (ambient != NULL)
+ {
+ for (AmbientList::iterator it = this->ambientSounds_.begin(); it != this->ambientSounds_.end(); ++it)
+ {
+ if (it->first == ambient)
+ {
+ it->second = true;
+ this->fadeOut(it->first);
+ return;
+ }
+ }
+ }
+ }
+
+ void SoundManager::fadeIn(AmbientSound* sound)
+ {
+ // If we're already fading out --> remove that
+ for (std::list<AmbientSound*>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it++)
+ {
+ if (*it == sound)
+ {
+ this->fadeOutList_.erase(it);
+ break;
+ }
+ }
+ // No duplicate entries
+ if (std::find(this->fadeInList_.begin(), this->fadeInList_.end(), sound) == this->fadeInList_.end())
+ this->fadeInList_.push_back(sound);
+ }
+
+ void SoundManager::fadeOut(AmbientSound* sound)
+ {
+ // If we're already fading in --> remove that
+ for (std::list<AmbientSound*>::iterator it = this->fadeInList_.begin(); it != this->fadeInList_.end(); it++)
+ {
+ if (*it == sound)
+ {
+ this->fadeInList_.erase(it);
+ break;
+ }
+ }
+ // No duplicate entries
+ if (std::find(this->fadeOutList_.begin(), this->fadeOutList_.end(), sound) == this->fadeOutList_.end())
+ this->fadeOutList_.push_back(sound);
+ }
+
+ void SoundManager::processCrossFading(float dt)
+ {
+
+ // Hacky solution to the fade delay while loading a level.
+ if(dt > 0.2)
+ {
+ return;
+ }
+
+ // FADE IN
+ for (std::list<AmbientSound*>::iterator it= this->fadeInList_.begin(); it != this->fadeInList_.end(); it)
+ {
+ if ((*it)->getVolume() + this->crossFadeStep_*dt > 1.0f)
+ {
+ (*it)->setVolume(1.0f);
+ this->fadeInList_.erase(it++);
+ }
+ else
+ {
+ (*it)->setVolume((*it)->getVolume() + this->crossFadeStep_*dt);
+ ++it;
+ }
+ }
+
+ // FADE OUT
+ for (std::list<AmbientSound*>::iterator it = this->fadeOutList_.begin(); it != this->fadeOutList_.end(); it)
+ {
+ if ((*it)->getVolume() - this->crossFadeStep_*dt < 0.0f)
+ {
+ (*it)->setVolume(0.0f);
+
+ // If sound is in the ambient list --> pause
+ for (AmbientList::const_iterator it2 = this->ambientSounds_.begin(); it2 != this->ambientSounds_.end(); ++it2)
+ {
+ if (it2->first == *it)
+ {
+ (*it)->doPause();
+ break;
+ }
+ }
+ // If not pause (by loop above for instance) --> stop
+ if (!(*it)->isPaused())
+ (*it)->doStop();
+
+ this->fadeOutList_.erase(it++);
+ }
+ else
+ {
+ (*it)->setVolume((*it)->getVolume() - this->crossFadeStep_*dt);
+ ++it;
+ }
+ }
+ }
}
Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.h 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.h 2009-11-22 15:01:16 UTC (rev 6117)
@@ -21,18 +21,19 @@
*
* Author:
* Erwin 'vaiursch' Herrsche
+ * Kevin Young
* Co-authors:
* ...
*/
+
#ifndef _SoundManager_H__
#define _SoundManager_H__
#include "OrxonoxPrereqs.h"
-#include <cassert>
#include <list>
+#include <string>
#include "util/Singleton.h"
-#include "tools/interfaces/Tickable.h"
namespace orxonox
{
@@ -41,20 +42,41 @@
* position. It is a singleton.
*
*/
- class _OrxonoxExport SoundManager : public Singleton<SoundManager>
+ class _OrxonoxExport SoundManager : public Singleton<SoundManager>, public OrxonoxClass
{
friend class Singleton<SoundManager>;
+
public:
SoundManager();
~SoundManager();
+ void update(const Clock& time);
+ void setConfigValues();
+
void setListenerPosition(const Vector3& position);
void setListenerOrientation(const Quaternion& orientation);
+ void registerAmbientSound(AmbientSound* newAmbient);
+ void unregisterAmbientSound(AmbientSound* oldAmbient);
+ void pauseAmbientSound(AmbientSound* ambient);
+
private:
+ void processCrossFading(float dt);
+ void fadeIn(AmbientSound* sound);
+ void fadeOut(AmbientSound* sound);
+
+ void checkFadeStepValidity();
+
ALCdevice* device_;
ALCcontext* context_;
-
+
+ typedef std::list<std::pair<AmbientSound*, bool> > AmbientList;
+ AmbientList ambientSounds_;
+
+ float crossFadeStep_; //!< Absolute change per second (0.1 means 10% of the nominal volume) for cross fading
+ std::list<AmbientSound*> fadeInList_;
+ std::list<AmbientSound*> fadeOutList_;
+
static SoundManager* singletonPtr_s;
};
}
Modified: code/branches/presentation2/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/WorldSound.cc 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/WorldSound.cc 2009-11-22 15:01:16 UTC (rev 6117)
@@ -52,9 +52,7 @@
void WorldSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(WorldSound, XMLPort, xmlelement, mode);
- XMLPortParamExtern(WorldSound, BaseSound, this, "source", setSource, getSource, xmlelement, mode);
- XMLPortParamExtern(WorldSound, BaseSound, this, "loop", setLoop, getLoop, xmlelement, mode);
- XMLPortParamExtern(WorldSound, BaseSound, this, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
+ BaseSound::XMLPortExtern(xmlelement, mode);
}
void WorldSound::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
@@ -88,4 +86,12 @@
}
}
+ void WorldSound::changedActivity()
+ {
+ SUPER(WorldSound, changedActivity);
+ if (this->isActive())
+ this->play();
+ else
+ this->stop();
+ }
}
Modified: code/branches/presentation2/src/orxonox/sound/WorldSound.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/WorldSound.h 2009-11-21 12:16:16 UTC (rev 6116)
+++ code/branches/presentation2/src/orxonox/sound/WorldSound.h 2009-11-22 15:01:16 UTC (rev 6117)
@@ -25,6 +25,7 @@
* ...
*
*/
+
#ifndef _WorldSound_H__
#define _WorldSound_H__
@@ -48,6 +49,7 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void changedActivity();
virtual void tick(float dt);
More information about the Orxonox-commit
mailing list