Changeset 8673 for code/branches/presentation/src/orxonox/overlays
- Timestamp:
- May 29, 2011, 11:59:17 PM (14 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
- Property svn:mergeinfo changed
/code/branches/hudimprovements (added) merged: 7920,7923,7932
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.cc
r8351 r8673 137 137 XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection, getAspectCorrection, xmlelement, mode); 138 138 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlelement, mode); 139 XMLPortParam(OrxonoxOverlay, "backgroundtex", setBackgroundTexture, getBackgroundTexture, xmlelement, mode); 139 140 } 140 141 … … 163 164 if (this->background_) 164 165 return this->background_->getMaterialName(); 166 else 167 return BLANKSTRING; 168 } 169 170 //! Sets the background texture name and creates a new material if necessary 171 void OrxonoxOverlay::setBackgroundTexture(const std::string& texture) 172 { 173 if (this->background_ && this->background_->getMaterial().isNull() && !texture.empty()) 174 { 175 // create new material 176 const std::string& materialname = "generated_material" + getUniqueNumberString(); 177 Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialname, "General")); 178 material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA); 179 Ogre::TextureUnitState* textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState(); 180 textureUnitState_->setTextureName(texture); 181 textureUnitState_->setNumMipmaps(0); 182 this->background_->setMaterialName(materialname); 183 } 184 } 185 186 //! Returns the the texture name of the background 187 const std::string& OrxonoxOverlay::getBackgroundTexture() const 188 { 189 if (this->background_) 190 { 191 Ogre::TextureUnitState* tempTx = this->background_->getMaterial()->getTechnique(0)->getPass(0)->getTextureUnitState(0); 192 return tempTx->getTextureName(); 193 } 165 194 else 166 195 return BLANKSTRING; … … 406 435 } 407 436 408 void OrxonoxOverlay::setBackgroundAlpha(float alpha) { 437 void OrxonoxOverlay::setBackgroundAlpha(float alpha) 438 { 409 439 Ogre::MaterialPtr ptr = this->background_->getMaterial(); 410 440 Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0); 411 441 tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha); 412 442 } 443 444 void OrxonoxOverlay::setBackgroundColour(ColourValue colour) 445 { 446 Ogre::MaterialPtr ptr = this->background_->getMaterial(); 447 Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0); 448 tempTx->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour); 449 } 413 450 } -
code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.h
r8309 r8673 160 160 const std::string& getBackgroundMaterial() const; 161 161 162 void setBackgroundTexture(const std::string& texture); 163 const std::string& getBackgroundTexture() const; 164 162 165 void setBackgroundAlpha(float alpha); 166 167 void setBackgroundColour(ColourValue colour); 163 168 164 169 virtual void changedVisibility();
Note: See TracChangeset
for help on using the changeset viewer.