Changeset 7932 for code/branches/hudimprovements/src/orxonox/overlays
- Timestamp:
- Feb 20, 2011, 4:53:43 PM (14 years ago)
- Location:
- code/branches/hudimprovements/src/orxonox/overlays
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note: See TracChangeset
for help on using the changeset viewer.