Changeset 2369 for code/branches/objecthierarchy2/src/orxonox/overlays/hud
- Timestamp:
- Dec 10, 2008, 3:37:48 AM (16 years ago)
- Location:
- code/branches/objecthierarchy2/src/orxonox/overlays/hud
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy2/src/orxonox/overlays/hud/CMakeLists.txt
r2131 r2369 4 4 HUDRadar.cc 5 5 HUDSpeedBar.cc 6 HUDHealthBar.cc 6 7 ChatOverlay.cc 7 8 ) -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDBar.cc
r2087 r2369 51 51 RegisterObject(BarColour); 52 52 53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0));54 setPosition(0.0);53 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 this->setPosition(0.0); 55 55 } 56 56 … … 84 84 this->bar_->setMaterialName(materialname); 85 85 86 setValue(0.4567654f); 87 setRightToLeft(false); 88 setAutoColour(true); 86 this->setValue(0.0f); 87 this->setRightToLeft(false); 88 this->setAutoColour(true); 89 this->currentColour_ = ColourValue::White; 89 90 90 91 this->background_->addChild(bar_); … … 101 102 SUPER(HUDBar, XMLPort, xmlElement, mode); 102 103 103 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode); 104 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode); 105 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode); 104 XMLPortParam(HUDBar, "initialvalue", setValue, getValue, xmlElement, mode); 105 XMLPortParam(HUDBar, "righttoleft", setRightToLeft, getRightToLeft, xmlElement, mode); 106 XMLPortParam(HUDBar, "autocolour", setAutoColour, getAutoColour, xmlElement, mode); 107 XMLPortParam(HUDBar, "bartexture", setBarTexture, getBarTexture, xmlElement, mode); 106 108 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode); 107 109 } … … 130 132 { 131 133 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2); 134 this->currentColour_ = colour2; 132 135 } 133 136 else if (value1 < this->value_) 134 137 { 135 138 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1); 139 this->currentColour_ = colour1; 136 140 } 137 141 else … … 139 143 //float interpolationfactor = (this->value_ - value2) / (value1 - value2); 140 144 float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f); 141 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor)); 145 this->currentColour_ = colour1 * interpolationfactor + colour2 * (1 - interpolationfactor); 146 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, this->currentColour_); 147 142 148 } 143 149 } … … 181 187 this->colours_.clear(); 182 188 } 189 190 void HUDBar::setBarTexture(const std::string& texture) 191 { 192 this->textureUnitState_->setTextureName(texture); 193 } 194 195 const std::string& HUDBar::getBarTexture() const 196 { 197 return this->textureUnitState_->getTextureName(); 198 } 183 199 } -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDBar.h
r2087 r2369 71 71 void clearColours(); 72 72 73 void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); } 74 bool getRightToLeft() const { return this->right2Left_; } 73 inline void setRightToLeft(bool r2l) 74 { 75 if (r2l != this->right2Left_) 76 { 77 this->right2Left_ = r2l; 78 this->valueChanged(); 79 } 80 } 81 inline bool getRightToLeft() const 82 { return this->right2Left_; } 75 83 76 void setValue(float value) { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); } 77 float getValue() const { return this->value_; } 84 inline void setValue(float value) 85 { 86 float temp = clamp(value, 0.0f, 1.0f); 87 if (temp != this->value_) 88 { 89 this->value_ = temp; 90 this->valueChanged(); 91 } 92 } 93 inline float getValue() const 94 { return this->value_; } 78 95 79 void setAutoColour(bool val) { this->autoColour_ = val; this->valueChanged(); } 80 bool getAutoColour() const { return this->autoColour_; } 96 inline void setAutoColour(bool val) 97 { 98 if (val != this->autoColour_) 99 { 100 this->autoColour_ = val; 101 this->valueChanged(); 102 103 if (!val) 104 this->currentColour_ = ColourValue::White; 105 } 106 } 107 inline bool getAutoColour() const 108 { return this->autoColour_; } 109 110 void setBarTexture(const std::string& texture); 111 const std::string& getBarTexture() const; 112 113 inline const ColourValue& getCurrentBarColour() const 114 { return this->currentColour_; } 81 115 82 116 protected: … … 90 124 bool autoColour_; //!< whether bar changes colour automatically 91 125 float value_; //!< progress of bar 126 ColourValue currentColour_; 92 127 93 128 Ogre::PanelOverlayElement* bar_; -
code/branches/objecthierarchy2/src/orxonox/overlays/hud/HUDSpeedBar.cc
r2361 r2369 56 56 if (this->owner_ && this->owner_->getEngine()) 57 57 { 58 float v = this->owner_->getVelocity().length(); 59 float value = v / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor()); 60 if (value != this->getValue()) 61 this->setValue(value); 58 float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor()); 59 this->setValue(value); 62 60 } 63 61 }
Note: See TracChangeset
for help on using the changeset viewer.