[Orxonox-commit 6244] r10901 - in code/branches/particleEffectsHS15: data/particle src/modules/weapons/projectiles

holzerj at orxonox.net holzerj at orxonox.net
Mon Nov 30 17:23:16 CET 2015


Author: holzerj
Date: 2015-11-30 17:23:15 +0100 (Mon, 30 Nov 2015)
New Revision: 10901

Added:
   code/branches/particleEffectsHS15/data/particle/MineExpl.particle
   code/branches/particleEffectsHS15/data/particle/MineExpl1.particle
   code/branches/particleEffectsHS15/data/particle/MineExpl2.particle
   code/branches/particleEffectsHS15/data/particle/mineparticle.particle
   code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.cc
   code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.h
Log:
Added explosions effects when the mine explodes.

Added: code/branches/particleEffectsHS15/data/particle/MineExpl.particle
===================================================================
--- code/branches/particleEffectsHS15/data/particle/MineExpl.particle	                        (rev 0)
+++ code/branches/particleEffectsHS15/data/particle/MineExpl.particle	2015-11-30 16:23:15 UTC (rev 10901)
@@ -0,0 +1,107 @@
+particle_system Orxonox/MineExpl
+{
+	material PE/lensflare
+	particle_width 65.0
+	particle_height 40.0
+	quota 500
+	cull_each false
+	sorted false
+	local_space false
+	iteration_interval 0.0
+	nonvisible_update_timeout 0.0
+	billboard_type oriented_self
+	billboard_origin center
+	billboard_rotation_type vertex
+	point_rendering false
+	accurate_facing false
+
+	emitter Point
+	{
+		position 0.0 0.0 0.0
+		direction -1.0 0.0 0.0
+		angle 55
+		emission_rate 1250
+		velocity_min 300
+		velocity_max 300
+		time_to_live_min 1
+		time_to_live_max 2
+		duration_min 0.1
+		duration_max 0.1
+		repeat_delay_min 10
+		repeat_delay_max 10
+		colour_range_start 0 0.333333 1 1
+		colour_range_end 0 0.333333 1 1
+	}
+
+	emitter Point
+	{
+		position 0.0 0.0 0.0
+		direction 1.0 0.0 0.0
+		angle 55
+		emission_rate 200
+		velocity_min 300
+		velocity_max 300
+		time_to_live_min 1
+		time_to_live_max 2
+		duration_min 0.1
+		duration_max 0.1
+		repeat_delay_min 10
+		repeat_delay_max 10
+		colour_range_start 0 0.333333 1 1
+		colour_range_end 0 0.333333 1 1
+	}
+
+	emitter Point
+	{
+		position 0.0 0.0 0.0
+		direction 0.0 0.0 -1.0
+		angle 55
+		emission_rate 1250
+		velocity_min 300
+		velocity_max 300
+		time_to_live_min 1
+		time_to_live_max 2
+		duration_min 0.1
+		duration_max 0.1
+		repeat_delay_min 10
+		repeat_delay_max 10
+		colour_range_start 0 0.333333 1 1
+		colour_range_end 0 0.333333 1 1
+	}
+
+	emitter Point
+	{
+		position 0.0 0.0 0.0
+		direction 0.0 0.0 1.0
+		angle 55
+		emission_rate 1250
+		velocity_min 300
+		velocity_max 300
+		time_to_live_min 1
+		time_to_live_max 2
+		duration_min 0.1
+		duration_max 0.1
+		repeat_delay_min 10
+		repeat_delay_max 10
+		colour_range_start 0 0.333333 1 1
+		colour_range_end 0 0.333333 1 1
+	}
+
+	affector DeflectorPlane
+	{
+		plane_point 0 -2 0
+		plane_normal 0 1 0
+		bounce 1
+	}
+
+	affector DeflectorPlane
+	{
+		plane_point 0 2 0
+		plane_normal 0 -1 0
+		bounce 1
+	}
+	affector Scaler
+	{
+		rate -2
+	}
+}

Added: code/branches/particleEffectsHS15/data/particle/MineExpl1.particle
===================================================================
--- code/branches/particleEffectsHS15/data/particle/MineExpl1.particle	                        (rev 0)
+++ code/branches/particleEffectsHS15/data/particle/MineExpl1.particle	2015-11-30 16:23:15 UTC (rev 10901)
@@ -0,0 +1,46 @@
+particle_system Orxonox/MineExpl1
+{
+	material PE/lensflare
+	particle_width 35.0
+	particle_height 35.0
+	quota 500
+	cull_each false
+	sorted false
+	local_space false
+	iteration_interval 0.0
+	nonvisible_update_timeout 0.0
+	billboard_type oriented_self
+	billboard_origin center
+	billboard_rotation_type vertex
+	point_rendering false
+	accurate_facing false
+
+	emitter Point
+	{
+		position 0.0 0.0 0.0
+		direction 0.0 1.0 0.0
+		angle 30
+		emission_rate 2000
+		velocity_min 300
+		velocity_max 300
+		time_to_live_min 1
+		time_to_live_max 2
+		duration_min 0.5
+		duration_max 1.5
+		repeat_delay_min 0.0
+		repeat_delay_max 0.0
+		colour_range_start 0 0.333333 1 1
+		colour_range_end 0 0.333333 1 1
+	}
+
+	affector DirectionRandomiser
+	{
+		randomness 5
+		scope 1
+		keep_velocity true
+	}
+	affector Scaler
+	{
+		rate -2
+	}
+}

Added: code/branches/particleEffectsHS15/data/particle/MineExpl2.particle
===================================================================
--- code/branches/particleEffectsHS15/data/particle/MineExpl2.particle	                        (rev 0)
+++ code/branches/particleEffectsHS15/data/particle/MineExpl2.particle	2015-11-30 16:23:15 UTC (rev 10901)
@@ -0,0 +1,46 @@
+particle_system Orxonox/MineExpl2
+{
+	material PE/lensflare
+	particle_width 35.0
+	particle_height 35.0
+	quota 500
+	cull_each false
+	sorted false
+	local_space false
+	iteration_interval 0.0
+	nonvisible_update_timeout 0.0
+	billboard_type oriented_self
+	billboard_origin center
+	billboard_rotation_type vertex
+	point_rendering false
+	accurate_facing false
+
+	emitter Point
+	{
+		position 0.0 0.0 0.0
+		direction 0.0 -1.0 0.0
+		angle 30
+		emission_rate 2000
+		velocity_min 300
+		velocity_max 300
+		time_to_live_min 1
+		time_to_live_max 2
+		duration_min 0.5
+		duration_max 1.5
+		repeat_delay_min 0.0
+		repeat_delay_max 0.0
+		colour_range_start 0 0.333333 1 1
+		colour_range_end 0 0.333333 1 1
+	}
+
+	affector DirectionRandomiser
+	{
+		randomness 5
+		scope 1
+		keep_velocity true
+	}
+	affector Scaler
+	{
+		rate -2
+	}
+}

Added: code/branches/particleEffectsHS15/data/particle/mineparticle.particle
===================================================================
--- code/branches/particleEffectsHS15/data/particle/mineparticle.particle	                        (rev 0)
+++ code/branches/particleEffectsHS15/data/particle/mineparticle.particle	2015-11-30 16:23:15 UTC (rev 10901)
@@ -0,0 +1,53 @@
+particle_system Orxonox/mineparticle
+{
+	material PE/lensflare
+	particle_width 5.0
+	particle_height 5.0
+	quota 2000
+	cull_each true
+	sorted true
+	local_space false
+	iteration_interval 0.0
+	nonvisible_update_timeout 0.0
+	billboard_type point
+	billboard_origin bottom_right
+	billboard_rotation_type vertex
+	point_rendering false
+	accurate_facing false
+
+	emitter HollowEllipsoid
+	{
+		position 0.0 0.0 0.0
+		direction 0.0 0.0 1.0
+		angle 0
+		width 20
+		height 20
+		depth 20
+		inner_width 0.99
+		inner_height 0.99
+		inner_depth 0.99
+		emission_rate 20.12
+		velocity_min 1
+		velocity_max 1
+		time_to_live_min 5
+		time_to_live_max 5
+		duration_min 0
+		duration_max 0
+		repeat_delay_min 0
+		repeat_delay_max 0
+		colour_range_start 1 0 0 1
+		colour_range_end 1 0 0 1
+	}
+
+	affector Scaler
+	{
+		rate -2
+	}
+	affector Rotator
+	{
+		rotation_speed_range_start 100
+		rotation_speed_range_end 500
+		rotation_range_start 0
+		rotation_range_end 180
+	}
+}

Added: code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.cc
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.cc	                        (rev 0)
+++ code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.cc	2015-11-30 16:23:15 UTC (rev 10901)
@@ -0,0 +1,234 @@
+/*
+ *   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:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MineProjectile.h
+    @brief Implementation of the MineProjectile class.
+*/
+
+#include "MineProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "graphics/Model.h"
+#include "core/command/Executor.h"
+#include "graphics/ParticleSpawner.h"
+#include "worldentities/pawns/Pawn.h"
+
+namespace orxonox
+{
+    RegisterClass(MineProjectile);
+
+    MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile()
+    {
+        RegisterObject(MineProjectile);
+
+        this->bActive_ = false;
+        this->maxTimeUntilExplosion_ = 10.0f;
+        this->timeUntilActivation_ = 1.0f;
+
+        rings1_ = new MovableEntity(this->getContext());
+        this->attach(rings1_);
+        rings1_->setPosition(Vector3(0.0,0.0,0.0));
+        rings1_->setAngularVelocity(Vector3(0.0,5.0,0.0));
+
+        rings2_ = new MovableEntity(this->getContext());
+        this->attach(rings2_);
+        rings2_->setPosition(Vector3(0.0,0.0,0.0));
+        rings2_->setAngularVelocity(Vector3(0.0,0.0,5.0));
+
+        core_ = new MovableEntity(this->getContext());
+        this->attach(core_);
+        core_->setPosition(Vector3(0.0,0.0,0.0));
+        core_->setAngularVelocity(Vector3(2.5,2.5,0.0));
+
+
+    //MODELS
+        //Core
+        modelCore_ = new Model(this->getContext());
+        modelCore_->setMeshSource("Mine_Core.mesh");
+        modelCore_->setScale(15.0);
+        core_->attach(modelCore_);
+        modelCore_->setPosition(Vector3(0,0,0));
+
+        //1
+        modelRing1_ = new Model(this->getContext());
+        modelRing1_->setMeshSource("Mine_Ring.mesh");
+        modelRing1_->setScale(15.0);
+        rings1_->attach(modelRing1_);
+        modelRing1_->setPosition(Vector3(0,0,0));
+        modelRing1_->yaw(Degree(0));
+        //2
+        modelRing2_ = new Model(this->getContext());
+        modelRing2_->setMeshSource("Mine_Ring.mesh");
+        modelRing2_->setScale(15.0);
+        rings1_->attach(modelRing2_);
+        modelRing2_->setPosition(Vector3(0,0,0));
+        modelRing2_->yaw(Degree(180));
+        //3
+        modelRing3_ = new Model(this->getContext());
+        modelRing3_->setMeshSource("Mine_Ring.mesh");
+        modelRing3_->setScale(15.0);
+        rings2_->attach(modelRing3_);
+        modelRing3_->setPosition(Vector3(0,0,0));
+        modelRing3_->yaw(Degree(90));
+        //4
+        modelRing4_ = new Model(this->getContext());
+        modelRing4_->setMeshSource("Mine_Ring.mesh");
+        modelRing4_->setScale(15.0);
+        rings2_->attach(modelRing4_);
+        modelRing4_->setPosition(Vector3(0,0,0));
+        modelRing4_->yaw(Degree(270));
+
+        // Add effect.
+        emitter_ = new ParticleEmitter(this->getContext());
+        this->attach(emitter_);
+        emitter_->setOrientation(this->getOrientation());
+        emitter_->setSource("Orxonox/mineparticle");  
+
+        if (GameMode::isMaster())
+        {
+            this->setMass(10.0f);
+            this->setFriction(100.0f);
+            this->enableCollisionCallback();
+            this->setCollisionResponse(false);
+            this->setCollisionType(Dynamic);
+
+            // Create a sphere collision shape and attach it to the projectile.
+            collisionShape_ = new SphereCollisionShape(this->getContext());
+            collisionShape_->setRadius(10.0f);
+            this->attachCollisionShape(collisionShape_);
+
+            // Create a distance trigger and attach it to the projectile.
+            distanceTrigger_ = new DistanceTrigger(this->getContext());
+            this->attach(distanceTrigger_);
+            distanceTrigger_->setPosition(Vector3(0,0,0));
+            distanceTrigger_->setDistance(40.0f);
+            distanceTrigger_->addTarget("Pawn");
+            distanceTrigger_->setStayActive(true);
+        }
+    }
+
+    MineProjectile::~MineProjectile()
+    {
+        /*if (modelCore_ != NULL)
+        {
+            modelCore_->destroy();
+        }*/
+        /*if (distanceTrigger_ != NULL)
+        {
+            distanceTrigger_->destroy();
+        }*/
+    }
+
+    /**
+    @brief
+        TODO
+    */
+    void MineProjectile::setMaxTimeUntilExplosion(float maxTimeUntilExplosion)
+    {
+        if (maxTimeUntilExplosion >= 0)
+        {
+            this->maxTimeUntilExplosion_ = maxTimeUntilExplosion;
+            if (GameMode::isMaster())
+            {
+                this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::Explode, this)));
+            }
+        }
+        else
+        {
+            this->maxTimeUntilExplosion_ = 0;
+        }
+    }
+
+    /**
+    @brief
+        TODO
+    */
+    void MineProjectile::setTimeUntilActivation(float timeUntilActivation)
+    {
+        timeUntilActivation_ = timeUntilActivation;
+
+        if (GameMode::isMaster())
+        {
+            this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this)));
+        }
+    }
+
+    /**
+    @brief
+        TODO
+    */
+    void MineProjectile::Explode()
+    {
+        orxout() << "MineProjectile::Explode" << endl;
+        destructionEffect();
+
+        this->destroyLater();
+
+
+    }
+
+    /**
+    @brief
+        TODO
+    */
+    void MineProjectile::Activate()
+    {
+        orxout() << "MineProjectile::Activate" << endl;
+
+        bActive_ = true;
+    }
+
+
+    void MineProjectile::destructionEffect()
+    {
+        ParticleSpawner *effect1, *effect2, *effect3;
+       
+            effect1 = new ParticleSpawner(this->getContext());
+            effect2 = new ParticleSpawner(this->getContext());
+            effect3 = new ParticleSpawner(this->getContext());
+
+        effect1->setPosition(this->getPosition());
+        effect1->setOrientation(this->getOrientation());
+        effect1->setDestroyAfterLife(true);
+        effect1->setSource("Orxonox/MineExpl");
+        effect1->setLifetime(2.5f);
+
+        effect2->setPosition(this->getPosition());
+        effect2->setOrientation(this->getOrientation());
+        effect2->setDestroyAfterLife(true);
+        effect2->setSource("Orxonox/MineExpl1");
+        effect2->setLifetime(2.5f);
+
+        effect3->setPosition(this->getPosition());
+        effect3->setOrientation(this->getOrientation());
+        effect3->setDestroyAfterLife(true);
+        effect3->setSource("Orxonox/MineExpl2");
+        effect3->setLifetime(2.5f);
+    }
+}

Added: code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.h
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.h	                        (rev 0)
+++ code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile2.h	2015-11-30 16:23:15 UTC (rev 10901)
@@ -0,0 +1,86 @@
+/*
+ *   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:
+ *      Fabien Vultier
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MineProjectile.h
+    @brief Definition of the MineProjectile class.
+*/
+
+#ifndef _MineProjectile_H__
+#define _MineProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "tools/Timer.h"
+#include "worldentities/MovableEntity.h"
+#include "objects/collisionshapes/SphereCollisionShape.h"
+#include "objects/triggers/DistanceTrigger.h"
+#include "BasicProjectile.h"
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        TODO
+    @ingroup WeaponsProjectiles
+    */
+    class _WeaponsExport MineProjectile : public MovableEntity, public BasicProjectile
+    {
+        public:
+            MineProjectile(Context* context);
+            virtual ~MineProjectile();
+
+            virtual void setMaxTimeUntilExplosion(float maxTimeUntilExplosion);
+            virtual void setTimeUntilActivation(float timeUntilActivation);
+            void destructionEffect();
+
+        private:
+            bool bActive_; // The mine can only explode if it is active
+            float maxTimeUntilExplosion_;
+            float timeUntilActivation_;
+            Timer activationTimer_;
+            Timer explodeTimer_;
+            Model* modelCore_;
+            Model* modelRing1_;
+            Model* modelRing2_;
+            Model* modelRing3_;
+            Model* modelRing4_;
+            MovableEntity* rings1_;
+            MovableEntity* rings2_;
+            MovableEntity* core_;
+            ParticleEmitter* emitter_;
+
+            WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
+            WeakPtr<DistanceTrigger> distanceTrigger_;
+
+            virtual void Activate();
+            virtual void Explode();
+    };
+}
+
+#endif /* _MineProjectile_H__ */




More information about the Orxonox-commit mailing list