[Orxonox-commit 1527] r6245 - in code/branches/presentation2/src: modules/weapons/weaponmodes orxonox/weaponsystem

youngk at orxonox.net youngk at orxonox.net
Fri Dec 4 15:52:28 CET 2009


Author: youngk
Date: 2009-12-04 15:52:28 +0100 (Fri, 04 Dec 2009)
New Revision: 6245

Modified:
   code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
   code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h
   code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.cc
   code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.h
   code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.cc
   code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.h
   code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
   code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h
Log:
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

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.cc	2009-12-04 14:52:28 UTC (rev 6245)
@@ -51,7 +51,7 @@
     {
         RegisterObject(HsW01);
 
-        this->reloadTime_ = 0.5;
+        this->reloadTime_ = 0.25;
         this->damage_ = 15;
         this->speed_ = 2500;
         this->delay_ = 0;
@@ -60,17 +60,11 @@
         this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&HsW01::shot, this)));
         this->delayTimer_.stopTimer();
 
-        this->defSndWpnFire_ = new WorldSound(this);
-        this->defSndWpnFire_->setLooping(false);
-        this->setDefaultSound("sounds/Weapon_Laser_shrt.ogg");
+        this->setDefaultSound("sounds/Weapon_HsW01.ogg");
     }
 
     HsW01::~HsW01()
     {
-        if(this->isInitialized())
-        {
-            delete this->defSndWpnFire_;
-        }
     }
 
     void HsW01::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -105,12 +99,7 @@
 
     void HsW01::fire()
     {
-        this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
-        this->defSndWpnFire_->play();
-
         this->delayTimer_.startTimer();
-
-        //this->defSndWpnFire_->stop();
     }
 
     void HsW01::muendungsfeuer()
@@ -141,14 +130,4 @@
 
         HsW01::muendungsfeuer();
     }
-
-    void HsW01::setDefaultSound(const std::string& soundPath)
-    {
-        this->defSndWpnFire_->setSource(soundPath);
-    }
-
-    const std::string& HsW01::getDefaultSound()
-    {
-        return this->defSndWpnFire_->getSource();
-    }
 }

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/HsW01.h	2009-12-04 14:52:28 UTC (rev 6245)
@@ -45,9 +45,6 @@
             virtual void fire();
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
-            void setDefaultSound(const std::string& soundPath);
-            const std::string& getDefaultSound();
-
         private:
             void setMaterial(const std::string& material);
             std::string& getMaterial();
@@ -60,8 +57,6 @@
             float speed_;
             float delay_;
             Timer delayTimer_;
-
-            WorldSound* defSndWpnFire_;
     };
 }
 

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.cc	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.cc	2009-12-04 14:52:28 UTC (rev 6245)
@@ -35,6 +35,8 @@
 #include "weaponsystem/WeaponSystem.h"
 #include "worldentities/pawns/Pawn.h"
 
+#include "sound/WorldSound.h"
+
 namespace orxonox
 {
     CreateFactory(LightningGun);
@@ -48,6 +50,7 @@
         this->speed_ = 150;
 
         this->setMunitionName("LaserMunition");
+        this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
     }
 
     LightningGun::~LightningGun()
@@ -55,7 +58,7 @@
     }
 
     void LightningGun::fire()
-    {
+    {        
         LightningGunProjectile* projectile = new LightningGunProjectile(this);
         projectile->setMaterial("Flares/LightningBall_");
 

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.h
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.h	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/LightningGun.h	2009-12-04 14:52:28 UTC (rev 6245)
@@ -41,6 +41,7 @@
             virtual ~LightningGun();
 
             virtual void fire();
+
        private:
             float speed_;
     };

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.cc
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.cc	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.cc	2009-12-04 14:52:28 UTC (rev 6245)
@@ -37,6 +37,8 @@
 #include "weaponsystem/WeaponSystem.h"
 #include "worldentities/pawns/Pawn.h"
 
+#include "sound/WorldSound.h"
+
 namespace orxonox
 {
     CreateFactory(RocketFire);
@@ -51,8 +53,13 @@
         this->speed_ = 500;
 
         this->setMunitionName("RocketMunition");
+        this->setDefaultSound("sounds/Rocket_Launch.ogg");
     }
 
+    RocketFire::~RocketFire()
+    {
+    }
+
     void RocketFire::fire()
     {
         Rocket* rocket = new Rocket(this);

Modified: code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.h
===================================================================
--- code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.h	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/modules/weapons/weaponmodes/RocketFire.h	2009-12-04 14:52:28 UTC (rev 6245)
@@ -38,7 +38,7 @@
     {
         public:
             RocketFire(BaseObject* creator);
-            virtual ~RocketFire() {}
+            virtual ~RocketFire();
 
             virtual void fire();
 

Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.cc	2009-12-04 14:52:28 UTC (rev 6245)
@@ -39,6 +39,8 @@
 #include "WeaponPack.h"
 #include "WeaponSystem.h"
 
+#include "sound/WorldSound.h"
+
 namespace orxonox
 {
     WeaponMode::WeaponMode(BaseObject* creator) : BaseObject(creator)
@@ -66,10 +68,17 @@
         this->muzzleOffset_ = Vector3::ZERO;
         this->muzzlePosition_ = Vector3::ZERO;
         this->muzzleOrientation_ = Quaternion::IDENTITY;
+
+        this->defSndWpnFire_ = new WorldSound(this);
+        this->defSndWpnFire_->setLooping(false);
     }
 
     WeaponMode::~WeaponMode()
     {
+        if(this->isInitialized())
+        {
+            delete this->defSndWpnFire_;
+        }
     }
 
     void WeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)
@@ -112,6 +121,13 @@
             this->reloadTimer_.setInterval(reloadtime);
             this->reloadTimer_.startTimer();
 
+            assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+            this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->attach(this->defSndWpnFire_);
+            if(!(this->defSndWpnFire_->isPlaying()))
+            {
+                this->defSndWpnFire_->play();
+            }
+            
             this->fire();
 
             return true;
@@ -199,6 +215,10 @@
 
     void WeaponMode::reloaded()
     {
+        if(this->defSndWpnFire_->isPlaying())
+        {
+            this->defSndWpnFire_->stop();
+        }
         this->bReloading_ = false;
     }
 
@@ -227,4 +247,14 @@
         else
             return WorldEntity::FRONT;
     }
+
+    void WeaponMode::setDefaultSound(const std::string& soundPath)
+    {
+        this->defSndWpnFire_->setSource(soundPath);
+    }
+
+    const std::string& WeaponMode::getDefaultSound()
+    {
+        return this->defSndWpnFire_->getSource();
+    }
 }

Modified: code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h	2009-12-04 14:26:08 UTC (rev 6244)
+++ code/branches/presentation2/src/orxonox/weaponsystem/WeaponMode.h	2009-12-04 14:52:28 UTC (rev 6245)
@@ -51,7 +51,11 @@
             bool fire(float* reloadTime);
             bool reload();
 
+            // Interacting with the default Firing sound
+            void setDefaultSound(const std::string& soundPath);
+            const std::string& getDefaultSound();
 
+
             // Munition
             inline Munition* getMunition() const
                 { return this->munition_; }
@@ -159,6 +163,8 @@
 
             Vector3 muzzlePosition_;
             Quaternion muzzleOrientation_;
+
+            WorldSound* defSndWpnFire_;
     };
 }
 




More information about the Orxonox-commit mailing list