[Orxonox-commit 2306] r7021 - in code/branches/presentation3/src/modules/weapons: . projectiles weaponmodes

gnadler at orxonox.net gnadler at orxonox.net
Sun May 30 15:57:05 CEST 2010


Author: gnadler
Date: 2010-05-30 15:57:05 +0200 (Sun, 30 May 2010)
New Revision: 7021

Modified:
   code/branches/presentation3/src/modules/weapons/RocketController.cc
   code/branches/presentation3/src/modules/weapons/RocketController.h
   code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc
   code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h
   code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
Log:
documentation & formatting commit

Modified: code/branches/presentation3/src/modules/weapons/RocketController.cc
===================================================================
--- code/branches/presentation3/src/modules/weapons/RocketController.cc	2010-05-30 13:46:08 UTC (rev 7020)
+++ code/branches/presentation3/src/modules/weapons/RocketController.cc	2010-05-30 13:57:05 UTC (rev 7021)
@@ -49,7 +49,6 @@
         this->rocket_ = new SimpleRocket(this);
         this->rocket_->setController(this);
         this->setControllableEntity(dynamic_cast<ControllableEntity*> (this->rocket_));
-        this->counter_=0;
     }
 
 
@@ -61,7 +60,6 @@
     */
     void RocketController::tick(float dt)
     {
-        counter_++;
 
         if (this->target_ && this->rocket_->hasFuel()) {
             this->setTargetPosition();
@@ -98,16 +96,17 @@
     {
         if (!this->getControllableEntity())
             return;
-        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
-        float distance = (target - this->getControllableEntity()->getWorldPosition()).length();
 
+        Vector2 coord = get2DViewdirection(this->rocket_->getPosition(), this->rocket_->getOrientation() * WorldEntity::FRONT, this->rocket_->getOrientation() * WorldEntity::UP, target);
+        float distance = (target - this->rocket_->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_->getVelocity().squaredLength()<160000) 
+            this->rocket_->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->rocket_->rotateYaw(-sgn(coord.x)*coord.x*coord.x);
+        this->rocket_->rotatePitch(sgn(coord.y)*coord.y*coord.y);
     }
 
 

Modified: code/branches/presentation3/src/modules/weapons/RocketController.h
===================================================================
--- code/branches/presentation3/src/modules/weapons/RocketController.h	2010-05-30 13:46:08 UTC (rev 7020)
+++ code/branches/presentation3/src/modules/weapons/RocketController.h	2010-05-30 13:57:05 UTC (rev 7021)
@@ -51,7 +51,8 @@
 			virtual ~RocketController();
             
             virtual void tick(float dt);
-			SimpleRocket* getRocket(){return this->rocket_;};
+			SimpleRocket* getRocket() const
+             {  return this->rocket_;  };
 			void setTarget(WorldEntity* target);
         protected:
 			void moveToPosition(const Vector3& target);
@@ -59,12 +60,11 @@
 			void moveToTargetPosition();
 
         private:
-			SimpleRocket* rocket_;
+			SimpleRocket* rocket_; //!<The Rocket it controlls
 			Vector3 targetPosition_;
 			WeakPtr<PlayerInfo> player_;
 						
 			WeakPtr<WorldEntity> target_;
-            int counter_;
 
 
     };

Modified: code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-30 13:46:08 UTC (rev 7020)
+++ code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-30 13:57:05 UTC (rev 7021)
@@ -44,13 +44,16 @@
 
 namespace orxonox
 {
+        /**
+    @file
+    @brief
+        SimpleRocket, follows direction from a Rocketcontroller, has fuel for 80% of its lifetime, afterwords it's fire disappears.
+    @author
+       Gabriel Nadler (Original file: Oli Scheuss)
+    */
     CreateFactory(SimpleRocket);
-    // create the factory for the SimpleRocket
 
-    /**
-    @brief
-        Constructor. Registers the object and initializes some default values.
-    */
+
     SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator)
     {
         RegisterObject(SimpleRocket);// - register the SimpleRocket class to the core
@@ -58,9 +61,9 @@
         this->localAngularVelocity_ = 0;
         this->bDestroy_ = false;
         this->lifetime_ = 120;
+
         this->setMass(15);
         COUT(4) << "simplerocket constructed\n";
-        this->maxLife_=90;
 
         if (GameMode::isMaster())
         {
@@ -91,45 +94,47 @@
         }
 
     }
-   
 
 
-
+    
+    /**
+    * @brief updates state of rocket, disables fire if no fuel
+    * @param dt tick-length
+    */
     void SimpleRocket::tick(float dt)
     {
 
         SUPER(SimpleRocket, tick, dt);
         if ( GameMode::isMaster() )
         {
-            if (this->getVelocity().squaredLength() >130000)
-                this->maxLife_-=dt; //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_)
             {
-                if (this->destroyTimer_.getRemainingTime()<  this->lifetime_-this->maxLife_ ) 
+                if (this->destroyTimer_.getRemainingTime()<  (static_cast<float>(this->FUEL_PERCENTAGE)/100) *this->lifetime_ ) 
                     this->fuel_=false;
-            }
-            else 
+            } else
                 this->disableFire();
 
-            if( this->bDestroy_ )
+            if( this->bDestroy_ ) 
                 this->destroy();
         }
                 
     }
 
+    /**
+    * @brief Sets the Acceleration to 0 and detaches the fire
+    * @return void
+    */
     void SimpleRocket::disableFire()
     {
-        this->setAcceleration(0,0,0);
-        this->fire_->destroy();
-        this->fire_ = 0;
-//         this->fire_->detachFromParent();
+        this->setAcceleration(0,0,0);        
+        this->fire_->detachFromParent();
     }
 
     /**s
@@ -143,7 +148,6 @@
             if( GameMode::isMaster() )
             {
                 this->getController()->destroy();
-                COUT(4)<< "simplerocket destroyed\n";
             }
         }
     }
@@ -161,12 +165,12 @@
     void SimpleRocket::setOwner(Pawn* owner)
     {
         this->owner_ = owner;
-        //this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
         this->player_ = this->owner_->getPlayer();
     }
 
 
 
+
     bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     {
         if (!this->bDestroy_ && GameMode::isMaster())

Modified: code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h
===================================================================
--- code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-30 13:46:08 UTC (rev 7020)
+++ code/branches/presentation3/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-30 13:57:05 UTC (rev 7021)
@@ -26,6 +26,16 @@
  *
  */
 
+    /**
+    @file
+    @brief
+        SimpleRocket, follows direction from a Rocketcontroller, has fuel for 80% of its lifetime, afterwords it's fire disappears.
+    @author
+       Gabriel Nadler (Original file: Oli Scheuss)
+    */
+
+
+
 #ifndef _SimpleRocket_H__
 #define _SimpleRocket_H__
 
@@ -39,13 +49,7 @@
 {
     class ConeCollisionShape;
 
-    /**
-    @brief
-        SimpleRocket, that is made to move upon a specified pattern.
-        This class was constructed for the PPS tutorial.
-    @author
-        Oli Scheuss
-    */
+
     class _WeaponsExport SimpleRocket : public ControllableEntity
     {
         public:
@@ -57,7 +61,7 @@
             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
             void destroyObject();
 
-            void disableFire();
+            void disableFire(); //!< Method to disable the fire and stop all acceleration
 
             virtual void moveFrontBack(const Vector2& value){}
             virtual void moveRightLeft(const Vector2& value){}
@@ -111,12 +115,9 @@
             void setOwner(Pawn* owner);
             inline Pawn* getOwner() const
                 { return this->owner_; }
-            inline bool hasFuel()
-            { return this->fuel_;}
+            inline bool hasFuel() const
+            { return this->fuel_; }
 
-            inline void fuelRefill()
-            {this->fuel_=true;}
-
             inline void setDamage(float damage)
                 { this->damage_ = damage; }
             inline float getDamage() const
@@ -127,16 +128,16 @@
             WeakPtr<Pawn> owner_;
             Vector3 localAngularVelocity_;
             float damage_;
-            bool bDestroy_;
-            bool fuel_;
+            bool bDestroy_; 
+            bool fuel_; //!< Bool is true while the rocket "has fuel"
 
 
             WeakPtr<PlayerInfo> player_;
             Timer destroyTimer_;
             float lifetime_;
-            float maxLife_;
+            static const int FUEL_PERCENTAGE=80; //!<Percentage of Lifetime the rocket has fuel
 
-            ParticleEmitter* fire_;
+            ParticleEmitter* fire_; //!< Fire-Emittor
 
 
 

Modified: code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-30 13:46:08 UTC (rev 7020)
+++ code/branches/presentation3/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-30 13:57:05 UTC (rev 7021)
@@ -39,6 +39,13 @@
 
 namespace orxonox
 {
+       /**
+    @file
+    @brief
+        FireMode for target-seeking Rocket
+        @author
+        Gabriel Nadler (Original file: Oli Scheuss)
+        */
     CreateFactory(SimpleRocketFire);
 
     SimpleRocketFire::SimpleRocketFire(BaseObject* creator) : WeaponMode(creator)




More information about the Orxonox-commit mailing list