[Orxonox-commit 482] r3054 - in branches/particles/src/orxonox: . objects/worldentities objects/worldentities/pawns

decapitb at orxonox.net decapitb at orxonox.net
Mon May 25 12:37:19 CEST 2009


Author: decapitb
Date: 2009-05-25 12:37:19 +0200 (Mon, 25 May 2009)
New Revision: 3054

Added:
   branches/particles/src/orxonox/objects/worldentities/BigExplosion.cc
   branches/particles/src/orxonox/objects/worldentities/BigExplosion.h
Modified:
   branches/particles/src/orxonox/OrxonoxPrereqs.h
   branches/particles/src/orxonox/objects/worldentities/CMakeLists.txt
   branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.cc
   branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.h
Log:
everything

Modified: branches/particles/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- branches/particles/src/orxonox/OrxonoxPrereqs.h	2009-05-25 02:19:14 UTC (rev 3053)
+++ branches/particles/src/orxonox/OrxonoxPrereqs.h	2009-05-25 10:37:19 UTC (rev 3054)
@@ -142,6 +142,7 @@
     class Model;
     class Billboard;
     class BlinkingBillboard;
+    class BigExplosion;
     class ExplosionChunk;
     class FadingBillboard;
     class GlobalShader;

Added: branches/particles/src/orxonox/objects/worldentities/BigExplosion.cc
===================================================================
--- branches/particles/src/orxonox/objects/worldentities/BigExplosion.cc	                        (rev 0)
+++ branches/particles/src/orxonox/objects/worldentities/BigExplosion.cc	2009-05-25 10:37:19 UTC (rev 3054)
@@ -0,0 +1,379 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin de Capitani
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BigExplosion.h"
+#include "MovableEntity.h"
+#include "Model.h"
+
+#include <OgreParticleSystem.h>
+#include <OgreSceneNode.h>
+
+#include "core/Core.h"
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "objects/Scene.h"
+#include "tools/ParticleInterface.h"
+#include "objects/worldentities/ParticleSpawner.h"
+#include "util/Exception.h"
+
+namespace orxonox
+{
+    CreateFactory(BigExplosion);
+
+    BigExplosion::BigExplosion(BaseObject* creator) : MovableEntity(creator)
+    {
+        RegisterObject(BigExplosion);
+
+        if ( Core::showsGraphics() && ( !this->getScene() || !this->getScene()->getSceneManager() ) )
+            ThrowException(AbortLoading, "Can't create BigExplosion, no scene or no scene manager given.");
+
+        this->bStop_ = false;
+        this->LOD_ = LODParticle::normal;
+
+        if ( Core::showsGraphics() )
+        {
+            try
+            {
+                this->init();
+            }
+            catch (...)
+            {
+                COUT(1) << "Error: Couln't load particle effect in BigExplosion." << std::endl;
+                this->initZero();
+            }
+        }
+        else
+        {
+            this->initZero();
+        }
+
+        if (Core::isMaster())
+        {
+            Vector3 velocity(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1));
+            velocity.normalise();
+            velocity *= rnd(20, 30);
+            this->setVelocity(velocity);
+
+            this->destroyTimer_.setTimer(rnd(4, 7), false, this, createExecutor(createFunctor(&BigExplosion::stop)));
+        }
+        this->registerVariables();
+    }
+
+    void BigExplosion::init()
+    {
+        Identifier* idDE1 = Class(MovableEntity);
+        BaseObject* oDE1 = idDE1->fabricate(this);
+        this->debrisEntity1_ = dynamic_cast<MovableEntity*>(oDE1);
+
+        Identifier* idDE2 = Class(MovableEntity);
+        BaseObject* oDE2 = idDE2->fabricate(this);
+        this->debrisEntity2_ = dynamic_cast<MovableEntity*>(oDE2);
+
+        Identifier* idDE3 = Class(MovableEntity);
+        BaseObject* oDE3 = idDE3 ->fabricate(this);
+        this->debrisEntity3_ = dynamic_cast<MovableEntity*>(oDE3);
+
+        Identifier* idDE4 = Class(MovableEntity);
+        BaseObject* oDE4 = idDE4->fabricate(this);
+        this->debrisEntity4_ = dynamic_cast<MovableEntity*>(oDE4);
+
+        Identifier* idD1 = Class(Model);
+        BaseObject* oD1 = idD1->fabricate(this);
+        this->debris1_ = dynamic_cast<Model*>(oD1);
+
+        Identifier* idD2 = Class(Model);
+        BaseObject* oD2 = idD2->fabricate(this);
+        this->debris2_ = dynamic_cast<Model*>(oD2);
+
+        Identifier* idD3 = Class(Model);
+        BaseObject* oD3 = idD3->fabricate(this);
+        this->debris3_ = dynamic_cast<Model*>(oD3);
+
+        Identifier* idD4 = Class(Model);
+        BaseObject* oD4 = idD4->fabricate(this);
+        this->debris4_ = dynamic_cast<Model*>(oD4);
+
+        Identifier* id6 = Class(StaticEntity);
+        BaseObject* object4 = id6->fabricate(this);
+        this->explosion_ = dynamic_cast<StaticEntity*>(object4);
+
+        this->debrisSmoke1_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
+        this->debrisSmoke2_ =  new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
+        this->debrisSmoke3_ =  new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
+        this->debrisSmoke4_ =  new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_);
+
+        this->debrisFire1_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_);
+        this->debrisFire2_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_);
+        this->debrisFire3_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_);
+        this->debrisFire4_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_);
+
+        this->debris1_->attachOgreObject(this->debrisSmoke1_->getParticleSystem());
+        this->debris1_->attachOgreObject(this->debrisFire1_->getParticleSystem());
+        this->debris2_->attachOgreObject(this->debrisSmoke2_->getParticleSystem());
+        this->debris2_->attachOgreObject(this->debrisFire2_->getParticleSystem());
+        this->debris3_->attachOgreObject(this->debrisSmoke3_->getParticleSystem());
+        this->debris3_->attachOgreObject(this->debrisFire3_->getParticleSystem());
+        this->debris4_->attachOgreObject(this->debrisSmoke4_->getParticleSystem());
+        this->debris4_->attachOgreObject(this->debrisFire4_->getParticleSystem());
+
+        this->debris1_->setMeshSource("CockpitDebris.mesh");
+        this->debris2_->setMeshSource("WingDebris1.mesh");
+        this->debris3_->setMeshSource("BodyDebris1.mesh");
+        this->debris4_->setMeshSource("WingDebris1.mesh");
+
+        this->debrisEntity1_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100));
+        this->debrisEntity1_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(1000).valueRadians());
+        this->debrisEntity1_->setScale(4);
+
+        this->debrisEntity2_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100));
+        this->debrisEntity2_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(1000).valueRadians());
+        this->debrisEntity2_->setScale(4);
+
+        this->debrisEntity3_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100));
+        this->debrisEntity3_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(1000).valueRadians());
+        this->debrisEntity3_->setScale(4);
+
+        this->debrisEntity4_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100));
+        this->debrisEntity4_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(1000).valueRadians());
+        this->debrisEntity4_->setScale(4);
+
+        this->debrisEntity1_->attach(debris1_);
+        this->debrisEntity2_->attach(debris2_);
+        this->debrisEntity3_->attach(debris3_);
+        this->debrisEntity4_->attach(debris4_);
+
+        ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
+        effect->setDestroyAfterLife(true);
+        effect->setSource("Orxonox/explosion2b");
+        effect->setLifetime(4.0f);
+
+        ParticleSpawner* effect2 = new ParticleSpawner(this->getCreator());
+        effect2->setDestroyAfterLife(true);
+        effect2->setSource("Orxonox/smoke6");
+        effect2->setLifetime(4.0f);
+
+        this->explosion_->attach(effect);
+        this->explosion_->attach(effect2);
+
+        this->attach(explosion_);
+        this->attach(debrisEntity1_);
+        this->attach(debrisEntity2_);
+        this->attach(debrisEntity3_);
+        this->attach(debrisEntity4_);
+
+
+        for(int i=0;i<50;i++)
+        {
+            Identifier* idf1 = Class(Model);
+            BaseObject* obj1 = idf1->fabricate(this);
+            Model* part1 = dynamic_cast<Model*>(obj1);
+
+
+            Identifier* idf2 = Class(Model);
+            BaseObject* obj2 = idf2->fabricate(this);
+            Model* part2 = dynamic_cast<Model*>(obj2);
+
+            Identifier* idf3 = Class(MovableEntity);
+            BaseObject* obj3 = idf3->fabricate(this);
+            MovableEntity* partEntity1 = dynamic_cast<MovableEntity*>(obj3);
+
+            Identifier* idf4 = Class(MovableEntity);
+            BaseObject* obj4 = idf4->fabricate(this);
+            MovableEntity* partEntity2 = dynamic_cast<MovableEntity*>(obj4);
+
+            partEntity1->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10,100));
+            partEntity1->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(1000).valueRadians());
+            partEntity1->setScale(2);
+
+            partEntity2->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(10, 100));
+            partEntity2->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(1000).valueRadians());
+            partEntity2->setScale(2);
+
+            part1->setMeshSource("SmallPart1.mesh");
+            part2->setMeshSource("SmallPart2.mesh");
+
+            partEntity1->attach(part1);
+            partEntity2->attach(part2);
+
+            this->attach(partEntity1);
+            this->attach(partEntity2);
+        }
+    }
+
+    void BigExplosion::initZero()
+    {
+        this->debrisFire1_ = 0;
+        this->debrisFire2_ = 0;
+        this->debrisFire3_ = 0;
+        this->debrisFire4_ = 0;
+
+        this->debrisSmoke1_ = 0;
+        this->debrisSmoke2_ = 0;
+        this->debrisSmoke3_ = 0;
+        this->debrisSmoke4_ = 0;
+
+        this->explosionSmoke_=0;
+        this->explosionFire_=0;
+    }
+
+    BigExplosion::~BigExplosion()
+    {
+        if (this->isInitialized())
+        {
+            if (this->debrisFire1_)
+            {
+                this->debris1_->detachOgreObject(this->debrisFire1_->getParticleSystem());
+                delete this->debrisFire1_;
+            }
+            if (this->debrisSmoke1_)
+            {
+                this->debris1_->detachOgreObject(this->debrisSmoke1_->getParticleSystem());
+                delete this->debrisSmoke1_;
+            }
+
+            if (this->debrisFire2_)
+            {
+                this->debris2_->detachOgreObject(this->debrisFire2_->getParticleSystem());
+                delete this->debrisFire2_;
+            }
+            if (this->debrisSmoke2_)
+            {
+                this->debris2_->detachOgreObject(this->debrisSmoke2_->getParticleSystem());
+                delete this->debrisSmoke2_;
+            }
+
+            if (this->debrisFire3_)
+            {
+                this->debris3_->detachOgreObject(this->debrisFire3_->getParticleSystem());
+                delete this->debrisFire3_;
+            }
+            if (this->debrisSmoke3_)
+            {
+                this->debris3_->detachOgreObject(this->debrisSmoke3_->getParticleSystem());
+                delete this->debrisSmoke3_;
+            }
+
+            if (this->debrisFire4_)
+            {
+                this->debris4_->detachOgreObject(this->debrisFire4_->getParticleSystem());
+                delete this->debrisFire4_;
+            }
+            if (this->debrisSmoke4_)
+            {
+                this->debris4_->detachOgreObject(this->debrisSmoke4_->getParticleSystem());
+                delete this->debrisSmoke4_;
+            }
+        }
+    }
+
+    void BigExplosion::registerVariables()
+    {
+        registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<BigExplosion>(this, &BigExplosion::LODchanged));
+        registerVariable(this->bStop_,       variableDirection::toclient, new NetworkCallback<BigExplosion>(this, &BigExplosion::checkStop));
+    }
+
+    void BigExplosion::LODchanged()
+    {
+        if (this->debrisFire1_)
+            this->debrisFire1_->setDetailLevel(this->LOD_);
+        if (this->debrisSmoke1_)
+            this->debrisSmoke1_->setDetailLevel(this->LOD_);
+
+        if (this->debrisFire2_)
+            this->debrisFire2_->setDetailLevel(this->LOD_);
+        if (this->debrisSmoke2_)
+            this->debrisSmoke2_->setDetailLevel(this->LOD_);
+
+        if (this->debrisFire3_)
+            this->debrisFire3_->setDetailLevel(this->LOD_);
+        if (this->debrisSmoke3_)
+            this->debrisSmoke3_->setDetailLevel(this->LOD_);
+
+        if (this->debrisFire4_)
+            this->debrisFire4_->setDetailLevel(this->LOD_);
+        if (this->debrisSmoke4_)
+            this->debrisSmoke4_->setDetailLevel(this->LOD_);
+    }
+
+    void BigExplosion::checkStop()
+    {
+        if (this->bStop_)
+            this->stop();
+    }
+
+    void BigExplosion::stop()
+    {
+        if (this->debrisFire1_)
+            this->debrisFire1_->setEnabled(false);
+        if (this->debrisSmoke1_)
+            this->debrisSmoke1_->setEnabled(false);
+
+        if (this->debrisFire2_)
+            this->debrisFire2_->setEnabled(false);
+        if (this->debrisSmoke2_)
+            this->debrisSmoke2_->setEnabled(false);
+
+        if (this->debrisFire3_)
+            this->debrisFire3_->setEnabled(false);
+        if (this->debrisSmoke3_)
+            this->debrisSmoke3_->setEnabled(false);
+
+        if (this->debrisFire4_)
+            this->debrisFire4_->setEnabled(false);
+        if (this->debrisSmoke4_)
+            this->debrisSmoke4_->setEnabled(false);
+
+        if (Core::isMaster())
+        {
+            this->bStop_ = true;
+            this->destroyTimer_.setTimer(1.0f, false, this, createExecutor(createFunctor(&BigExplosion::destroy)));
+        }
+    }
+
+    void BigExplosion::destroy()
+    {
+        delete this;
+    }
+
+     void BigExplosion::tick(float dt)
+    {
+
+
+//        static const unsigned int CHANGES_PER_SECOND = 5;
+//
+//        if (Core::isMaster() && rnd() < dt*CHANGES_PER_SECOND)
+//        {
+//            Vector3 velocity = this->object2_->getVelocity();
+//            velocity /= 1.5;
+//            this->object2_->setVelocity(velocity);
+//        }
+
+        SUPER(BigExplosion, tick, dt);
+    }
+}

Added: branches/particles/src/orxonox/objects/worldentities/BigExplosion.h
===================================================================
--- branches/particles/src/orxonox/objects/worldentities/BigExplosion.h	                        (rev 0)
+++ branches/particles/src/orxonox/objects/worldentities/BigExplosion.h	2009-05-25 10:37:19 UTC (rev 3054)
@@ -0,0 +1,94 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin de Capitani
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _BigExplosion_H__
+#define _BigExplosion_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "MovableEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BigExplosion : public MovableEntity
+    {
+        public:
+            BigExplosion(BaseObject* creator);
+            virtual ~BigExplosion();
+
+            virtual void tick(float dt);
+            void registerVariables();
+
+            inline void setLOD(LODParticle::LOD level)
+                { this->LOD_ = level; this->LODchanged(); }
+            inline LODParticle::LOD getLOD() const
+                { return this->LOD_; }
+
+        private:
+
+            void LODchanged();
+            void checkStop();
+            void stop();
+            void destroy();
+            void init();
+            void initZero();
+
+            bool                  bStop_;
+
+            StaticEntity*         explosion_;
+
+            MovableEntity*        debrisEntity1_;
+            MovableEntity*        debrisEntity2_;
+            MovableEntity*        debrisEntity3_;
+            MovableEntity*        debrisEntity4_;
+
+            Model*                debris1_;
+            Model*                debris2_;
+            Model*                debris3_;
+            Model*                debris4_;
+
+            ParticleInterface*    debrisSmoke1_;
+            ParticleInterface*    debrisSmoke2_;
+            ParticleInterface*    debrisSmoke3_;
+            ParticleInterface*    debrisSmoke4_;
+
+            ParticleInterface*    debrisFire1_;
+            ParticleInterface*    debrisFire2_;
+            ParticleInterface*    debrisFire3_;
+            ParticleInterface*    debrisFire4_;
+
+            ParticleInterface*    explosionSmoke_;
+            ParticleInterface*    explosionFire_;
+
+            LODParticle::LOD      LOD_;
+            Timer<BigExplosion> destroyTimer_;
+    };
+}
+
+#endif /* _BigExplosion_H__ */

Modified: branches/particles/src/orxonox/objects/worldentities/CMakeLists.txt
===================================================================
--- branches/particles/src/orxonox/objects/worldentities/CMakeLists.txt	2009-05-25 02:19:14 UTC (rev 3053)
+++ branches/particles/src/orxonox/objects/worldentities/CMakeLists.txt	2009-05-25 10:37:19 UTC (rev 3054)
@@ -8,6 +8,7 @@
   Backlight.cc
   Billboard.cc
   BlinkingBillboard.cc
+  BigExplosion.cc	
   ExplosionChunk.cc
   FadingBillboard.cc
   Light.cc

Modified: branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.cc
===================================================================
--- branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-25 02:19:14 UTC (rev 3053)
+++ branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.cc	2009-05-25 10:37:19 UTC (rev 3054)
@@ -38,6 +38,7 @@
 #include "objects/gametypes/Gametype.h"
 #include "objects/worldentities/ParticleSpawner.h"
 #include "objects/worldentities/ExplosionChunk.h"
+#include "objects/worldentities/BigExplosion.h"
 
 namespace orxonox
 {
@@ -128,8 +129,9 @@
         this->fire_ = this->firehack_;
         this->firehack_ = 0x0;
 
-        if (this->health_ <= 0)
+        if (this->health_ <= 0 && bAlive_){
             this->death();
+        }
     }
 
     void Pawn::setPlayer(PlayerInfo* player)
@@ -211,12 +213,21 @@
                 this->getPlayer()->stopControl(this);
 
             if (Core::isMaster())
-                this->deatheffect();
+            // this->deathEffect();
+                this->goWithStyle();
         }
         else
             this->setHealth(1);
     }
+    void Pawn::goWithStyle()
+    {
+        this->bAlive_ = false;
+        this->setDestroyWhenPlayerLeft(false);
 
+        BigExplosion* chunk = new BigExplosion(this->getCreator());
+        chunk->setPosition(this->getPosition());
+
+    }
     void Pawn::deatheffect()
     {
         // play death effect

Modified: branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.h
===================================================================
--- branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-25 02:19:14 UTC (rev 3053)
+++ branches/particles/src/orxonox/objects/worldentities/pawns/Pawn.h	2009-05-25 10:37:19 UTC (rev 3054)
@@ -113,6 +113,7 @@
 
         protected:
             virtual void death();
+            virtual void goWithStyle();
             virtual void deatheffect();
             virtual void spawneffect();
 




More information about the Orxonox-commit mailing list