Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 20, 2011, 4:53:43 PM (14 years ago)
Author:
bknecht
Message:

The boost bar is now flashing red when the boost is cooling down. However the solution in OrxonoxOverlay is a bit questionable and could probably be solved less hacky…

Location:
code/branches/hudimprovements/src/orxonox/overlays
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hudimprovements/src/orxonox/overlays/OrxonoxOverlay.cc

    r7401 r7932  
    136136        XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection,   getAspectCorrection,   xmlelement, mode);
    137137        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlelement, mode);
     138        XMLPortParam(OrxonoxOverlay, "backgroundtex", setBackgroundTexture,  getBackgroundTexture,  xmlelement, mode);
    138139    }
    139140
     
    162163        if (this->background_)
    163164            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        }
    164193        else
    165194            return BLANKSTRING;
     
    385414    }
    386415
    387     void OrxonoxOverlay::setBackgroundAlpha(float alpha) {
     416    void OrxonoxOverlay::setBackgroundAlpha(float alpha)
     417    {
    388418        Ogre::MaterialPtr ptr = this->background_->getMaterial();
    389419        Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
    390420        tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha);
    391421    }
     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    }
    392429}
  • code/branches/hudimprovements/src/orxonox/overlays/OrxonoxOverlay.h

    r7401 r7932  
    159159        const std::string& getBackgroundMaterial() const;
    160160
     161        void setBackgroundTexture(const std::string& texture);
     162        const std::string& getBackgroundTexture() const;
     163
    161164        void setBackgroundAlpha(float alpha);
     165
     166        void setBackgroundColour(ColourValue colour);
    162167
    163168        virtual void changedVisibility();
Note: See TracChangeset for help on using the changeset viewer.