Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 31, 2015, 12:20:00 PM (10 years ago)
Author:
gania
Message:

move functions were added, everyone stays in formations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc

    r10725 r10729  
    3434
    3535    RegisterClass(DivisionController);
    36     static const float ACTION_INTERVAL = 1.0f;
    3736
    3837    DivisionController::DivisionController(Context* context) : LeaderController(context)
     
    4544        this->myWingman_ = 0;
    4645        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
     46       
     47        /*Vector3* pos = new Vector3(500,500,-500);
     48        this->setTargetPosition(*pos);*/
    4749
    4850    }
     
    5456    void DivisionController::tick(float dt)
    5557    {
     58        if (this->bHasTargetPosition_)
     59        {
     60            this->moveToTargetPosition();
     61        }
     62
    5663        SUPER(DivisionController, tick, dt);
    5764
     
    5966    void DivisionController::action()
    6067    {
    61 /*        setDesiredPositionOfFollower();
    62         setDesiredPositionOfWingman();*/
     68        setTargetPositionOfFollower();
     69        setTargetPositionOfWingman();
    6370    }
    6471
     
    7683    }
    7784
    78    /* void DivisionController::setDesiredPositionOfWingman()
     85    void DivisionController::setTargetPositionOfWingman()
    7986    {
    8087        if (!this->myWingman_)
    8188            return;
    82 
     89        Vector3* targetRelativePositionOfWingman;
    8390        switch (this->formationMode_){
    8491            case WALL:
    8592            {
    86                 myWingman_->desiredRelativePosition_ = new Vector3 (200, 0, 0);  
     93                targetRelativePositionOfWingman = new Vector3 (400, 0, 0); 
    8794                break;
    8895            }
     
    100107            }
    101108        }
     109        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
     110       
     111        Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) +
     112        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
     113       
     114        myWingman_->setTargetOrientation(orient);
     115        myWingman_->setTargetPosition(targetAbsolutePositionOfWingman);
    102116       
    103117    }
    104     void DivisionController::setDesiredPositionOfFollower()
     118    void DivisionController::setTargetPositionOfFollower()
    105119    {
    106120        if (!this->myFollower_)
    107121            return;
    108 
     122        Vector3* targetRelativePositionOfFollower;
    109123        switch (this->formationMode_){
    110124            case WALL:
    111125            {
    112                 myWingman_->desiredRelativePosition_ = new Vector3 (-200, 0, 0);   
     126                targetRelativePositionOfFollower = new Vector3 (-400, 0, 0);   
    113127                break;
    114128            }
     
    126140            }
    127141        }
     142        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
     143       
     144        Vector3 targetAbsolutePositionOfFollower = ((this->getControllableEntity()->getWorldPosition()) +
     145        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfFollower)));
     146       
     147        myFollower_->setTargetOrientation(orient);
     148        myFollower_->setTargetPosition(targetAbsolutePositionOfFollower);
    128149       
    129     }*/
     150    }
    130151    void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    131152    {
Note: See TracChangeset for help on using the changeset viewer.