Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 25, 2009, 10:23:58 PM (14 years ago)
Author:
rgrieder
Message:

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/weaponsystem/WeaponMode.cc

    r5929 r6417  
    3232#include "core/CoreIncludes.h"
    3333#include "core/XMLPort.h"
     34#include "controllers/Controller.h"
     35#include "worldentities/pawns/Pawn.h"
    3436
    3537#include "Munition.h"
     
    3739#include "WeaponPack.h"
    3840#include "WeaponSystem.h"
     41#include "WeaponSlot.h"
     42
     43#include "sound/WorldSound.h"
    3944
    4045namespace orxonox
     
    6166
    6267        this->damage_ = 0;
     68
    6369        this->muzzleOffset_ = Vector3::ZERO;
     70        this->muzzlePosition_ = Vector3::ZERO;
     71        this->muzzleOrientation_ = Quaternion::IDENTITY;
     72
     73        if( GameMode::isMaster() )
     74        {
     75            this->defSndWpnFire_ = new WorldSound(this);
     76            this->defSndWpnFire_->setLooping(false);
     77            this->bSoundAttached_ = false;
     78        }
     79        else
     80            this->defSndWpnFire_ = 0;
    6481    }
    6582
    6683    WeaponMode::~WeaponMode()
    6784    {
     85        if (this->isInitialized())
     86        {
     87            if (this->defSndWpnFire_)
     88                this->defSndWpnFire_->destroy();
     89        }
    6890    }
    6991
     
    90112    {
    91113        (*reloadTime) = this->reloadTime_;
     114        if( !this->bSoundAttached_ && GameMode::isMaster() )
     115        {
     116            assert(this->getWeapon());
     117            this->getWeapon()->attach(this->defSndWpnFire_);
     118            this->bSoundAttached_ = true;
     119        }
    92120
    93121        if (!this->bReloading_ && this->munition_ && this->munition_->takeMunition(this->munitionPerShot_, this))
     
    108136            this->reloadTimer_.startTimer();
    109137
     138            if( this->defSndWpnFire_ && !(this->defSndWpnFire_->isPlaying()))
     139            {
     140                this->defSndWpnFire_->play();
     141            }
     142
    110143            this->fire();
    111144
     
    145178    {
    146179        this->munitionname_ = munitionname;
    147         this->munitiontype_ = ClassByString(this->munitionname_);
     180        Identifier* identifier = ClassByString(this->munitionname_);
     181        if (identifier)
     182            this->munitiontype_ = identifier;
     183        else
     184            COUT(2) << "Warning: No munition class defined in WeaponMode " << this->getName() << std::endl;
    148185        this->updateMunition();
    149186    }
     
    191228    void WeaponMode::reloaded()
    192229    {
     230        if( this->defSndWpnFire_ && this->defSndWpnFire_->isPlaying())
     231        {
     232            this->defSndWpnFire_->stop();
     233        }
    193234        this->bReloading_ = false;
    194235    }
    195236
    196     Vector3 WeaponMode::getMuzzlePosition() const
     237    void WeaponMode::computeMuzzleParameters(const Vector3& target)
    197238    {
    198239        if (this->weapon_)
    199             return (this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_);
    200         else
    201             return this->muzzleOffset_;
    202     }
    203 
    204     const Quaternion& WeaponMode::getMuzzleOrientation() const
     240        {
     241            this->muzzlePosition_ = this->weapon_->getWorldPosition() + this->weapon_->getWorldOrientation() * this->muzzleOffset_;
     242
     243            Vector3 muzzleDirection;
     244            muzzleDirection = target - this->muzzlePosition_;
     245//             COUT(0) << "muzzleDirection " << muzzleDirection << endl;
     246            this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
     247        }
     248        else
     249        {
     250            this->muzzlePosition_ = this->muzzleOffset_;
     251            this->muzzleOrientation_ = Quaternion::IDENTITY;
     252        }
     253    }
     254
     255    Vector3 WeaponMode::getMuzzleDirection() const
    205256    {
    206257        if (this->weapon_)
    207             return this->weapon_->getWorldOrientation();
    208         else
    209             return Quaternion::IDENTITY;
    210     }
    211 
    212     Vector3 WeaponMode::getMuzzleDirection() const
    213     {
    214         if (this->weapon_)
    215             return (this->weapon_->getWorldOrientation() * WorldEntity::FRONT);
     258            return (this->getMuzzleOrientation() * WorldEntity::FRONT);
    216259        else
    217260            return WorldEntity::FRONT;
    218261    }
     262
     263    void WeaponMode::setDefaultSound(const std::string& soundPath)
     264    {
     265        if( this->defSndWpnFire_ )
     266            this->defSndWpnFire_->setSource(soundPath);
     267    }
     268
     269    const std::string& WeaponMode::getDefaultSound()
     270    {
     271        if( this->defSndWpnFire_ )
     272            return this->defSndWpnFire_->getSource();
     273        else
     274            return BLANKSTRING;
     275    }
    219276}
  • code/trunk/src/orxonox/weaponsystem/WeaponMode.h

    r5929 r6417  
    5151            bool fire(float* reloadTime);
    5252            bool reload();
     53
     54            // Interacting with the default Firing sound
     55            void setDefaultSound(const std::string& soundPath);
     56            const std::string& getDefaultSound();
    5357
    5458
     
    109113                { return this->muzzleOffset_; }
    110114
    111             Vector3 getMuzzlePosition() const;
    112             const Quaternion& getMuzzleOrientation() const;
     115            void computeMuzzleParameters(const Vector3& target);
     116            const Vector3& getMuzzlePosition() const
     117                { return this->muzzlePosition_; }
     118            const Quaternion& getMuzzleOrientation() const
     119                { return this->muzzleOrientation_; }
    113120            Vector3 getMuzzleDirection() const;
    114121
     
    124131            inline unsigned int getMode() const
    125132                { return this->mode_; }
     133
     134            Vector3 getTarget();
    126135
    127136        protected:
     
    152161            Timer reloadTimer_;
    153162            bool bReloading_;
     163
     164            Vector3 muzzlePosition_;
     165            Quaternion muzzleOrientation_;
     166
     167            WorldSound* defSndWpnFire_;
     168            bool        bSoundAttached_;
    154169    };
    155170}
  • code/trunk/src/orxonox/weaponsystem/WeaponPack.cc

    r5929 r6417  
    4949    WeaponPack::~WeaponPack()
    5050    {
    51         if (this->isInitialized() && this->weaponSystem_)
     51        if (this->isInitialized())
    5252        {
    53             this->weaponSystem_->removeWeaponPack(this);
     53            if( this->weaponSystem_ )
     54                this->weaponSystem_->removeWeaponPack(this);
    5455
    5556            while (!this->weapons_.empty())
     
    7172    void WeaponPack::fire(unsigned int weaponmode)
    7273    {
    73         for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     74        for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    7475            (*it)->fire(weaponmode);
    7576    }
     
    7778    void WeaponPack::reload()
    7879    {
    79         for (std::set<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     80        for (std::vector<Weapon *>::iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    8081            (*it)->reload();
    8182    }
     
    8687            return;
    8788
    88         this->weapons_.insert(weapon);
     89        this->weapons_.push_back(weapon);
    8990        weapon->setWeaponPack(this);
    9091    }
     
    9596            return;
    9697
    97         this->weapons_.erase(weapon);
     98        std::vector<Weapon*>::iterator it = std::find(this->weapons_.begin(), this->weapons_.end(), weapon);
     99        assert(it != this->weapons_.end());
     100        this->weapons_.erase(it);
    98101        weapon->setWeaponPack(0);
    99102    }
     
    103106        unsigned int i = 0;
    104107
    105         for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     108        for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    106109        {
    107110            if (i == index)
     
    142145    void WeaponPack::notifyWeapons()
    143146    {
    144         for (std::set<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
     147        for (std::vector<Weapon *>::const_iterator it = this->weapons_.begin(); it != this->weapons_.end(); ++it)
    145148            (*it)->setWeaponPack(this);
    146149    }
  • code/trunk/src/orxonox/weaponsystem/WeaponPack.h

    r5781 r6417  
    6969            void notifyWeapons();
    7070
    71             std::set<Weapon *> weapons_;
     71            std::vector<Weapon *> weapons_;
    7272            std::set<DefaultWeaponmodeLink *> links_;
    7373            WeaponSystem * weaponSystem_;
  • code/trunk/src/orxonox/weaponsystem/WeaponSystem.cc

    r5929 r6417  
    202202        }
    203203
    204         this->weaponPacks_.insert(wPack);
     204        this->weaponPacks_.push_back(wPack);
    205205        wPack->setWeaponSystem(this);
    206206
     
    221221
    222222        // Remove the WeaponPack from the WeaponSystem
    223         this->weaponPacks_.erase(wPack);
     223        std::vector<WeaponPack*>::iterator it = std::find(this->weaponPacks_.begin(),this->weaponPacks_.end(), wPack);
     224        assert(it !=this->weaponPacks_.end());
     225        this->weaponPacks_.erase(it);
    224226    }
    225227
     
    227229    {
    228230        unsigned int i = 0;
    229         for (std::set<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
     231        for (std::vector<WeaponPack*>::const_iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); ++it)
    230232        {
    231233            ++i;
     
    258260
    259261        // Check if the WeaponPack belongs to this WeaponSystem
    260         std::set<WeaponPack *>::iterator it1 = this->weaponPacks_.find(wPack);
     262        std::vector<WeaponPack *>::iterator it1 = std::find( this->weaponPacks_.begin(), this->weaponPacks_.end(), wPack );
    261263        if (it1 == this->weaponPacks_.end())
    262264            return;
  • code/trunk/src/orxonox/weaponsystem/WeaponSystem.h

    r5781 r6417  
    9292            std::map<unsigned int, WeaponSet *> weaponSets_;
    9393            std::vector<WeaponSlot *> weaponSlots_;
    94             std::set<WeaponPack *> weaponPacks_;
     94            std::vector<WeaponPack *> weaponPacks_;
    9595            std::map<Identifier *, Munition *> munitions_;
    9696            Pawn * pawn_;
Note: See TracChangeset for help on using the changeset viewer.