[Orxonox-commit 5775] r10435 - in code/branches/weaponFS15: data/particle src/modules/weapons/projectiles src/modules/weapons/weaponmodes

meggiman at orxonox.net meggiman at orxonox.net
Thu May 7 17:43:37 CEST 2015


Author: meggiman
Date: 2015-05-07 17:43:36 +0200 (Thu, 07 May 2015)
New Revision: 10435

Added:
   code/branches/weaponFS15/data/particle/FieldExplosion.particle
   code/branches/weaponFS15/data/particle/GravityBombField.particle
Modified:
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
   code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h
   code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc
   code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h
Log:
Added new models and fixed dammage bug. Bomb now fully working.

Added: code/branches/weaponFS15/data/particle/FieldExplosion.particle
===================================================================
--- code/branches/weaponFS15/data/particle/FieldExplosion.particle	                        (rev 0)
+++ code/branches/weaponFS15/data/particle/FieldExplosion.particle	2015-05-07 15:43:36 UTC (rev 10435)
@@ -0,0 +1,165 @@
+particle_system Orxonox/FieldExplosion
+
+{
+
+	material PE/lensflare
+
+	particle_width 152.940002441406
+
+	particle_height 154.119995117188
+
+	quota 2000
+
+	cull_each false
+
+	sorted false
+
+	local_space false
+
+	iteration_interval 0.0
+
+	nonvisible_update_timeout 0.0
+
+	billboard_type point
+
+	billboard_origin center
+
+	billboard_rotation_type texcoord
+
+	point_rendering false
+
+	accurate_facing false
+
+
+
+	emitter Point
+
+	{
+
+		position 0.0 0.0 0.0
+
+		direction 1.0 0.0 0.0
+
+		angle 0.0
+
+		emission_rate 200.0
+
+		velocity_min -1000.0
+
+		velocity_max 1000.0
+
+		time_to_live_min 2.0
+
+		time_to_live_max 4.0
+
+		duration_min 0.0
+
+		duration_max 0.0
+
+		repeat_delay_min 0.0
+
+		repeat_delay_max 0.0
+
+		colour_range_start 1 1 1 1
+
+		colour_range_end 0.666667 0 0 1
+
+	}
+
+
+
+	emitter Point
+
+	{
+
+		position 0.0 0.0 0.0
+
+		direction 0.0 0.0 1.0
+
+		angle 0.0
+
+		emission_rate 200.0
+
+		velocity_min -1000.0
+
+		velocity_max 1000.0
+
+		time_to_live_min 2.0
+
+		time_to_live_max 4.0
+
+		duration_min 0.0
+
+		duration_max 0.0
+
+		repeat_delay_min 0.0
+
+		repeat_delay_max 0.0
+
+		colour_range_start 1 1 1 1
+
+		colour_range_end 0.333333 0 1 1
+
+	}
+
+
+
+	emitter Point
+
+	{
+
+		position 0.0 0.0 0.0
+
+		direction 0.0 1.0 0.0
+
+		angle 0.0
+
+		emission_rate 200.0
+
+		velocity_min -1000.0
+
+		velocity_max 1000.0
+
+		time_to_live_min 2.0
+
+		time_to_live_max 4.0
+
+		duration_min 0.0
+
+		duration_max 0.0
+
+		repeat_delay_min 0.0
+
+		repeat_delay_max 0.0
+
+		colour_range_start 1 1 1 1
+
+		colour_range_end 0 1 0.498039 1
+
+	}
+
+
+
+	affector LinearForce
+
+	{
+
+		force_vector 0.0 -45.62 0.0
+
+		force_application add
+
+	}
+
+
+
+	affector Scaler
+
+	{
+
+		rate 16.47
+
+	}
+	
+
+}
+

Added: code/branches/weaponFS15/data/particle/GravityBombField.particle
===================================================================
--- code/branches/weaponFS15/data/particle/GravityBombField.particle	                        (rev 0)
+++ code/branches/weaponFS15/data/particle/GravityBombField.particle	2015-05-07 15:43:36 UTC (rev 10435)
@@ -0,0 +1,65 @@
+particle_system Orxonox/GravityBombField
+{
+	material PE/lensflare
+	particle_width 33.6500015258789
+	particle_height 1.91999995708466
+	quota 2000
+	cull_each false
+	sorted false
+	local_space true
+	iteration_interval 0.0
+	nonvisible_update_timeout 0.0
+	billboard_type point
+	billboard_origin center
+	billboard_rotation_type vertex
+	point_rendering false
+	accurate_facing false
+
+	emitter HollowEllipsoid
+	{
+		position 0.0 0.0 0.0
+		direction 0.0 1.0 0.0
+		angle 180
+		width 350
+		height 350
+		depth 350
+		inner_width 0.99
+		inner_height 0.99
+		inner_depth 0.99
+		emission_rate 2000
+		velocity_min 0
+		velocity_max 5
+		time_to_live_min 2
+		time_to_live_max 5
+		duration_min 0
+		duration_max 0
+		repeat_delay_min 0
+		repeat_delay_max 0
+		colour_range_start 1 0.666667 0 1
+		colour_range_end 1 0 0 1
+	}
+
+	affector Rotator
+	{
+		rotation_speed_range_start 0
+		rotation_speed_range_end 0
+		rotation_range_start 0
+		rotation_range_end 180
+	}
+
+	affector ColourInterpolator
+	{
+		time0 0
+		colour0 1 0.666667 0 1
+		time1 0.2
+		colour1 1 0.584314 0 1
+		time2 0.4
+		colour2 1 0 0 1
+		time3 0.6
+		colour3 1 0 0 1
+		time4 0.8
+		colour4 0.666667 0 0 1
+		time5 1
+		colour5 0 0 0 1
+	}
+}

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc	2015-05-07 15:21:45 UTC (rev 10434)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc	2015-05-07 15:43:36 UTC (rev 10435)
@@ -11,6 +11,8 @@
 namespace orxonox{
 	RegisterClass(GravityBomb);
 
+	const float GravityBomb::LIFETIME = 5;
+
 	GravityBomb::GravityBomb(Context* context):
 				BasicProjectile(),
 				MovableEntity(context),
@@ -23,7 +25,7 @@
 			if (GameMode::isMaster())
 			{
 				//Define CollisionType of the bomb
-				this->timeToLife_= 5;
+				this->timeToLife_= LIFETIME;
 				this->setCollisionResponse(false);
 				this->setCollisionType(WorldEntity::Dynamic);
 				this->enableCollisionCallback();
@@ -34,11 +36,16 @@
 				this->attachCollisionShape(collisionShape);
 
 				//Create Bomb Model
-	            Model* model = new Model(this->getContext());
-	            model->setMeshSource("rocket.mesh"); //Demo Model from SimpleRocket
-	            model->scale(0.7f);
-	            this->attach(model);
+	            Model* rocketModel = new Model(this->getContext());
+	            rocketModel->setMeshSource("GravityBombRocket.mesh"); //Demo Model from SimpleRocket
+	            rocketModel->scale(3.0f);
+	            this->attach(rocketModel);
 
+	            Model* bombModel =  new Model(this->getContext());
+	            bombModel->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
+				bombModel->scale(3.0f);
+				this->attach(bombModel);
+
 			}
 		}
 
@@ -81,6 +88,7 @@
 	void GravityBomb::detonate()
 	{
 		GravityBombField* field = new GravityBombField(this->getContext());
+		field->setShooter(this->getShooter());
 		field->setPosition(getPosition());
 		orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
 		orxout(debug_output) << "Field is at Position: " << getPosition() << endl;

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h	2015-05-07 15:21:45 UTC (rev 10434)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h	2015-05-07 15:43:36 UTC (rev 10435)
@@ -64,6 +64,8 @@
 			virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
 			void detonate();
 		private:
+		static const float LIFETIME;
+
 		bool isDetonated_; //Used to check whether the Bomb has to be destroyed during next tick.
 		float timeToLife_; //Time the bomb flies before it explodes.
 

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc	2015-05-07 15:21:45 UTC (rev 10434)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc	2015-05-07 15:43:36 UTC (rev 10435)
@@ -14,6 +14,11 @@
 	const float GravityBombField::FORCE_FIELD_LIFETIME = 20;
 	const float GravityBombField::FORCE_SPHERE_START_RADIUS = 250;
 	const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -500;
+	const float GravityBombField::PEAK_EXPLOSION_FORCE = 1e6;
+	const float GravityBombField::FORCE_FIELD_EXPLOSION_DAMMAGE = 100;
+	const float GravityBombField::EXPLOSION_DURATION = 1;
+	const float GravityBombField::EXPLOSION_RADIUS = 400;
+	const float GravityBombField::PEAK_ANGULAR_VELOCITY = 20;
 
 	GravityBombField::GravityBombField(Context* context) : ForceField(context),RadarViewable(this, static_cast<WorldEntity*>(this))
 	{
@@ -32,15 +37,37 @@
 		this->setRadarObjectShape(RadarViewable::Dot);
 		this->setRadarObjectScale(0.5f);
 
-		//Attach Demo Model for debuging.
-			Model* model = new Model(this->getContext());
-			model->setMeshSource("rocket.mesh"); //Demo Model from SimpleRocket
-			model->scale(0.7f);
-			this->attach(model);
+		//Attach Model
+		Model* model = new Model(this->getContext());
+		model->setMeshSource("GravityBomb.mesh"); //Demo Model from SimpleRocket
+		model->scale(3.0f);
+		bombModel_ = new MovableEntity(context);
+		bombModel_->attach(model);
+		this->attach(bombModel_);
 
+		Backlight* centreLight = new Backlight(context);
+		centreLight->setColour(ColourValue(0.9,0.5,0.5,1));
+		centreLight->setScale(1.0);
+		centreLight->setTrailMaterial("Trail/backlighttrail");
+		centreLight->setMaterial("Examples/Flare");
+		centreLight->setLifetime(20);
+		bombModel_->attach(centreLight);
+
+		Vector3 randomRotation;
+		srand(time(NULL));
+		randomRotation.x = rand();
+		randomRotation.y = rand();
+		randomRotation.y = rand();
+		randomRotation.normalise();
+		bombModel_->setAngularAcceleration(randomRotation*(PEAK_ANGULAR_VELOCITY/FORCE_FIELD_LIFETIME));
+
+		//Add Collision Shape
+		SphereCollisionShape* collisionShape = new SphereCollisionShape(context);
+		collisionShape->setRadius(3.0);
+		this->attachCollisionShape(collisionShape);
+
 		this->particleSphere_ = new ParticleEmitter(this->getContext());
 		this->attach(this->particleSphere_);
-
 		particleSphere_->setSource("Orxonox/GravityBombField");
 	}
 
@@ -50,19 +77,61 @@
 	{
 		SUPER(GravityBombField,tick,dt);
 		lifetime_-=dt;
-		forceStrength_ *= (1+dt/10);
-		if(lifetime_ < 0.2 && !fieldExploded_)
+
+		if(lifetime_ > EXPLOSION_DURATION)
 		{
-			forceStrength_ *= -2;
-			forceSphereRadius_ *= 2;
-			fieldExploded_ = true;
-			orxout(debug_output) << "Field exploded. Inverting Force." << endl;
+			forceStrength_ *= (1+dt/10);
+			forceSphereRadius_ = FORCE_SPHERE_START_RADIUS*(1-((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME)*((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME)*((FORCE_FIELD_LIFETIME-lifetime_)/FORCE_FIELD_LIFETIME));
 		}
+		else if(lifetime_ > 0)
+		{
+			if (!fieldExploded_)
+			{
+				forceStrength_ = PEAK_EXPLOSION_FORCE;
+				fieldExploded_ = true;
 
+				explosionCross_ = new ParticleEmitter(this->getContext());
+				this->attach(explosionCross_);
+				explosionCross_->setSource("Orxonox/FieldExplosion");
+			}
+
+			for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+			{
+				Vector3 distanceVector = it->getWorldPosition()-this->getWorldPosition();
+				 orxout(debug_output) << "Found Pawn:" << it->getWorldPosition() << endl;
+				if(distanceVector.length()< forceSphereRadius_)
+				 {
+					 orxout(debug_output) << "Force sphere radius is: " << forceSphereRadius_ << " Distance to Pawn is: " << distanceVector.length();
+					 if (std::find(victimsAlreadyDamaged_.begin(),victimsAlreadyDamaged_.end(),*it) == victimsAlreadyDamaged_.end())
+					 {
+						 orxout(debug_output) << "Found Pawn to damage: " << it->getWorldPosition() << endl;
+						 float damage = FORCE_FIELD_EXPLOSION_DAMMAGE*(1-distanceVector.length()/EXPLOSION_RADIUS);
+						 orxout(debug_output) << "Damage: " << damage << endl;
+						 it->hit(shooter_, it->getWorldPosition(), NULL, damage, 0,0);
+//						 it->removeHealth(damage);
+						 victimsAlreadyDamaged_.push_back(*it);
+					 }
+				 }
+			}
+
+			forceSphereRadius_ = EXPLOSION_RADIUS*(1-lifetime_/EXPLOSION_DURATION);
+			explosionCross_->setScale(forceSphereRadius_/FORCE_SPHERE_START_RADIUS);
+		}
+		else if (lifetime_ > -4)
+		{
+			bombModel_->setVisible(false);
+			this->setRadarVisibility(false);
+			forceStrength_ = 0;
+			forceSphereRadius_ = 0.00001;
+			particleSphere_->getParticleInterface()->removeAllEmitters();
+			explosionCross_->getParticleInterface()->removeAllEmitters();
+		}
+
 		setDiameter(forceSphereRadius_*2);
 		setVelocity(forceStrength_);
+		particleSphere_->setScale(forceSphereRadius_/FORCE_SPHERE_START_RADIUS);
 
-		if(lifetime_ < 0)
+		if (lifetime_ <= -4)
 		{
 			orxout(debug_output) << "Timeout. Destroying field." << endl;
 			this->destroy();

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h	2015-05-07 15:21:45 UTC (rev 10434)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.h	2015-05-07 15:43:36 UTC (rev 10435)
@@ -16,8 +16,11 @@
 #include "core/CoreIncludes.h"
 #include "GravityBomb.h"
 #include "graphics/ParticleSpawner.h"
+#include "tools/ParticleInterface.h"
+#include <stdlib.h>
+#include <time.h>
+#include "graphics/Backlight.h"
 
-
 namespace orxonox {
 class GravityBombField: public ForceField, public RadarViewable {
 public:
@@ -25,17 +28,33 @@
 	virtual ~GravityBombField();
 	virtual void tick(float dt);
 	virtual void destroy();
+
+	void setShooter(Pawn* shooter)
+	{ this->shooter_ = shooter; }
+
+	Pawn* getShooter()
+	{ return this->shooter_; }
+
 private:
 	static const float FORCE_FIELD_LIFETIME;
 	static const float FORCE_SPHERE_START_RADIUS;
 	static const float FORCE_SPHERE_START_STRENGTH;
+	static const float FORCE_FIELD_EXPLOSION_DAMMAGE;
+	static const float EXPLOSION_DURATION;
+	static const float EXPLOSION_RADIUS;
+	static const float PEAK_ANGULAR_VELOCITY;
+	static const float PEAK_EXPLOSION_FORCE;
 
 	float forceSphereRadius_;
 	float forceStrength_;
 	float lifetime_;
+	Vector3 rotationVector_;
 	bool fieldExploded_;
 	ParticleEmitter * particleSphere_;
-
+	ParticleEmitter * explosionCross_;
+	std::vector<Pawn*> victimsAlreadyDamaged_;
+	MovableEntity * bombModel_;
+	Pawn* shooter_;
 };
 
 }

Modified: code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc	2015-05-07 15:21:45 UTC (rev 10434)
+++ code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc	2015-05-07 15:43:36 UTC (rev 10435)
@@ -18,6 +18,8 @@
 {
 	RegisterClass(GravityBombFire);
 
+	const float GravityBombFire::BOMB_VELOCITY = 400.0;
+
 	GravityBombFire::GravityBombFire(Context* context) : WeaponMode(context)
 	{
 		RegisterObject(GravityBombFire);
@@ -25,7 +27,7 @@
 		this->reloadTime_ = 0.50f;
 		this->bParallelReload_ = false;
 		this->damage_ = 0.0f;
-		this->speed_ = 100.0f;
+		this->speed_ = BOMB_VELOCITY;
 
 		this->setMunitionName("GravityBombMunition");
 		// The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)

Modified: code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h	2015-05-07 15:21:45 UTC (rev 10434)
+++ code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h	2015-05-07 15:43:36 UTC (rev 10435)
@@ -57,6 +57,7 @@
 
         private:
             float speed_; //!< The initial speed of the bomb when it is launched.
+            static const float BOMB_VELOCITY;
     };
 }
 




More information about the Orxonox-commit mailing list