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/SectionController.cc

    r10725 r10729  
    3333
    3434    RegisterClass(SectionController);
    35     static const float ACTION_INTERVAL = 1.0f;
    3635
    3736    SectionController::SectionController(Context* context) : LeaderController(context)
    3837    {
    3938        RegisterObject(SectionController);
    40                 this->setFormationMode(WALL);
     39        this->setFormationMode(WALL);
    4140
    4241        bIsDivisionLeader_ = false;
     
    4443        this->myWingman_ = 0;
    4544        this->myDivisionLeader_ = 0;
    46         this->desiredRelativePosition_ = 0;
    4745
    4846        orxout(internal_error) << this << "Was created" << endl;
     
    5452       
    5553    }
    56     /*void SectionController::setDesiredPositionOfWingman()
     54    void SectionController::setTargetPositionOfWingman()
    5755    {
    5856        if (!this->myWingman_)
    5957            return;
    60 
     58        Vector3* targetRelativePositionOfWingman;
    6159        switch (this->formationMode_){
    6260            case WALL:
    6361            {
    64                 myWingman_->desiredRelativePosition_ = new Vector3 (-200, 0, 0);  
     62                targetRelativePositionOfWingman = new Vector3 (-400, 0, 0); 
    6563                break;
    6664            }
     
    7876            }
    7977        }
     78        Quaternion orient = this->getControllableEntity()->getWorldOrientation();
     79       
     80        Vector3 targetAbsolutePositionOfWingman = ((this->getControllableEntity()->getWorldPosition()) +
     81        (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman)));
     82       
     83        myWingman_->setTargetOrientation(orient);
     84        myWingman_->setTargetPosition(targetAbsolutePositionOfWingman);
    8085       
    8186    }
    82 */
     87
    8388    LeaderController* SectionController::findNewDivisionLeader()
    8489    {
     
    104109
    105110
    106            
    107            
    108 
    109111            float distance = ((it)->getControllableEntity()->getPosition() - this->getControllableEntity()->getPosition()).length();
    110112           
     
    114116                minDistance = distance;
    115117            }
    116            /* // is pawn in range?
    117             if (distance < RADIUS_TO_SEARCH_FOR_LEADER)
    118             {
    119 
    120                 if ((it)->setFollower(this))
    121                     return (*it);
    122             }*/
     118         
    123119        }
    124120        if (closestLeader)
     
    142138
    143139        }
    144 /*        setDesiredPositionOfWingman();
    145 */    }
     140        setTargetPositionOfWingman();
     141
     142    }
    146143    /*
    147144    Wingmen and Leaders attack target_, which is a member variable of their classes.
     
    158155
    159156    */
    160    /* void SectionController::keepDivisionTick()
    161     {
    162 
    163 
    164         if (this->myDivisionLeader_ && this->myDivisionLeader_->getControllableEntity() && desiredRelativePosition_)
    165         {
    166 
    167             Vector3 desiredAbsolutePosition = ((this->myDivisionLeader_->getControllableEntity()->getWorldPosition()) +
    168                 (this->myDivisionLeader_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_)));
    169             this->moveToPosition (desiredAbsolutePosition);
    170         }
    171     }*/
     157   
    172158    void SectionController::tick(float dt)
    173159    {
    174        
    175 
    176        /*
    177160        if (!this->isActive())
    178161            return;
    179162       
    180         //--------------------------Stay in division--------------------------
    181         this->keepDivisionTick();
    182         */
    183         //If ordered to move -> move to a target Point
    184        
    185         //No orders -> Don't move, but shoot at whatever is close, unless Boss is shooting at it.
    186         //(Section shoots same target, Boss's section shoots another target)
    187        
     163        if (this->bHasTargetPosition_)
     164        {
     165            this->moveToTargetPosition();
     166        }
    188167
    189         //orxout(internal_error) << "my Wingman is " << this->myWingman_ << endl;
    190168       
    191169        SUPER(SectionController, tick, dt);
Note: See TracChangeset for help on using the changeset viewer.