[668] | 1 | /* |
---|
[708] | 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * License notice: |
---|
| 6 | * |
---|
| 7 | * This program is free software; you can redistribute it and/or |
---|
| 8 | * modify it under the terms of the GNU General Public License |
---|
| 9 | * as published by the Free Software Foundation; either version 2 |
---|
| 10 | * of the License, or (at your option) any later version. |
---|
| 11 | * |
---|
| 12 | * This program is distributed in the hope that it will be useful, |
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | * GNU General Public License for more details. |
---|
| 16 | * |
---|
| 17 | * You should have received a copy of the GNU General Public License |
---|
| 18 | * along with this program; if not, write to the Free Software |
---|
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 20 | * |
---|
| 21 | * Author: |
---|
| 22 | * Yuning Chai |
---|
| 23 | * Co-authors: |
---|
| 24 | * ... |
---|
| 25 | * |
---|
| 26 | */ |
---|
[991] | 27 | |
---|
| 28 | |
---|
| 29 | #include "OrxonoxStableHeaders.h" |
---|
| 30 | #include <OgreOverlay.h> |
---|
| 31 | #include <OgreOverlayContainer.h> |
---|
[1099] | 32 | #include <OgreOverlayManager.h>ma |
---|
[1000] | 33 | #include <OgreSceneNode.h> |
---|
[1012] | 34 | #include <OgreEntity.h> |
---|
[991] | 35 | |
---|
| 36 | #include "HUD.h" |
---|
[1099] | 37 | #include "BarOverlayElement.h" |
---|
| 38 | #include "OverlayElementFactories.h" |
---|
[1000] | 39 | // ugly hack |
---|
| 40 | #include "Orxonox.h" |
---|
[991] | 41 | |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | using namespace Ogre; |
---|
| 46 | |
---|
| 47 | HUD::HUD(int zoom){ |
---|
| 48 | |
---|
| 49 | Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton(); |
---|
[1099] | 50 | |
---|
| 51 | BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory(); |
---|
| 52 | overlayManager.addOverlayElementFactory(barOverlayElementFactory); |
---|
| 53 | |
---|
| 54 | SmartBarOverlayElementFactory *smartBarOverlayElementFactory = new SmartBarOverlayElementFactory(); |
---|
| 55 | overlayManager.addOverlayElementFactory(smartBarOverlayElementFactory); |
---|
| 56 | |
---|
| 57 | Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD"); |
---|
[991] | 58 | |
---|
| 59 | Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel")); |
---|
[1099] | 60 | |
---|
| 61 | energyCounter = static_cast<SmartBarOverlayElement*>(overlayManager.createOverlayElement("SmartBar", "energyCounter")); |
---|
| 62 | energyCounter->show(); |
---|
| 63 | |
---|
| 64 | energyCounterPanel->addChild(energyCounter); |
---|
[991] | 65 | energyCounterPanel->show(); |
---|
| 66 | |
---|
| 67 | orxonoxOverlay->add2D(energyCounterPanel); |
---|
[1099] | 68 | orxonoxOverlay->show(); |
---|
[1000] | 69 | |
---|
| 70 | // important: don't use SceneManager to create the node! but register the creator scene manager. |
---|
[1099] | 71 | /* ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely"); |
---|
[1000] | 72 | |
---|
| 73 | ogreNode_->setPosition(80,-60,-200); |
---|
| 74 | ogreNode_->setScale(0.4,0.4,0.4); |
---|
| 75 | // ugly hack, but I haven't figured out yet how we could change this, since we really need the |
---|
| 76 | // scene manager.. |
---|
| 77 | ogreNode_->attachObject(Orxonox::getSingleton()->getSceneManager()->createEntity("head", "ogrehead.mesh")); |
---|
[1099] | 78 | // orxonoxOverlay->add3D(ogreNode_); |
---|
| 79 | */ |
---|
| 80 | |
---|
| 81 | energyCounterPanel->setLeft(-50); |
---|
| 82 | energyCounterPanel->setTop(10); |
---|
| 83 | energyCounterPanel->setWidth(100); |
---|
| 84 | energyCounterPanel->setHeight(20); |
---|
| 85 | energyCounterPanel->setHorizontalAlignment(Ogre::GHA_CENTER); |
---|
| 86 | energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS); |
---|
| 87 | |
---|
| 88 | energyCounter->initSmartBarOverlayElement(-100,0,200,20,BarOverlayElement::LEFT); |
---|
| 89 | energyCounter->reset(80); |
---|
[1000] | 90 | |
---|
[1099] | 91 | |
---|
[991] | 92 | } |
---|
| 93 | |
---|
[1099] | 94 | /* void HUD::tick(float dt) |
---|
[1000] | 95 | { |
---|
| 96 | if (this->ogreNode_) |
---|
| 97 | { |
---|
| 98 | this->ogreNode_->roll(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL); |
---|
[1012] | 99 | this->ogreNode_->yaw(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL); |
---|
| 100 | this->ogreNode_->pitch(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL); |
---|
[1000] | 101 | } |
---|
| 102 | } |
---|
[1099] | 103 | */ |
---|
[991] | 104 | HUD::~HUD(void){} |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | |
---|
| 114 | |
---|