Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 27, 2015, 7:58:44 PM (8 years ago)
Author:
gania
Message:

finished copyOrientation function. Now ships move smoothly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc

    r10877 r10879  
    7171            Action::FIGHTALL && this->myLeader_->getAction() != Action::ATTACK)
    7272        {
     73        }   
     74       
     75        SUPER(WingmanController, tick, dt);
     76    }
     77   
     78    //----action for hard calculations----
     79    void WingmanController::action()
     80    {
     81
     82        //----If no leader, find one----
     83        if (!this->myLeader_)
     84        {
     85            ActionpointController* newLeader = (findNewLeader());
     86            this->myLeader_ = newLeader;
     87            if (this->myLeader_)
     88            {
     89
     90            }
     91        }
     92        //----If have leader, he will deal with logic----
     93        else
     94        {
     95
     96        }
     97        if (!this->myLeader_)
     98        {
     99           ActionpointController::action();
     100        }
     101        else if (this->myLeader_)
     102        {
     103            switch (this->myLeader_->getAction())
     104            {
     105                case Action::FIGHT:
     106                {
     107                    if (!this->hasTarget())
     108                    {
     109                        this->setTarget(this->myLeader_->getTarget());
     110                    }
     111                    break;
     112                }
     113                case Action::FIGHTALL:
     114                {
     115                    if (!this->hasTarget())
     116                    {
     117                        this->setTarget(this->myLeader_->getTarget());
     118                    }
     119                    break;
     120                }
     121                case Action::ATTACK:
     122                {
     123                    if (!this->hasTarget())
     124                    {
     125                        this->setTarget(this->myLeader_->getTarget());
     126                    }
     127                    break;
     128                }
     129                default:
     130                {
     131                   
    73132            ControllableEntity* myEntity = this->getControllableEntity();
    74133            Vector3 myPosition = myEntity->getWorldPosition();
     
    80139            Quaternion orient = leaderEntity->getWorldOrientation();
    81140            Vector3 leaderPosition = leaderEntity->getWorldPosition();
    82 
    83141            Vector3 targetRelativePosition = getFormationPosition();
    84142            if (!this->myLeader_)
     
    99157               this->getControllableEntity()->boost(false);
    100158            }
    101         }   
    102        
    103         SUPER(WingmanController, tick, dt);
    104     }
    105    
    106     //----action for hard calculations----
    107     void WingmanController::action()
    108     {
    109 
    110         //----If no leader, find one----
    111         if (!this->myLeader_)
    112         {
    113             ActionpointController* newLeader = (findNewLeader());
    114             this->myLeader_ = newLeader;
    115            
    116         }
    117         //----If have leader, he will deal with logic----
    118         else
    119         {
    120 
    121         }
    122         if (!this->myLeader_)
    123         {
    124            ActionpointController::action();
    125         }
    126         else if (this->myLeader_)
    127         {
    128             switch (this->myLeader_->getAction())
    129             {
    130                 case Action::FIGHT:
    131                 {
    132                     if (!this->hasTarget())
    133                     {
    134                         this->setTarget(this->myLeader_->getTarget());
    135                     }
    136                     break;
    137                 }
    138                 case Action::FIGHTALL:
    139                 {
    140                     if (!this->hasTarget())
    141                     {
    142                         this->setTarget(this->myLeader_->getTarget());
    143                     }
    144                     break;
    145                 }
    146                 case Action::ATTACK:
    147                 {
    148                     if (!this->hasTarget())
    149                     {
    150                         this->setTarget(this->myLeader_->getTarget());
    151                     }
    152                     break;
    153                 }
    154                 default:
    155                 {
    156                    
    157159                }
    158160            }
     
    179181                case FormationMode::WALL:
    180182                {
    181                     targetRelativePosition = new Vector3 (2*this->spread_, 0, 0); 
     183                    targetRelativePosition = new Vector3 (2*this->spread_, 0, 0 - this->tolerance_); 
    182184                    break;
    183185                }
    184186                case FormationMode::FINGER4:
    185187                {
    186                     targetRelativePosition = new Vector3 (2*this->spread_, 0, this->spread_); 
     188                    targetRelativePosition = new Vector3 (2*this->spread_, 0, this->spread_ - this->tolerance_); 
    187189                    break;
    188190                }
    189191                case FormationMode::DIAMOND:
    190192                {
    191                     targetRelativePosition = new Vector3 (2*this->spread_, 0, this->spread_);                 
     193                    targetRelativePosition = new Vector3 (2*this->spread_, 0, this->spread_ - this->tolerance_);                 
    192194                    break;
    193195                }
     
    200202                case FormationMode::WALL:
    201203                {
    202                     targetRelativePosition = new Vector3 (-2*this->spread_, 0, 0); 
     204                    targetRelativePosition = new Vector3 (-2*this->spread_, 0, 0 - this->tolerance_); 
    203205                    break;
    204206                }
    205207                case FormationMode::FINGER4:
    206208                {
    207                     targetRelativePosition = new Vector3 (-2*this->spread_, 0, this->spread_); 
     209                    targetRelativePosition = new Vector3 (-2*this->spread_, 0, this->spread_ - this->tolerance_); 
    208210                    break;
    209211                }
    210212                case FormationMode::DIAMOND:
    211213                {
    212                     targetRelativePosition = new Vector3 (2*this->spread_, -this->spread_, 0);                 
     214                    targetRelativePosition = new Vector3 (2*this->spread_, -this->spread_, 0 - this->tolerance_);                 
    213215                    break;
    214216                }
Note: See TracChangeset for help on using the changeset viewer.