[1494] | 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. * |
---|
[1454] | 2 | * Author: |
---|
| 3 | * Felix Schulthess |
---|
| 4 | * Co-authors: |
---|
| 5 | * ... |
---|
| 6 | * |
---|
| 7 | */ |
---|
[1346] | 8 | |
---|
[1480] | 9 | #include "OrxonoxStableHeaders.h" |
---|
| 10 | #include "RadarObject.h" |
---|
| 11 | |
---|
[1450] | 12 | #include <OgreOverlayManager.h> |
---|
| 13 | #include <OgreStringConverter.h> |
---|
| 14 | #include "GraphicsEngine.h" |
---|
[1346] | 15 | |
---|
| 16 | namespace orxonox |
---|
| 17 | { |
---|
| 18 | using namespace Ogre; |
---|
| 19 | |
---|
[1410] | 20 | int RadarObject::count = 0; // initialize static variable |
---|
[1346] | 21 | |
---|
[1450] | 22 | RadarObject::RadarObject(OverlayContainer* container, SceneNode* node, int colour){ |
---|
[1410] | 23 | container_ = container; |
---|
[1450] | 24 | node_ = node; |
---|
| 25 | colour_ = colour; |
---|
[1410] | 26 | om = &OverlayManager::getSingleton(); |
---|
| 27 | panel_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", |
---|
[1450] | 28 | "Object"+StringConverter::toString(count))); |
---|
| 29 | setColour(colour_); |
---|
[1410] | 30 | panel_->setDimensions(3,3); |
---|
[1346] | 31 | panel_->setMetricsMode(Ogre::GMM_PIXELS); |
---|
| 32 | panel_->show(); |
---|
| 33 | index_ = count; |
---|
| 34 | count++; |
---|
| 35 | container_->addChild(panel_); |
---|
[1410] | 36 | } |
---|
[1450] | 37 | |
---|
| 38 | RadarObject::~RadarObject(){ |
---|
[1456] | 39 | delete panel_; |
---|
[1450] | 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 | } |
---|
[1456] | 60 | |
---|
| 61 | SceneNode* RadarObject::getNode(){ |
---|
| 62 | return node_; |
---|
| 63 | } |
---|
[1346] | 64 | } |
---|
[1450] | 65 | |
---|