[Orxonox-commit 5681] r10341 - in code/branches/weaponFS15/src/modules: objects weapons/projectiles

meggiman at orxonox.net meggiman at orxonox.net
Thu Apr 2 16:08:52 CEST 2015


Author: meggiman
Date: 2015-04-02 16:08:52 +0200 (Thu, 02 Apr 2015)
New Revision: 10341

Added:
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h
Modified:
   code/branches/weaponFS15/src/modules/objects/ForceField.h
   code/branches/weaponFS15/src/modules/weapons/projectiles/CMakeLists.txt
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
Log:
Started implementing GravityBombField

Modified: code/branches/weaponFS15/src/modules/objects/ForceField.h
===================================================================
--- code/branches/weaponFS15/src/modules/objects/ForceField.h	2015-04-02 13:57:34 UTC (rev 10340)
+++ code/branches/weaponFS15/src/modules/objects/ForceField.h	2015-04-02 14:08:52 UTC (rev 10341)
@@ -159,14 +159,16 @@
             void setMode(const std::string& mode); //!< Set the mode of the ForceField.
             const std::string& getMode(void); //!< Get the mode of the ForceField.
 
+            static const std::string modeTube_s;
+			static const std::string modeSphere_s;
+			static const std::string modeInvertedSphere_s;
+			static const std::string modeNewtonianGravity_s;
+
+			static const std::string modeHomogen_s;
+
         private:
             //! Strings to represent the modes.
-            static const std::string modeTube_s;
-            static const std::string modeSphere_s;
-            static const std::string modeInvertedSphere_s;
-            static const std::string modeNewtonianGravity_s;
 
-            static const std::string modeHomogen_s;
 
             float velocity_; //!< The velocity of the ForceField.
             float radius_; //!< The radius of the ForceField.

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/CMakeLists.txt	2015-04-02 13:57:34 UTC (rev 10340)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/CMakeLists.txt	2015-04-02 14:08:52 UTC (rev 10341)
@@ -7,4 +7,5 @@
   Rocket.cc
   SimpleRocket.cc
   GravityBomb.cc
+  GravityBombField.cc
 )

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc	2015-04-02 13:57:34 UTC (rev 10340)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc	2015-04-02 14:08:52 UTC (rev 10341)
@@ -10,39 +10,62 @@
 namespace orxonox{
 	RegisterClass(GravityBomb);
 
-	const float GravityBomb::FUEL_START = 10;
-	const float GravityBomb::FORCE_SPHERE_START_RADIUS = 30;
-	const float GravityBomb::FORCE_SPHERE_START_STRENGTH = 100;
+	const float GravityBomb::INITIAL_VELOCITY = 20;
+	const float GravityBomb::SLOW_DOWN_RATIO = 2;
 
 	GravityBomb::GravityBomb(Context* context):
-			BasicProjectile(),
-			MovableEntity(context),
-			RadarViewable(this,static_cast<WorldEntity*>(this))
+				BasicProjectile(),
+				MovableEntity(context),
+				RadarViewable(this,static_cast<WorldEntity*>(this))
 		{
 			RegisterObject(GravityBomb);
-			this->lifetime_=FUEL_START;
-			this->forceSphereRadius_= FORCE_SPHERE_START_RADIUS;
-			this->forceStrength_ = FORCE_SPHERE_START_STRENGTH;
 
-			ForceField* field = new ForceField(context);
-			field->setMode("sphere");
-			field->setDiameter(this->forceSphereRadius_);
-			field->setVelocity(this->forceStrength_);
-			this->attach(field);
+			this->setMass(15.0);
+			if (GameMode::isMaster())
+			{
+				//Define movement of the bomb
+				this->setVelocity(this->getOrientation()*WorldEntity::FRONT*INITIAL_VELOCITY);
+				this->velocityAtLastTick_=INITIAL_VELOCITY;
+				this->setAcceleration(this->getOrientation()*WorldEntity::BACK*SLOW_DOWN_RATIO);
+				this->setCollisionType(WorldEntity::Dynamic);
+				this->enableCollisionCallback();
 
+				//Add Collision Shape
+				SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
+				collisionShape->setRadius(5.0);
+				this->attachCollisionShape(collisionShape);
+
+				//Create Bomb Model
+
+
+			}
 		}
 
 	GravityBomb::~GravityBomb(){}
 
 	void GravityBomb::tick(float dt)
 	{
-
+			if(velocityAtLastTick_ < this->getVelocity().length())
+			{
+				setVelocity(Vector3::ZERO);
+				setAcceleration(Vector3::ZERO);
+				velocityAtLastTick_=0;
+				detonate();
+			}
+			velocityAtLastTick_=getVelocity().length();
 	}
 
 	bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
 	{
+		detonate();
+		processCollision(otherObject, contactPoint,cs);
 		return true;
 	}
+
+	void GravityBomb::detonate()
+	{
+		GravityBombField* field = new GravityBombField(this->getContext());
+	}
 }
 
 

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h	2015-04-02 13:57:34 UTC (rev 10340)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h	2015-04-02 14:08:52 UTC (rev 10341)
@@ -47,12 +47,13 @@
 #include "BasicProjectile.h"
 #include "worldentities/MovableEntity.h"
 #include "core/CoreIncludes.h"
+#include "objects/collisionshapes/SphereCollisionShape.h"
+#include "../../../orxonox/worldentities/WorldEntity.h"
+#include "GravityBombField.h"
 
 namespace orxonox
 {
 
-	class ConeCollisionShape;
-
 	class _WeaponsExport GravityBomb : public BasicProjectile , public MovableEntity, public RadarViewable
 	{
 		public:
@@ -61,18 +62,14 @@
 			virtual void tick(float dt);
 
 			virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
+			void detonate();
 
 		private:
-		static const float FUEL_START;
-		static const float FORCE_SPHERE_START_RADIUS;
-		static const float FORCE_SPHERE_START_STRENGTH;
+		static const float INITIAL_VELOCITY;
+		static const float SLOW_DOWN_RATIO;
 
-		float fuel_;
-		float lifetime_;
-		float forceSphereRadius_;
-		float forceStrength_;
+		float velocityAtLastTick_; //Used to check wether the Object is already accelarating in the oposite direction to detect the time to detonate it.
 
-
 	};
 }
 #endif /* GravityBOMB_H_ */

Added: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc	                        (rev 0)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc	2015-04-02 14:08:52 UTC (rev 10341)
@@ -0,0 +1,42 @@
+/*
+ * GravityBombField.cc
+ *
+ *  Created on: Apr 2, 2015
+ *      Author: meggiman
+ */
+
+#include "GravityBombField.h"
+
+namespace orxonox{
+	RegisterClass(GravityBombField);
+
+	const float GravityBombField::FORCE_FIELD_LIFETIME = 10;
+	const float GravityBombField::FORCE_SPHERE_START_RADIUS = 50;
+	const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -300;
+
+	GravityBombField::GravityBombField(Context* context) : ForceField(context)
+	{
+		lifetime_=FORCE_FIELD_LIFETIME;
+		setVelocity(FORCE_SPHERE_START_STRENGTH);
+		setDiameter(FORCE_SPHERE_START_RADIUS);
+		setMode(modeInvertedSphere_s);
+	}
+
+	GravityBombField::~GravityBombField(){}
+
+	void GravityBombField::tick(float dt)
+	{
+		lifetime_-=dt;
+		if(lifetime_ < 0)
+		{
+			this->destroy();
+		}
+	}
+
+	void GravityBombField::destroy()
+	{
+		//Animation
+		//SUPER(GravityBombField,destroy);
+	}
+
+}

Added: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h	                        (rev 0)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h	2015-04-02 14:08:52 UTC (rev 10341)
@@ -0,0 +1,39 @@
+/*
+ * GravityBombField.h
+ *
+ *  Created on: Apr 2, 2015
+ *      Author: meggiman
+ */
+
+#ifndef GRAVITYBOMBFIELD_H_
+#define GRAVITYBOMBFIELD_H_
+
+#include "graphics/ParticleSpawner.h"
+#include "interfaces/RadarViewable.h"
+#include "objects/ForceField.h"
+#include "BasicProjectile.h"
+#include "worldentities/MovableEntity.h"
+#include "core/CoreIncludes.h"
+#include "GravityBomb.h"
+
+namespace orxonox {
+class GravityBombField: public ForceField {
+public:
+	GravityBombField(Context* context);
+	virtual ~GravityBombField();
+	virtual void tick(float dt);
+	virtual void destroy();
+private:
+	static const float FORCE_FIELD_LIFETIME;
+	static const float FORCE_SPHERE_START_RADIUS;
+	static const float FORCE_SPHERE_START_STRENGTH;
+
+	float forceSphereRadius_;
+	float forceStrength_;
+	float lifetime_;
+
+};
+
+}
+#endif /* GRAVITYBOMBFIELD_H_ */
+




More information about the Orxonox-commit mailing list