1 | /* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
---|
2 | * Author: |
---|
3 | * Felix Schulthess |
---|
4 | * Co-authors: |
---|
5 | * ... |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "OrxonoxStableHeaders.h" |
---|
10 | #include "RadarObject.h" |
---|
11 | |
---|
12 | #include <OgreOverlayManager.h> |
---|
13 | #include <OgreStringConverter.h> |
---|
14 | #include "GraphicsEngine.h" |
---|
15 | |
---|
16 | namespace orxonox |
---|
17 | { |
---|
18 | using namespace Ogre; |
---|
19 | |
---|
20 | int RadarObject::count = 0; // initialize static variable |
---|
21 | |
---|
22 | RadarObject::RadarObject(OverlayContainer* container, SceneNode* node, int colour){ |
---|
23 | container_ = container; |
---|
24 | node_ = node; |
---|
25 | colour_ = colour; |
---|
26 | om = &OverlayManager::getSingleton(); |
---|
27 | panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", |
---|
28 | "Object"+StringConverter::toString(count))); |
---|
29 | setColour(colour_); |
---|
30 | panel_->setDimensions(3,3); |
---|
31 | panel_->setMetricsMode(Ogre::GMM_PIXELS); |
---|
32 | panel_->show(); |
---|
33 | index_ = count; |
---|
34 | count++; |
---|
35 | container_->addChild(panel_); |
---|
36 | } |
---|
37 | |
---|
38 | RadarObject::~RadarObject(){ |
---|
39 | delete panel_; |
---|
40 | } |
---|
41 | |
---|
42 | void RadarObject::setColour(int colour){ |
---|
43 | switch(colour){ |
---|
44 | case RED: panel_->setMaterialName("Orxonox/RedDot"); break; |
---|
45 | case YELLOW: panel_->setMaterialName("Orxonox/YellowDot"); break; |
---|
46 | case GREEN: panel_->setMaterialName("Orxonox/GreenDot"); break; |
---|
47 | case BLUE: panel_->setMaterialName("Orxonox/BlueDot"); break; |
---|
48 | case WHITE: panel_->setMaterialName("Orxonox/WhiteDot"); break; |
---|
49 | default: panel_->setMaterialName("Orxonox/RedDot"); break; |
---|
50 | } |
---|
51 | } |
---|
52 | |
---|
53 | void RadarObject::resetColour(){ |
---|
54 | setColour(colour_); |
---|
55 | } |
---|
56 | |
---|
57 | Vector3 RadarObject::getPosition(){ |
---|
58 | return node_->getPosition(); |
---|
59 | } |
---|
60 | |
---|
61 | SceneNode* RadarObject::getNode(){ |
---|
62 | return node_; |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|