Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7932


Ignore:
Timestamp:
Feb 20, 2011, 4:53:43 PM (13 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
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • code/branches/hudimprovements/data/overlays/HUDTemplates3.oxo

    r7920 r7932  
    6767    <HUDBoostBar
    6868     name          = "BoostBar1"
    69      background    = "Orxonox/BarBackground"
     69     backgroundtex = "bar1.png"
    7070     size          = "0.35, 0.05"
    7171     position      = "0.0 , 1.0 "
  • code/branches/hudimprovements/src/modules/overlays/hud/HUDBar.cc

    r7801 r7932  
    2626 *      Fabian 'x3n' Landau
    2727 *      Reto Grieder
     28 *      Benjamin Knecht
    2829 *
    2930 */
  • code/branches/hudimprovements/src/modules/overlays/hud/HUDBar.h

    r7401 r7932  
    2626 *      Fabian 'x3n' Landau
    2727 *      Reto Grieder
     28 *      Benjamin Knecht
    2829 *
    2930 */
  • code/branches/hudimprovements/src/modules/overlays/hud/HUDBoostBar.cc

    r7923 r7932  
    4343
    4444        this->owner_ = 0;
     45        this->flashInterval_ = 0.25f;
     46        this->flashDt_ = 0.0f;
    4547    }
    4648
     
    5557        if (this->owner_)
    5658        {
    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
    5877            float value = this->owner_->getBoostPower() / this->owner_->getInitialBoostPower();
    5978            this->setValue(value);
  • code/branches/hudimprovements/src/modules/overlays/hud/HUDBoostBar.h

    r7920 r7932  
    4747
    4848    private:
    49         SpaceShip* owner_;
     49        SpaceShip*  owner_;
     50        float       flashInterval_;
     51        float       flashDt_;
    5052    };
    5153}
  • 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();
  • code/branches/hudimprovements/src/orxonox/worldentities/pawns/SpaceShip.h

    r7920 r7932  
    7474                { return this->bBoost_; }
    7575
    76             inline float getBoostPower()
     76            inline float getBoostPower() const
    7777                { return this->boostPower_; }
    78             inline float getInitialBoostPower()
     78            inline float getInitialBoostPower() const
    7979                { return this->initialBoostPower_; }
    8080
     
    8888            inline bool getPermanentBoost() const
    8989                { return this->bPermanentBoost_; }
     90
     91            inline bool isBoostCoolingDown() const
     92                { return bBoostCooldown_; }
    9093
    9194        protected:
Note: See TracChangeset for help on using the changeset viewer.