Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10673


Ignore:
Timestamp:
Oct 19, 2015, 5:15:17 PM (9 years ago)
Author:
gania
Message:

added setDesiredPositionOfSlaves() to FormationController, Vector3* desiredRelativePosition_ as a member var to FormationController, added a "stay in formation" functionality to tick of AIController. TODO change from moveToPosition to a Waypoint. Remark: create a WorldEntity object at certain position

Location:
code/branches/AI_HS15
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/data/levels/AITest.oxw

    r10655 r10673  
    3232
    3333    <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
    34     <SpawnPoint team=0 position="-1000,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
     34    <SpawnPoint team=0 position="-2000,-1000,3000" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
    3535   
    3636    <?lua
    3737      for i = 0, 5, 1 do
    3838    ?>
    39     <SpaceShip position="<?lua print(1600+i*200) ?>,3000, 2000 ?>" lookat="0,0,0">
     39    <SpaceShip position="<?lua print(1600+i*200) ?>,<?lua print(3000-i*500) ?>, -1500 ?>" lookat="0,0,0">
    4040      <templates>
    4141        <Template link=spaceshipassff />
  • code/branches/AI_HS15/src/orxonox/controllers/AIController.cc

    r10670 r10673  
    205205        float maxrand = 100.0f / ACTION_INTERVAL;
    206206        ControllableEntity* controllable = this->getControllableEntity();
    207         if (this->state_ == SLAVE)
    208         {
    209             Vector3 desiredAbsolutePosition = this->myMaster_->getControllableEntity()->getWorldPosition() + this->myMaster_->getControllableEntity()->getWorldOrientation()*desiredRelativePosition_;
    210            
    211             orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext());
    212             waypoint->setPosition(desiredAbsolutePosition);
    213            
    214             this->addWaypoint(waypoint);
     207        if (this->state_ == SLAVE && controllable && this->mode_ == DEFAULT)
     208        {
     209           
     210            if (this->myMaster_ && this->myMaster_->getControllableEntity() && desiredRelativePosition_){
     211                Vector3 desiredAbsolutePosition = this->myMaster_->getControllableEntity()->getWorldPosition() + this->myMaster_->getControllableEntity()->getWorldOrientation()* (*desiredRelativePosition_);
     212                this->moveToPosition (desiredAbsolutePosition);
     213                //WorldEntity* waypoint = new WorldEntity(this->getContext());
     214                //waypoint->setPosition(desiredAbsolutePosition);
     215           
     216                //this->addWaypoint(waypoint);
     217           
     218            }
     219         
    215220        }
    216221        //DOES: Either move to the waypoint or search for a Point of interest
  • code/branches/AI_HS15/src/orxonox/controllers/AIController.h

    r10670 r10673  
    3030#define _AIController_H__
    3131
    32 #include "OrxonoxPrereqs.h"
     32#include "OrxonoxPrereqs.h" 
    3333
     34#include "util/Math.h"
    3435#include "tools/Timer.h"
    3536#include "tools/interfaces/Tickable.h"
    3637#include "ArtificialController.h"
     38
    3739
    3840namespace orxonox
     
    5557            Timer actionTimer_; //<! Regularly calls action().
    5658            std::vector<WeakPtr<AIController> > enemies_, allies_;
    57             Vector3* desiredRelativePosition_;
    58             Vector3* currentRelativePosition_;
     59           
    5960    };
    6061}
  • code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc

    r10670 r10673  
    712712        switch (this->formationMode_){
    713713            case ATTACK:
    714             for(std::vector<FormationController*>::iterator it = slaves_.begin(), float i = 0; it != slaves_.end(); it++, ++i)
    715             {
    716                 (*it)->desiredPosition_ = new Vector3 ((i-slaves_.size()/2)*200, 0, 0);
    717                
    718             }
    719             break;
    720             case NORMAL:
    721 
    722             break;
    723             case DEFEND:
    724 
    725             break;
     714            {
     715                float i = 0;
     716                for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
     717                {
     718                    (*it)->desiredRelativePosition_ = new Vector3 ((i-slaves_.size()/2)*200, 0, 0);
     719                    i++;
     720                }
     721                break;
     722            }
     723            case NORMAL:
     724            {
     725                break;
     726            }
     727            case DEFEND:
     728            {
     729                break;
     730            }
    726731        }
    727732       
  • code/branches/AI_HS15/src/orxonox/controllers/FormationController.h

    r10670 r10673  
    7373      @brief If master, set the desired position of slaves (Vector2) for all the slaves.
    7474      */
    75       inline void setDesiredPositionOfSlaves();
    76      
     75      void setDesiredPositionOfSlaves();
     76
    7777      inline void setPassive(bool passive)
    7878           { this->passive_ = passive; }
     
    106106
    107107  protected:
     108      Vector3* desiredRelativePosition_;
    108109      bool formationFlight_;
    109110      bool passive_;
Note: See TracChangeset for help on using the changeset viewer.