[Orxonox-commit 6301] r10958 - in code/branches/campaignHS15: data/levels src/orxonox/controllers

gania at orxonox.net gania at orxonox.net
Tue Dec 8 13:02:26 CET 2015


Author: gania
Date: 2015-12-08 13:02:25 +0100 (Tue, 08 Dec 2015)
New Revision: 10958

Modified:
   code/branches/campaignHS15/data/levels/AITest.oxw
   code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
   code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
   code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
   code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
   code/branches/campaignHS15/src/orxonox/controllers/MasterController.cc
   code/branches/campaignHS15/src/orxonox/controllers/MasterController.h
Log:
separated MasterController from my hierarchy

Modified: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw	2015-12-08 10:15:47 UTC (rev 10957)
+++ code/branches/campaignHS15/data/levels/AITest.oxw	2015-12-08 12:02:25 UTC (rev 10958)
@@ -161,7 +161,7 @@
    
 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
 <!-- HERE STARTS DEMO FOR FIGHTING -->
-    
+    <!-- 
 
     <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1">
       <templates>
@@ -237,11 +237,11 @@
         <WingmanController team=1>
         </WingmanController>
       </controller>
-    </SpaceShip> 
+    </SpaceShip>  -->
 
 <!-- HERE ENDS DEMO FOR FIGHTING -->
 <!-- HERE STARTS DEMO FOR FORMATIONS -->
-    <!-- 
+    
     <Model mesh="cube.mesh" scale=8 position="   0,2000,    0" />
     <Model mesh="cube.mesh" scale=8 position="   0,2000,-2000" />
     <Model mesh="cube.mesh" scale=8 position="2000,2000,-2000" />
@@ -290,7 +290,7 @@
         </WingmanController>
       </controller>
     </SpaceShip> 
-    -->
+   
 <!-- HERE ENDS DEMO FOR FORMATIONS -->
     <!-- 1 division is roughly equal to 6 AIControllers--!>
 <!-- 

Modified: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	2015-12-08 10:15:47 UTC (rev 10957)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	2015-12-08 12:02:25 UTC (rev 10958)
@@ -297,8 +297,6 @@
                 this->executeActionpoint();
             }
         }
-
-
     }
     /**
     @brief
@@ -306,12 +304,10 @@
     */
     void ActionpointController::setProtect (ControllableEntity* protect)
     {
-
         this->protect_ = protect;
     }
     ControllableEntity* ActionpointController::getProtect ()
     {
-
         return this->protect_;
     }
     //XML method

Modified: code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	2015-12-08 10:15:47 UTC (rev 10957)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	2015-12-08 12:02:25 UTC (rev 10958)
@@ -59,9 +59,8 @@
             bool bKeepFormation_;   //even if action_ == FIGHT, you might still want to keep formation if far enough form the target
             virtual void maneuver(); //<! sets this->targetPosition_, which is a Vector3 of where this ship flies. Decision is made based on
                              //<! the distance to enemy, if being attacked, dodge() is called, otherwise ship just flies towards this->target_.
-            bool bShooting_;
+            bool bShooting_;    //<! if true, ship shoots each tick
             bool canFire(); //<! check if target_ is in radius and if this is looking at target_
-            virtual void action(){};//<! action() is called in regular intervals managing the bot's behaviour. Only gets called by MasterController, is implemented in ActionpointController
         protected:
             void setTarget(ControllableEntity* target); //set a target to shoot at
 

Modified: code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	2015-12-08 10:15:47 UTC (rev 10957)
+++ code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	2015-12-08 12:02:25 UTC (rev 10958)
@@ -44,6 +44,7 @@
         this->rotationProgress_ = 0;
         this->spread_ = 200;
         this->tolerance_ = 80;
+        this->bCopyOrientation_ = true;
     }
     FlyingController::~FlyingController() 
     {
@@ -265,7 +266,7 @@
             (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
              + (orient* (targetRelativePosition)));
         //let ship finish rotating. also don't call copyOrientation too often as it is a slow function. Don't know how to do it different
-        if (static_cast<int>(rnd(1.0f) * 100) % 3 == 0)
+        if (this->bCopyOrientation_)
             this->setTargetOrientation (orient);
         //set a position to fly to
         this->setTargetPosition (targetAbsolutePosition);

Modified: code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h	2015-12-08 10:15:47 UTC (rev 10957)
+++ code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h	2015-12-08 12:02:25 UTC (rev 10958)
@@ -71,7 +71,8 @@
                 { this->formationMode_ = val; }
             FormationMode::Value getFormationMode() const
                 { return this->formationMode_; }
-
+            bool bCopyOrientation_;                             //<! set to true by default, MasterController sets it in its tick(),
+                                                                //<! if true, this will set its leader orientation as target orientation in action()
         protected:
             void stopMoving();                                  //<! don't call moveToTargetPosition() in tick, call lookAtTarget() from FightingController instead
 
@@ -85,8 +86,9 @@
             void setTargetOrientation(const Quaternion& orient);        //<! preset a desired orientation
             void setTargetOrientation(ControllableEntity* target);      //<! preset a desired orientation
             virtual void boostControl();                                //<! boost if you can
-            void keepFormation (const ControllableEntity* leaderEntity, Vector3& targetRelativePosition);   //<! preset targetPosition, so that 
-                                                                                                            //<! this stays in a certain position relative to leader      
+            void keepFormation (const ControllableEntity* leaderEntity, 
+                                Vector3& targetRelativePosition);   //<! preset targetPosition, so that 
+                                                                    //<! this stays in a certain position relative to leader      
             
             FormationMode::Value formationMode_;
           

Modified: code/branches/campaignHS15/src/orxonox/controllers/MasterController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/MasterController.cc	2015-12-08 10:15:47 UTC (rev 10957)
+++ code/branches/campaignHS15/src/orxonox/controllers/MasterController.cc	2015-12-08 12:02:25 UTC (rev 10958)
@@ -34,7 +34,7 @@
     RegisterClass(MasterController);
 
     //Leaders share the fact that they have Wingmans
-    MasterController::MasterController(Context* context) : FightingController(context)
+    MasterController::MasterController(Context* context) : Controller(context)
     {
         RegisterObject(MasterController);
         // orxout(internal_error) << "MasterController was created" << endl;
@@ -119,7 +119,9 @@
                     return;
                 }
                 //orxout (internal_error) << "Executing action of Controller # " << this->indexOfCurrentController_ << endl;
-                this->controllers_.at(this->indexOfCurrentController_)->action();
+                this->controllers_.at(this->indexOfCurrentController_)->action();    
+                //bCopyOrientation makes ship oscillate like crazy if set to true all the time.s
+                this->controllers_.at(this->indexOfCurrentController_)->bCopyOrientation_ = this->ticks_ % 3 == 0;
 
                 ++this->numberOfTicksPassedSinceLastActionCall_;
                 ++this->indexOfCurrentController_;

Modified: code/branches/campaignHS15/src/orxonox/controllers/MasterController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/MasterController.h	2015-12-08 10:15:47 UTC (rev 10957)
+++ code/branches/campaignHS15/src/orxonox/controllers/MasterController.h	2015-12-08 12:02:25 UTC (rev 10958)
@@ -29,7 +29,8 @@
 #ifndef _MasterController_H__
 #define _MasterController_H__
 
-#include "controllers/FightingController.h"
+#include "controllers/Controller.h"
+#include "controllers/ActionpointController.h"
 #include "tools/interfaces/Tickable.h"
 
 
@@ -49,7 +50,7 @@
         </controller>
       </Pawn>
     */
-    class _OrxonoxExport MasterController : public FightingController, public Tickable
+    class _OrxonoxExport MasterController : public Controller, public Tickable
     {
         public:
             //----[language demanded functions]----            
@@ -66,7 +67,7 @@
         protected:
           
         private:
-            std::vector<WeakPtr<FightingController> > controllers_;  //<! vector of controllers, which action(), canFire() and maneuver() methods are to be called
+            std::vector<WeakPtr<ActionpointController> > controllers_;  //<! vector of controllers, which action(), canFire() and maneuver() methods are to be called
             size_t indexOfCurrentController_;                        //<! index of current controller
             unsigned int numberOfTicksPassedSinceLastActionCall_;
             unsigned int ticks_;                                     //<! local tick counter            




More information about the Orxonox-commit mailing list