Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/Presentation_HS16/src/modules/waypoints/WaypointGroup.cc @ 11475

Last change on this file since 11475 was 11321, checked in by ooguz, 8 years ago

Distance Trigger works!

File size: 2.7 KB
Line 
1#include "Waypoint.h"
2
3#include <OgreSceneNode.h>
4#include <BulletDynamics/Dynamics/btRigidBody.h>
5#include "util/OrxAssert.h"
6#include "WaypointGroup.h"
7#include "core/CoreIncludes.h"
8#include "core/XMLPort.h"
9
10
11namespace orxonox
12{
13    RegisterClass(WaypointGroup);
14
15    WaypointGroup::WaypointGroup(Context* context) : StaticEntity(context)
16    {
17        RegisterObject(WaypointGroup);
18        activeWaypoint = nullptr;
19        current = 0;
20
21        //model = new Model(this->getContext());
22        //model->setMeshSource("cube.mesh");  // Name of the arrow file for now bottle
23        //is->attach(model);
24        //model->setScale(3);
25        //model->setOrientation(Vector3(0,0,-1));
26        //model->setPosition(Vector3(0.0,0.0,0.0));        // this is wrong, it has to be triggered
27        //waypoint_active = false;
28        //distancetrigger = new DistanceTrigger(this->getContext());
29        //distancetrigger->setDistance(100);
30        //this->attach(distancetrigger);
31
32    }
33
34    WaypointGroup::~WaypointGroup()
35    {
36    }
37
38
39     //WorldEntity::setDirection
40     //WorldEntity::getPosition()
41     //setOrientation()
42
43
44
45
46    Waypoint* WaypointGroup::getWaypoint(unsigned int index)
47    {
48        unsigned int i = 0;
49        for (Waypoint* child : this->waypoints_)
50        {
51            if (i == index)
52                return child;
53            ++i;
54        }
55        return nullptr;
56    }
57
58    void WaypointGroup::setWaypoint(Waypoint* object)
59    {
60        object->setWaypointGroup(this);
61        this->waypoints_.insert(object);
62    }
63
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    }
70
71    Waypoint* WaypointGroup::getActive(){
72          if (activeWaypoint == nullptr){
73            orxout() << "Null Pointer" << endl;
74            activateNext();
75
76          }
77          return activeWaypoint;
78    }
79
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;
94 //   }
95
96
97
98    void WaypointGroup::XMLPort(Element& xmlelement, XMLPort::Mode mode){
99        SUPER(WaypointGroup, XMLPort, xmlelement, mode); // From the SpaceShip.cc file
100        XMLPortObject(WaypointGroup, Waypoint, "waypoints", setWaypoint, getWaypoint, xmlelement, mode);
101
102    }
103
104
105
106}
Note: See TracBrowser for help on using the repository browser.