1 | #include "Waypointarrow.h" |
---|
2 | |
---|
3 | #include <OgreSceneNode.h> |
---|
4 | #include <BulletDynamics/Dynamics/btRigidBody.h> |
---|
5 | #include "util/OrxAssert.h" |
---|
6 | #include "core/CoreIncludes.h" |
---|
7 | |
---|
8 | namespace orxonox |
---|
9 | { |
---|
10 | RegisterClass(Waypointarrow); |
---|
11 | |
---|
12 | Waypointarrow::Waypointarrow(Context* context) : StaticEntity(context) |
---|
13 | { |
---|
14 | RegisterObject(Waypointarrow); |
---|
15 | model = new Model(this->getContext()); |
---|
16 | model->setMeshSource("arrow.mesh"); // Name of the arrow file for now bottle |
---|
17 | this->attach(model); |
---|
18 | model->setScale(3); |
---|
19 | // model->setOrientation(Vector3(0,0,-1)); |
---|
20 | model->setPosition(Vector3(0,15, 0)); |
---|
21 | waypoints_ = nullptr; |
---|
22 | } |
---|
23 | |
---|
24 | Waypointarrow::~Waypointarrow() |
---|
25 | { |
---|
26 | } |
---|
27 | |
---|
28 | /* |
---|
29 | Waypoint* WaypointGroup::getActive(){ |
---|
30 | for (Waypoint* object : this->waypoints_){ |
---|
31 | if(!(object->waypoint_actived)){ |
---|
32 | object->enable_waypoint(); |
---|
33 | return object; |
---|
34 | } |
---|
35 | } |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | void tick::getActive |
---|
40 | |
---|
41 | |
---|
42 | */ |
---|
43 | |
---|
44 | |
---|
45 | WaypointGroup* Waypointarrow::getWaypointgroup() |
---|
46 | { |
---|
47 | if (waypoints_ == nullptr){ |
---|
48 | |
---|
49 | for (WaypointGroup* group : ObjectList<WaypointGroup>()) |
---|
50 | waypoints_ = group; |
---|
51 | |
---|
52 | } |
---|
53 | |
---|
54 | return waypoints_; |
---|
55 | } |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | void Waypointarrow::tick(float dt){ |
---|
61 | |
---|
62 | if (getWaypointgroup() == nullptr){ |
---|
63 | //orxout() << "Second" << endl; |
---|
64 | |
---|
65 | return; |
---|
66 | } |
---|
67 | |
---|
68 | waypoints_ = getWaypointgroup(); |
---|
69 | waypoint = waypoints_->getActive(); |
---|
70 | Vector3 waypoint_position = waypoint->getWorldPosition(); |
---|
71 | |
---|
72 | |
---|
73 | //orxout() << "dsfsf" << waypoint_position.x << 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; |
---|
78 | |
---|
79 | |
---|
80 | Vector3 origin = model->getWorldPosition();; |
---|
81 | model->setDirection( origin - waypoint_position, TransformSpace::World); |
---|
82 | |
---|
83 | |
---|
84 | } |
---|
85 | |
---|
86 | void Waypointarrow::XMLPort(Element& xmlelement, XMLPort::Mode mode){ |
---|
87 | SUPER(Waypointarrow, XMLPort, xmlelement, mode); // From the SpaceShip.cc file |
---|
88 | //XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, Vector3) |
---|
89 | //XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode); // TRY ADDING THE WAYPOINT ARROW LIKE AN ENGINE |
---|
90 | |
---|
91 | |
---|
92 | } |
---|
93 | |
---|
94 | |
---|
95 | } |
---|