[Orxonox-commit 2189] r6905 - in code/branches/rocket/src: modules/weapons modules/weapons/projectiles modules/weapons/weaponmodes orxonox/controllers orxonox/worldentities

gnadler at orxonox.net gnadler at orxonox.net
Sat May 15 18:12:13 CEST 2010


Author: gnadler
Date: 2010-05-15 18:12:13 +0200 (Sat, 15 May 2010)
New Revision: 6905

Modified:
   code/branches/rocket/src/modules/weapons/RocketController.cc
   code/branches/rocket/src/modules/weapons/RocketController.h
   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
   code/branches/rocket/src/orxonox/controllers/DroneController.cc
   code/branches/rocket/src/orxonox/controllers/DroneController.h
   code/branches/rocket/src/orxonox/controllers/NewHumanController.cc
   code/branches/rocket/src/orxonox/controllers/NewHumanController.h
   code/branches/rocket/src/orxonox/worldentities/Drone.cc
Log:
rockets get target but moveToPosition function does not work correctly.

Modified: code/branches/rocket/src/modules/weapons/RocketController.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.cc	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/modules/weapons/RocketController.cc	2010-05-15 16:12:13 UTC (rev 6905)
@@ -62,13 +62,17 @@
     void RocketController::tick(float dt)
     {
 		haha++;
+		
 
         SimpleRocket *rocket = static_cast<SimpleRocket*>(this->getControllableEntity());
+		if (haha<30)rocket->setVelocity(rocket->getVelocity()*1.03);
 		if (this->target_) {
-		rocket->rotatePitch(0.5);
-		rocket->rotateYaw(0.5);
+			this->setTargetPosition();
+			this->moveToTargetPosition();
+		
 		}
-		rocket->setVelocity(rocket->getVelocity()*1.03);
+		
+		if (haha>500) rocket->setDestroy();;
 	
 	}
 
@@ -79,12 +83,41 @@
 		COUT(0)<< "RocketController destroyed\n";
 	}
 
+	void RocketController::setTargetPosition() {
+		this->targetPosition_=this->target_->getPosition();
+		//this->targetPosition_ = getPredictedPosition(this->getControllableEntity()->getPosition(),this->getControllableEntity()->getVelocity().length() , this->target_->getPosition(), this->target_->getVelocity());
+	}
+	void RocketController::moveToTargetPosition() {
+		this->moveToPosition(this->targetPosition_);
+	}
 
-	void RocketController::setTarget(Pawn* target) {
+
+
+	void RocketController::setTarget(WorldEntity* target) {
 		this->target_ = target;
+		COUT(0)<<"got target\n";
 	}
 
+	void RocketController::moveToPosition(const Vector3& target)
+    {
+       if (!this->getControllableEntity())
+            return;
 
+	   COUT(0)<<"moving";
 
+        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
+        float distance = (target - this->getControllableEntity()->getPosition()).length();
 
+        if (this->target_ || distance > 10)
+        {
+            // Multiply with 0.8 to make them a bit slower
+			 this->getControllableEntity()->rotateYaw(-0.2f * sgn(coord.x) * coord.x*coord.x);
+            this->getControllableEntity()->rotatePitch(0.2f * sgn(coord.y) * coord.y*coord.y);
+			
+        }
+    }
+
+
+
+
 }

Modified: code/branches/rocket/src/modules/weapons/RocketController.h
===================================================================
--- code/branches/rocket/src/modules/weapons/RocketController.h	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/modules/weapons/RocketController.h	2010-05-15 16:12:13 UTC (rev 6905)
@@ -52,15 +52,18 @@
             
             virtual void tick(float dt);
 			SimpleRocket* getRocket(){return this->rocket;};
-			void setTarget(Pawn* target);
+			void setTarget(WorldEntity* target);
         protected:
+			void moveToPosition(const Vector3& target);
+			void setTargetPosition();
+			void moveToTargetPosition();
 
-
         private:
 			SimpleRocket* rocket;
+			Vector3 targetPosition_;
 			WeakPtr<PlayerInfo> player_;
 						int haha;
-			WeakPtr<Pawn> target_;
+			WeakPtr<WorldEntity> target_;
 
 
     };

Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.cc	2010-05-15 16:12:13 UTC (rev 6905)
@@ -179,6 +179,10 @@
             this->destroy();
         }
     }
+	void SimpleRocket::setDestroy() {
+		this->bDestroy_=true;
+		COUT(0)<<"trying to destroy";
+	}
 
     void SimpleRocket::fired(unsigned int firemode)
     {

Modified: code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h
===================================================================
--- code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/modules/weapons/projectiles/SimpleRocket.h	2010-05-15 16:12:13 UTC (rev 6905)
@@ -63,6 +63,7 @@
             virtual void rotateYaw(const Vector2& value);
             virtual void rotatePitch(const Vector2& value);
             virtual void rotateRoll(const Vector2& value);
+			void setDestroy();
 
             /**
             @brief Moves the SimpleRocket in the Front/Back-direction by the specifed amount.
@@ -94,13 +95,16 @@
             @param value  The amount by which the SimpleRocket is to be rotated.
             */
             inline void rotatePitch(float value)
-            { this->rotatePitch(Vector2(value, 0)); }
+            {   COUT(0)<<"rotated rocket yaw";
+				this->rotatePitch(Vector2(value, 0)); }
             /**
             @brief Rotates the SimpleRocket around the z-axis by the specifed amount.
             @param value  The amount by which the SimpleRocket is to be rotated.
             */
             inline void rotateRoll(float value)
-            { this->rotateRoll(Vector2(value, 0)); }
+            { 
+				COUT(0)<<"rotated rocket roll";
+				this->rotateRoll(Vector2(value, 0)); }
 
             void setOwner(Pawn* owner);
             inline Pawn* getOwner() const

Modified: code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/modules/weapons/weaponmodes/SimpleRocketFire.cc	2010-05-15 16:12:13 UTC (rev 6905)
@@ -68,5 +68,10 @@
         rocket->setPosition(pos);
 		rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
 		rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+		rocket->setDamage(this->damage_);
+		WorldEntity* pawnn=(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getTarget());
+		if (pawnn) {
+		con->setTarget(pawnn);
+		}
     }
 }

Modified: code/branches/rocket/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/rocket/src/orxonox/controllers/DroneController.cc	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/orxonox/controllers/DroneController.cc	2010-05-15 16:12:13 UTC (rev 6905)
@@ -48,6 +48,7 @@
         // and saves the pointer to the drone for the controlling commands
         assert(dynamic_cast<Drone*>(creator)!=0);
         this->setControllableEntity(dynamic_cast<Drone*>(creator));
+		this->counter=0;
     }
 
     DroneController::~DroneController()
@@ -62,6 +63,7 @@
     */
     void DroneController::tick(float dt)
     {
+		this->counter++;
         // Place your code here:
         // - steering commands
         Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
@@ -69,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->rotateYaw(0.2);
-
     }
 }

Modified: code/branches/rocket/src/orxonox/controllers/DroneController.h
===================================================================
--- code/branches/rocket/src/orxonox/controllers/DroneController.h	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/orxonox/controllers/DroneController.h	2010-05-15 16:12:13 UTC (rev 6905)
@@ -53,6 +53,7 @@
         protected:
 
         private:
+			int counter;
     };
 }
 

Modified: code/branches/rocket/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/branches/rocket/src/orxonox/controllers/NewHumanController.cc	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/orxonox/controllers/NewHumanController.cc	2010-05-15 16:12:13 UTC (rev 6905)
@@ -573,62 +573,6 @@
             this->arrowsOverlay4_->hide();
         }
     }
-
-	Pawn* NewHumanController::getRocketTarget() {
-
-
- Ogre::RaySceneQuery * rsq = HumanController::localController_s->getControllableEntity()->getScene()->getSceneManager()->createRayQuery(Ogre::Ray());
-
-        Ogre::Ray mouseRay = HumanController::localController_s->getControllableEntity()->getCamera()->getOgreCamera()->getCameraToViewportRay(static_cast<float>(this->currentYaw_)/2*-1+.5f, static_cast<float>(this->currentPitch_)/2*-1+.5f);
-
-        rsq->setRay(mouseRay);
-        rsq->setSortByDistance(true);
-
-        /*
-        Distance of objects:
-        ignore everything under 200 maybe even take 1000 as min distance to shoot at
-
-        shots are regularly traced and are entities!!!!!!!!! this is the biggest problem
-        they vanish only after a distance of 10'000
-        */
-
-
-        Ogre::RaySceneQueryResult& result = rsq->execute();
-        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
-
-        Ogre::RaySceneQueryResult::iterator itr;
-        for (itr = result.begin(); itr != result.end(); ++itr)
-        {
-            if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 500)
-            {
-                // Try to cast the user pointer
-                WorldEntity* wePtr = dynamic_cast<WorldEntity*>(Ogre::any_cast<OrxonoxClass*>(itr->movable->getUserAny()));
-                if (wePtr)
-                {
-                    // go through all parents of object and look whether they are sightable or not
-                    bool isSightable = false;
-                    WorldEntity* parent = wePtr->getParent();
-                    while (parent)
-                    {
-                        if (this->targetMask_.isExcluded(parent->getIdentifier()))
-                        {
-                            parent = parent->getParent();
-                            continue;
-                        }
-                        else
-                        {
-                            isSightable = true;
-                            break;
-                        }
-                    }
-                    if (!isSightable)
-                        continue;
-                }
-
-				return dynamic_cast<Pawn*> (wePtr);
-			}
-		}
-	}
 		
 
 	

Modified: code/branches/rocket/src/orxonox/controllers/NewHumanController.h
===================================================================
--- code/branches/rocket/src/orxonox/controllers/NewHumanController.h	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/orxonox/controllers/NewHumanController.h	2010-05-15 16:12:13 UTC (rev 6905)
@@ -66,9 +66,7 @@
             virtual void doPauseControl();
             virtual void doResumeControl();
 
-			Pawn* getRocketTarget();
 
-
         protected:
             void updateTarget();
             void alignArrows();

Modified: code/branches/rocket/src/orxonox/worldentities/Drone.cc
===================================================================
--- code/branches/rocket/src/orxonox/worldentities/Drone.cc	2010-05-15 13:24:06 UTC (rev 6904)
+++ code/branches/rocket/src/orxonox/worldentities/Drone.cc	2010-05-15 16:12:13 UTC (rev 6905)
@@ -48,7 +48,7 @@
         // - register the drone class to the core
         this->myController_ = 0;
         
-        this->localLinearAcceleration_.setValue(0, 0, 0);
+        this->localLinearAcceleration_.setValue(1, 1, 1);
         this->localAngularAcceleration_.setValue(0, 0, 0);
         this->primaryThrust_  = 100;
         this->auxilaryThrust_ = 100;




More information about the Orxonox-commit mailing list