Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6957 was 6942, checked in by scheusso, 14 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
RevLine 
[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
[3280]31#include "util/StringUtils.h"
[1818]32#include "core/CoreIncludes.h"
[5738]33#include "worldentities/WorldEntity.h"
34#include "Radar.h"
[5929]35#include "Scene.h"
[1818]36
37namespace orxonox
38{
39    /**
40        @brief Constructor.
41    */
[6942]42    RadarViewable::RadarViewable(BaseObject* creator)
43        : isHumanShip_(false)
[6417]44        , bVisibility_(true)
[6942]45        , bInitialized_(false)
46        , creator_(creator)
[3089]47        , radarObjectCamouflage_(0.0f)
[2662]48        , radarObjectShape_(Dot)
[1818]49        , radarObjectDescription_("staticObject")
50    {
51        RegisterRootObject(RadarViewable);
[3064]52
[3089]53        this->uniqueId_=getUniqueNumberString();
[6942]54        this->radar_ = this->creator_->getScene()->getRadar();
55        this->radar_->addRadarObject(this);
56        this->bInitialized_ = true;
[1818]57    }
58
[3089]59
60    RadarViewable::~RadarViewable()
61    {
[6942]62        if( this->bInitialized_ )
63            this->radar_->removeRadarObject(this);
[3089]64    }
65
[6942]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//     }
[3089]77
[2662]78    const Vector3& RadarViewable::getRVWorldPosition() const
[1818]79    {
[2662]80        const WorldEntity* object = this->getWorldEntity();
81        validate(object);
82        return object->getWorldPosition();
[1818]83    }
84
[2662]85    Vector3 RadarViewable::getRVOrientedVelocity() const
[1818]86    {
[2662]87        const WorldEntity* object = this->getWorldEntity();
88        validate(object);
89        return object->getWorldOrientation() * object->getVelocity();
[1818]90    }
[3182]91
92    void RadarViewable::validate(const WorldEntity* object) const
93    {
94        if (!object)
95        {
[6417]96            COUT(1) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
[3182]97            assert(0);
98        }
99    }
[6942]100   
101    void RadarViewable::settingsChanged()
102    {
103        this->radar_->radarObjectChanged(this);
104    }
[1818]105}
Note: See TracBrowser for help on using the repository browser.