Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 4, 2009, 3:52:28 PM (15 years ago)
Author:
youngk
Message:

Implemented Firing sounds in Weapons HsW01, LightningGun and RocketFire. Engine and Explosion sounds for the Rocket are not yet implemented.
From now on, when creating a new sound for a weapon, just insert "this→setDefaultSound(PATH_TO_FILE)" into the constructor of the weapon.

Sound Files for HsW01 and LightningGun will be available in a couple of minutes

Location:
code/branches/presentation2/src/orxonox/weaponsystem
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc

    r6165 r6245  
    4040#include "WeaponSystem.h"
    4141
     42#include "sound/WorldSound.h"
     43
    4244namespace orxonox
    4345{
     
    6769        this->muzzlePosition_ = Vector3::ZERO;
    6870        this->muzzleOrientation_ = Quaternion::IDENTITY;
     71
     72        this->defSndWpnFire_ = new WorldSound(this);
     73        this->defSndWpnFire_->setLooping(false);
    6974    }
    7075
    7176    WeaponMode::~WeaponMode()
    7277    {
     78        if(this->isInitialized())
     79        {
     80            delete this->defSndWpnFire_;
     81        }
    7382    }
    7483
     
    113122            this->reloadTimer_.startTimer();
    114123
     124            assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
     125            this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
     126            if(!(this->defSndWpnFire_->isPlaying()))
     127            {
     128                this->defSndWpnFire_->play();
     129            }
     130           
    115131            this->fire();
    116132
     
    200216    void WeaponMode::reloaded()
    201217    {
     218        if(this->defSndWpnFire_->isPlaying())
     219        {
     220            this->defSndWpnFire_->stop();
     221        }
    202222        this->bReloading_ = false;
    203223    }
     
    228248            return WorldEntity::FRONT;
    229249    }
     250
     251    void WeaponMode::setDefaultSound(const std::string& soundPath)
     252    {
     253        this->defSndWpnFire_->setSource(soundPath);
     254    }
     255
     256    const std::string& WeaponMode::getDefaultSound()
     257    {
     258        return this->defSndWpnFire_->getSource();
     259    }
    230260}
  • code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h

    r6150 r6245  
    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
     
    160164            Vector3 muzzlePosition_;
    161165            Quaternion muzzleOrientation_;
     166
     167            WorldSound* defSndWpnFire_;
    162168    };
    163169}
Note: See TracChangeset for help on using the changeset viewer.