Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/hud/src/hud/hud_overlay.cc @ 253

Last change on this file since 253 was 253, checked in by rgrieder, 12 years ago
  • added 2 files for Chai's HUD
  • files contain a wrapper class for the overlay
  • not yet implemented in orxonox.cc
File size: 5.6 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 modify
8 *   it under the terms of the GNU General Public License as published by
9 *   the Free Software Foundation, either version 3 of the License, or
10 *   (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, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 *   Author:
22 *      HUD design: Yuning Chai
23 *      Implementation: Yuning Chai
24 *   Co-authors:
25 *      Implementation: Reto Grieder
26 *
27 */
28
29//#include "OgreMath.h"
30//#include "OgreVector3.h"
31#include "OgreStringConverter.h"
32#include "OgreOverlayManager.h"
33#include "OgreOverlay.h"
34#include "OgreOverlayElement.h"
35
36#include "hud_overlay.h"
37
38
39namespace orxonox {
40namespace hud {
41  using namespace Ogre;
42
43  HUDOverlay::HUDOverlay()
44  {
45    //TODO: write safe guard
46    overlay_ = OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
47  }
48
49
50  HUDOverlay::~HUDOverlay()
51  {
52  }
53
54
55  void HUDOverlay::show()
56  {
57    //TODO: safe guard
58    overlay_->show();
59  }
60
61
62  void HUDOverlay::hide()
63  {
64    //TODO: safe guard
65    overlay_->hide();
66  }
67
68
69  bool HUDOverlay::tick(unsigned long, Ogre::Real)
70  {
71                // set Time
72                int TimeMin = 99;
73                int TimeSec = 55;
74                OverlayElement* TimeText = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/Time/Text");
75                TimeText->setCaption(StringConverter::toString(TimeMin) + ":" + StringConverter::toString(TimeSec));
76               
77                // set TargetWindow
78                String TargetWindowName = "HURRA";
79                int TargetWindowDistance = 12;
80                String TargetWindowStatus = "Dead";
81                int TargetWindowHitRating = 30;
82                OverlayElement* TargetWindowNameText = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/Name");
83                TargetWindowNameText->setCaption( TargetWindowName);           
84                OverlayElement* TargetWindowDistanceText = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/DistanceText");
85                TargetWindowDistanceText->setCaption(StringConverter::toString(TargetWindowDistance) + "km" );
86                OverlayElement* TargetWindowStatusText = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/StatusText");
87                TargetWindowStatusText->setCaption( TargetWindowStatus );
88                OverlayElement* TargetWindowHitRatingText = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/TargetWindow/HitRatingText");
89                TargetWindowHitRatingText->setCaption(StringConverter::toString(TargetWindowHitRating) + "%" );
90               
91                // set Energy
92                int EnergyValue = 60.0;
93                OverlayElement* EnergyLength = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyBackground");
94                EnergyLength->setWidth((int)((double)60/(double)100*200));
95               
96                // set Shild
97                bool ShildLeftTopValue = true;
98                bool ShildRightTopValue = false;
99                bool ShildLeftBottomValue = false;
100                bool ShildRightBottomValue = true;
101                OverlayElement* ShildLeftTop = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/ShildLeftTop");
102                if (ShildLeftTopValue) ShildLeftTop->show();
103                else ShildLeftTop->hide();
104                OverlayElement* ShildRightTop = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/ShildRightTop");
105                if (ShildRightTopValue) ShildRightTop->show();
106                else ShildRightTop->hide();
107                OverlayElement* ShildLeftBottom = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/ShildLeftBottom");
108                if (ShildLeftBottomValue) ShildLeftBottom->show();
109                else ShildLeftBottom->hide();
110                OverlayElement* ShildRightBottom = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/ShildRightBottom");
111                if (ShildRightBottomValue) ShildRightBottom->show();
112                else ShildRightBottom->hide();
113               
114                // set Rockets
115                int Rocket1 = 11;
116                int Rocket2 = 22;
117                int Rocket3 = 33;
118                int Rocket4 = 44;
119                OverlayElement* RocketNum1 = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum1");
120                RocketNum1->setCaption(StringConverter::toString(Rocket1));
121                OverlayElement* RocketNum2 = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum2");
122                RocketNum2->setCaption(StringConverter::toString(Rocket2));
123                OverlayElement* RocketNum3 = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum3");
124                RocketNum3->setCaption(StringConverter::toString(Rocket3));
125                OverlayElement* RocketNum4 = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/RocketNum4");
126                RocketNum4->setCaption(StringConverter::toString(Rocket4));
127               
128                // set EnergyDistribution
129                double EnergyDistrPixelX = 100;
130                double EnergyDistrPixelY = 86;         
131                double EnergyDistrShild = 32;
132                double EnergyDistrEngine = 50;
133                double EnergyDistrLaser = 18;
134                double EnergyDistrShildInv = 100 - EnergyDistrShild;
135                double EnergyDistrEngineInv = 100 - EnergyDistrEngine;
136                double EnergyDistrLaserInv = 100 - EnergyDistrLaser;
137                double EnergyDistrY = (double)EnergyDistrEngineInv/((double)EnergyDistrEngineInv+(double)EnergyDistrLaserInv) * EnergyDistrPixelY;
138                double EnergyDistrX = EnergyDistrY/1.7321;
139               
140               
141               
142                OverlayElement* EnergyDistrPoint = OverlayManager::getSingleton().getOverlayElement("Orxonox/HUD1.2/EnergyDistrPoint");
143//              EnergyDistrPoint->setLeft();
144//              EnergyDistrPoint->setTop();
145
146
147    // keep rendering
148    return true;
149  }
150}
151}
Note: See TracBrowser for help on using the repository browser.