Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hudelements/src/orxonox/interfaces/RadarViewable.cc @ 6716

Last change on this file since 6716 was 6716, checked in by scheusso, 14 years ago

removed some bindings to map

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
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"
30
31#include <OgreSceneManager.h>
32#include <OgreSceneNode.h>
33#include <OgreEntity.h>
34
35#include "util/StringUtils.h"
36#include "core/CoreIncludes.h"
37#include "tools/DynamicLines.h"
38#include "worldentities/WorldEntity.h"
39#include "Radar.h"
40#include "Scene.h"
41
42namespace orxonox
43{
44    /**
45        @brief Constructor.
46    */
47    RadarViewable::RadarViewable()
48        : isHumanShip_(false)
49        , bVisibility_(true)
50        , radarObjectCamouflage_(0.0f)
51        , radarObjectShape_(Dot)
52        , radarObjectDescription_("staticObject")
53    {
54        RegisterRootObject(RadarViewable);
55
56        this->uniqueId_=getUniqueNumberString();
57    }
58
59
60    RadarViewable::~RadarViewable()
61    {
62    }
63
64    void RadarViewable::setRadarObjectDescription(const std::string& str)
65    {
66        Radar* radar = this->getWorldEntity()->getScene()->getRadar();
67        if (radar)
68            this->radarObjectShape_ = radar->addObjectDescription(str);
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
76    const Vector3& RadarViewable::getRVWorldPosition() const
77    {
78        const WorldEntity* object = this->getWorldEntity();
79        validate(object);
80        return object->getWorldPosition();
81    }
82
83    Vector3 RadarViewable::getRVOrientedVelocity() const
84    {
85        const WorldEntity* object = this->getWorldEntity();
86        validate(object);
87        return object->getWorldOrientation() * object->getVelocity();
88    }
89
90    void RadarViewable::validate(const WorldEntity* object) const
91    {
92        if (!object)
93        {
94            COUT(1) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
95            assert(0);
96        }
97    }
98}
Note: See TracBrowser for help on using the repository browser.