Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud3/src/orxonox/hud/HUD.cc @ 1331

Last change on this file since 1331 was 1331, checked in by FelixSchulthess, 16 years ago

bug

File size: 3.0 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*      Felix Schulthess
25*
26*/
27
28
29#include "OrxonoxStableHeaders.h"
30#include <OgreOverlay.h>
31#include <OgreOverlayContainer.h>
32#include <OgreOverlayManager.h>
33#include <OgreSceneNode.h>
34#include <OgreEntity.h>
35#include "core/Debug.h"
36
37#include "HUD.h"
38#include "BarOverlayElement.h"
39#include "RadarOverlayElement.h"
40#include "OverlayElementFactories.h"
41#include "DialogBox.h"
42
43namespace orxonox
44{
45    using namespace Ogre;
46
47    HUD::HUD(int zoom){
48        om = &Ogre::OverlayManager::getSingleton();
49
50        BarOverlayElementFactory *barOverlayElementFactory = new BarOverlayElementFactory();
51        om->addOverlayElementFactory(barOverlayElementFactory);
52
53        RadarOverlayElementFactory *radarOverlayElementFactory = new RadarOverlayElementFactory();
54        om->addOverlayElementFactory(radarOverlayElementFactory);
55
56        orxonoxHUD = om->create("Orxonox/HUD");
57
58        container = static_cast<Ogre::OverlayContainer*>(om->createOverlayElement("Panel", "Orxonox/HUD/container"));
59
60        energyCounter = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "energyCounter"));
61        energyCounter->show();
62
63        speedo = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "speedo"));
64        speedo->show();
65
66        radar = static_cast<RadarOverlayElement*>(om->createOverlayElement("Radar", "radar"));
67        radar->show();
68
69        container->show();
70        orxonoxHUD->add2D(container);
71        orxonoxHUD->show();
72        container->setLeft(0.0);
73        container->setTop(0.0);
74        container->setWidth(1.0);
75        container->setHeight(1.0);
76        container->setMetricsMode(Ogre::GMM_RELATIVE);
77
78        energyCounter->init(0.01, 0.95, 0.4, 0.04, container);
79        energyCounter->setValue(1);
80
81        speedo->init(0.01, 0.90, 0.4, 0.04, container);
82
83        radar->init(0.5, 0.9, 0.2, container);
84
85        Dial
86    }
87
88    void HUD::tick(float dt)
89    {
90        energyCounter->resize();
91
92        float v = SpaceShip::instance_s->getVelocity().length();
93        float vmax = SpaceShip::instance_s->getMaxSpeed();
94        speedo->setValue(v/vmax);
95        speedo->resize();
96
97        radar->resize();
98        radar->update();
99    }
100
101    HUD::~HUD(void){
102    }
103}
104
105
106
107
108
109
Note: See TracBrowser for help on using the repository browser.