[1818] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Reto Grieder |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "RadarViewable.h" |
---|
[2662] | 30 | |
---|
[3130] | 31 | #include <OgreSceneManager.h> |
---|
[3157] | 32 | #include <OgreSceneNode.h> |
---|
| 33 | #include <OgreEntity.h> |
---|
| 34 | |
---|
[3280] | 35 | #include "util/StringUtils.h" |
---|
[1818] | 36 | #include "core/CoreIncludes.h" |
---|
[3174] | 37 | #include "tools/DynamicLines.h" |
---|
[5738] | 38 | #include "worldentities/WorldEntity.h" |
---|
| 39 | #include "Radar.h" |
---|
[5929] | 40 | #include "Scene.h" |
---|
[1818] | 41 | |
---|
| 42 | namespace orxonox |
---|
| 43 | { |
---|
| 44 | /** |
---|
| 45 | @brief Constructor. |
---|
| 46 | */ |
---|
| 47 | RadarViewable::RadarViewable() |
---|
[6716] | 48 | : isHumanShip_(false) |
---|
[6417] | 49 | , bVisibility_(true) |
---|
[3089] | 50 | , radarObjectCamouflage_(0.0f) |
---|
[2662] | 51 | , radarObjectShape_(Dot) |
---|
[1818] | 52 | , radarObjectDescription_("staticObject") |
---|
| 53 | { |
---|
| 54 | RegisterRootObject(RadarViewable); |
---|
[3064] | 55 | |
---|
[3089] | 56 | this->uniqueId_=getUniqueNumberString(); |
---|
[1818] | 57 | } |
---|
| 58 | |
---|
[3089] | 59 | |
---|
| 60 | RadarViewable::~RadarViewable() |
---|
| 61 | { |
---|
| 62 | } |
---|
| 63 | |
---|
[1818] | 64 | void RadarViewable::setRadarObjectDescription(const std::string& str) |
---|
| 65 | { |
---|
[5929] | 66 | Radar* radar = this->getWorldEntity()->getScene()->getRadar(); |
---|
[1818] | 67 | if (radar) |
---|
[2662] | 68 | this->radarObjectShape_ = radar->addObjectDescription(str); |
---|
[1818] | 69 | else |
---|
| 70 | { |
---|
| 71 | CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl; |
---|
| 72 | } |
---|
| 73 | this->radarObjectDescription_ = str; |
---|
| 74 | } |
---|
| 75 | |
---|
[2662] | 76 | const Vector3& RadarViewable::getRVWorldPosition() const |
---|
[1818] | 77 | { |
---|
[2662] | 78 | const WorldEntity* object = this->getWorldEntity(); |
---|
| 79 | validate(object); |
---|
| 80 | return object->getWorldPosition(); |
---|
[1818] | 81 | } |
---|
| 82 | |
---|
[2662] | 83 | Vector3 RadarViewable::getRVOrientedVelocity() const |
---|
[1818] | 84 | { |
---|
[2662] | 85 | const WorldEntity* object = this->getWorldEntity(); |
---|
| 86 | validate(object); |
---|
| 87 | return object->getWorldOrientation() * object->getVelocity(); |
---|
[1818] | 88 | } |
---|
[3182] | 89 | |
---|
| 90 | void RadarViewable::validate(const WorldEntity* object) const |
---|
| 91 | { |
---|
| 92 | if (!object) |
---|
| 93 | { |
---|
[6417] | 94 | COUT(1) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; |
---|
[3182] | 95 | assert(0); |
---|
| 96 | } |
---|
| 97 | } |
---|
[1818] | 98 | } |
---|