[Orxonox-commit 502] r3060 - in trunk: . bin cmake src src/core src/cpptcl src/network/synchronisable src/orxonox src/orxonox/gamestates src/orxonox/objects src/orxonox/objects/collisionshapes src/orxonox/objects/gametypes src/orxonox/objects/items src/orxonox/objects/pickup src/orxonox/objects/quest src/orxonox/objects/worldentities src/orxonox/objects/worldentities/triggers src/orxonox/sound src/tolua src/util

scheusso at orxonox.net scheusso at orxonox.net
Mon May 25 15:07:31 CEST 2009


Author: scheusso
Date: 2009-05-25 15:07:31 +0200 (Mon, 25 May 2009)
New Revision: 3060

Added:
   trunk/src/orxonox/sound/
   trunk/src/orxonox/sound/CMakeLists.txt
   trunk/src/orxonox/sound/SoundBase.cc
   trunk/src/orxonox/sound/SoundBase.h
   trunk/src/orxonox/sound/SoundMainMenu.cc
   trunk/src/orxonox/sound/SoundMainMenu.h
   trunk/src/orxonox/sound/SoundManager.cc
   trunk/src/orxonox/sound/SoundManager.h
Removed:
   trunk/src/audio/
Modified:
   trunk/
   trunk/bin/client1.bat.in
   trunk/bin/client2.bat.in
   trunk/bin/dedicated.bat.in
   trunk/bin/run.bat.in
   trunk/bin/server.bat.in
   trunk/bin/standalone.bat.in
   trunk/cmake/FindDirectX.cmake
   trunk/cmake/LibraryConfigTardis.cmake
   trunk/src/CMakeLists.txt
   trunk/src/core/LuaBind.cc
   trunk/src/core/LuaBind.h
   trunk/src/core/Template.cc
   trunk/src/core/Template.h
   trunk/src/core/XMLFile.h
   trunk/src/core/XMLIncludes.h
   trunk/src/cpptcl/cpptcl.cc
   trunk/src/cpptcl/cpptcl.h
   trunk/src/network/synchronisable/NetworkCallback.h
   trunk/src/network/synchronisable/Synchronisable.cc
   trunk/src/network/synchronisable/Synchronisable.h
   trunk/src/orxonox/CMakeLists.txt
   trunk/src/orxonox/CameraManager.cc
   trunk/src/orxonox/CameraManager.h
   trunk/src/orxonox/OrxonoxPrereqs.h
   trunk/src/orxonox/gamestates/GSMainMenu.cc
   trunk/src/orxonox/gamestates/GSMainMenu.h
   trunk/src/orxonox/objects/Level.cc
   trunk/src/orxonox/objects/Level.h
   trunk/src/orxonox/objects/collisionshapes/
   trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc
   trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h
   trunk/src/orxonox/objects/items/Engine.cc
   trunk/src/orxonox/objects/items/Engine.h
   trunk/src/orxonox/objects/pickup/Usable.h
   trunk/src/orxonox/objects/quest/AddQuest.cc
   trunk/src/orxonox/objects/quest/AddQuest.h
   trunk/src/orxonox/objects/quest/AddQuestHint.cc
   trunk/src/orxonox/objects/quest/AddQuestHint.h
   trunk/src/orxonox/objects/quest/AddReward.cc
   trunk/src/orxonox/objects/quest/AddReward.h
   trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc
   trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
   trunk/src/orxonox/objects/quest/CompleteQuest.cc
   trunk/src/orxonox/objects/quest/CompleteQuest.h
   trunk/src/orxonox/objects/quest/FailQuest.cc
   trunk/src/orxonox/objects/quest/FailQuest.h
   trunk/src/orxonox/objects/quest/GlobalQuest.cc
   trunk/src/orxonox/objects/quest/GlobalQuest.h
   trunk/src/orxonox/objects/quest/LocalQuest.cc
   trunk/src/orxonox/objects/quest/LocalQuest.h
   trunk/src/orxonox/objects/quest/Quest.cc
   trunk/src/orxonox/objects/quest/Quest.h
   trunk/src/orxonox/objects/quest/QuestDescription.cc
   trunk/src/orxonox/objects/quest/QuestDescription.h
   trunk/src/orxonox/objects/quest/QuestEffect.cc
   trunk/src/orxonox/objects/quest/QuestEffect.h
   trunk/src/orxonox/objects/quest/QuestHint.cc
   trunk/src/orxonox/objects/quest/QuestHint.h
   trunk/src/orxonox/objects/quest/QuestItem.cc
   trunk/src/orxonox/objects/quest/QuestItem.h
   trunk/src/orxonox/objects/quest/QuestManager.cc
   trunk/src/orxonox/objects/quest/QuestManager.h
   trunk/src/orxonox/objects/quest/Rewardable.cc
   trunk/src/orxonox/objects/quest/Rewardable.h
   trunk/src/orxonox/objects/worldentities/Backlight.cc
   trunk/src/orxonox/objects/worldentities/Backlight.h
   trunk/src/orxonox/objects/worldentities/Camera.cc
   trunk/src/orxonox/objects/worldentities/Camera.h
   trunk/src/orxonox/objects/worldentities/MobileEntity.cc
   trunk/src/orxonox/objects/worldentities/MobileEntity.h
   trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc
   trunk/src/orxonox/objects/worldentities/ParticleSpawner.h
   trunk/src/orxonox/objects/worldentities/StaticEntity.cc
   trunk/src/orxonox/objects/worldentities/StaticEntity.h
   trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
   trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
   trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
   trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
   trunk/src/tolua/all-5.0.lua
   trunk/src/tolua/all-5.1.lua
   trunk/src/util/
   trunk/src/util/Exception.cc
   trunk/src/util/Exception.h
   trunk/src/util/SignalHandler.cc
   trunk/src/util/SignalHandler.h
Log:
merged sound2 back to trunk



Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128
/branches/pickups2:2108-2498
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891
   + /branches/buildsystem:1875-2277,2279-2401
/branches/buildsystem2:2507-2659
/branches/buildsystem3:2663-2709
/branches/ceguilua:1803-1809
/branches/core3:1573-1740
/branches/gametypes:2827-3032
/branches/gcc43:1581
/branches/gui:1636-1724,2796-2895
/branches/input:1630-1637
/branches/lodfinal:2373-2412
/branches/miniprojects:2755-2825
/branches/network:2357
/branches/network64:2211-2356
/branches/objecthierarchy:1912-2086,2101,2111-2170
/branches/objecthierarchy2:2172-2480
/branches/overlay:2118-2386
/branches/physics:1913-2056,2108-2440
/branches/physics_merge:2437-2458
/branches/pickups:1927-2087,2128
/branches/pickups2:2108-2498
/branches/presentation:2370-2653,2655-2661
/branches/questsystem:1895-2089
/branches/questsystem2:2108-2260
/branches/questsystem5:2777-2906
/branches/script_trigger:1296-1954,1956
/branches/sound:2830-3011
/branches/weapon:1926-2095
/branches/weapon2:2108-2489
/branches/weapons:2898-3052
/branches/weaponsystem:2743-2891


Property changes on: trunk/bin/client1.bat.in
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/bin/client1.bat.in:2830-3011


Property changes on: trunk/bin/client2.bat.in
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/bin/client2.bat.in:2830-3011


Property changes on: trunk/bin/dedicated.bat.in
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/bin/dedicated.bat.in:2830-3011


Property changes on: trunk/bin/run.bat.in
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/bin/run.bat.in:2830-3011


Property changes on: trunk/bin/server.bat.in
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/bin/server.bat.in:2830-3011


Property changes on: trunk/bin/standalone.bat.in
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/bin/standalone.bat.in:2830-3011


Property changes on: trunk/cmake/FindDirectX.cmake
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/cmake/FindDirectX.cmake:2830-3011


Property changes on: trunk/cmake/LibraryConfigTardis.cmake
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/cmake/LibraryConfigTardis.cmake:2830-3011

Modified: trunk/src/CMakeLists.txt
===================================================================
--- trunk/src/CMakeLists.txt	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/CMakeLists.txt	2009-05-25 13:07:31 UTC (rev 3060)
@@ -140,7 +140,6 @@
 # Orxonox code
 ADD_SUBDIRECTORY(util)
 ADD_SUBDIRECTORY(core)
-#ADD_SUBDIRECTORY(audio)
 ADD_SUBDIRECTORY(network)
 ADD_SUBDIRECTORY(orxonox)
 


Property changes on: trunk/src/core/LuaBind.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/core/LuaBind.cc:2830-3011


Property changes on: trunk/src/core/LuaBind.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/core/LuaBind.h:2830-3011


Property changes on: trunk/src/core/Template.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/core/Template.cc:2830-3011


Property changes on: trunk/src/core/Template.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/core/Template.h:2830-3011


Property changes on: trunk/src/core/XMLFile.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/core/XMLFile.h:2830-3011


Property changes on: trunk/src/core/XMLIncludes.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/core/XMLIncludes.h:2830-3011


Property changes on: trunk/src/cpptcl/cpptcl.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/cpptcl/cpptcl.cc:2830-3011


Property changes on: trunk/src/cpptcl/cpptcl.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/cpptcl/cpptcl.h:2830-3011


Property changes on: trunk/src/network/synchronisable/NetworkCallback.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/network/synchronisable/NetworkCallback.h:2830-3011


Property changes on: trunk/src/network/synchronisable/Synchronisable.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/network/synchronisable/Synchronisable.cc:2830-3011


Property changes on: trunk/src/network/synchronisable/Synchronisable.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/network/synchronisable/Synchronisable.h:2830-3011

Modified: trunk/src/orxonox/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/CMakeLists.txt	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/CMakeLists.txt	2009-05-25 13:07:31 UTC (rev 3060)
@@ -30,6 +30,7 @@
 ADD_SUBDIRECTORY(objects)
 ADD_SUBDIRECTORY(overlays)
 ADD_SUBDIRECTORY(tools)
+ADD_SUBDIRECTORY(sound)
 GET_ALL_HEADER_FILES(ORXONOX_HDR_FILES)
 SET(ORXONOX_FILES ${ORXONOX_SRC_FILES} ${ORXONOX_HDR_FILES})
 
@@ -50,6 +51,11 @@
   ${LUA_LIBRARIES}
   ${CEGUILUA_LIBRARY}
   ${Boost_SYSTEM_LIBRARY}
+  ${OPENAL_LIBRARY}
+  ${ALUT_LIBRARY}
+  ${VORBISFILE_LIBRARY}
+  ${VORBIS_LIBRARY}
+  ${OGG_LIBRARY}
   ogreceguirenderer_orxonox
   tinyxml++_orxonox
   tolua++_orxonox
@@ -57,7 +63,6 @@
   util
   core
   network
-  #audio
 )
 
 ORXONOX_INSTALL(orxonox)


Property changes on: trunk/src/orxonox/CameraManager.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/CameraManager.cc:2830-3011

Modified: trunk/src/orxonox/CameraManager.h
===================================================================
--- trunk/src/orxonox/CameraManager.h	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/CameraManager.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -55,6 +55,7 @@
             void releaseFocus(Camera* camera);
 
             static CameraManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+            static CameraManager* getInstancePtr() { return singletonRef_s; }
 
             void useCamera(Ogre::Camera* camera);
 


Property changes on: trunk/src/orxonox/CameraManager.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/CameraManager.h:2830-3011

Modified: trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- trunk/src/orxonox/OrxonoxPrereqs.h	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/OrxonoxPrereqs.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -254,6 +254,11 @@
 
     //gui
     class GUIManager;
+
+    //sound
+    class SoundBase;
+    class SoundManager;
+    class SoundMainMenu;
 }
 
 namespace Ogre

Modified: trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- trunk/src/orxonox/gamestates/GSMainMenu.cc	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/gamestates/GSMainMenu.cc	2009-05-25 13:07:31 UTC (rev 3060)
@@ -39,6 +39,7 @@
 #include "gui/GUIManager.h"
 #include "objects/Scene.h"
 #include "GraphicsManager.h"
+#include "sound/SoundMainMenu.h"
 
 namespace orxonox
 {
@@ -78,10 +79,15 @@
         }
 
         InputManager::getInstance().requestEnterState("mainMenu");
+
+        this->ambient_ = new SoundMainMenu();
+        this->ambient_->play(true);
     }
 
     void GSMainMenu::deactivate()
     {
+        delete this->ambient_;
+
         InputManager::getInstance().requestLeaveState("mainMenu");
         InputManager::getInstance().requestDestroyState("mainMenu");
 

Modified: trunk/src/orxonox/gamestates/GSMainMenu.h
===================================================================
--- trunk/src/orxonox/gamestates/GSMainMenu.h	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/gamestates/GSMainMenu.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -54,6 +54,9 @@
 
         // console commands
         ConsoleCommand* ccStartGame_;
+
+        // ambient sound for the main menu
+        SoundMainMenu* ambient_;
     };
 }
 

Modified: trunk/src/orxonox/objects/Level.cc
===================================================================
--- trunk/src/orxonox/objects/Level.cc	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/objects/Level.cc	2009-05-25 13:07:31 UTC (rev 3060)
@@ -40,6 +40,7 @@
 #include "objects/infos/PlayerInfo.h"
 #include "objects/gametypes/Gametype.h"
 #include "overlays/OverlayGroup.h"
+#include "sound/SoundBase.h"
 
 #include "util/Math.h"
 
@@ -67,6 +68,9 @@
 
             if (this->xmlfile_)
                 Loader::unload(this->xmlfile_);
+
+            if(this->ambientsound_ != NULL)
+                delete this->ambientsound_;
         }
     }
 
@@ -77,6 +81,8 @@
         XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
         XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
 
+        XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);
+
         XMLPortObjectExtended(Level, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
     }
 
@@ -147,6 +153,21 @@
         return 0;
     }
 
+    void Level::loadAmbientSound(const std::string& filename)
+    {
+        if(filename == "") return;
+        else
+        {
+            if(this->ambientsound_ == NULL)
+            {
+                this->ambientsound_ = new SoundBase();
+            }
+
+            this->ambientsound_->loadFile(filename);
+            this->ambientsound_->play(true);
+        }
+    }
+
     void Level::playerEntered(PlayerInfo* player)
     {
         COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;


Property changes on: trunk/src/orxonox/objects/Level.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/Level.cc:2830-3011

Modified: trunk/src/orxonox/objects/Level.h
===================================================================
--- trunk/src/orxonox/objects/Level.h	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/objects/Level.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -50,6 +50,8 @@
             inline const std::string& getDescription() const
                 { return this->description_; }
 
+            void loadAmbientSound(const std::string& filename);
+
             void playerEntered(PlayerInfo* player);
             void playerLeft(PlayerInfo* player);
 
@@ -68,6 +70,8 @@
             std::string            xmlfilename_;
             XMLFile*               xmlfile_;
             std::list<BaseObject*> objects_;
+
+            SoundBase*             ambientsound_;
     };
 }
 


Property changes on: trunk/src/orxonox/objects/Level.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/Level.h:2830-3011


Property changes on: trunk/src/orxonox/objects/collisionshapes
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/collisionshapes:2830-3011


Property changes on: trunk/src/orxonox/objects/gametypes/TeamDeathmatch.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/gametypes/TeamDeathmatch.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/gametypes/TeamDeathmatch.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/gametypes/TeamDeathmatch.h:2830-3011

Modified: trunk/src/orxonox/objects/items/Engine.cc
===================================================================
--- trunk/src/orxonox/objects/items/Engine.cc	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/objects/items/Engine.cc	2009-05-25 13:07:31 UTC (rev 3060)
@@ -35,6 +35,7 @@
 #include "objects/Scene.h"
 #include "objects/worldentities/pawns/SpaceShip.h"
 #include "tools/Shader.h"
+#include "sound/SoundBase.h"
 
 namespace orxonox
 {
@@ -65,6 +66,8 @@
 
         this->setConfigValues();
         this->registerVariables();
+
+        this->sound_ = NULL;
     }
 
     Engine::~Engine()
@@ -75,6 +78,9 @@
 
             if (this->boostBlur_)
                 delete this->boostBlur_;
+
+            if(this->sound_ != NULL)
+                delete this->sound_;
         }
     }
 
@@ -94,6 +100,8 @@
         XMLPortParam(Engine, "accelerationback",      setAccelerationBack,      setAccelerationBack,      xmlelement, mode);
         XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
         XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
+
+        XMLPortParamLoadOnly(Engine, "sound", loadSound, xmlelement, mode);
     }
 
     void Engine::setConfigValues()
@@ -218,6 +226,7 @@
     void Engine::addToSpaceShip(SpaceShip* ship)
     {
         this->ship_ = ship;
+
         if (ship)
         {
             this->shipID_ = ship->getObjectID();
@@ -229,6 +238,9 @@
                 delete this->boostBlur_;
                 this->boostBlur_ = 0;
             }
+
+            if(this->sound_ != NULL)
+                this->sound_->attachToEntity(ship);
         }
     }
 
@@ -239,4 +251,19 @@
         else
             return Vector3::ZERO;
     }
+
+    void Engine::loadSound(const std::string filename)
+    {
+        if(filename == "") return;
+        else
+        {
+            if(this->sound_ == NULL)
+            {
+                this->sound_ = new SoundBase(this->ship_);
+            }
+
+            this->sound_->loadFile(filename);
+            this->sound_->play(true);
+        }
+    }
 }

Modified: trunk/src/orxonox/objects/items/Engine.h
===================================================================
--- trunk/src/orxonox/objects/items/Engine.h	2009-05-25 13:01:08 UTC (rev 3059)
+++ trunk/src/orxonox/objects/items/Engine.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -106,6 +106,8 @@
 
             virtual const Vector3& getDirection() const;
 
+            void loadSound(const std::string filename);
+
         private:
             void networkcallback_shipID();
 
@@ -128,6 +130,8 @@
 
             Shader* boostBlur_;
             float blurStrength_;
+
+            SoundBase* sound_;
     };
 }
 


Property changes on: trunk/src/orxonox/objects/pickup/Usable.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/pickup/Usable.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/AddQuest.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/AddQuest.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/AddQuest.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/AddQuest.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/AddQuestHint.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/AddQuestHint.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/AddQuestHint.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/AddQuestHint.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/AddReward.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/AddReward.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/AddReward.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/AddReward.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/ChangeQuestStatus.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/ChangeQuestStatus.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/CompleteQuest.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/CompleteQuest.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/CompleteQuest.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/CompleteQuest.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/FailQuest.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/FailQuest.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/FailQuest.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/FailQuest.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/GlobalQuest.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/GlobalQuest.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/GlobalQuest.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/GlobalQuest.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/LocalQuest.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/LocalQuest.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/LocalQuest.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/LocalQuest.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/Quest.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/Quest.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/Quest.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/Quest.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestDescription.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestDescription.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestDescription.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestDescription.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestEffect.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestEffect.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestEffect.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestEffect.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestHint.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestHint.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestHint.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestHint.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestItem.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestItem.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestItem.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestItem.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestManager.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestManager.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/QuestManager.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/QuestManager.h:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/Rewardable.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/Rewardable.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/quest/Rewardable.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/quest/Rewardable.h:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/Backlight.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/Backlight.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/Backlight.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/Backlight.h:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/Camera.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/Camera.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/Camera.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/Camera.h:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/MobileEntity.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/MobileEntity.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/MobileEntity.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/MobileEntity.h:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/ParticleSpawner.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/ParticleSpawner.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/ParticleSpawner.h:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/StaticEntity.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/StaticEntity.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/StaticEntity.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/StaticEntity.h:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/triggers/Trigger.cc:2830-3011


Property changes on: trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/orxonox/objects/worldentities/triggers/Trigger.h:2830-3011

Added: trunk/src/orxonox/sound/CMakeLists.txt
===================================================================
--- trunk/src/orxonox/sound/CMakeLists.txt	                        (rev 0)
+++ trunk/src/orxonox/sound/CMakeLists.txt	2009-05-25 13:07:31 UTC (rev 3060)
@@ -0,0 +1,10 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+    SoundManager.h
+    SoundBase.h
+    SoundMainMenu.h
+
+    SoundManager.cc
+    SoundBase.cc
+    SoundMainMenu.cc
+)
+

Added: trunk/src/orxonox/sound/SoundBase.cc
===================================================================
--- trunk/src/orxonox/sound/SoundBase.cc	                        (rev 0)
+++ trunk/src/orxonox/sound/SoundBase.cc	2009-05-25 13:07:31 UTC (rev 3060)
@@ -0,0 +1,216 @@
+/*
+ *   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:
+ *       Erwin 'vaiursch' Herrsche
+ *   Co-authors:
+ *      ...
+ *
+ */
+#include <vector>
+#include <AL/alut.h>
+#include <vorbis/vorbisfile.h>
+
+#include "orxonox/objects/worldentities/WorldEntity.h"
+#include "util/Math.h"
+#include "SoundBase.h"
+#include "SoundManager.h"
+#include "core/Core.h"
+
+namespace orxonox 
+{
+    SoundManager* SoundBase::soundmanager_s = NULL;
+
+    SoundBase::SoundBase(WorldEntity* entity)
+    {
+        if(SoundBase::soundmanager_s == NULL)
+        {
+            SoundBase::soundmanager_s = new SoundManager();
+        }
+
+        this->source_ = 0;
+        this->buffer_ = 0;
+        this->entity_ = entity;
+
+        SoundBase::soundmanager_s->addSound(this);
+    }
+
+    SoundBase::~SoundBase()
+    {
+        alSourcei(this->source_, AL_BUFFER, 0);
+        alDeleteSources(1, &this->source_);
+        alDeleteBuffers(1, &this->buffer_);
+    }
+
+    void SoundBase::attachToEntity(WorldEntity* entity)
+    {
+        this->entity_ = entity;
+        this->update();
+    }
+
+    void SoundBase::update() {
+        if(this->entity_ != NULL && alIsSource(this->source_)) {
+            Vector3 pos = this->entity_->getPosition();
+            alSource3f(this->source_, AL_POSITION, pos.x, pos.y, pos.z);
+            ALenum error = alGetError();
+            if(error == AL_INVALID_VALUE)
+                COUT(2) << "Sound: OpenAL: Invalid sound position" << std::endl;
+
+            Vector3 vel = this->entity_->getVelocity();
+            alSource3f(this->source_, AL_VELOCITY, vel.x, vel.y, vel.z);
+            error = alGetError();
+            if(error == AL_INVALID_VALUE)
+                COUT(2) << "Sound: OpenAL: Invalid sound velocity" << std::endl;
+
+            Quaternion orient = this->entity_->getOrientation();
+            Vector3 at = orient.zAxis();
+            alSource3f(this->source_, AL_DIRECTION, at.x, at.y, at.z);
+            error = alGetError();
+            if(error == AL_INVALID_VALUE)
+                COUT(2) << "Sound: OpenAL: Invalid sound direction" << std::endl;
+        }
+    }
+
+    void SoundBase::play(bool loop) {
+        if(alIsSource(this->source_)) {
+            if(loop)
+                alSourcei(this->source_, AL_LOOPING, AL_TRUE);
+            else
+                alSourcei(this->source_, AL_LOOPING, AL_FALSE);
+            alSourcePlay(this->source_);
+        }
+    }
+
+    void SoundBase::stop() {
+        if(alIsSource(this->source_)) {
+            alSourceStop(this->source_);
+        }
+    }
+
+    void SoundBase::pause() {
+        if(alIsSource(this->source_)) {
+            alSourcePause(this->source_);
+        }
+    }
+
+    bool SoundBase::isPlaying() {
+        if(alIsSource(this->source_)) {
+            return getSourceState() == AL_PLAYING;
+        }
+        return false;
+    }
+
+    bool SoundBase::isPaused() {
+        if(alIsSource(this->source_)) {
+            return getSourceState() == AL_PAUSED;
+        }
+        return true;
+    }
+
+    bool SoundBase::isStopped() {
+        if(alIsSource(this->source_)) {
+            return getSourceState() == AL_INITIAL || getSourceState() == AL_STOPPED;
+        }
+        return true;
+    }
+
+    bool SoundBase::loadFile(std::string filename) {
+        filename = Core::getMediaPathString() + "/audio/" + filename;
+
+        if(!SoundBase::soundmanager_s->isSoundAvailable())
+        {
+            COUT(3) << "Sound: not available, skipping " << filename << std::endl;
+            return false;
+        }
+
+        COUT(3) << "Sound: OpenAL ALUT: loading file " << filename << std::endl;
+        this->buffer_ = alutCreateBufferFromFile(filename.c_str());
+        if(this->buffer_ == AL_NONE) {
+            COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
+            if(filename.find("ogg", 0) != std::string::npos)
+            {
+                COUT(2) << "Sound: Trying fallback ogg loader" << std::endl;
+                this->buffer_ = loadOggFile(filename);
+            }
+
+            if(this->buffer_ == AL_NONE)
+            {
+                COUT(2) << "Sound: fallback ogg loader failed: " << alutGetErrorString(alutGetError()) << std::endl;
+                return false;
+            }
+        }
+
+        alGenSources(1, &this->source_);
+        alSourcei(this->source_, AL_BUFFER, this->buffer_);
+        if(alGetError() != AL_NO_ERROR) {
+            COUT(2) << "Sound: OpenAL: Error loading sample file: " << filename << std::endl;
+            return false;
+        }
+        return true;
+    }
+
+    ALint SoundBase::getSourceState() {
+        ALint state;
+        alGetSourcei(this->source_, AL_SOURCE_STATE, &state);
+        return state;
+    }
+
+    ALuint SoundBase::loadOggFile(std::string filename)
+    {
+        char inbuffer[4096];
+        std::vector<char> outbuffer;
+        OggVorbis_File vf;
+        int eof = false;
+        int current_section;
+
+        FILE* f = fopen(filename.c_str(), "rb");
+
+        if(ov_open(f, &vf, NULL, 0) < 0)
+        {
+            COUT(2) << "Sound: libvorbisfile: File seems not to be an Ogg Vorbis bitstream" << std::endl;
+            ov_clear(&vf);
+            return AL_NONE;
+        }
+
+        while(!eof)
+        {
+            long ret = ov_read(&vf, inbuffer, sizeof(inbuffer), 0, 2, 1, &current_section);
+            if (ret == 0)
+            {
+                eof = true;
+            }
+            else if (ret < 0)
+            {
+                COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+                ov_clear(&vf);
+                return AL_NONE;
+            }
+            else
+            {
+                outbuffer.insert(outbuffer.end(), inbuffer, inbuffer + sizeof(inbuffer));
+            }
+        }
+
+        ov_clear(&vf);
+
+        return alutCreateBufferFromFileImage(&outbuffer, outbuffer.size());
+    }
+} // namespace: orxonox

Added: trunk/src/orxonox/sound/SoundBase.h
===================================================================
--- trunk/src/orxonox/sound/SoundBase.h	                        (rev 0)
+++ trunk/src/orxonox/sound/SoundBase.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -0,0 +1,73 @@
+/*
+ *   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:
+ *       Erwin 'vaiursch' Herrsche
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef _SOUNDBASE_H__
+#define _SOUNDBASE_H__
+
+#include <AL/al.h>
+#include <string>
+
+#include "OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+    /**
+     * The SoudBase class is the base class for all sound file loader classes.
+     * It server as main interface to the OpenAL library.
+     *
+     */
+    class _OrxonoxExport SoundBase
+    {
+    public:
+        SoundBase(WorldEntity* entity = NULL);
+        ~SoundBase();
+
+        void attachToEntity(WorldEntity* entity);
+        void update();
+        void play(bool loop = false);
+        void stop();
+        void pause();
+
+        bool isPlaying();
+        bool isPaused();
+        bool isStopped();
+
+        bool loadFile(std::string filename);
+
+    private:
+        ALuint loadOggFile(std::string filename);
+        ALuint source_;
+        ALuint buffer_;
+        WorldEntity* entity_;
+
+        ALint getSourceState();
+
+        static SoundManager* soundmanager_s;
+    }; // class SoundBase
+} // namepsace orxonox
+
+#endif // _SOUNDBASE_H__

Added: trunk/src/orxonox/sound/SoundMainMenu.cc
===================================================================
--- trunk/src/orxonox/sound/SoundMainMenu.cc	                        (rev 0)
+++ trunk/src/orxonox/sound/SoundMainMenu.cc	2009-05-25 13:07:31 UTC (rev 3060)
@@ -0,0 +1,46 @@
+/*
+ *   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:
+ *       Erwin 'vaiursch' Herrsche
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "SoundMainMenu.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    SoundMainMenu::SoundMainMenu()
+    {
+        RegisterObject(SoundMainMenu);
+        setConfigValues();
+        loadFile(this->filename_);
+    }
+
+    void SoundMainMenu::setConfigValues()
+    {
+        SetConfigValue(filename_, "ambient/mainmenu.wav");
+    }
+}

Added: trunk/src/orxonox/sound/SoundMainMenu.h
===================================================================
--- trunk/src/orxonox/sound/SoundMainMenu.h	                        (rev 0)
+++ trunk/src/orxonox/sound/SoundMainMenu.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -0,0 +1,50 @@
+/*
+ *   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:
+ *       Erwin 'vaiursch' Herrsche
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _SOUNDMAINMENU_H__
+#define _SOUNDMAINMENU_H__
+
+#include <string>
+
+#include "core/OrxonoxClass.h"
+#include "OrxonoxPrereqs.h"
+#include "SoundBase.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport SoundMainMenu : public SoundBase, public virtual OrxonoxClass
+    {
+        public:
+            SoundMainMenu();
+            void setConfigValues();
+
+        private:
+            std::string filename_;
+    };
+}
+#endif

Added: trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- trunk/src/orxonox/sound/SoundManager.cc	                        (rev 0)
+++ trunk/src/orxonox/sound/SoundManager.cc	2009-05-25 13:07:31 UTC (rev 3060)
@@ -0,0 +1,163 @@
+/*
+ *   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:
+ *       Erwin 'vaiursch' Herrsche
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <AL/alut.h>
+
+#include "orxonox/CameraManager.h"
+#include "orxonox/objects/worldentities/Camera.h"
+#include "util/Math.h"
+#include "SoundBase.h"
+#include "SoundManager.h"
+
+namespace orxonox
+{
+    ALCdevice* SoundManager::device_s = NULL;
+
+    /**
+     * Default constructor
+     */
+    SoundManager::SoundManager()
+    {
+        this->soundavailable_ = true;
+        if(!alutInitWithoutContext(NULL,NULL))
+        {
+            COUT(2) << "Sound: OpenAL ALUT: " << alutGetErrorString(alutGetError()) << std::endl;
+            this->soundavailable_ = false;
+        }
+        else
+        {
+            COUT(4) << "Sound: OpenAL ALUT version: " << alutGetMajorVersion() << "." << alutGetMinorVersion() << std::endl;
+            COUT(4) << "Sound: OpenAL ALUT supported MIME types: " << alutGetMIMETypes(ALUT_LOADER_BUFFER) << std::endl;
+            if(SoundManager::device_s == NULL)
+            {
+                COUT(3) << "Sound: OpenAL: Open sound device..." << std::endl;
+                SoundManager::device_s = alcOpenDevice(NULL);
+            }
+
+            if(SoundManager::device_s == NULL)
+            {
+                COUT(2) << "Sound: OpenAL: Could not open sound device" << std::endl;
+                this->soundavailable_ = false;
+            }
+            else
+            {
+                COUT(3) << "Sound: OpenAL: Sound device opened" << std::endl;
+                this->context_ = alcCreateContext(SoundManager::device_s, NULL);
+                if(this->context_ == NULL)
+                {
+                    COUT(2) << "Sound: OpenAL: Could not create sound context" << std::endl;
+                    this->soundavailable_ = false;
+                }
+                else
+                {
+                    if(alcMakeContextCurrent(this->context_) == AL_TRUE)
+                        COUT(3) << "Sound: OpenAL: Context " << this->context_ << " loaded" << std::endl;
+                }
+            }
+        }
+    }
+
+    SoundManager::~SoundManager()
+    {
+        alcDestroyContext(this->context_);
+        alcCloseDevice(SoundManager::device_s);
+        alutExit();
+    }
+
+    /**
+     * Add a SoundBase object to the list. Every SoundBase object should be in
+     * this list.
+     *
+     * @param sound Pointer to the SoundBase object to add
+     */
+    void SoundManager::addSound(SoundBase* sound)
+    {
+        this->soundlist_.push_back(sound);
+    }
+
+    /**
+     * Remove a SoundBase object from the list and destroy it.
+     */
+    void SoundManager::removeSound(SoundBase* sound)
+    {
+        std::list<SoundBase*>::iterator pos = this->soundlist_.end();
+        for(std::list<SoundBase*>::iterator i = this->soundlist_.begin(); i != this->soundlist_.end(); i++)
+        {
+            if((*i) == sound)
+                pos = i;
+        }
+
+        delete (*pos);
+        this->soundlist_.erase(pos);
+    }
+
+    /**
+     * Tick function, updates listener and registred SoundBase objects
+     *
+     * @param dt @see Orxonox::Tickable
+     */
+    void SoundManager::tick(float dt)
+    {
+        if (!CameraManager::getInstancePtr())
+            return;
+
+        // update listener position
+        Camera* camera = CameraManager::getInstance().getActiveCamera();
+        if(camera == NULL) return;
+        Vector3 pos = camera->getPosition();
+        alListener3f(AL_POSITION, pos.x, pos.y, pos.z);
+        ALenum error = alGetError();
+        if(error == AL_INVALID_VALUE)
+            COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl;
+
+        // update listener orientation
+        Quaternion orient = camera->getOrientation();
+        Vector3 up = orient.xAxis(); // just a wild guess
+        Vector3 at = orient.zAxis();
+
+        ALfloat orientation[6] = { at.x, at.y, at.z, 
+                                 up.x, up.y, up.z };
+
+        alListenerfv(AL_POSITION, orientation);
+        error = alGetError();
+        if(error == AL_INVALID_VALUE)
+            COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl;
+
+        // update sounds
+        for(std::list<SoundBase*>::iterator i = this->soundlist_.begin(); i != this->soundlist_.end(); i++)
+            (*i)->update();
+    }
+    
+    /**
+    * Check if sound is available
+    */
+    bool SoundManager::isSoundAvailable()
+    {
+        return this->soundavailable_;
+    }
+}

Added: trunk/src/orxonox/sound/SoundManager.h
===================================================================
--- trunk/src/orxonox/sound/SoundManager.h	                        (rev 0)
+++ trunk/src/orxonox/sound/SoundManager.h	2009-05-25 13:07:31 UTC (rev 3060)
@@ -0,0 +1,63 @@
+/*
+ *   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:
+ *       Erwin 'vaiursch' Herrsche
+ *   Co-authors:
+ *      ...
+ */
+#ifndef _SOUNDMANGER_H__
+#define _SOUNDMANGER_H__
+
+#include <AL/al.h>
+#include <AL/alc.h>
+
+#include "OrxonoxPrereqs.h"
+#include "orxonox/objects/Tickable.h"
+
+namespace orxonox
+{
+    /**
+     * The SoundManager class manages the OpenAL device, context and listener
+     * position. It has a list of all SoundBase objects and calls their update
+     * function every tick. It is a singleton.
+     *
+     */
+    class _OrxonoxExport SoundManager : public Tickable 
+    {
+    public:
+        SoundManager();
+        ~SoundManager();
+        void addSound(SoundBase* sound);
+        void removeSound(SoundBase* sound);
+        virtual void tick(float dt);
+        bool isSoundAvailable();
+
+    private:
+        static ALCdevice* device_s;
+        ALCcontext* context_;
+        std::list<SoundBase*> soundlist_;
+        bool soundavailable_;
+
+    }; // class SoundManager
+} // namespace orxonox
+
+#endif // _SOUNDMANAGER_H__


Property changes on: trunk/src/tolua/all-5.0.lua
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/tolua/all-5.0.lua:2830-3011


Property changes on: trunk/src/tolua/all-5.1.lua
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/tolua/all-5.1.lua:2830-3011


Property changes on: trunk/src/util
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/util:2830-3011


Property changes on: trunk/src/util/Exception.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/util/Exception.cc:2830-3011


Property changes on: trunk/src/util/Exception.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/util/Exception.h:2830-3011


Property changes on: trunk/src/util/SignalHandler.cc
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/util/SignalHandler.cc:2830-3011


Property changes on: trunk/src/util/SignalHandler.h
___________________________________________________________________
Added: svn:mergeinfo
   + /branches/sound/src/util/SignalHandler.h:2830-3011




More information about the Orxonox-commit mailing list