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