Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2980 for code/branches


Ignore:
Timestamp:
May 18, 2009, 2:24:34 PM (16 years ago)
Author:
erwin
Message:

added config ability to sound, few other changes

Location:
code/branches/sound/src/orxonox
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/sound/src/orxonox/OrxonoxPrereqs.h

    r2826 r2980  
    257257    class GSServer;
    258258    class GSClient;
    259     class GSGUI;
     259    class GSGUI;
     260
     261    //sound
     262    class SoundBase;
     263    class SoundManger;
    260264}
    261265
  • code/branches/sound/src/orxonox/objects/Level.cc

    r2966 r2980  
    4141#include "objects/gametypes/Gametype.h"
    4242#include "overlays/OverlayGroup.h"
     43#include "sound/SoundBase.h"
    4344
    4445#include "util/Math.h"
     
    5758        if (this->xmlfilename_.length() >= Core::getMediaPathString().length())
    5859            this->xmlfilename_ = this->xmlfilename_.substr(Core::getMediaPathString().length());
    59            
    60         this->sndmgr_ = new SoundManager();
    6160    }
    6261
     
    7069            if (this->xmlfile_)
    7170                Loader::unload(this->xmlfile_);
    72            
     71
    7372            if(this->ambientsound_ != NULL)
    7473                delete this->ambientsound_;
    75            
    76             delete this->sndmgr_;
    7774        }
    7875    }
     
    8481        XMLPortParam(Level, "description", setDescription, getDescription, xmlelement, mode);
    8582        XMLPortParam(Level, "gametype", setGametypeString, getGametypeString, xmlelement, mode).defaultValues("Gametype");
    86        
     83
    8784        XMLPortParamLoadOnly(Level, "ambientsound", loadAmbientSound, xmlelement, mode);
    8885
     
    165162            {
    166163                this->ambientsound_ = new SoundBase();
    167                 this->sndmgr_->addSound(this->ambientsound_);
    168164            }
    169165
  • code/branches/sound/src/orxonox/objects/Level.h

    r2966 r2980  
    3333
    3434#include "network/synchronisable/Synchronisable.h"
    35 #include "sound/SoundBase.h"
    36 #include "sound/SoundManager.h"
    3735#include "core/BaseObject.h"
    3836
     
    7371            XMLFile*               xmlfile_;
    7472            std::list<BaseObject*> objects_;
    75             SoundManager*          sndmgr_;
     73
    7674            SoundBase*             ambientsound_;
    7775    };
  • code/branches/sound/src/orxonox/objects/items/Engine.cc

    r2662 r2980  
    3636#include "objects/worldentities/pawns/SpaceShip.h"
    3737#include "tools/Shader.h"
     38#include "sound/SoundBase.h"
    3839
    3940namespace orxonox
     
    9596        XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
    9697        XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
     98
     99        XMLPortParamLoadOnly(Engine, "sound", loadSound, xmlelement, mode);
    97100    }
    98101
     
    219222    {
    220223        this->ship_ = ship;
     224        this->sound_->attachToEntity(ship);
     225
    221226        if (ship)
    222227        {
     
    240245            return Vector3::ZERO;
    241246    }
     247
     248    void Engine::loadSound(const std::string filename)
     249    {
     250        if(filename == "") return;
     251        else
     252        {
     253            if(this->sound_ == NULL)
     254            {
     255                this->sound_ = new SoundBase(this->ship_);
     256            }
     257
     258            this->sound_->loadFile(filename);
     259            this->sound_->play(true);
     260        }
     261    }
    242262}
  • code/branches/sound/src/orxonox/objects/items/Engine.h

    r2662 r2980  
    107107            virtual const Vector3& getDirection() const;
    108108
     109            void loadSound(const std::string filename);
     110
    109111        private:
    110112            void networkcallback_shipID();
     
    129131            Shader* boostBlur_;
    130132            float blurStrength_;
     133
     134            SoundBase* sound_;
    131135    };
    132136}
  • code/branches/sound/src/orxonox/sound/SoundBase.cc

    r2968 r2980  
    3131#include "orxonox/objects/worldentities/WorldEntity.h"
    3232#include "util/Math.h"
     33#include "SoundBase.h"
    3334#include "SoundManager.h"
    34 #include "SoundBase.h"
    3535
    3636namespace orxonox
    3737{
    38     SoundBase::SoundBase()
    39     {
    40         this->source_ = 0;
    41         this->buffer_ = 0;
    42         this->entity_ = NULL;
    43     }
     38    SoundManager* SoundBase::soundmanager_s = NULL;
    4439
    4540    SoundBase::SoundBase(WorldEntity* entity)
    4641    {
     42        if(SoundBase::soundmanager_s == NULL)
     43        {
     44            SoundBase::soundmanager_s = new SoundManager();
     45        }
     46
    4747        this->source_ = 0;
    4848        this->buffer_ = 0;
    4949        this->entity_ = entity;
     50
     51        SoundBase::soundmanager_s->addSound(this);
    5052    }
    5153
  • code/branches/sound/src/orxonox/sound/SoundBase.h

    r2967 r2980  
    3636    class SoundManager;
    3737    class WorldEntity;
     38
    3839    /**
    3940     * The SoudBase class is the base class for all sound file loader classes.
     
    4445    {
    4546    public:
    46         SoundBase();
    47         SoundBase(WorldEntity* entity);
     47        SoundBase(WorldEntity* entity = NULL);
    4848        ~SoundBase();
    4949
     
    6767
    6868        ALint getSourceState();
     69
     70        static SoundManager* soundmanager_s;
    6971    }; // class SoundBase
    7072} // namepsace orxonox
  • code/branches/sound/src/orxonox/sound/SoundManager.cc

    r2966 r2980  
    5454            if(SoundManager::device_s == NULL)
    5555            {
    56                 COUT(3) << "OpenAL: open sound device..." << std::endl;
     56                COUT(3) << "OpenAL: Open sound device..." << std::endl;
    5757                SoundManager::device_s = alcOpenDevice(NULL);
    5858            }
     
    6464            else
    6565            {
     66                COUT(3) << "OpenAL: Sound device opened";
    6667                this->context_ = alcCreateContext(SoundManager::device_s, NULL);
    6768                if(this->context_ == NULL)
     
    7172                else
    7273                {
     74                    COUT(3) << "OpenAL: Context " << this->context_ << "loaded";
    7375                    alcMakeContextCurrent(this->context_);
    7476                }
Note: See TracChangeset for help on using the changeset viewer.