Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2008, 4:05:25 AM (17 years ago)
Author:
rgrieder
Message:

Added stats overlay. "OverlayGroup toggleVisibility Stats" will do what it says.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation/src/orxonox/overlays/stats/Stats.cc

    r2492 r2495  
    5656
    5757        this->setConfigValues();
     58
     59        // create overlay and elements
     60        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
     61
     62        // create BorderPanel
     63        this->statsOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "StatsBorderPanel" + getUniqueNumberString()));
     64        //this->statsOverlayBorder_->setMaterialName("StatsCenter");
     65        this->statsOverlayBorder_->setBorderSize(0.003, 16 * 0.003);
     66        this->statsOverlayBorder_->setBorderMaterialName("StatsBorder");
     67        this->statsOverlayBorder_->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
     68        this->statsOverlayBorder_->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
     69        this->statsOverlayBorder_->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
     70        this->statsOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
     71        this->statsOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
     72        this->statsOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
     73        this->statsOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
     74        this->statsOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
     75
     76        background_->addChild(statsOverlayBorder_);
     77
     78        // create noise
     79        //this->statsOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "StatsNoise" + getUniqueNumberString()));
     80        //this->statsOverlayNoise_->setPosition(0,0);
     81        //this->statsOverlayNoise_->setMaterialName("StatsNoiseSmall");
     82        // comment following line to disable noise
     83        //background_->addChild(this->statsOverlayNoise_);
     84    }
     85
     86    Stats::~Stats()
     87    {
     88        if (this->isInitialized())
     89        {
     90            Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
     91            ovMan->destroyOverlayElement(this->statsOverlayBorder_);
     92            //ovMan->destroyOverlayElement(this->statsOverlayNoise_);
     93        }
    5894    }
    5995
     
    72108    {
    73109        OrxonoxOverlay::XMLPort(xmlElement, mode);
    74 
    75         // create overlay and elements
    76         Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
    77 
    78         // create BorderPanel
    79         this->statsOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "StatsBorderPanel"));
    80         this->statsOverlayBorder_->setMaterialName("StatsCenter");
    81         this->statsOverlayBorder_->setBorderSize(0.02, 0.02, 0.02, 0.02);
    82         this->statsOverlayBorder_->setBorderMaterialName("StatsBorder");
    83         this->statsOverlayBorder_->setTopBorderUV(0.49, 0.0, 0.51, 0.5);
    84         this->statsOverlayBorder_->setTopLeftBorderUV(0.0, 0.0, 0.5, 0.5);
    85         this->statsOverlayBorder_->setTopRightBorderUV(0.5, 0.0, 1.0, 0.5);
    86         this->statsOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
    87         this->statsOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
    88         this->statsOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
    89         this->statsOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
    90         this->statsOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
    91 
    92         background_->addChild(statsOverlayBorder_);
    93 
    94         // create noise
    95         this->statsOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "StatsNoise"));
    96         this->statsOverlayNoise_->setPosition(0,0);
    97         this->statsOverlayNoise_->setMaterialName("StatsNoiseSmall");
    98         // comment following line to disable noise
    99         background_->addChild(this->statsOverlayNoise_);
    100 
    101110    }
    102111
     
    106115
    107116            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
    108             float uRand = (rand() & 1023) / 1023.0f * 0.2f;
    109             float vRand = (rand() & 1023) / 1023.0f * 0.2f;
    110             this->statsOverlayNoise_->setUV(uRand, vRand, 7.5f + uRand, 7.5f + vRand);
     117            //float uRand = (rand() & 1023) / 1023.0f * 0.2f;
     118            //float vRand = (rand() & 1023) / 1023.0f * 0.2f;
     119            //this->statsOverlayNoise_->setUV(uRand, vRand, 7.5f + uRand, 7.5f + vRand);
    111120    }
    112121
Note: See TracChangeset for help on using the changeset viewer.