Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10763


Ignore:
Timestamp:
Nov 3, 2015, 5:06:05 PM (9 years ago)
Author:
gania
Message:

fixed a bug

Location:
code/branches/AI_HS15/src/orxonox/controllers
Files:
4 edited

Legend:

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

    r10762 r10763  
    190190    void CommonController::moveToPosition(const Vector3& target)
    191191    {
     192        float factor = 1;
    192193        if (!this->getControllableEntity())
    193194            return;
    194195        if (this->rank_ == Rank::DIVISIONLEADER)
    195             SPEED *= 0.8;
     196            factor = 0.8;
    196197        if (this->rank_ == Rank::SECTIONLEADER)
    197             SPEED *= 0.9;
     198            factor = 0.9;
    198199       
    199200        //100 is (so far) the smallest tolerance (empirically found) that can be reached,
     
    233234                }
    234235            }
    235             this->getControllableEntity()->moveFrontBack(1.2f*SPEED);
     236                    orxout (internal_error) << "MOVING" <<endl ;
     237
     238            this->getControllableEntity()->moveFrontBack(1.2f*SPEED*factor);
    236239        }
    237240        else
     
    257260    {
    258261        //check pointers
    259         if (!this->getControllableEntity() || !this->target_ || !this->target_->getControllableEntity())
     262        if (!this->getControllableEntity() || !this->target_)
    260263            return false;
    261        
     264
    262265        //check if this points in the direction of target_
    263266
    264267        Vector3 myPosition = this->getControllableEntity()->getWorldPosition();
    265         Vector3 targetPosition = this->target_->getControllableEntity()->getWorldPosition();
     268        Vector3 targetPosition = this->target_->getWorldPosition();
    266269        Vector3 differenceVector = targetPosition - myPosition;
    267         float scalarProduct = differenceVector * WorldEntity::FRONT;
     270        float scalarProduct = differenceVector.dotProduct(WorldEntity::FRONT);
    268271        Vector3 projection = scalarProduct * WorldEntity::FRONT;
    269272        if ((differenceVector - projection).length() > 50)
     
    282285                allyPosition = it->getControllableEntity()->getWorldPosition();
    283286                allyDifference = allyPosition - myPosition;
    284                 allyScalarProduct = allyDifference * WorldEntity::FRONT;
     287                allyScalarProduct = allyDifference.dotProduct(WorldEntity::FRONT);
    285288                allyProjection = allyScalarProduct * WorldEntity::FRONT;
    286289                if (allyScalarProduct < 0 || allyScalarProduct > scalarProduct)
     
    291294        }
    292295
     296        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
     297        if (pawn)
     298            pawn->setAimPosition(WorldEntity::FRONT);
     299   
    293300        return true;
    294301
  • code/branches/AI_HS15/src/orxonox/controllers/CommonController.h

    r10762 r10763  
    109109
    110110            void setTarget(ControllableEntity* target);
    111 
     111           
    112112            void setTargetOrientation(const Quaternion& orient);
    113113            void setTargetOrientation(ControllableEntity* target);
  • code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc

    r10762 r10763  
    4040       
    4141        this->setFormationMode(FormationMode::DIAMOND);
    42 
     42        this->target_ = 0;
    4343        this->myFollower_ = 0;
    4444        this->myWingman_ = 0;
     
    4646        this->rank_ = Rank::DIVISIONLEADER;
    4747
    48         Vector3* pos = new Vector3(-4000,-1000,-2000);
    49         this->setTargetPosition(*pos);
    5048
    5149    }
     
    7674    void DivisionController::action()
    7775    {
     76/*
     77        Vector3* pos = new Vector3(4000,1000,2000);
     78        this->setTargetPosition(*pos);*/
     79
    7880        setTargetPositionOfFollower();
    7981        setTargetPositionOfWingman();
  • code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc

    r10759 r10763  
    5858        this->divisions_.clear();
    5959       
    60         /*for (ObjectList<DivisionController>::iterator it = ObjectList<DivisionController>::begin(); it; ++it)
     60        for (ObjectList<DivisionController>::iterator it = ObjectList<DivisionController>::begin(); it; ++it)
    6161        {
    6262            if ((this->getControllableEntity()->getTeam() == (it)->getControllableEntity()->getTeam()))
     
    6565            }
    6666        }
     67        /*for(std::vector<WeakPtr<DivisionController> >::iterator it2 = divisions_.begin(); it2 != divisions_.end(); ++it2)
     68        {
     69            (*it2)->setTargetPosition(this->getControllableEntity()->getWorldPosition());   
     70        }*/
    6771        for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
    6872        {
    69             if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()) && (it)->getControllableEntity()->getTeam() != 0)
     73            if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()) && (it)->getControllableEntity()->getTeam() == 0)
    7074            {
    7175                for(std::vector<WeakPtr<DivisionController> >::iterator it2 = divisions_.begin(); it2 != divisions_.end(); ++it2) {
    7276                    (*it2)->setTarget(it->getControllableEntity());   
     77                    (*it2)->setTargetPosition(it->getControllableEntity()->getWorldPosition());
    7378                }               
    7479                break;
    7580            }
    76         }*/
     81        }
    7782
    7883    }
Note: See TracChangeset for help on using the changeset viewer.