[Orxonox-commit 2184] r6900 - in code/branches/rocket/src/modules/weapons: . projectiles weaponmodes

gnadler at orxonox.net gnadler at orxonox.net
Fri May 14 12:41:04 CEST 2010


Author: gnadler
Date: 2010-05-14 12:41:04 +0200 (Fri, 14 May 2010)
New Revision: 6900

Modified:
   code/branches/rocket/src/modules/weapons/RocketController.cc
   code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
   code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
   code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
Log:
rockentcontroller doesn't control the rocket it spawns itself. 
Rocket collides wih asteroids& at least drones but does not despawn.

Modified: code/branches/rocket/src/modules/weapons/RocketController.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.cc	2010-05-13 11:19:04 UTC (rev 6899)
+++ code/branches/rocket/src/modules/weapons/RocketController.cc	2010-05-14 10:41:04 UTC (rev 6900)
@@ -41,11 +41,12 @@
     */
     RocketController::RocketController(BaseObject* creator) : Controller(creator)
     {
+		RegisterObject(RocketController);
 		COUT(0)<< "RocketController constructed\n";
 
-        RegisterObject(RocketController);
+        
 		this->rocket = new SimpleRocket(this);
-		this->rocket->setController(dynamic_cast<RocketController*>(this));
+		this->rocket->setController(this);
 		this->setControllableEntity(dynamic_cast<ControllableEntity*> (rocket));
 		this->haha=0;
     }
@@ -62,17 +63,13 @@
 		haha++;
 
         SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity());
-		rocket->setAcceleration(rocket->getAcceleration()*2);
-		if (haha < 100) rocket->rotateYaw(10);
-		else {
-		if (rand() > 0.5) rocket->rotateRoll(5); 
-		else rocket->rotatePitch(5);
-		}
+		rocket->moveRightLeft(5);
+	
+	}
 
-    }
 
-
 	RocketController::~RocketController() {
+
 		
 		COUT(0)<< "RocketController destroyed\n";
 	}

Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-13 11:19:04 UTC (rev 6899)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-14 10:41:04 UTC (rev 6900)
@@ -61,8 +61,8 @@
 		COUT(0)<< "simplerocket constructed\n";
 
 
-        //if (GameMode::isMaster())
-        //{
+        if (GameMode::isMaster())
+       {
            this->setCollisionType(WorldEntity::Kinematic);
             this->setVelocity(0,0,100);
 
@@ -86,9 +86,13 @@
             this->attachCollisionShape(collisionShape);
 
             this->destroyTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&SimpleRocket::destroyObject, this)));
-       // }
+        }
 
     }
+	void SimpleRocket::tick(float dt)
+    {
+        SUPER(SimpleRocket, tick, dt);
+	}
 
     /**s
     @brief

Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-13 11:19:04 UTC (rev 6899)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-14 10:41:04 UTC (rev 6900)
@@ -50,7 +50,7 @@
         public:
             SimpleRocket(BaseObject* creator);
             virtual ~SimpleRocket();
-
+			virtual void tick(float dt);
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a SimpleRocket through XML.
 
             virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);

Modified: code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-13 11:19:04 UTC (rev 6899)
+++ code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-14 10:41:04 UTC (rev 6900)
@@ -60,7 +60,6 @@
 
     void SimpleRocketFire::fire()
     {
-        //SimpleRocket* rocket = new SimpleRocket(this);
 		RocketController* con = new RocketController(this);
 		SimpleRocket* rocket = con->getRocket();
 		this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
@@ -68,22 +67,6 @@
 		Vector3 pos = this->getMuzzlePosition() + (this->getMuzzleOrientation()* Vector3(-2, -3, -2));
         rocket->setPosition(pos);
 		rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
-		//Ogre::Vector3 vec = this->getMuzzlePosition();
-		//vec.normalise();
-		//rocket->setAcceleration(100*vec);
 		rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
-		//con->getRocket()->setPosition(this->getMuzzlePosition());
-	//con->setControllableEntity(dynamic_cast<rocket*>(ControllableEntity));
-	//con->getControllableEntity()->setPosition(this->getMuzzlePosition());
-
-        /* this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
-        rocket->setOrientation(this->getMuzzleOrientation());
-        rocket->setPosition(this->getMuzzlePosition());
-		rocket->scale(10);
-        rocket->setVelocity(this->getMuzzleDirection() * this->speed_);
-        rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
-        rocket->setDamage(this->getDamage()); 
-        rocket->scale(2);
-		*/
     }
 }




More information about the Orxonox-commit mailing list