[Orxonox-commit 387] r2979 - in branches/weapons/src/orxonox/objects: weaponsystem/weaponmodes worldentities

Hagen at orxonox.net Hagen at orxonox.net
Mon May 18 14:06:05 CEST 2009


Author: Hagen
Date: 2009-05-18 14:06:04 +0200 (Mon, 18 May 2009)
New Revision: 2979

Modified:
   branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt
   branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.cc
   branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h
   branches/weapons/src/orxonox/objects/worldentities/CMakeLists.txt
Log:
working laser style weapon with muzzleflash

Modified: branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt
===================================================================
--- branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt	2009-05-17 19:23:41 UTC (rev 2978)
+++ branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/CMakeLists.txt	2009-05-18 12:06:04 UTC (rev 2979)
@@ -1,5 +1,9 @@
 ADD_SOURCE_FILES(ORXONOX_SRC_FILES
   FusionFire.cc
   LaserFire.cc
+<<<<<<< .mine
+  HsW01.cc
+=======
   LightningGun.cc
+>>>>>>> .r2978
 )

Modified: branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.cc
===================================================================
--- branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.cc	2009-05-17 19:23:41 UTC (rev 2978)
+++ branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.cc	2009-05-18 12:06:04 UTC (rev 2979)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Martin Polak
+ *      Hagen Seifert
  *   Co-authors:
  *      ...
  *
@@ -31,49 +31,91 @@
 
 #include "core/CoreIncludes.h"
 #include "core/XMLPort.h"
+#include "objects/weaponsystem/projectiles/ParticleProjectile.h"
+#include "objects/worldentities/Model.h"
+#include "objects/worldentities/MuzzleFlash.h"
 
+#include "objects/weaponsystem/Weapon.h"
+#include "objects/weaponsystem/WeaponPack.h"
+#include "objects/weaponsystem/WeaponSystem.h"
+
 namespace orxonox
 {
     CreateFactory(HsW01);
 
-    HsW01::HsW01(BaseObject* creator) : Weapon(creator)
+    HsW01::HsW01(BaseObject* creator) : WeaponMode(creator)
     {
         RegisterObject(HsW01);
 
-        this->speed_ = 1250;
+        this->reloadTime_ = 0.25;
+        this->damage_ = 15;
+        this->speed_ = 2500;
+        this->delay_ = 0;
+        this->setMunitionName("HsW01");
 
+        this->delayTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&HsW01::shot)));
+        this->delayTimer_.stopTimer();
     }
 
-    HsW01::~HsW01()
+    void HsW01::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
+        SUPER(HsW01, XMLPort, xmlelement, mode);
+
+        XMLPortParam(HsW01, "delay", setDelay, getDelay, xmlelement, mode);
+        XMLPortParam(HsW01, "material", setMaterial, getMaterial, xmlelement, mode);
+
     }
 
-    void HsW01::reloadBullet()
+    void HsW01::setMaterial(const std::string& material)
     {
-        this->bulletTimer(this->bulletLoadingTime_);
+        this->material_ = material;
     }
 
-    void HsW01::reloadMagazine()
+    std::string& HsW01::getMaterial()
     {
-        this->magazineTimer(this->magazineLoadingTime_);
+        return this->material_;
     }
 
-    void HsW01::takeBullets()
+    void HsW01::setDelay(float d)
     {
-        this->munition_->removeBullets(1);
+        this->delay_ = d;
+        this->delayTimer_.setInterval(this->delay_);
     }
 
-    void HsW01::takeMagazines()
+    float HsW01::getDelay() const
     {
-        this->munition_->removeMagazines(1);
+        return this->delay_;
     }
 
-    void HsW01::createProjectile()
+    void HsW01::fire()
     {
-        BillboardProjectile* projectile = new ParticleProjectile(this);
-        projectile->setOrientation(this->getWorldOrientation());
-        projectile->setPosition(this->getWorldPosition());
-        projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
-        projectile->setOwner(this->getWeaponSystem()->getPawn());
+        this->delayTimer_.startTimer();
     }
+
+    void HsW01::muendungsfeuer()
+    {
+        MuzzleFlash *muzzleFlash = new MuzzleFlash(this);
+        this->getWeapon()->attach(muzzleFlash);
+        muzzleFlash->setPosition(this->getMuzzleOffset());
+        muzzleFlash->setMaterial(this->material_);
+    }
+
+    void HsW01::shot()
+    {
+        Projectile* projectile = new Projectile(this);
+	Model* model = new Model(projectile);
+	model->setMeshSource("laserbeam.mesh");
+	model->setCastShadows(false);
+	projectile->attach(model);
+	model->setScale(5);
+
+        projectile->setOrientation(this->getMuzzleOrientation());
+        projectile->setPosition(this->getMuzzlePosition());
+        projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+        projectile->setDamage(this->getDamage());
+
+        HsW01::muendungsfeuer();
+    }
 }

Modified: branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h
===================================================================
--- branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h	2009-05-17 19:23:41 UTC (rev 2978)
+++ branches/weapons/src/orxonox/objects/weaponsystem/weaponmodes/HsW01.h	2009-05-18 12:06:04 UTC (rev 2979)
@@ -20,7 +20,7 @@
  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
  *   Author:
- *      Martin Polak
+ *      Hagen Seifert
  *   Co-authors:
  *      ...
  *
@@ -30,32 +30,32 @@
 #define _HsW01_H__
 
 #include "OrxonoxPrereqs.h"
+#include "objects/weaponsystem/WeaponMode.h"
+#include "tools/Timer.h"
 
-#include "core/BaseObject.h"
-
-#include "../munitions/LaserGunMunition.h"
-#include "util/Math.h"
-#include "../Weapon.h"
-#include "../projectiles/BillboardProjectile.h"
-#include "../projectiles/ParticleProjectile.h"
-
 namespace orxonox
 {
-    class _OrxonoxExport HsW01 : public Weapon
+    class _OrxonoxExport HsW01 : public WeaponMode
     {
         public:
             HsW01(BaseObject* creator);
-            virtual ~HsW01();
+            virtual ~HsW01() {}
 
-            virtual void takeBullets();
-            virtual void takeMagazines();
-            virtual void createProjectile();
-            virtual void reloadBullet();
-            virtual void reloadMagazine();
+            virtual void fire();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
 
         private:
+            void setMaterial(const std::string& material);
+            std::string& getMaterial();
+            void setDelay(float d);
+            float getDelay() const;
+            void shot();
+            void muendungsfeuer();
+
+            std::string material_;
             float speed_;
-
+            float delay_;
+            Timer<HsW01> delayTimer_;
     };
 }
 

Modified: branches/weapons/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- branches/weapons/src/orxonox/objects/worldentities/CMakeLists.txt	2009-05-17 19:23:41 UTC (rev 2978)
+++ branches/weapons/src/orxonox/objects/worldentities/CMakeLists.txt	2009-05-18 12:06:04 UTC (rev 2979)
@@ -14,6 +14,7 @@
   Camera.cc
   CameraPosition.cc
   Model.cc
+  MuzzleFlash.cc
   ParticleEmitter.cc
   ParticleSpawner.cc
   Planet.cc




More information about the Orxonox-commit mailing list