Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 29, 2011, 11:59:17 PM (13 years ago)
Author:
dafrick
Message:

Merging hudimprovements branch into presentation branch.

Location:
code/branches/presentation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.cc

    r8351 r8673  
    137137        XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection,   getAspectCorrection,   xmlelement, mode);
    138138        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlelement, mode);
     139        XMLPortParam(OrxonoxOverlay, "backgroundtex", setBackgroundTexture,  getBackgroundTexture,  xmlelement, mode);
    139140    }
    140141
     
    163164        if (this->background_)
    164165            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        }
    165194        else
    166195            return BLANKSTRING;
     
    406435    }
    407436
    408     void OrxonoxOverlay::setBackgroundAlpha(float alpha) {
     437    void OrxonoxOverlay::setBackgroundAlpha(float alpha)
     438    {
    409439        Ogre::MaterialPtr ptr = this->background_->getMaterial();
    410440        Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
    411441        tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha);
    412442    }
     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    }
    413450}
Note: See TracChangeset for help on using the changeset viewer.