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 | |
---|
11 | namespace orxonox |
---|
12 | { |
---|
13 | RegisterClass(WaypointGroup); |
---|
14 | |
---|
15 | WaypointGroup::WaypointGroup(Context* context) : StaticEntity(context) |
---|
16 | { |
---|
17 | RegisterObject(WaypointGroup); |
---|
18 | activeWaypoint = nullptr; |
---|
19 | |
---|
20 | //model = new Model(this->getContext()); |
---|
21 | //model->setMeshSource("cube.mesh"); // Name of the arrow file for now bottle |
---|
22 | //is->attach(model); |
---|
23 | //model->setScale(3); |
---|
24 | //model->setOrientation(Vector3(0,0,-1)); |
---|
25 | //model->setPosition(Vector3(0.0,0.0,0.0)); // this is wrong, it has to be triggered |
---|
26 | //waypoint_active = false; |
---|
27 | //distancetrigger = new DistanceTrigger(this->getContext()); |
---|
28 | //distancetrigger->setDistance(100); |
---|
29 | //this->attach(distancetrigger); |
---|
30 | |
---|
31 | } |
---|
32 | |
---|
33 | WaypointGroup::~WaypointGroup() |
---|
34 | { |
---|
35 | } |
---|
36 | |
---|
37 | |
---|
38 | //WorldEntity::setDirection |
---|
39 | //WorldEntity::getPosition() |
---|
40 | //setOrientation() |
---|
41 | |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | Waypoint* WaypointGroup::getWaypoint(unsigned int index) |
---|
46 | { |
---|
47 | unsigned int i = 0; |
---|
48 | for (Waypoint* child : this->waypoints_) |
---|
49 | { |
---|
50 | if (i == index) |
---|
51 | return child; |
---|
52 | ++i; |
---|
53 | } |
---|
54 | return nullptr; |
---|
55 | } |
---|
56 | |
---|
57 | void WaypointGroup::setWaypoint(Waypoint* object) |
---|
58 | { |
---|
59 | this->waypoints_.insert(object); |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | Waypoint* WaypointGroup::getActive(){ |
---|
64 | if (activeWaypoint == nullptr){ |
---|
65 | orxout() << "OOOOOOOOOO" << endl; |
---|
66 | |
---|
67 | activateNext(); |
---|
68 | |
---|
69 | } |
---|
70 | return activeWaypoint; |
---|
71 | } |
---|
72 | |
---|
73 | Waypoint* WaypointGroup::activateNext(){ |
---|
74 | for (Waypoint* object : this->waypoints_){ |
---|
75 | if(!(object->waypoint_actived)){ |
---|
76 | object->enable_waypoint(); |
---|
77 | activeWaypoint = object; |
---|
78 | } |
---|
79 | } |
---|
80 | return activeWaypoint; |
---|
81 | } |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | void WaypointGroup::XMLPort(Element& xmlelement, XMLPort::Mode mode){ |
---|
87 | SUPER(WaypointGroup, XMLPort, xmlelement, mode); // From the SpaceShip.cc file |
---|
88 | XMLPortObject(WaypointGroup, Waypoint, "waypoints", setWaypoint, getWaypoint, xmlelement, mode); |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | |
---|
94 | } |
---|