[Orxonox-commit 2250] r6966 - in code/branches/rocket2: data/levels data/particle src/modules/weapons src/modules/weapons/projectiles src/modules/weapons/weaponmodes src/orxonox/controllers src/orxonox/graphics

gnadler at orxonox.net gnadler at orxonox.net
Wed May 26 16:28:15 CEST 2010


Author: gnadler
Date: 2010-05-26 16:28:14 +0200 (Wed, 26 May 2010)
New Revision: 6966

Added:
   code/branches/rocket2/data/particle/simplerocketfire.particle
Modified:
   code/branches/rocket2/data/levels/tutorial.oxw
   code/branches/rocket2/src/modules/weapons/RocketController.cc
   code/branches/rocket2/src/modules/weapons/RocketController.h
   code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.cc
   code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.h
   code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
   code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.h
   code/branches/rocket2/src/orxonox/controllers/DroneController.cc
   code/branches/rocket2/src/orxonox/graphics/Model.cc
Log:
now rocket slows and then finally stops after a given number of ticks (aka fuel).
rocket speeds up if distance is greater than x (right now 1000 but can be changed).
collisionShape not yet fixed.

Modified: code/branches/rocket2/data/levels/tutorial.oxw
===================================================================
--- code/branches/rocket2/data/levels/tutorial.oxw	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/data/levels/tutorial.oxw	2010-05-26 14:28:14 UTC (rev 6966)
@@ -13,6 +13,9 @@
    skybox       = "Orxonox/skypanoramagen1"
   >
 
+  
+  
+  
 <Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10" mass= "50" linearDamping = "0.9" angularDamping = "0.7">
   <attached>
     <Model scale="1" mesh="drone.mesh"/>

Added: code/branches/rocket2/data/particle/simplerocketfire.particle
===================================================================
--- code/branches/rocket2/data/particle/simplerocketfire.particle	                        (rev 0)
+++ code/branches/rocket2/data/particle/simplerocketfire.particle	2010-05-26 14:28:14 UTC (rev 6966)
@@ -0,0 +1,50 @@
+	particle_system Orxonox/simplerocketfire
+{
+	quota	300
+	material	PE/explosion
+	particle_width	5
+	particle_height	2
+	cull_each	false
+	renderer	billboard
+	sorted	false
+	local_space	false
+	iteration_interval	0
+	nonvisible_update_timeout	0
+	billboard_type	point
+	billboard_origin	center
+	billboard_rotation_type	texcoord
+	common_up_vector	0 1 0
+	point_rendering	false
+	accurate_facing	false
+
+	emitter Ellipsoid
+	{
+		angle	2
+		colour	1 0.682759 1 1
+		colour_range_start	1 0.682759 1 1
+		colour_range_end	1 0.682759 1 1
+		direction	0 0 1
+		emission_rate	1200
+		position	0 0 3
+		velocity	10
+		velocity_min	10
+		velocity_max	48
+		time_to_live	0.1
+		time_to_live_min	0.1
+		time_to_live_max	0.2
+		duration	0
+		duration_min	0
+		duration_max	0
+		repeat_delay	0
+		repeat_delay_min	0
+		repeat_delay_max	0
+		width	0.8
+		height	0.8
+		depth	7
+	}
+
+	affector Scaler
+	{
+		rate	-20
+	}
+}

Modified: code/branches/rocket2/src/modules/weapons/RocketController.cc
===================================================================
--- code/branches/rocket2/src/modules/weapons/RocketController.cc	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/modules/weapons/RocketController.cc	2010-05-26 14:28:14 UTC (rev 6966)
@@ -1,30 +1,30 @@
 /*
- *   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:
- *     Gabriel Nadler, Originalfile: Oli Scheuss
- *   Co-authors:
- *      ...
- *
- */
+*   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:
+*     Gabriel Nadler, Originalfile: Oli Scheuss
+*   Co-authors:
+*      ...
+*
+*/
 
 #include "RocketController.h"
 #include "projectiles/SimpleRocket.h" 
@@ -38,38 +38,37 @@
 {
     /**
     @brief
-        Constructor.
+    Constructor.
     */
     RocketController::RocketController(BaseObject* creator) : Controller(creator)
     {
         RegisterObject(RocketController);
         COUT(5)<< "RocketController constructed\n";
 
-        
-        this->rocket = new SimpleRocket(this);
-        this->rocket->setController(this);
-        this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
-        this->haha=0;
+
+        this->rocket_ = new SimpleRocket(this);
+        this->rocket_->setController(this);
+        this->setControllableEntity(dynamic_cast<ControllableEntity*> (this->rocket_));
+        this->counter_=0;
     }
 
 
     /**
     @brief
-        The controlling happens here. This method defines what the controller has to do each tick.
+    The controlling happens here. This method defines what the controller has to do each tick.
     @param dt
-        The duration of the tick.
+    The duration of the tick.
     */
     void RocketController::tick(float dt)
     {
-        haha++;
+        counter_++;
 
-        //if (haha<30)this->rocket->setVelocity(rocket->getVelocity()*1.03);
-        if (this->target_) {
+        if (this->target_ && this->rocket_->hasFuel()) {
             this->setTargetPosition();
             this->moveToTargetPosition();
         }
-        if (haha>500) rocket->setDestroy();;
-
+        
+        
     }
 
 
@@ -93,45 +92,23 @@
     void RocketController::setTarget(WorldEntity* target)
     {
         this->target_ = target;
-        CCOUT(4) << "got target" << endl;
     }
 
     void RocketController::moveToPosition(const Vector3& target)
     {
         if (!this->getControllableEntity())
             return;
-        float dx = target.x-this->getControllableEntity()->getPosition().x;
-        float dy = target.y-this->getControllableEntity()->getPosition().y;
-        COUT(4)<<"\n diff: ";
-        COUT(4)<<target-this->getControllableEntity()->getPosition() << endl;
-        //COUT(0)<<"\n 2D view: ";
-        /* COUT(0)<<this->getControllableEntity()->getPosition().x;
-        COUT(0)<<" ";
-        COUT(0)<<this->getControllableEntity()->getPosition().y;
-        COUT(0)<<" ";
-        COUT(0)<<this->getControllableEntity()->getPosition().z;
-        COUT(0)<<"\n";*/
+     
         Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
-        float distance = (target - this->getControllableEntity()->getPosition()).length();
-        //Vector3D diff =target-this->rocket->getPosition();
-        COUT(4) << "viewdirection: "<< coord << endl;
-        //COUT(0)<<"  ";
-        //COUT(0)<<coord.y;
+        float distance = (target - this->getControllableEntity()->getWorldPosition()).length();
+
+
+        if (distance > 1000&&this->getControllableEntity()->getVelocity().squaredLength()<160000) 
+            this->getControllableEntity()->setAcceleration(this->rocket_->getOrientation()*Vector3(-20,-20,-20));
+        if (distance <1000) this->rocket_->setAcceleration(0,0,0);
+        
         this->getControllableEntity()->rotateYaw(-sgn(coord.x)*coord.x*coord.x);
         this->getControllableEntity()->rotatePitch(sgn(coord.y)*coord.y*coord.y);
-//         this->getControllableEntity()->rotateYaw(10);
-//         this->getControllableEntity()->rotatePitch(0);
-        //this->getControllableEntity()->rotatePitch(rotation.getPitch().valueRadians());
-        //this->getControllableEntity()->rotateYaw(rotation.getYaw().valueRadians());
-        //this->getControllableEntity()->moveUpDown(coord.y);
-        //this->getControllableEntity()->moveRightLeft(coord.x);
-        //this->getControllableEntity()->rotatePitch(coord);
-   //     if (this->target_ || distance > 10)
-   //     {
-   //         // Multiply with 0.8 to make them a bit slower
-            //this->getControllableEntity()->rotateYaw(coord.x );
-   //         this->getControllableEntity()->rotatePitch(coord.y);
-   //     }
     }
 
 

Modified: code/branches/rocket2/src/modules/weapons/RocketController.h
===================================================================
--- code/branches/rocket2/src/modules/weapons/RocketController.h	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/modules/weapons/RocketController.h	2010-05-26 14:28:14 UTC (rev 6966)
@@ -40,7 +40,7 @@
 {
     /**
     @brief
-        Controller for the Drone of the PPS tutorial.
+        Controller for the Rocket (targetseeking)
     @author
         Gabriel Nadler, Originalfile: Oli Scheuss
     */
@@ -51,7 +51,7 @@
 			virtual ~RocketController();
             
             virtual void tick(float dt);
-			SimpleRocket* getRocket(){return this->rocket;};
+			SimpleRocket* getRocket(){return this->rocket_;};
 			void setTarget(WorldEntity* target);
         protected:
 			void moveToPosition(const Vector3& target);
@@ -59,11 +59,12 @@
 			void moveToTargetPosition();
 
         private:
-			SimpleRocket* rocket;
+			SimpleRocket* rocket_;
 			Vector3 targetPosition_;
 			WeakPtr<PlayerInfo> player_;
-						int haha;
+						
 			WeakPtr<WorldEntity> target_;
+            int counter_;
 
 
     };

Modified: code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-26 14:28:14 UTC (rev 6966)
@@ -58,50 +58,85 @@
         this->localAngularVelocity_ = 0;
         this->bDestroy_ = false;
         this->lifetime_ = 100;
+        this->setMass(15);
         COUT(4) << "simplerocket constructed\n";
+        this->counter_=0;
+        this->slowing_=false;
 
-
         if (GameMode::isMaster())
        {
             this->setCollisionType(WorldEntity::Kinematic);
-            //this->setVelocity(0,0,100);
+            this->fuel_=true;
 
             Model* model = new Model(this);
             model->setMeshSource("rocket.mesh");
             model->scale(0.7f);
             this->attach(model);
 
-            ParticleEmitter* fire = new ParticleEmitter(this);
-            this->attach(fire);
-            fire->setOrientation(this->getOrientation());
-            fire->setSource("Orxonox/rocketfire2");
-
+            this->fire_ = new ParticleEmitter(this);
+            this->attach(this->fire_);
+           
+            this->fire_->setOrientation(this->getOrientation());
+            this->fire_->setSource("Orxonox/simplerocketfire");
             this->enableCollisionCallback();
             this->setCollisionResponse(false);
             this->setCollisionType(Kinematic);
 
             // TODO: fix the orientation and size of this collision shape to match the rocket
             ConeCollisionShape* collisionShape = new ConeCollisionShape(this);
-            collisionShape->setRadius(3);
-            collisionShape->setHeight(5);
+            collisionShape->setOrientation(this->getOrientation());
+            collisionShape->setRadius(1.5f);
+            collisionShape->setHeight(200);
             this->attachCollisionShape(collisionShape);
+            
 
             this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this)));
         }
 
     }
-    
+   
+    void SimpleRocket::disableFire(){
+        this->setAcceleration(0,0,0);
+        this->setVelocity(Vector3(0,0,0));
+        
+        this->fire_->detachFromParent();
+        //this->fire_->setVisible(false);
+
+    }
+
+
     void SimpleRocket::tick(float dt)
     {
+
         SUPER(SimpleRocket, tick, dt);
+        counter_++;
+        if (this->getVelocity().squaredLength() >130000 && !slowing_) counter_++; //if Velocity bigger than about 360, uses a lot more "fuel" :)
 
             this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
             this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
             this->localAngularVelocity_ = 0;
 
+            
+            if (this->fuel_) {
+                COUT(0)<<this->getVelocity().length()<<endl;
+                if (this->counter_>1000 && counter_%12==0) 
+                    
+                    if (!this->slowing_) {
+                        this->setAcceleration(this->getOrientation()*Vector3(10,10,10));
+                        this->slowing_=true;
+                    }
+
+                if (this->counter_ > 1800) 
+                    this->fuel_=false;
+            }
             if( this->bDestroy_ )
                 this->destroy();
+            if (!this->fuel_) 
+                this->disableFire();
         
+           
+            
+        
     }
 
     /**s
@@ -135,6 +170,7 @@
     }
 
 
+
     bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     {
         if (!this->bDestroy_ && GameMode::isMaster())

Modified: code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.h
===================================================================
--- code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-26 14:28:14 UTC (rev 6966)
@@ -33,6 +33,7 @@
 
 #include "tools/Timer.h"
 #include "worldentities/ControllableEntity.h"
+#include "graphics/ParticleSpawner.h"
 
 namespace orxonox
 {
@@ -56,6 +57,8 @@
             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
             void destroyObject();
 
+            void disableFire();
+
             virtual void moveFrontBack(const Vector2& value){}
             virtual void moveRightLeft(const Vector2& value){}
             virtual void moveUpDown(const Vector2& value){}
@@ -95,7 +98,7 @@
             @param value  The amount by which the SimpleRocket is to be rotated.
             */
             inline void rotatePitch(float value)
-            {   COUT(0)<<"rotated rocket yaw";
+            {   
 				this->rotatePitch(Vector2(value, 0)); }
             /**
             @brief Rotates the SimpleRocket around the z-axis by the specifed amount.
@@ -103,13 +106,17 @@
             */
             inline void rotateRoll(float value)
             { 
-				COUT(0)<<"rotated rocket roll";
 				this->rotateRoll(Vector2(value, 0)); }
 
             void setOwner(Pawn* owner);
             inline Pawn* getOwner() const
                 { return this->owner_; }
+            inline bool hasFuel()
+            { return this->fuel_;}
 
+            inline void fuelRefill()
+            {this->fuel_=true;}
+
             inline void setDamage(float damage)
                 { this->damage_ = damage; }
             inline float getDamage() const
@@ -122,12 +129,17 @@
             Vector3 localAngularVelocity_;
             float damage_;
             bool bDestroy_;
+            bool fuel_;
+            bool slowing_;
+            int counter_;
 
 
             WeakPtr<PlayerInfo> player_;
             Timer destroyTimer_;
             float lifetime_;
+            ParticleEmitter* fire_;
 
+
     };
 
 }

Modified: code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-26 14:28:14 UTC (rev 6966)
@@ -45,7 +45,7 @@
     {
         RegisterObject(SimpleRocketFire);
 
-        this->reloadTime_ = 0.20f;
+        this->reloadTime_ = 4;
         this->bParallelReload_ = false;
         this->damage_ = 100;
         this->speed_ = 300;
@@ -63,18 +63,12 @@
         RocketController* con = new RocketController(this);
         SimpleRocket* rocket = con->getRocket();
         this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
-//      rocket->setOrientation(this->getMuzzleOrientation());
         rocket->setOrientation(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getWorldOrientation());
-        Vector3 pos = this->getMuzzlePosition();
-        rocket->setPosition(pos);
-//      rocket->setAcceleration(20*rocket->getOrientation() * WorldEntity::FRONT);
+        rocket->setPosition(this->getMuzzlePosition());
         rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
         rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
         rocket->setDamage(this->damage_);
         WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
-        if (pawnn)
-        {
-            con->setTarget(pawnn);
-        }
+        if (pawnn) con->setTarget(pawnn);
     }
 }

Modified: code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.h
===================================================================
--- code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.h	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/modules/weapons/weaponmodes/SimpleRocketFire.h	2010-05-26 14:28:14 UTC (rev 6966)
@@ -39,11 +39,12 @@
         public:
             SimpleRocketFire(BaseObject* creator);
             virtual ~SimpleRocketFire();
-
+            void deactivateFire();
             virtual void fire();
 
         private:
             float speed_;
+
     };
 }
 

Modified: code/branches/rocket2/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/rocket2/src/orxonox/controllers/DroneController.cc	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/orxonox/controllers/DroneController.cc	2010-05-26 14:28:14 UTC (rev 6966)
@@ -71,8 +71,8 @@
         // - moveFrontBack, moveRightLeft, moveUpDown 
         // - rotatePitch, rotateYaw, rotateRoll 
         // - apply the to myDrone (e.g. myDrone->rotateYaw(..) ) 
-		myDrone->rotatePitch(0.08);
-		myDrone->moveFrontBack(1);
+		//myDrone->rotatePitch(0.08);
+		//myDrone->moveFrontBack(1);
 
     }
 }

Modified: code/branches/rocket2/src/orxonox/graphics/Model.cc
===================================================================
--- code/branches/rocket2/src/orxonox/graphics/Model.cc	2010-05-24 14:59:23 UTC (rev 6965)
+++ code/branches/rocket2/src/orxonox/graphics/Model.cc	2010-05-26 14:28:14 UTC (rev 6966)
@@ -148,7 +148,7 @@
 
                         
                         //Generiert LOD-Levels
-                        this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
+                        //this->mesh_.getEntity()->getMesh()->generateLodLevels(distList, Ogre::ProgressiveMesh::VRQ_PROPORTIONAL, reductionValue);
                     }
                     else
                     {




More information about the Orxonox-commit mailing list