Changeset 7932
- Timestamp:
- Feb 20, 2011, 4:53:43 PM (14 years ago)
- Location:
- code/branches/hudimprovements
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/hudimprovements/data/overlays/HUDTemplates3.oxo
r7920 r7932 67 67 <HUDBoostBar 68 68 name = "BoostBar1" 69 background = "Orxonox/BarBackground"69 backgroundtex = "bar1.png" 70 70 size = "0.35, 0.05" 71 71 position = "0.0 , 1.0 " -
code/branches/hudimprovements/src/modules/overlays/hud/HUDBar.cc
r7801 r7932 26 26 * Fabian 'x3n' Landau 27 27 * Reto Grieder 28 * Benjamin Knecht 28 29 * 29 30 */ -
code/branches/hudimprovements/src/modules/overlays/hud/HUDBar.h
r7401 r7932 26 26 * Fabian 'x3n' Landau 27 27 * Reto Grieder 28 * Benjamin Knecht 28 29 * 29 30 */ -
code/branches/hudimprovements/src/modules/overlays/hud/HUDBoostBar.cc
r7923 r7932 43 43 44 44 this->owner_ = 0; 45 this->flashInterval_ = 0.25f; 46 this->flashDt_ = 0.0f; 45 47 } 46 48 … … 55 57 if (this->owner_) 56 58 { 57 this->show(); 59 if (this->owner_->isBoostCoolingDown()) 60 { 61 this->setBackgroundColour(ColourValue(0.7f, 0.2f, 0.2f)); 62 if (this->flashDt_ <= 0.0f) 63 { 64 this->flashDt_ = this->flashInterval_; 65 this->setVisible(!this->isVisible()); 66 } 67 else 68 this->flashDt_ -= dt; 69 } 70 else 71 { 72 this->flashDt_ = 0.0f; 73 this->show(); 74 this->setBackgroundColour(ColourValue(0.2f, 0.7f, 0.2f)); 75 } 76 58 77 float value = this->owner_->getBoostPower() / this->owner_->getInitialBoostPower(); 59 78 this->setValue(value); -
code/branches/hudimprovements/src/modules/overlays/hud/HUDBoostBar.h
r7920 r7932 47 47 48 48 private: 49 SpaceShip* owner_; 49 SpaceShip* owner_; 50 float flashInterval_; 51 float flashDt_; 50 52 }; 51 53 } -
code/branches/hudimprovements/src/orxonox/overlays/OrxonoxOverlay.cc
r7401 r7932 136 136 XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection, getAspectCorrection, xmlelement, mode); 137 137 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlelement, mode); 138 XMLPortParam(OrxonoxOverlay, "backgroundtex", setBackgroundTexture, getBackgroundTexture, xmlelement, mode); 138 139 } 139 140 … … 162 163 if (this->background_) 163 164 return this->background_->getMaterialName(); 165 else 166 return BLANKSTRING; 167 } 168 169 //! Sets the background texture name and creates a new material if necessary 170 void OrxonoxOverlay::setBackgroundTexture(const std::string& texture) 171 { 172 if (this->background_ && this->background_->getMaterial().isNull() && !texture.empty()) 173 { 174 // create new material 175 const std::string& materialname = "generated_material" + getUniqueNumberString(); 176 Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialname, "General")); 177 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 178 Ogre::TextureUnitState* textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 179 textureUnitState_->setTextureName(texture); 180 textureUnitState_->setNumMipmaps(0); 181 this->background_->setMaterialName(materialname); 182 } 183 } 184 185 //! Returns the the texture name of the background 186 const std::string& OrxonoxOverlay::getBackgroundTexture() const 187 { 188 if (this->background_) 189 { 190 Ogre::TextureUnitState* tempTx = this->background_->getMaterial()->getTechnique(0)->getPass(0)->getTextureUnitState(0); 191 return tempTx->getTextureName(); 192 } 164 193 else 165 194 return BLANKSTRING; … … 385 414 } 386 415 387 void OrxonoxOverlay::setBackgroundAlpha(float alpha) { 416 void OrxonoxOverlay::setBackgroundAlpha(float alpha) 417 { 388 418 Ogre::MaterialPtr ptr = this->background_->getMaterial(); 389 419 Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0); 390 420 tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha); 391 421 } 422 423 void OrxonoxOverlay::setBackgroundColour(ColourValue colour) 424 { 425 Ogre::MaterialPtr ptr = this->background_->getMaterial(); 426 Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0); 427 tempTx->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour); 428 } 392 429 } -
code/branches/hudimprovements/src/orxonox/overlays/OrxonoxOverlay.h
r7401 r7932 159 159 const std::string& getBackgroundMaterial() const; 160 160 161 void setBackgroundTexture(const std::string& texture); 162 const std::string& getBackgroundTexture() const; 163 161 164 void setBackgroundAlpha(float alpha); 165 166 void setBackgroundColour(ColourValue colour); 162 167 163 168 virtual void changedVisibility(); -
code/branches/hudimprovements/src/orxonox/worldentities/pawns/SpaceShip.h
r7920 r7932 74 74 { return this->bBoost_; } 75 75 76 inline float getBoostPower() 76 inline float getBoostPower() const 77 77 { return this->boostPower_; } 78 inline float getInitialBoostPower() 78 inline float getInitialBoostPower() const 79 79 { return this->initialBoostPower_; } 80 80 … … 88 88 inline bool getPermanentBoost() const 89 89 { return this->bPermanentBoost_; } 90 91 inline bool isBoostCoolingDown() const 92 { return bBoostCooldown_; } 90 93 91 94 protected:
Note: See TracChangeset
for help on using the changeset viewer.