Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 980


Ignore:
Timestamp:
Apr 3, 2008, 2:52:50 PM (17 years ago)
Author:
chaiy
Message:

hallo

Location:
code/branches/hud/src/orxonox/hud
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hud/src/orxonox/hud/Bar.cc

    r979 r980  
    33*
    44*
    5 *   License notice:asdf
     5*   License notice:
    66*
    77*   This program is free software; you can redistribute it and/or
     
    2828#include <OgreOverlayManager.h>
    2929#include <OgreOverlayElement.h>
     30#include <OgreTextAreaOverlayElement.h>
    3031#include <OgreStringConverter.h>
    31 #include <OgreColourValue.h>
    3232#include <string.h>
    3333
     
    3737{
    3838  using namespace Ogre;
     39   
     40  Bar::Bar(Real left, Real top, Real width, Real height,
     41          int dir,  int colour, std::string name){
     42    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
     43    element = overlayManager.createOverlayElement("Panel",name);
     44    element->setMetricsMode(Ogre::GMM_PIXELS);
     45    dir_ = dir;
     46    left_ = left;
     47    top_ = top;
     48    width_ = width;
     49    height_ = height;
     50    element->setPosition(left_,top_);
     51    element->setDimensions(width_,height_);
     52    setColour(colour);
     53  }
     54 
     55  Bar::~Bar(void){}
     56 
     57 
     58  void Bar::reset(int percentage){
     59    switch(dir_){
     60      case 1:
     61        element->setPosition(left_,top_);
     62        element->setDimensions(width_,height_*percentage/100);
     63        break;
     64      case 2:
     65        element->setPosition(left_+width_-width_*percentage/100,top_);
     66        element->setDimensions(width_*percentage/100,height_);
     67        break;
     68      case 3:
     69        element->setPosition(left_,top_+height_-height_*percentage/100);
     70        element->setDimensions(width_,height_*percentage/100);
     71        break;
     72      default:
     73        element->setPosition(left_,top_);
     74        element->setDimensions(width_*percentage/100,height_); 
     75    }
     76  }
    3977
    40   Bar::Bar(void){}
     78  void Bar::setColour(int colour){
     79    switch(colour){
     80     case 0:
     81        element->setMaterialName("Orxonox/Red");
     82        break;
     83     case 1:
     84        element->setMaterialName("Orxonox/Yellow");
     85        break;
     86     case 2:
     87        element->setMaterialName("Orxonox/Green");
     88    }
     89  }
    4190
    42   Bar::~Bar(void){}
     91  void Bar::show(){element->show();}
     92
     93  void Bar::hide(){element->hide();}
     94
     95  SmartBar::SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,
     96        int dir, std::string name) : Bar::Bar(left, top, width, height, dir, Bar::YELLOW, name){
     97  }
     98
     99  SmartBar::~SmartBar(void){}
    43100
    44101
    45 /*  void Bar::setPercentage(Ogre::Real percentage){
    46     percentage_=percentage;
    47     if(horz_){setWidth(int(percentage_* maxLength_));}
    48         else {setHeight(int(percentage_ * maxHeight_));}
    49     }
    50 */
    51 
    52   void Bar::setPercentage(Ogre::Real percentage){
    53     percentage_ = percentage;
    54 //    setWidth(getWidth());
     102  void SmartBar::reset(int percentage){
     103    if (percentage>50) {setColour(Bar::GREEN);}
     104    else if (percentage>25) {setColour(Bar::YELLOW);}
     105    else setColour(Bar::RED);
     106    Bar::reset(percentage);
    55107  }
    56108
     109}
    57110
    58111
    59 
    60   void Bar::setColor(ColourValue color){
    61     color_=color;
    62     setColour(color);
    63   }
    64 
    65 
    66 }
  • code/branches/hud/src/orxonox/hud/Bar.h

    r825 r980  
    3030#define _BAR_H__
    3131
    32 #include <string>
    33 #include <OgreColourValue.h>
     32#include <string.h>
    3433#include <OgreOverlayElement.h>
     34#include <OgreTextAreaOverlayElement.h>
    3535#include <OgrePrerequisites.h>
    36 #include <string.h>
    3736#include "../OrxonoxPrereqs.h"
    3837
    3938
    4039
    41 // namespace hud
    4240namespace orxonox
    4341{
    44   class Bar : public Ogre::OverlayElement
     42  class _OrxonoxExport Bar
    4543  {
    4644  private:
    47     double percentage_;
    48     bool horz_;
    49     Ogre::ColourValue color_;
     45    int percentage_;
     46    int dir_;   
     47    int left_;
     48    int top_;
     49    int width_;
     50    int height_;
     51       
     52  public:
     53    static const int LEFT = 0;
     54    static const int UP = 1;
     55    static const int RIGHT = 2;
     56    static const int DOWN = 3;
     57
     58    static const int RED = 0;
     59    static const int YELLOW = 1;
     60    static const int GREEN = 2;
     61
     62    Ogre::OverlayElement* element;
     63
     64    Bar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,
     65        int dir, int colour, std::string name);
     66    ~Bar(void);
     67    void reset(int percentage);
     68    void setColour(int colour);
     69    void show();
     70    void hide();
     71   
     72  };
    5073
    5174
     75  class _OrxonoxExport SmartBar : public Bar
     76  {
     77  private:
     78
    5279  public:
    53     Bar(void);
    54     ~Bar(void);
    55     void setPercentage(Ogre::Real percentage);
    56     void setColor(Ogre::ColourValue color);
     80    SmartBar(Ogre::Real left, Ogre::Real top, Ogre::Real width, Ogre::Real height,
     81        int dir, std::string name);
     82    ~SmartBar(void);
     83    void reset(int percentage);
    5784  };
    5885}
  • code/branches/hud/src/orxonox/hud/HUD.cc

    r964 r980  
    88*   modify it under the terms of the GNU General Public License
    99*   as published by the Free Software Foundation; either version 2
    10 *   of the License, or (at your option)asdf any later version.
     10*   of the License, or (at your option) any later version.
    1111*
    1212*   This program is distributed in the hope that it will be useful,
     
    2626*/
    2727
     28
    2829#include "OrxonoxStableHeaders.h"
     30#include <OgreOverlay.h>
     31#include <OgreOverlayContainer.h>
     32#include <OgreOverlayManager.h>
     33
     34#include "HUD.h"
     35#include "Bar.h"
     36
     37
     38namespace orxonox
     39{
     40  using namespace Ogre;
     41
     42
     43
     44
     45
     46  HUD::HUD(int zoom){
     47
     48    Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
     49
     50    energyCounter = new Bar(0,0,100,20,Bar::LEFT,Bar::YELLOW,"Orxonox/HUD/energyCounterPanel/energyCounter");
     51
     52    Ogre::OverlayContainer* energyCounterPanel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "Orxonox/HUD/energyCounterPanel"));
     53    energyCounterPanel->setLeft(-50);
     54    energyCounterPanel->setTop(10);
     55    energyCounterPanel->setWidth(100);
     56    energyCounterPanel->setHeight(20);
     57    energyCounterPanel->setHorizontalAlignment(Ogre::GHA_CENTER);
     58    energyCounterPanel->setMetricsMode(Ogre::GMM_PIXELS);       
     59    energyCounterPanel->show();
     60    energyCounterPanel->addChild(energyCounter->element);
     61
     62    Ogre::Overlay* orxonoxOverlay = overlayManager.create("Orxonox/HUD");
     63    orxonoxOverlay->add2D(energyCounterPanel);
     64    orxonoxOverlay->show();
     65  }
     66
     67  HUD::~HUD(void){}
     68
     69
     70
     71}
     72
     73
     74
     75
     76
     77
     78/*#include "OrxonoxStableHeaders.h"
    2979
    3080#include <OgreOverlayManager.h>
     
    3484#include "HUD.h"
    3585#include "Bar.h"
    36 
    3786
    3887namespace orxonox
     
    51100    setTargetWindowDistance(30);
    52101
    53     setEnergyValue(60.0);
     102    setEnergyValue(60);
    54103
    55104    setShieldLeftTopValue(true);
     
    69118    energyDistrPixelX_ = 100;
    70119    energyDistrPixelY_ = 86;
     120
    71121
    72122  }
     
    218268
    219269}
     270*/
  • code/branches/hud/src/orxonox/hud/HUD.h

    r790 r980  
    2626*/
    2727
     28
    2829#ifndef _HUD_H__
     30#define _HUD_H__
     31
     32#include <string.h>
     33#include <OgreOverlayElement.h>
     34#include <OgreTextAreaOverlayElement.h>
     35#include <OgrePrerequisites.h>
     36#include "../OrxonoxPrereqs.h"
     37
     38#include "Bar.h"
     39
     40
     41namespace orxonox
     42{
     43  class _OrxonoxExport HUD
     44  {
     45  private:
     46
     47  public:
     48    HUD(int zoom);
     49    ~HUD();
     50
     51    Bar* energyCounter;
     52  };
     53}       
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63#endif _HUD_H_
     64
     65/*#ifndef _HUD_H__
    2966#define _HUD_H__
    3067
Note: See TracChangeset for help on using the changeset viewer.