[Orxonox-commit 2202] r6918 - in code/branches/ai: data/levels data/levels/templates src/orxonox/controllers src/orxonox/worldentities

gasserlu at orxonox.net gasserlu at orxonox.net
Mon May 17 16:36:18 CEST 2010


Author: gasserlu
Date: 2010-05-17 16:36:18 +0200 (Mon, 17 May 2010)
New Revision: 6918

Modified:
   code/branches/ai/data/levels/pickup.oxw
   code/branches/ai/data/levels/templates/pickup_representation_templates.oxt
   code/branches/ai/src/orxonox/controllers/ArtificialController.cc
   code/branches/ai/src/orxonox/controllers/CMakeLists.txt
   code/branches/ai/src/orxonox/controllers/DroneController.cc
   code/branches/ai/src/orxonox/controllers/DroneController.h
   code/branches/ai/src/orxonox/worldentities/Drone.cc
Log:
drone follows in realistic matter

Modified: code/branches/ai/data/levels/pickup.oxw
===================================================================
--- code/branches/ai/data/levels/pickup.oxw	2010-05-17 13:51:43 UTC (rev 6917)
+++ code/branches/ai/data/levels/pickup.oxw	2010-05-17 14:36:18 UTC (rev 6918)
@@ -22,50 +22,13 @@
   include("includes/pickups.oxi")
 ?>
 
-    <Template name=droneTemplate>
-        <Drone name="meineDrohne"  mass= "50" linearDamping = "0.9" angularDamping = "0.7">
-        <attached>
-            <Model scale="1" mesh="drone.mesh"/>
-        </attached>
-        <collisionShapes>
-            <BoxCollisionShape position="0,0,0"      halfExtents="1, 1, 1" />
-        </collisionShapes>
-    
 
-    <weaponslots>
-      <WeaponSlot position="    0,   0,0" />
-    </weaponslots>
-    <weaponsets>
-      <WeaponSet firemode=0 />
-    </weaponsets>
-    <weapons>
-      <WeaponPack>
-        <links>
-          <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
-        </links>
-        <Weapon>
-          <attached>
-            <Model mesh="hs-w01.mesh" roll="195" position="0,1,0" scale=2 />
-            <Model mesh="hs-w01s.mesh" roll="195" position="0.1,0.5,0" scale=2 />
-          </attached>
-          <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5,-4" />
-          <HsW01 mode=0 munitionpershot=0 delay=0     material="Flares/point_lensflare" muzzleoffset="-0.9, 1.1,-4" />
-        </Weapon>
-      </WeaponPack>
-    </weapons>
-
-
-        </Drone>
-     </Template>
-
     <PickupSpawner position="-100,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
         <pickup>
             <DronePickup droneTemplate=droneTemplate />
         </pickup>
     </PickupSpawner>
 
-
-
     <PickupSpawner position="-75,0,-100" triggerDistance="10" respawnTime="30" maxSpawnedItems="10">
         <pickup>
             <MetaPickup metaType="use" />

Modified: code/branches/ai/data/levels/templates/pickup_representation_templates.oxt
===================================================================
--- code/branches/ai/data/levels/templates/pickup_representation_templates.oxt	2010-05-17 13:51:43 UTC (rev 6917)
+++ code/branches/ai/data/levels/templates/pickup_representation_templates.oxt	2010-05-17 14:36:18 UTC (rev 6918)
@@ -106,4 +106,36 @@
         </pickupables>
     </PickupCollection>
 </Template>
-    
\ No newline at end of file
+
+
+<Template name=droneTemplate>
+    <Drone name="meineDrohne"  mass= "50" linearDamping = "0.7" angularDamping = "0.9999999" primaryThrust_=250 auxilaryThrust_=250 rotationThrust_=50>
+        <attached>
+            <Model scale="1" mesh="drone.mesh"/>
+        </attached>
+        <collisionShapes>
+            <BoxCollisionShape position="0,0,0"      halfExtents="1, 1, 1" />
+        </collisionShapes>
+        <weaponslots>
+            <WeaponSlot position="    0,   0,0" />
+        </weaponslots>
+        <weaponsets>
+            <WeaponSet firemode=0 />
+        </weaponsets>
+        <weapons>
+            <WeaponPack>
+                <links>
+                    <DefaultWeaponmodeLink firemode=0 weaponmode=0 />
+                </links>
+                <Weapon>
+                    <attached>
+                        <Model mesh="hs-w01.mesh" roll="195" position="0,1,0" scale=2 />
+                        <Model mesh="hs-w01s.mesh" roll="195" position="0.1,0.5,0" scale=2 />
+                    </attached>
+                    <HsW01 mode=0 munitionpershot=0 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.7, 1.5,-4" />
+                    <HsW01 mode=0 munitionpershot=0 delay=0     material="Flares/point_lensflare" muzzleoffset="-0.9, 1.1,-4" />
+                </Weapon>
+            </WeaponPack>
+        </weapons>
+    </Drone>
+</Template>

Modified: code/branches/ai/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.cc	2010-05-17 13:51:43 UTC (rev 6917)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.cc	2010-05-17 14:36:18 UTC (rev 6918)
@@ -35,6 +35,7 @@
 #include "worldentities/pawns/TeamBaseMatchBase.h"
 #include "gametypes/TeamDeathmatch.h"
 #include "controllers/WaypointPatrolController.h"
+#include "controllers/DroneController.h"
 #include "util/Math.h"
 
 namespace orxonox
@@ -347,6 +348,7 @@
 
     void ArtificialController::searchNewTarget()
     {
+COUT(0) << "search new target - start" << std::endl;
         if (!this->getControllableEntity())
             return;
 
@@ -371,6 +373,7 @@
                 }
             }
         }
+COUT(0) << "search new target - end: " << this->target_ << std::endl;
     }
 
     void ArtificialController::forgetTarget()

Modified: code/branches/ai/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/ai/src/orxonox/controllers/CMakeLists.txt	2010-05-17 13:51:43 UTC (rev 6917)
+++ code/branches/ai/src/orxonox/controllers/CMakeLists.txt	2010-05-17 14:36:18 UTC (rev 6918)
@@ -7,5 +7,5 @@
   ScriptController.cc
   WaypointController.cc
   WaypointPatrolController.cc
-  DroneController.cc  
+  DroneController.cc
 )

Modified: code/branches/ai/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.cc	2010-05-17 13:51:43 UTC (rev 6917)
+++ code/branches/ai/src/orxonox/controllers/DroneController.cc	2010-05-17 14:36:18 UTC (rev 6918)
@@ -46,12 +46,6 @@
 
     DroneController::DroneController(BaseObject* creator) : ArtificialController(creator)
     {
-        // - do any kind of initialisation
-
-        // this checks that our creator really is a drone
-        // and saves the pointer to the drone for the controlling commands
-
-    
         RegisterObject(DroneController);
 
         this->owner_ = 0;
@@ -85,36 +79,35 @@
         const Vector3& dronePosition = getDrone()->getWorldPosition();
 
         const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system
-
-        int distance = sqrt( (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
-                           + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y)
-                           + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z)); //distance to Owner
-
-        if (distance > 500) { //TODO: variable implementation of maxdistance
-            drone_->moveUpDown(locOwnerDir.y);
-            drone_->moveFrontBack(-locOwnerDir.z);
-            drone_->moveRightLeft(locOwnerDir.x);
-        }
-
-
+/*
+        int distance_square  = (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
+                             + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y)
+                             + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z); //distance to Owner squared
+*/
         random = rnd(maxrand);
         if ( random < 30 && (!this->target_))
             this->searchNewTarget();
-
-
-        this->aimAtTarget();
-        drone_->fire(0);
+/*
+        //face target
+        drone_->rotateYaw(-targetPosition_.x);
+        drone_->rotatePitch(targetPosition_.y);
+  */      
+        if (this->target_)
+        {
+            this->aimAtTarget();
+            drone_->fire(0);
+        }
          
 
 
-
-        //COUT(0) << "Drone: " << dronePosition << endl;
-        //COUT(0) << "Distance: " << distance << endl;
+/*
+        COUT(0) << "Drone: " << dronePosition << endl;
+        COUT(0) << "Distance: " << distance << endl;
         COUT(0) << "locDrone: " << locOwnerDir << endl;
         COUT(0) << "target: " << targetPosition_ << endl;
         COUT(0) << "Owner: " << ownerPosition << endl;
         COUT(0) << "Rand: " << random << endl;
-
+*/
 /*
         // search enemy
         random = rnd(maxrand);
@@ -170,10 +163,9 @@
 
 	Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
 
-        if(myDrone != NULL) {
+        if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength()  > 150*150) { //TODO: variable implementation of maxdistance
+            this->moveToPosition(this->getOwner()->getWorldPosition());
 
-        setTargetPosition(this->getControllableEntity()->getPosition());
-
         }
 
         SUPER(AIController, tick, dt);

Modified: code/branches/ai/src/orxonox/controllers/DroneController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.h	2010-05-17 13:51:43 UTC (rev 6917)
+++ code/branches/ai/src/orxonox/controllers/DroneController.h	2010-05-17 14:36:18 UTC (rev 6918)
@@ -46,7 +46,7 @@
     @author
         Oli Scheuss
     */
-    class _OrxonoxExport DroneController : public ArtificialController
+    class _OrxonoxExport DroneController : public ArtificialController, public Tickable
     {
         public:
             DroneController(BaseObject* creator);

Modified: code/branches/ai/src/orxonox/worldentities/Drone.cc
===================================================================
--- code/branches/ai/src/orxonox/worldentities/Drone.cc	2010-05-17 13:51:43 UTC (rev 6917)
+++ code/branches/ai/src/orxonox/worldentities/Drone.cc	2010-05-17 14:36:18 UTC (rev 6918)
@@ -168,7 +168,7 @@
     */
     void Drone::rotateYaw(const Vector2& value)
     {
-        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
+        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
     }
 
     /**




More information about the Orxonox-commit mailing list