Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7854 for code/trunk/src


Ignore:
Timestamp:
Feb 11, 2011, 1:03:47 PM (14 years ago)
Author:
landauf
Message:

detached AmbientSound from BaseObject - AmbientSound can not be placed directly in a level file anymore
instead added WorldAmbientSound, a BaseObject which can be placed in a level file to create and control ambient sound

with this change, the level can be destroyed completely because WorldAmbientSound can be deleted immediately at the end of the level, while the AmbientSound remains active until it faded out.

Location:
code/trunk/src/orxonox
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r7655 r7854  
    151151    class SoundStreamer;
    152152    class WorldSound;
     153    class WorldAmbientSound;
    153154
    154155    // weaponsystem
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r7284 r7854  
    154154            if (find == this->staticObjects_.end())
    155155            {
    156                 COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << ')' << std::endl;
     156                COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << std::endl;
    157157            }
    158158        }
  • code/trunk/src/orxonox/gamestates/GSMainMenu.cc

    r7689 r7854  
    7777        {
    7878            // Load sound
    79             this->ambient_ = new AmbientSound(0);
    80             this->ambient_->setSyncMode(0x0);
     79            this->ambient_ = new AmbientSound();
    8180        }
    8281    }
  • code/trunk/src/orxonox/sound/AmbientSound.cc

    r6417 r7854  
    2929#include "AmbientSound.h"
    3030
    31 #include "core/CoreIncludes.h"
    32 #include "core/EventIncludes.h"
    3331#include "core/GameMode.h"
    3432#include "core/Resource.h"
    35 #include "core/XMLPort.h"
    3633#include "SoundManager.h"
    3734
    3835namespace orxonox
    3936{
    40     CreateFactory(AmbientSound);
    41 
    42     AmbientSound::AmbientSound(BaseObject* creator)
    43         : BaseObject(creator)
    44         , Synchronisable(creator)
    45         , bPlayOnLoad_(false)
     37    AmbientSound::AmbientSound()
     38        : bPlayOnLoad_(false)
    4639    {
    47         RegisterObject(AmbientSound);
    48 
    4940        // Ambient sounds always fade in
    5041        this->setVolume(0);
    51         this->registerVariables();
    5242    }
    5343
     
    5949            SoundManager::getInstance().unregisterAmbientSound(this);
    6050        }
    61     }
    62 
    63     void AmbientSound::registerVariables()
    64     {
    65         registerVariable(ambientSource_, ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::ambientSourceChanged));
    66         registerVariable(bLooping_,      ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::loopingChanged));
    67         registerVariable(pitch_,         ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::pitchChanged));
    68         registerVariable(bPlayOnLoad_,   ObjectDirection::ToClient, new NetworkCallback<AmbientSound>(this, &AmbientSound::playOnLoadChanged));
    69     }
    70 
    71     void AmbientSound::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    72     {
    73         SUPER(AmbientSound, XMLPort, xmlelement, mode);
    74         BaseSound::XMLPortExtern(xmlelement, mode);
    75         XMLPortParam(AmbientSound, "ambientSource", setAmbientSource, getAmbientSource, xmlelement, mode);
    76         XMLPortParam(AmbientSound, "playOnLoad", setPlayOnLoad, getPlayOnLoad, xmlelement, mode);
    77     }
    78 
    79     void AmbientSound::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    80     {
    81         SUPER(AmbientSound, XMLEventPort, xmlelement, mode);
    82         XMLPortEventState(AmbientSound, BaseObject, "play", play, xmlelement, mode);
    8351    }
    8452
     
    132100            this->play();
    133101    }
    134 
    135     void AmbientSound::changedActivity()
    136     {
    137         SUPER(AmbientSound, changedActivity);
    138         if (this->isActive())
    139             this->play();
    140         else
    141             this->stop();
    142     }
    143102}
  • code/trunk/src/orxonox/sound/AmbientSound.h

    r6417 r7854  
    3333#include "OrxonoxPrereqs.h"
    3434
    35 #include "core/BaseObject.h"
    36 #include "network/synchronisable/Synchronisable.h"
    3735#include "BaseSound.h"
    3836#include "MoodManager.h"
     
    4139{
    4240    /**
    43      * The AmbientSound class is the base class for all sound file loader classes.
    44      * It server as main interface to the OpenAL library.
    45      *
     41     * The AmbientSound class is used to play background music. It can not be placed
     42     * directly in a level file, use WorldAmbientSound instead.
    4643     */
    47     class _OrxonoxExport AmbientSound : public BaseSound, public BaseObject, public Synchronisable, public MoodListener
     44    class _OrxonoxExport AmbientSound : public BaseSound, public MoodListener
    4845    {
    4946        friend class SoundManager;
     47        friend class WorldAmbientSound;
    5048
    5149    public:
    52         AmbientSound(BaseObject* creator);
    53 
    54         void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    55         void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    56         void changedActivity();
     50        AmbientSound();
    5751
    5852        void play();
     
    7367    private:
    7468        void preDestroy();
    75         void registerVariables();
    7669        float getRealVolume();
    7770        void moodChanged(const std::string& mood);
  • code/trunk/src/orxonox/sound/BaseSound.h

    r7163 r7854  
    4141    /**
    4242     * The BaseSound class is the base class for all sound file loader classes.
    43      * It server as main interface to the OpenAL library.
    44      *
     43     * It serves as main interface to the OpenAL library.
    4544     */
    4645    class _OrxonoxExport BaseSound : virtual public OrxonoxClass
  • code/trunk/src/orxonox/sound/CMakeLists.txt

    r6417 r7854  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    2     AmbientSound.cc
    3     BaseSound.cc
    4     SoundBuffer.cc
    5     SoundManager.cc
    6     WorldSound.cc
    7     SoundStreamer.cc
     2  AmbientSound.cc
     3  BaseSound.cc
     4  SoundBuffer.cc
     5  SoundManager.cc
     6  SoundStreamer.cc
     7  WorldAmbientSound.cc
     8  WorldSound.cc
    89)
    910
  • code/trunk/src/orxonox/sound/WorldSound.h

    r6417 r7854  
    3838namespace orxonox
    3939{
    40     /*
     40    /**
    4141    @brief
    4242        The WorldSound class is to be used for sounds with position and orientation.
Note: See TracChangeset for help on using the changeset viewer.