[11274] | 1 | #include "Waypoint.h" |
---|
| 2 | |
---|
| 3 | #include <OgreSceneNode.h> |
---|
| 4 | #include <BulletDynamics/Dynamics/btRigidBody.h> |
---|
| 5 | #include "util/OrxAssert.h" |
---|
[11287] | 6 | #include "WaypointGroup.h" |
---|
[11274] | 7 | #include "core/CoreIncludes.h" |
---|
[11287] | 8 | #include "core/XMLPort.h" |
---|
[11274] | 9 | |
---|
[11287] | 10 | |
---|
[11274] | 11 | namespace orxonox |
---|
| 12 | { |
---|
| 13 | RegisterClass(WaypointGroup); |
---|
| 14 | |
---|
| 15 | WaypointGroup::WaypointGroup(Context* context) : StaticEntity(context) |
---|
| 16 | { |
---|
[11287] | 17 | RegisterObject(WaypointGroup); |
---|
[11298] | 18 | activeWaypoint = nullptr; |
---|
[11318] | 19 | current = 0; |
---|
[11298] | 20 | |
---|
[11287] | 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); |
---|
[11274] | 25 | //model->setOrientation(Vector3(0,0,-1)); |
---|
[11287] | 26 | //model->setPosition(Vector3(0.0,0.0,0.0)); // this is wrong, it has to be triggered |
---|
| 27 | //waypoint_active = false; |
---|
[11318] | 28 | //distancetrigger = new DistanceTrigger(this->getContext()); |
---|
[11287] | 29 | //distancetrigger->setDistance(100); |
---|
| 30 | //this->attach(distancetrigger); |
---|
[11318] | 31 | |
---|
[11274] | 32 | } |
---|
| 33 | |
---|
| 34 | WaypointGroup::~WaypointGroup() |
---|
| 35 | { |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | //WorldEntity::setDirection |
---|
| 40 | //WorldEntity::getPosition() |
---|
| 41 | //setOrientation() |
---|
| 42 | |
---|
| 43 | |
---|
| 44 | |
---|
[11318] | 45 | |
---|
[11274] | 46 | Waypoint* WaypointGroup::getWaypoint(unsigned int index) |
---|
| 47 | { |
---|
| 48 | unsigned int i = 0; |
---|
[11287] | 49 | for (Waypoint* child : this->waypoints_) |
---|
[11274] | 50 | { |
---|
| 51 | if (i == index) |
---|
[11287] | 52 | return child; |
---|
[11274] | 53 | ++i; |
---|
| 54 | } |
---|
| 55 | return nullptr; |
---|
| 56 | } |
---|
| 57 | |
---|
[11287] | 58 | void WaypointGroup::setWaypoint(Waypoint* object) |
---|
[11274] | 59 | { |
---|
[11318] | 60 | object->setWaypointGroup(this); |
---|
[11274] | 61 | this->waypoints_.insert(object); |
---|
| 62 | } |
---|
| 63 | |
---|
[11318] | 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 | } |
---|
[11274] | 70 | |
---|
[11287] | 71 | Waypoint* WaypointGroup::getActive(){ |
---|
[11298] | 72 | if (activeWaypoint == nullptr){ |
---|
[11309] | 73 | orxout() << "Null Pointer" << endl; |
---|
[11321] | 74 | activateNext(); |
---|
[11298] | 75 | |
---|
[11318] | 76 | } |
---|
[11298] | 77 | return activeWaypoint; |
---|
| 78 | } |
---|
| 79 | |
---|
[11318] | 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 | |
---|
[11321] | 91 | // Waypoint* WaypointGroup::getFirst(){ |
---|
| 92 | // std::set<Waypoint*>::iterator it = waypoints_.begin(); |
---|
| 93 | // return *it; |
---|
| 94 | // } |
---|
[11274] | 95 | |
---|
| 96 | |
---|
[11287] | 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 | |
---|
[11274] | 102 | } |
---|
| 103 | |
---|
| 104 | |
---|
[11287] | 105 | |
---|
[11274] | 106 | } |
---|