Changeset 1329 for code/branches/hud3/src
- Timestamp:
- May 19, 2008, 10:51:53 PM (17 years ago)
- Location:
- code/branches/hud3/src/orxonox/hud
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hud3/src/orxonox/hud/BarOverlayElement.cc
r1328 r1329 49 49 color_ = 2; 50 50 autoColor_ = true; 51 dir_ = BarOverlayElement::RIGHT;51 left2Right = false; // default: right to left progress 52 52 53 53 // get window data... … … 66 66 67 67 // create background... 68 bar_ = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", name_+"Bar")); 69 bar_->show(); 70 container_->addChild(bar_); 71 bar_->setPosition(left_, top_); 72 bar_->setDimensions(width_, height_); 73 bar_->setMetricsMode(Ogre::GMM_PIXELS); 74 bar_->setMaterialName("Orxonox/Green"); 68 background_ = static_cast<OverlayContainer*>(om->createOverlayElement("Panel", name_+"container")); 69 background_->show(); 70 container_->addChild(background_); 71 background_->setMetricsMode(Ogre::GMM_PIXELS); 72 background_->setMaterialName("Orxonox/BarBackground"); 75 73 76 s etPosition(left_,top_);77 setDimensions(width_,height_);74 show(); 75 background_->addChild(this); 78 76 setMetricsMode(Ogre::GMM_PIXELS); 79 setMaterialName("Orxonox/BarBackground"); 77 setMaterialName("Orxonox/Green"); 78 resize(); 79 } 80 81 void BarOverlayElement::resize(){ 82 windowW_ = GraphicsEngine::getSingleton().getWindowWidth(); 83 windowH_ = GraphicsEngine::getSingleton().getWindowHeight(); 84 // cálculate new absolute coordinates... 85 left_ = leftRel_ * windowW_; 86 top_ = topRel_ * windowH_; 87 width_ = widthRel_ * windowW_; 88 height_ = heightRel_ * windowH_; 89 // adapt background 90 background_->setPosition(left_, top_); 91 background_->setDimensions(width_, height_); 92 // adapt bar 80 93 setValue(value_); 81 94 } 82 95 83 84 void BarOverlayElement::setValue(float value){ 96 void BarOverlayElement::setValue(float value){ 85 97 value_ = value; 86 98 // set color, if nescessary … … 91 103 } 92 104 // set value 93 switch(dir_){ 94 case BarOverlayElement::DOWN: 95 bar_->setPosition(left_,top_); 96 bar_->setDimensions(width_,height_*value_); 97 break; 98 case BarOverlayElement::LEFT: 99 bar_->setPosition(left_+width_-width_*value_,top_); 100 bar_->setDimensions(width_*value_,height_); 101 break; 102 case BarOverlayElement::UP: 103 bar_->setPosition(left_,top_+height_-height_*value_); 104 bar_->setDimensions(width_,height_*value_); 105 break; 106 default: 107 bar_->setPosition(left_,top_); 108 bar_->setDimensions(width_*value_,height_); 109 break; 105 if(left2Right){ // backward case 106 setPosition(0+width_-width_*value_, 0); 107 setDimensions(width_*value_,height_); 108 }else{ // default case 109 setPosition(0, 0); 110 setDimensions(width_*value_,height_); 110 111 } 111 } 112 113 void BarOverlayElement::setDir(int dir){ 112 if(value_ != 0) setTiling(value_, 1.0); 114 113 } 115 114 … … 118 117 switch(color){ 119 118 case 0: 120 bar_->setMaterialName("Orxonox/Red");119 setMaterialName("Orxonox/Red"); 121 120 break; 122 121 case 1: 123 bar_->setMaterialName("Orxonox/Yellow");122 setMaterialName("Orxonox/Yellow"); 124 123 break; 125 124 case 2: 126 bar_->setMaterialName("Orxonox/Green");125 setMaterialName("Orxonox/Green"); 127 126 } 128 127 } -
code/branches/hud3/src/orxonox/hud/BarOverlayElement.h
r1328 r1329 44 44 { 45 45 private: 46 47 bool autoColor_; // whether bar changes color automatically 48 float value_; // progress of bar 49 int dir_; // direction of progress 50 int color_; 51 int left_; 52 int top_; 53 int width_; 54 int height_; 55 int windowW_, windowH_; 56 Ogre::Real leftRel_; 57 Ogre::Real topRel_; 58 Ogre::Real widthRel_; 59 Ogre::Real heightRel_; 60 Ogre::PanelOverlayElement* bar_; // the actual bar 61 Ogre::OverlayManager* om; // our overlay manager 62 Ogre::OverlayContainer* container_; // our parent container to attach to 63 Ogre::String name_; 46 bool autoColor_; // whether bar changes color automatically 47 float value_; // progress of bar 48 int color_; 49 int left_; 50 int top_; 51 int width_; 52 int height_; 53 int windowW_, windowH_; 54 Ogre::Real leftRel_; 55 Ogre::Real topRel_; 56 Ogre::Real widthRel_; 57 Ogre::Real heightRel_; 58 Ogre::OverlayManager* om; // our overlay manager 59 Ogre::OverlayContainer* container_; // our parent container to attach to 60 Ogre::OverlayContainer* background_; 61 Ogre::String name_; 64 62 65 63 public: 66 // directions 67 static const int RIGHT = 0; 68 static const int UP = 1; 69 static const int LEFT = 2; 70 static const int DOWN = 3; 71 // predefined colors 72 static const int RED = 0; 64 bool left2Right; 65 static const int RED = 0; // predefined colors 73 66 static const int YELLOW = 1; 74 67 static const int GREEN = 2; … … 76 69 BarOverlayElement(const Ogre::String& name); 77 70 virtual ~BarOverlayElement(); 78 79 71 void init(Real leftRel, Real topRel, Real widthRel, Real heightRel, Ogre::OverlayContainer* container); 80 void setDir(int dir);72 void resize(); 81 73 void setValue(float value); 82 74 void setColor(int color); 83 84 75 float getValue(); 85 76 int getBarColor(); -
code/branches/hud3/src/orxonox/hud/HUD.cc
r1328 r1329 66 66 radar->show(); 67 67 68 container->addChild(energyCounter);69 container->addChild(speedo);70 container->addChild(radar);71 68 container->show(); 72 69 orxonoxHUD->add2D(container); … … 78 75 container->setMetricsMode(Ogre::GMM_RELATIVE); 79 76 80 energyCounter->init(0.01, 0. 01, 0.2, 0.02, container);77 energyCounter->init(0.01, 0.95, 0.4, 0.04, container); 81 78 energyCounter->setValue(1); 82 79 83 speedo->init(0.01, 0. 04, 0.2, 0.02, container);80 speedo->init(0.01, 0.90, 0.4, 0.04, container); 84 81 85 82 radar->init(0.5, 0.9, 0.2, container); … … 88 85 void HUD::tick(float dt) 89 86 { 87 energyCounter->resize(); 88 90 89 float v = SpaceShip::instance_s->getVelocity().length(); 91 90 float vmax = SpaceShip::instance_s->getMaxSpeed(); 92 91 speedo->setValue(v/vmax); 92 speedo->resize(); 93 94 radar->resize(); 93 95 radar->update(); 94 96 } -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.cc
r1328 r1329 78 78 point = static_cast<PanelOverlayElement*>(om->createOverlayElement("Panel", "point")); 79 79 point->show(); 80 container->addChild(this); 80 81 container->addChild(point); 81 82 point->setMaterialName("Orxonox/RedDot"); … … 97 98 98 99 void RadarOverlayElement::update() { 99 resize();100 100 shipPos_ = SpaceShip::instance_s->getPosition(); 101 101 currentDir_ = SpaceShip::instance_s->getOrientation()*initialDir_; // according to beni.... -
code/branches/hud3/src/orxonox/hud/RadarOverlayElement.h
r1328 r1329 41 41 namespace orxonox 42 42 { 43 class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement 44 { 45 private: 46 Ogre::PanelOverlayElement* point; 47 Ogre::OverlayContainer* container_; 48 Ogre::OverlayManager* om; // pointer to the one and only overlay manager 49 Vector3 initialDir_; // direction of nose 50 Vector3 currentDir_; 51 Vector3 initialOrth_; // direction of normal 52 Vector3 currentOrth_; 53 Vector3 targetPos_; // position of target 54 Vector3 shipPos_; // position of ship 43 55 44 class _OrxonoxExport RadarOverlayElement : public Ogre::PanelOverlayElement 45 { 46 private: 56 Ogre::Real radius_; // radius on the radar 57 Ogre::Real phi_; // angle on the radar 58 bool right_; // checks whether the object is on the right side (since cos is not bijective) 59 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension 60 int left_, top_, dim_; // absolute position/dimension 61 int windowW_, windowH_; // absolute window dimensions 62 int count_; 47 63 48 Ogre::PanelOverlayElement* point; 49 Ogre::OverlayContainer* container_; 50 Ogre::OverlayManager* om; // pointer to the one and only overlay manager 51 Vector3 initialDir_; // direction of nose 52 Vector3 currentDir_; 53 Vector3 initialOrth_; // direction of normal 54 Vector3 currentOrth_; 55 Vector3 targetPos_; // position of target 56 Vector3 shipPos_; // position of ship 57 58 Ogre::Real radius_; // radius on the radar 59 Ogre::Real phi_; // angle on the radar 60 bool right_; // checks whether the object is on the right side (since cos is not bijective) 61 Ogre::Real leftRel_, topRel_, dimRel_; // relative position/dimension 62 int left_, top_, dim_; // absolute position/dimension 63 int windowW_, windowH_; // absolute window dimensions 64 int count_; 65 66 void resize(); 67 68 public: 69 70 RadarOverlayElement(const Ogre::String& name); 71 virtual ~RadarOverlayElement(); 72 virtual void initialise(); 73 void update(); 74 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 75 void setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ); 76 int newShip(int X, int Y, int Z); 77 78 void resetShip(int shipID, int Y, int Z); 79 }; 64 public: 65 RadarOverlayElement(const Ogre::String& name); 66 virtual ~RadarOverlayElement(); 67 virtual void initialise(); 68 void update(); 69 void init(Real leftRel, Real topRel, Real dimRel, Ogre::OverlayContainer* container); 70 void setMainShipPosition(int dirX, int dirY, int dirZ, int ortX, int ortY, int ortZ); 71 int newShip(int X, int Y, int Z); 72 void resize(); 73 void resetShip(int shipID, int Y, int Z); 74 }; 80 75 } 81 76
Note: See TracChangeset
for help on using the changeset viewer.