[Orxonox-commit 1364] r6082 - in code/branches/particles2/src: modules/weapons/projectiles orxonox/infos

scheusso at orxonox.net scheusso at orxonox.net
Tue Nov 17 22:57:44 CET 2009


Author: scheusso
Date: 2009-11-17 22:57:44 +0100 (Tue, 17 Nov 2009)
New Revision: 6082

Modified:
   code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
   code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
   code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
   code/branches/particles2/src/orxonox/infos/PlayerInfo.h
Log:
some fixes in Rocket
there are two new function ins PlayerInfo: startTemporaryControl and stopTemporaryControl which expand start/stop-Control but without removing the player from the currently controlled controllable entity


Modified: code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc
===================================================================
--- code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc	2009-11-17 10:58:38 UTC (rev 6081)
+++ code/branches/particles2/src/modules/weapons/projectiles/Rocket.cc	2009-11-17 21:57:44 UTC (rev 6082)
@@ -54,9 +54,10 @@
         this->setCollisionType(WorldEntity::Kinematic);
         this->setVelocity(0,0,-100);
         this->model_ = new Model(this);
-        this->model_->setMeshSource("can.mesh");
+        this->model_->setMeshSource("rocket_test.mesh");
         this->attach(this->model_);
         this->lifetime_ = 100;
+        this->bDestroy_ = false;
         
         if (GameMode::isMaster())
         {
@@ -73,7 +74,7 @@
         }
         
         this->camPosition_ = new CameraPosition(this);
-        this->camPosition_->setPosition(0,0,0);
+        this->camPosition_->setPosition(0,10,40);
         this->attach( this->camPosition_ );
         this->addCameraPosition( this->camPosition_ );
     }
@@ -89,8 +90,8 @@
             this->collisionShape_->destroy();
             this->model_->destroy();
             
-            if (GameMode::isMaster() && this->owner_)
-                this->owner_->getPlayer()->startControl(this->originalControllableEntity_);
+            if (GameMode::isMaster() && this->player_)
+                this->player_->stopTemporaryControl();
             this->camPosition_->destroy();
         }
     }
@@ -108,10 +109,10 @@
     void Rocket::setOwner(Pawn* owner)
     {
         this->owner_ = owner;
-            
+        
         this->originalControllableEntity_ = this->owner_->getPlayer()->getControllableEntity();
-        this->originalControllableEntity_->setDestroyWhenPlayerLeft( false );
-        this->owner_->getPlayer()->startControl(this);
+        this->player_ = this->owner_->getPlayer();
+        this->owner_->getPlayer()->startTemporaryControl(this);
     }
 
     /**
@@ -125,19 +126,11 @@
         SUPER(Rocket, tick, dt);
         
         this->setAngularVelocity(this->getOrientation() * this->localAngularVelocity_);
-        this->setVelocity( (this->getOrientation()*WorldEntity::FRONT)*100 );
+        this->setVelocity( this->getOrientation()*WorldEntity::FRONT*this->getVelocity().length() );
         this->localAngularVelocity_ = 0;
-//         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
-//         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
-//         if (this->localLinearAcceleration_.z() > 0)
-//             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
-//         else
-//             this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
-//         this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
-//         this->localLinearAcceleration_.setValue(0, 0, 0);
-//     
-//         this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
-//         this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
+        
+        if( this->bDestroy_ )
+            this->destroy();
     }
     
     bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
@@ -146,7 +139,7 @@
         {
             if (otherObject == this->owner_)
                 return false;
-
+            
             this->bDestroy_ = true;
 
             if (this->owner_)
@@ -176,6 +169,7 @@
             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
             if (victim)
                 victim->damage(dmg, this->owner_);
+//             this->destroy();
         }
         return false;
     }
@@ -194,7 +188,7 @@
     */
     void Rocket::rotateYaw(const Vector2& value)
     {
-        this->localAngularVelocity_.y = value.x;
+        this->localAngularVelocity_.y += value.x;
     }
 
     /**
@@ -205,7 +199,7 @@
     */
     void Rocket::rotatePitch(const Vector2& value)
     {
-        this->localAngularVelocity_.x = value.x;
+        this->localAngularVelocity_.x += value.x;
     }
 
     /**
@@ -216,7 +210,7 @@
     */
     void Rocket::rotateRoll(const Vector2& value)
     {
-        this->localAngularVelocity_.z = value.x;
+        this->localAngularVelocity_.z += value.x;
     }
     
 }

Modified: code/branches/particles2/src/modules/weapons/projectiles/Rocket.h
===================================================================
--- code/branches/particles2/src/modules/weapons/projectiles/Rocket.h	2009-11-17 10:58:38 UTC (rev 6081)
+++ code/branches/particles2/src/modules/weapons/projectiles/Rocket.h	2009-11-17 21:57:44 UTC (rev 6082)
@@ -109,7 +109,7 @@
                 { this->damage_ = damage; }
             inline float getDamage() const
                 { return this->damage_; }
-            virtual void fire(unsigned int firemode) {}
+            virtual void fire(unsigned int firemode) { this->destroy(); }
             
         private:
             WeakPtr<Pawn> owner_;
@@ -121,6 +121,7 @@
             Model* model_;
             CameraPosition* camPosition_;
             ConeCollisionShape* collisionShape_;
+            PlayerInfo* player_;
             Timer destroyTimer_;
             float lifetime_;
     };

Modified: code/branches/particles2/src/orxonox/infos/PlayerInfo.cc
===================================================================
--- code/branches/particles2/src/orxonox/infos/PlayerInfo.cc	2009-11-17 10:58:38 UTC (rev 6081)
+++ code/branches/particles2/src/orxonox/infos/PlayerInfo.cc	2009-11-17 21:57:44 UTC (rev 6082)
@@ -162,7 +162,30 @@
 
         this->changedControllableEntity();
     }
+    
+    void PlayerInfo::startTemporaryControl(ControllableEntity* entity)
+    {
+        if (!entity || entity == this->controllableEntity_)
+            return;
 
+//         if (this->controllableEntity_)
+//             this->stopControl();
+
+        this->oldControllableEntity_ = this->controllableEntity_;
+
+        this->controllableEntity_ = entity;
+        this->controllableEntityID_ = entity->getObjectID();
+
+        entity->setPlayer(this);
+
+        this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
+
+        if (this->controller_)
+            this->controller_->setControllableEntity(entity);
+
+        this->changedControllableEntity();
+    }
+
     void PlayerInfo::stopControl()
     {
         ControllableEntity* entity = this->controllableEntity_;
@@ -177,10 +200,34 @@
             this->controller_->setControllableEntity(0);
 
         entity->removePlayer();
+        
+        if ( this->oldControllableEntity_ )
+        {
+            this->oldControllableEntity_->removePlayer();
+            this->oldControllableEntity_ = 0;
+        }
 
         this->changedControllableEntity();
     }
+    
+    void PlayerInfo::stopTemporaryControl()
+    {
+        ControllableEntity* entity = this->controllableEntity_;
 
+        if (!entity)
+            return;
+
+        this->controllableEntity_ = this->oldControllableEntity_.get();
+        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
+
+        if (this->controller_)
+            this->controller_->setControllableEntity(this->controllableEntity_);
+
+        entity->removePlayer();
+        
+        this->changedControllableEntity();
+    }
+
     void PlayerInfo::networkcallback_changedcontrollableentityID()
     {
         if (this->controllableEntityID_ != OBJECTID_UNKNOWN)

Modified: code/branches/particles2/src/orxonox/infos/PlayerInfo.h
===================================================================
--- code/branches/particles2/src/orxonox/infos/PlayerInfo.h	2009-11-17 10:58:38 UTC (rev 6081)
+++ code/branches/particles2/src/orxonox/infos/PlayerInfo.h	2009-11-17 21:57:44 UTC (rev 6082)
@@ -68,6 +68,8 @@
 
             void startControl(ControllableEntity* entity);
             void stopControl();
+            void startTemporaryControl(ControllableEntity* entity);
+            void stopTemporaryControl();
 
             inline ControllableEntity* getControllableEntity() const
                 { return this->controllableEntity_; }
@@ -95,6 +97,7 @@
             bool bReadyToSpawn_;
             Controller* controller_;
             ControllableEntity* controllableEntity_;
+            WeakPtr<ControllableEntity> oldControllableEntity_;
             unsigned int controllableEntityID_;
 
             const GametypeInfo* gtinfo_;




More information about the Orxonox-commit mailing list