Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud2/src/orxonox/hud/HUD.cc @ 1218

Last change on this file since 1218 was 1099, checked in by chaiy, 17 years ago

Bars finally work

File size: 3.5 KB
Line 
1/*
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*/
27
28
29#include "OrxonoxStableHeaders.h"
30#include <OgreOverlay.h>
31#include <OgreOverlayContainer.h>
32#include <OgreOverlayManager.h>ma
33#include <OgreSceneNode.h>
34#include <OgreEntity.h>
35
36#include "HUD.h"
37#include "BarOverlayElement.h"
38#include "OverlayElementFactories.h"
39// ugly hack
40#include "Orxonox.h"
41
42
43namespace orxonox
44{
45  using namespace Ogre;
46
47  HUD::HUD(int zoom){
48
49    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
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"); 
58
59    Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel"));
60   
61    energyCounter = static_cast<SmartBarOverlayElement*>(overlayManager.createOverlayElement("SmartBar", "energyCounter"));
62    energyCounter->show();
63   
64    energyCounterPanel->addChild(energyCounter);
65    energyCounterPanel->show();
66
67    orxonoxOverlay->add2D(energyCounterPanel);
68    orxonoxOverlay->show();
69
70    // important: don't use SceneManager to create the node! but register the creator scene manager.
71/*    ogreNode_ = new Ogre::SceneNode(Orxonox::getSingleton()->getSceneManager(), "hudNoedely");
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"));
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);
90
91   
92  }
93
94/*  void HUD::tick(float dt)
95  {
96    if (this->ogreNode_)
97    {
98      this->ogreNode_->roll(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
99      this->ogreNode_->yaw(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
100      this->ogreNode_->pitch(Ogre::Degree(dt*200),Ogre::Node::TS_LOCAL);
101    }
102  }
103*/
104  HUD::~HUD(void){}
105
106
107
108}
109
110
111
112
113
114
Note: See TracBrowser for help on using the repository browser.