[Orxonox-commit 6128] r10786 - in code/branches/explosionChunksHS15: data/levels src/orxonox/worldentities src/orxonox/worldentities/pawns

vaydin at orxonox.net vaydin at orxonox.net
Mon Nov 9 15:51:18 CET 2015


Author: vaydin
Date: 2015-11-09 15:51:17 +0100 (Mon, 09 Nov 2015)
New Revision: 10786

Modified:
   code/branches/explosionChunksHS15/data/levels/emptyLevel.oxw
   code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.cc
   code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.h
   code/branches/explosionChunksHS15/src/orxonox/worldentities/pawns/Pawn.cc
Log:
added ability to attach second particle effect to explosionpart, added ability to define range of velocity of explosionpart

Modified: code/branches/explosionChunksHS15/data/levels/emptyLevel.oxw
===================================================================
--- code/branches/explosionChunksHS15/data/levels/emptyLevel.oxw	2015-11-09 13:14:47 UTC (rev 10785)
+++ code/branches/explosionChunksHS15/data/levels/emptyLevel.oxw	2015-11-09 14:51:17 UTC (rev 10786)
@@ -33,11 +33,16 @@
     <SpaceShip
         team                = "1"
         position            = "1000,0,0"
-   explosionchunks        = 60
         >
         <templates>
-                      <Template link=spaceshipassff />
+          <Template link=spaceshipassff />
         </templates>
+
+        <explosion >
+          <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_flash2" effect2="orxonox/explosion_flame2" />
+          <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_shockwave2" effect2="orxonox/explosion_sparks2" />
+          <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_streak2" effect2="orxonox/explosion_afterglow" />
+        </explosion>
           
                     
     </SpaceShip>
@@ -46,13 +51,23 @@
         position            = "1000,200,0"
         >
         <templates>
-                      <Template link=spaceshipassff />
-                    </templates>
-                    <explosion>
+          <Template link=spaceshipassff />
+        </templates>
 
-          <ExplosionPart mesh="ship.mesh" effect="Orxonox/smoke7" />
-          <ExplosionPart mesh="ship.mesh" effect="Orxonox/smoke7" />
+        <explosion >
+          <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_flash2" effect2="orxonox/explosion_flame2" />
+          <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_shockwave2" effect2="orxonox/explosion_sparks2" />
+          <ExplosionPart minspeed=0 maxspeed=0 effect1="orxonox/explosion_streak2" effect2="orxonox/explosion_afterglow" />
 
+          <ExplosionPart minspeed=0 maxspeed=0 effect1="Orxonox/explosion2b" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="CockpitDebris.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="BodyDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="WingDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="WingDebris2.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="CockpitDebris.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="BodyDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="WingDebris1.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
+          <ExplosionPart mesh="WingDebris2.mesh" effect1="Orxonox/fire4" effect2="Orxonox/smoke6" />
         </explosion>
                     
     </SpaceShip>
@@ -61,14 +76,14 @@
         position            = "1000,400,0"
         >
         <templates>
-                      <Template link=spaceshipassff />
-                    </templates>
-                    <explosion>
+          <Template link=spaceshipassff />
+        </templates>
 
-          <ExplosionPart mesh="ship.mesh" effect="Orxonox/smoke7" />
-          <ExplosionPart mesh="ship.mesh" effect="Orxonox/smoke7" />
+        <explosion>
+          
+        </explosion>
 
-        </explosion>
+        
                     
     </SpaceShip>
     

Modified: code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.cc
===================================================================
--- code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.cc	2015-11-09 13:14:47 UTC (rev 10785)
+++ code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.cc	2015-11-09 14:51:17 UTC (rev 10786)
@@ -42,9 +42,11 @@
 		this->bStop_ = false;
         this->LOD_ = LODParticle::Normal;
 		this->mesh_ = "";
-		this->effect_ = "";
+		this->effect1_ = "";
+		this->effect2_ = "";
 		this->model_= new Model(this->getContext());
-		this->particleInterface_= NULL;
+		this->effect1Particle_= NULL;
+		this->effect2Particle_= NULL;
 		this->explosionEntity_ = new MovableEntity(this->getContext());
 
 
@@ -52,12 +54,33 @@
 	}
 
 
+	ExplosionPart::~ExplosionPart()
+    {
+        if (this->isInitialized())
+        {
+            if (this->effect1Particle_)
+            {
+                this->model_->detachOgreObject(this->effect1Particle_->getParticleSystem());
+                delete this->effect1Particle_;
+            }
+            if (this->effect2Particle_)
+            {
+                this->model_->detachOgreObject(this->effect2Particle_->getParticleSystem());
+                delete this->effect2Particle_;
+            }
+        }
+    }
+
+
 	void ExplosionPart::XMLPort(Element& xmlelement, XMLPort::Mode mode)
 	{
 		SUPER(ExplosionPart, XMLPort, xmlelement, mode);
 
-		XMLPortParam(ExplosionPart, "mesh", setMesh, getMesh, xmlelement, mode);
-		XMLPortParam(ExplosionPart, "effect", setEffect, getEffect, xmlelement, mode);
+		XMLPortParam(ExplosionPart, "mesh", setMesh, getMesh, xmlelement, mode).defaultValues("");
+		XMLPortParam(ExplosionPart, "minspeed", setMinSpeed, getMinSpeed, xmlelement, mode).defaultValues(50);
+		XMLPortParam(ExplosionPart, "maxspeed", setMaxSpeed, getMaxSpeed, xmlelement, mode).defaultValues(100);
+		XMLPortParam(ExplosionPart, "effect1", setEffect1, getEffect1, xmlelement, mode).defaultValues("");
+		XMLPortParam(ExplosionPart, "effect2", setEffect2, getEffect2, xmlelement, mode).defaultValues("");
 
 
 	}
@@ -67,8 +90,6 @@
 	{
 		orxout() << "Explode" << endl;
 
-		orxout() << getMesh() << endl;
-		orxout() << getEffect() << endl;
 
 		this->model_->setVisible(true);
 
@@ -76,13 +97,19 @@
 
 		//this->model_->setSyncMode(0);
 
-		this->particleInterface_ = new ParticleInterface(this->getScene()->getSceneManager(), effect_, this->LOD_);
+		if(effect1_ != "")
+		{
+			this->effect1Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect1_, this->LOD_);
+			this->model_->attachOgreObject(this->effect1Particle_->getParticleSystem());
+		}
 
-		this->model_->attachOgreObject(this->particleInterface_->getParticleSystem());
+		if(effect2_ != "")
+		{
+			this->effect2Particle_ = new ParticleInterface(this->getScene()->getSceneManager(), effect2_, this->LOD_);
+			this->model_->attachOgreObject(this->effect2Particle_->getParticleSystem());
+		}	
 
-		
-
-		this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100));
+		this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(minSpeed_,maxSpeed_));
         this->explosionEntity_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(400).valueRadians());
         this->explosionEntity_->setScale(4);
 
@@ -90,29 +117,81 @@
 
         this->attach(explosionEntity_);
 
+        if (GameMode::isMaster())
+        {
+            this->destroyTimer_.setTimer(rnd(2, 3), false, createExecutor(createFunctor(&ExplosionPart::stop, this)));
+        }
+
 	}
 
+	void ExplosionPart::stop()
+	{
+		if (this->effect1Particle_)
+            this->effect1Particle_->setEnabled(false);
+        if (this->effect2Particle_)
+            this->effect2Particle_->setEnabled(false);
+        if (this->model_)
+            this->model_->setVisible(false);
 
+        if (GameMode::isMaster())
+        {
+            this->bStop_ = true;
+            this->destroyTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&ExplosionPart::destroy, this)));
+        }
+	}
 
 
+
+
 	void ExplosionPart::setMesh(const std::string& newString)
 	{
-		this->mesh_ = newString;
-		this->model_->setMeshSource(mesh_);
-		this->model_->setVisible(false);
-		orxout() << newString << endl;
+		if(newString != "")
+		{
+			this->mesh_ = newString;
+			this->model_->setMeshSource(mesh_);
+			this->model_->setVisible(false);
+		}
 	}
 
-	void ExplosionPart::setEffect(const std::string& newString)
+	void ExplosionPart::setEffect1(const std::string& newString)
 	{
-		this->effect_ = newString;
+		this->effect1_ = newString;
 	}
 
+	void ExplosionPart::setEffect2(const std::string& newString)
+	{
+		this->effect2_ = newString;
+	}
+
+	void ExplosionPart::setMinSpeed(float speed)
+	{
+		this->minSpeed_ = speed;
+	}
+
+	void ExplosionPart::setMaxSpeed(float speed)
+	{
+		this->maxSpeed_ = speed;
+	}
+
 	std::string& ExplosionPart::getMesh()
 	{ return this->mesh_; }
 
-	std::string& ExplosionPart::getEffect()
-	{ return this->effect_; }
+	std::string& ExplosionPart::getEffect1()
+	{ return this->effect1_; }
 
+	std::string& ExplosionPart::getEffect2()
+	{ return this->effect2_; }
 
+	float ExplosionPart::getMinSpeed()
+	{
+		return this->minSpeed_;
+	}
+
+	float ExplosionPart::getMaxSpeed()
+	{
+		return this->maxSpeed_;
+	}
+
+
+
 }
\ No newline at end of file

Modified: code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.h
===================================================================
--- code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.h	2015-11-09 13:14:47 UTC (rev 10785)
+++ code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.h	2015-11-09 14:51:17 UTC (rev 10786)
@@ -40,6 +40,7 @@
 #include "util/Exception.h"
 #include "core/command/Executor.h"
 #include "Scene.h"
+#include "tools/Timer.h"
 
 
  namespace orxonox
@@ -48,13 +49,21 @@
     {
         public:
             ExplosionPart(Context* context);
+            ~ExplosionPart();
             void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             void Explode();
+            void stop();
 
             void setMesh(const std::string& newString);
             std::string& getMesh();
-            void setEffect(const std::string& newString);
-            std::string& getEffect();
+            void setEffect1(const std::string& newString);
+            std::string& getEffect1();
+            void setEffect2(const std::string& newString);
+            std::string& getEffect2();
+            void setMinSpeed(float speed);
+            float getMinSpeed();
+            void setMaxSpeed(float speed);
+            float getMaxSpeed();
          
 
         private:
@@ -64,13 +73,20 @@
 
 
         	Model* model_;
-        	ParticleInterface* particleInterface_;
+        	ParticleInterface* effect1Particle_;
+            ParticleInterface* effect2Particle_;
 
+
+            float minSpeed_;
+            float maxSpeed_;
         	std::string mesh_;
-        	std::string effect_;
+        	std::string effect1_;
+            std::string effect2_;
 
             MovableEntity* explosionEntity_;
 
+            Timer destroyTimer_;
+
         	
 
     };

Modified: code/branches/explosionChunksHS15/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/explosionChunksHS15/src/orxonox/worldentities/pawns/Pawn.cc	2015-11-09 13:14:47 UTC (rev 10785)
+++ code/branches/explosionChunksHS15/src/orxonox/worldentities/pawns/Pawn.cc	2015-11-09 14:51:17 UTC (rev 10786)
@@ -373,7 +373,7 @@
             }
             if (GameMode::isMaster())
             {
-                this->deatheffect();
+                //this->deatheffect();
                 this->goWithStyle();
             }
         }




More information about the Orxonox-commit mailing list