Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation3/src/orxonox/interfaces/RadarViewable.cc @ 6945

Last change on this file since 6945 was 6942, checked in by scheusso, 15 years ago

merging hudelements into presentation3 and reducing (or increasing) output level of lod debug output

  • Property svn:eol-style set to native
File size: 3.0 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->radar_ = this->creator_->getScene()->getRadar();
55        this->radar_->addRadarObject(this);
56        this->bInitialized_ = true;
57    }
58
59
60    RadarViewable::~RadarViewable()
61    {
62        if( this->bInitialized_ )
63            this->radar_->removeRadarObject(this);
64    }
65
66//     void RadarViewable::setRadarObjectDescription(const std::string& str)
67//     {
68//         Radar* radar = this->getWorldEntity()->getScene()->getRadar();
69//         if (radar)
70//             this->radarObjectShape_ = radar->addObjectDescription(str);
71//         else
72//         {
73//             CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
74//         }
75//         this->radarObjectDescription_ = str;
76//     }
77
78    const Vector3& RadarViewable::getRVWorldPosition() const
79    {
80        const WorldEntity* object = this->getWorldEntity();
81        validate(object);
82        return object->getWorldPosition();
83    }
84
85    Vector3 RadarViewable::getRVOrientedVelocity() const
86    {
87        const WorldEntity* object = this->getWorldEntity();
88        validate(object);
89        return object->getWorldOrientation() * object->getVelocity();
90    }
91
92    void RadarViewable::validate(const WorldEntity* object) const
93    {
94        if (!object)
95        {
96            COUT(1) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
97            assert(0);
98        }
99    }
100   
101    void RadarViewable::settingsChanged()
102    {
103        this->radar_->radarObjectChanged(this);
104    }
105}
Note: See TracBrowser for help on using the repository browser.