Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 5, 2016, 3:59:38 PM (8 years ago)
Author:
ooguz
Message:

Distance Trigger Added

Location:
code/branches/QuestGuide_HS16/src/modules/waypoints
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/QuestGuide_HS16/src/modules/waypoints/Waypoint.cc

    r11309 r11318  
    11#include "Waypoint.h"
    2 
    32#include <OgreSceneNode.h>
    43#include <BulletDynamics/Dynamics/btRigidBody.h>
     
    65#include "core/CoreIncludes.h"
    76#include "core/XMLPort.h"
     7#include "WaypointGroup.h"
     8#include "core/EventIncludes.h"
    89
    910
     
    2627        distancetrigger = new DistanceTrigger(this->getContext());   
    2728        distancetrigger->setDistance(100);
    28         distanceTrigger_->addTarget("Pawn");
    29          this->addEventSource(distanceTrigger_, "explode");
    30 
     29        distancetrigger->addTarget("Pawn");
     30        distancetrigger->setStayActive(false);
     31        this->addEventSource(distancetrigger, "activate");
    3132        this->attach(distancetrigger);
    3233    }
     
    3738
    3839
     40    void Waypoint::activate(){
     41        orxout() << "activate function" << endl;
     42        ///++order;
     43        waypointgroup->activateNext();
     44    }
     45
     46
    3947     //WorldEntity::setDirection
    4048     //WorldEntity::getPosition()
    4149     //setOrientation()
     50 
    4251
    43 
    44     void Waypoint::XMLPort(Element& xmlelement, XMLPort::Mode mode){
    45         SUPER(Waypoint, XMLPort, xmlelement, mode); // From the SpaceShip.cc file
    46        
    47         XMLPortParam(Waypoint, "order", setOrder, getOrder, xmlelement, mode);
     52    void Waypoint::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){
     53        SUPER(Waypoint, XMLEventPort, xmlelement, mode); // From the SpaceShip.cc file
     54        //XMLPortParam(Waypoint, "order", setOrder, getOrder, xmlelement, mode);
     55        XMLPortEventState(Waypoint, BaseObject, "activate", activate, xmlelement, mode);
    4856
    4957    }
  • code/branches/QuestGuide_HS16/src/modules/waypoints/Waypoint.h

    r11298 r11318  
    55
    66#include "OrxonoxPrereqs.h"
     7#include "Waypointprereqs.h"
    78#include "worldentities/StaticEntity.h"
    89#include "graphics/Model.h"
     
    1415#include "util/OgreForwardRefs.h"
    1516#include "tools/interfaces/Tickable.h"
     17#include "WaypointGroup.h"
     18
    1619
    1720namespace orxonox
     
    3740
    3841
    39             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
     42            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;
    4043
    4144            inline void enable_waypoint(){
     
    5154            }
    5255
     56            inline void setWaypointGroup(WaypointGroup* waypointgroup_){
     57                this->waypointgroup = waypointgroup_;
     58            }
     59
     60            void activate();
     61
    5362           
    5463            bool waypoint_actived;
     
    5968            Model* model;
    6069            DistanceTrigger* distancetrigger;
    61             int order;
    62            
     70            unsigned int order = 0;
     71            WaypointGroup* waypointgroup;
     72
    6373            // network callbacks
    6474    };
  • code/branches/QuestGuide_HS16/src/modules/waypoints/WaypointGroup.cc

    r11309 r11318  
    1717        RegisterObject(WaypointGroup);
    1818        activeWaypoint = nullptr;
     19        current = 0;
    1920
    2021        //model = new Model(this->getContext());
     
    2526        //model->setPosition(Vector3(0.0,0.0,0.0));        // this is wrong, it has to be triggered
    2627        //waypoint_active = false;
    27         //distancetrigger = new DistanceTrigger(this->getContext());   
     28        //distancetrigger = new DistanceTrigger(this->getContext());
    2829        //distancetrigger->setDistance(100);
    2930        //this->attach(distancetrigger);
    30        
     31
    3132    }
    3233
     
    4041     //setOrientation()
    4142
    42  
     43
    4344
    4445
     
    5758    void WaypointGroup::setWaypoint(Waypoint* object)
    5859    {
     60        object->setWaypointGroup(this);
    5961        this->waypoints_.insert(object);
    6062    }
    6163
     64    void WaypointGroup::activateNext(){
     65        if (std::next(waypoints_.begin(), current) != std::next(waypoints_.end(), 0)){
     66          activeWaypoint = *std::next(waypoints_.begin(), current);
     67          ++current;
     68        }
     69    }
    6270
    6371    Waypoint* WaypointGroup::getActive(){
    6472          if (activeWaypoint == nullptr){
    6573            orxout() << "Null Pointer" << endl;
    66             activateNext();
     74            activeWaypoint = getFirst();
    6775
    68           }
    69           //else if (activeWaypoint->)           
     76          }
    7077          return activeWaypoint;
    7178    }
    7279
    73     Waypoint* WaypointGroup::activateNext(){
    74         for (Waypoint* object : this->waypoints_){
    75             if(!(object->waypoint_actived)){
    76                 object->enable_waypoint();
    77                 activeWaypoint = object;
    78                 break;
    79             }
    80         }
    81         return activeWaypoint;
     80//    Waypoint* WaypointGroup::activateNext(){
     81//        for (Waypoint* object : this->waypoints_){
     82//            if(!(object->waypoint_actived)){
     83//                //object->enable_waypoint();
     84//                activeWaypoint = object;
     85//                break;
     86//            }
     87//        }
     88//        return activeWaypoint;
     89//    }
     90
     91    Waypoint* WaypointGroup::getFirst(){
     92        std::set<Waypoint*>::iterator it = waypoints_.begin();
     93        return *it;
    8294    }
    8395
    8496
    85    
    8697
    8798    void WaypointGroup::XMLPort(Element& xmlelement, XMLPort::Mode mode){
  • code/branches/QuestGuide_HS16/src/modules/waypoints/WaypointGroup.h

    r11298 r11318  
    55
    66#include "OrxonoxPrereqs.h"
     7#include "Waypointprereqs.h"
    78#include "worldentities/StaticEntity.h"
    89#include "graphics/Model.h"
     
    3132
    3233    class _OrxonoxExport WaypointGroup : public StaticEntity {
    33        
     34
    3435        public:
    3536
     
    4647
    4748        Waypoint* getActive();
    48          
    4949
    50         Waypoint* activateNext();
    5150
    52            
     51        void activateNext();
    5352
    54            
     53        Waypoint* getFirst();
     54
     55
     56
     57
    5558
    5659
    5760        private:
    58    
     61
    5962            //virtual bool isCollisionTypeLegal(CollisionType type) const override;
    60          
     63
    6164        std::set<Waypoint*> waypoints_;
    6265        Waypoint* activeWaypoint;
     66        unsigned int current = 1;
     67        //std::set<Waypoint*>::iterator it;
    6368
    6469            // network callbacks
  • code/branches/QuestGuide_HS16/src/modules/waypoints/Waypointarrow.cc

    r11309 r11318  
    6161
    6262        if (getWaypointgroup() == nullptr){
    63                   orxout() << "Second" << endl;
     63                //orxout() << "Second" << endl;
    6464
    6565            return;
     
    6767
    6868        waypoints_ = getWaypointgroup();
    69 
    7069        waypoint = waypoints_->getActive();
    71 
    7270        Vector3 waypoint_position = waypoint->getWorldPosition();
    7371
    7472
    7573        //orxout() << "dsfsf" << waypoint_position.x << endl;
    76     //    orxout() << "waypoint " << waypoint_position.x <<  "waypoint " << waypoint_position.y << "waypoint " << waypoint_position.z << endl;
    77       //  orxout() << "model " << this->model->getWorldPosition().x <<  "model " << this->model->getWorldPosition().y << "model " << this->model->getWorldPosition().z << endl;
    78       //  orxout() << "this " << this->getWorldPosition().x <<  "this " << this->getWorldPosition().y << "this " << this->getWorldPosition().z << endl;
    79        // orxout() << "trial " << trial.x <<  "trial " << trial.y << "trial " << trial.z << endl;
     74        //orxout() << "waypoint " << waypoint_position.x <<  "waypoint " << waypoint_position.y << "waypoint " << waypoint_position.z << endl;
     75        //orxout() << "model " << this->model->getWorldPosition().x <<  "model " << this->model->getWorldPosition().y << "model " << this->model->getWorldPosition().z << endl;
     76        //orxout() << "this " << this->getWorldPosition().x <<  "this " << this->getWorldPosition().y << "this " << this->getWorldPosition().z << endl;
     77        //orxout() << "trial " << trial.x <<  "trial " << trial.y << "trial " << trial.z << endl;
    8078
    8179
     
    8886    void Waypointarrow::XMLPort(Element& xmlelement, XMLPort::Mode mode){
    8987        SUPER(Waypointarrow, XMLPort, xmlelement, mode); // From the SpaceShip.cc file
    90 
    9188        //XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, Vector3)
    92 
    9389        //XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); // TRY ADDING THE WAYPOINT ARROW LIKE AN ENGINE
    9490
Note: See TracChangeset for help on using the changeset viewer.