Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7854


Ignore:
Timestamp:
Feb 11, 2011, 1:03:47 PM (13 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
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/levels/presentationHS09b.oxw

    r7679 r7854  
    3535  >
    3636
    37     <AmbientSound ambientSource="Mars.ogg" looping="true" playOnLoad="true" />
     37    <WorldAmbientSound source="Mars.ogg" looping="true" playOnLoad="true" />
    3838
    3939   <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" />
     
    256256    <?lua end ?>
    257257
    258     <AmbientSound ambientSource="Earth.ogg" looping="true" playOnLoad="false">
     258    <WorldAmbientSound source="Earth.ogg" looping="true" playOnLoad="false">
    259259      <events>
    260260        <activity>
     
    262262        </activity>
    263263      </events>
    264     </AmbientSound>
     264    </WorldAmbientSound>
    265265
    266266    <SpawnPoint position="5000,0,2000" spawnclass=SpaceShip pawndesign=spaceshipassff  team=0 />
  • code/trunk/data/levels/presentationPong.oxw

    r7853 r7854  
    5151  </templates>
    5252
    53   <AmbientSound ambientSource="mainmenu.ogg" playOnLoad=true />
     53  <WorldAmbientSound source="mainmenu.ogg" playOnLoad=true />
    5454
    5555  <Scene
  • code/trunk/data/levels/sound.oxw

    r7679 r7854  
    2929  >
    3030
    31   <AmbientSound ambientSource="Earth.ogg" looping="true" playOnLoad="true" />
    32   <AmbientSound ambientSource="Mars.ogg" looping="true">
     31  <WorldAmbientSound source="Earth.ogg" looping="true" playOnLoad="true" />
     32  <WorldAmbientSound source="Mars.ogg" looping="true">
    3333    <events>
    3434      <activity>
     
    4040      </activity>
    4141    </events>
    42   </AmbientSound>
    43   <AmbientSound ambientSource="Jupiter.ogg" looping="true">
     42  </WorldAmbientSound>
     43  <WorldAmbientSound source="Jupiter.ogg" looping="true">
    4444    <events>
    4545      <activity>
     
    5151      </activity>
    5252    </events>
    53   </AmbientSound>
     53  </WorldAmbientSound>
    5454
    5555
  • 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.