Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

HUDRadar now working again

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