void addTextureDebugOverlay( TrayLocation loc, const String& texname, size_t i )
 {// Create material
   String matName = "Ogre/DebugTexture" + StringConverter::toString( i );
   MaterialPtr debugMat = MaterialManager::getSingleton().getByName( matName );
   if( debugMat.isNull() )
   {
     debugMat = MaterialManager::getSingleton().create( matName,
       ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
   }
   Pass* p = debugMat->getTechnique( 0 )->getPass( 0 );
   p->removeAllTextureUnitStates();
   p->setLightingEnabled( false );
   TextureUnitState *t = p->createTextureUnitState( texname );
   t->setTextureAddressingMode( TextureUnitState::TAM_CLAMP );
   // create template
   if( !OverlayManager::getSingleton().hasOverlayElement( "Ogre/DebugTexOverlay", true ) )
   {
     OverlayElement* e = OverlayManager::getSingleton().createOverlayElement( "Panel", "Ogre/DebugTexOverlay", true );
     e->setMetricsMode( GMM_PIXELS );
     e->setWidth( 128 );
     e->setHeight( 128 );
   }
   // add widget
   String widgetName = "DebugTex" + StringConverter::toString( i );
   Widget* w = mTrayMgr->getWidget( widgetName );
   if( !w )
   {
     w = mTrayMgr->createDecorWidget( loc, widgetName, "Ogre/DebugTexOverlay" );
   }
   w->getOverlayElement()->setMaterialName( matName );
 }
Example #2
0
    //-----------------------------------------------------------------------
    OverlayElement* Profiler::createTextArea(const String& name, Real width, Real height, Real top, Real left, 
                                         uint fontSize, const String& caption, bool show) {


        OverlayElement* textArea = 
			OverlayManager::getSingleton().createOverlayElement("TextArea", name);
        textArea->setMetricsMode(GMM_PIXELS);
        textArea->setWidth(width);
        textArea->setHeight(height);
        textArea->setTop(top);
        textArea->setLeft(left);
        textArea->setParameter("font_name", "BlueHighway");
        textArea->setParameter("char_height", StringConverter::toString(fontSize));
        textArea->setCaption(caption);
        textArea->setParameter("colour_top", "1 1 1");
        textArea->setParameter("colour_bottom", "1 1 1");

        if (show) {
            textArea->show();
        }
        else {
            textArea->hide();
        }

        return textArea;

    }
Example #3
0
  void _setOverlay(void)
  {
    mOverlayMgr = OverlayManager::getSingletonPtr();
    mTextOverlay = mOverlayMgr->create("TextOverlay");

    mPanel = static_cast<Ogre::OverlayContainer*>(mOverlayMgr->createOverlayElement("Panel", "container1"));
    mPanel->setDimensions(1, 1);
    mPanel->setPosition(-0.3f, 0.5f);

    OverlayElement* textBox = mOverlayMgr->createOverlayElement("TextArea", "TextID");
    textBox->setMetricsMode(Ogre::GMM_PIXELS);
    textBox->setPosition(10, 10);
    textBox->setWidth(100);
    textBox->setHeight(20);
    textBox->setParameter("font_name", "Font/NanumBold18");
    textBox->setParameter("char_height", "40");
    textBox->setColour(Ogre::ColourValue::White);
    textBox->setCaption(L"한국산업기술대학교 이대현 선수");
    mPanel->addChild(textBox);

    mTextOverlay->add2D(mPanel);
    mTextOverlay->show();

    mLogoOverlay = OverlayManager::getSingleton().getByName("Overlay/KPU_LOGO");
    mLogoOverlay->show();

mLogoOverlay = OverlayManager::getSingleton().getByName("Overlay/Information");
mLogoOverlay->show(); 
  }
Example #4
0
void TruckHUD::checkOverflow(Ogre::OverlayElement* e)
{
	int newval = e->getLeft() + e->getWidth() + border;
	if(newval > this->width)
	{
		this->width = newval;
		OverlayElement *panel = OverlayManager::getSingleton().getOverlayElement("tracks/TruckInfoBox/MainPanel");
		panel->setWidth(width);
	}
}
    //-----------------------------------------------------------------------
    OverlayElement* OverlayProfileSessionListener::createPanel(const String& name, Real width, Real height, Real top, Real left, 
                                      const String& materialName, bool show)
    {
        OverlayElement* panel = 
            OverlayManager::getSingleton().createOverlayElement("Panel", name);
        panel->setMetricsMode(GMM_PIXELS);
        panel->setWidth(width);
        panel->setHeight(height);
        panel->setTop(top);
        panel->setLeft(left);
        panel->setMaterialName(materialName);

        if (show) {
            panel->show();
        }
        else {
            panel->hide();
        }

        return panel;
    }
Example #6
0
    //-----------------------------------------------------------------------
    void Profiler::displayResults() {

        if (!mEnabled) {

            return;

        }

        // if its time to update the display
        if (!(mCurrentFrame % mUpdateDisplayFrequency)) {


            ProfileHistoryList::iterator iter;
            ProfileBarList::iterator bIter;

            OverlayElement* g;

            Real newGuiHeight = mGuiHeight;

            int profileCount = 0; 

			Real maxTimeMillisecs = (Real)mMaxTotalFrameTime / 1000.0f;

            // go through each profile and display it
            for (iter = mProfileHistory.begin(), bIter = mProfileBars.begin(); 
				iter != mProfileHistory.end() && bIter != mProfileBars.end(); 
				++iter, ++bIter) 
			{

                // display the profile's name and the number of times it was called in a frame
                g = *bIter;
                g->show();
                g->setCaption(String((*iter).name + " (" + StringConverter::toString((*iter).numCallsThisFrame) + ")"));
                g->setLeft(10 + (*iter).hierarchicalLvl * 15.0f);

                // display the main bar that show the percentage of the frame time that this
                // profile has taken
                bIter++;
                g = *bIter;
                g->show();
                // most of this junk has been set before, but we do this to get around a weird
                // Ogre gui issue (bug?)
                g->setMetricsMode(GMM_PIXELS);
                g->setHeight(mBarHeight);
				if (mDisplayMode == DISPLAY_PERCENTAGE)
					g->setWidth(((*iter).currentTimePercent) * mGuiWidth);
				else
					g->setWidth(((*iter).currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth);
                g->setLeft(mGuiWidth);
                g->setTop(mGuiBorderWidth + profileCount * (mBarHeight + mBarSpacing));

                // display line to indicate the minimum frame time for this profile
                bIter++;
                g = *bIter;
                g->show();
				if (mDisplayMode == DISPLAY_PERCENTAGE)
		            g->setLeft(mBarIndent + (*iter).minTimePercent * mGuiWidth);
				else
					g->setLeft(mBarIndent + ((*iter).minTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

                // display line to indicate the maximum frame time for this profile
                bIter++;
                g = *bIter;
                g->show();
				if (mDisplayMode == DISPLAY_PERCENTAGE)
	                g->setLeft(mBarIndent + (*iter).maxTimePercent * mGuiWidth);
				else
					g->setLeft(mBarIndent + ((*iter).maxTimeMillisecs / maxTimeMillisecs) * mGuiWidth);
                // display line to indicate the average frame time for this profile
                bIter++;
                g = *bIter;
                g->show();
                if ((*iter).totalCalls != 0)
					if (mDisplayMode == DISPLAY_PERCENTAGE)
	                    g->setLeft(mBarIndent + ((*iter).totalTimePercent / (*iter).totalCalls) * mGuiWidth);
					else
						g->setLeft(mBarIndent + (((*iter).totalTimeMillisecs / (*iter).totalCalls) / maxTimeMillisecs) * mGuiWidth);
                else
                    g->setLeft(mBarIndent);

				// display text
				bIter++;
				g = *bIter;
				g->show();
				if (mDisplayMode == DISPLAY_PERCENTAGE)
				{
					g->setLeft(mBarIndent + (*iter).currentTimePercent * mGuiWidth + 2);
					g->setCaption(StringConverter::toString((*iter).currentTimePercent * 100.0f, 3, 3) + "%");
				}
				else
				{
					g->setLeft(mBarIndent + ((*iter).currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth + 2);
					g->setCaption(StringConverter::toString((*iter).currentTimeMillisecs, 3, 3) + "ms");
				}

				// we set the height of the display with respect to the number of profiles displayed
                newGuiHeight += mBarHeight + mBarSpacing;

                profileCount++;

            }

            // set the main display dimensions
            mProfileGui->setMetricsMode(GMM_PIXELS);
            mProfileGui->setHeight(newGuiHeight);
            mProfileGui->setWidth(mGuiWidth * 2 + 15);
            mProfileGui->setTop(5);
            mProfileGui->setLeft(5);

            // we hide all the remaining pre-created bars
            for (; bIter != mProfileBars.end(); ++bIter) {

                (*bIter)->hide();

            }

        }

		mCurrentFrame++;

    }
    //-----------------------------------------------------------------------
    void OverlayProfileSessionListener::displayResults(ProfileInstance* instance, ProfileBarList::const_iterator& bIter, Real& maxTimeMillisecs, Real& newGuiHeight, int& profileCount)
    {
        OverlayElement* g;

        // display the profile's name and the number of times it was called in a frame
        g = *bIter;
        ++bIter;
        g->show();
        g->setCaption(String(instance->name + " (" + StringConverter::toString(instance->history.numCallsThisFrame) + ")"));
        g->setLeft(10 + instance->hierarchicalLvl * 15.0f);


        // display the main bar that show the percentage of the frame time that this
        // profile has taken
        g = *bIter;
        ++bIter;
        g->show();
        // most of this junk has been set before, but we do this to get around a weird
        // Ogre gui issue (bug?)
        g->setMetricsMode(GMM_PIXELS);
        g->setHeight(mBarHeight);

        if (mDisplayMode == DISPLAY_PERCENTAGE)
            g->setWidth( (instance->history.currentTimePercent) * mGuiWidth);
        else
            g->setWidth( (instance->history.currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

        g->setLeft(mGuiWidth);
        g->setTop(mGuiBorderWidth + profileCount * (mBarHeight + mBarSpacing));



        // display line to indicate the minimum frame time for this profile
        g = *bIter;
        ++bIter;
        g->show();
        if(mDisplayMode == DISPLAY_PERCENTAGE)
            g->setLeft(mBarIndent + instance->history.minTimePercent * mGuiWidth);
        else
            g->setLeft(mBarIndent + (instance->history.minTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

        // display line to indicate the maximum frame time for this profile
        g = *bIter;
        ++bIter;
        g->show();
        if(mDisplayMode == DISPLAY_PERCENTAGE)
            g->setLeft(mBarIndent + instance->history.maxTimePercent * mGuiWidth);
        else
            g->setLeft(mBarIndent + (instance->history.maxTimeMillisecs / maxTimeMillisecs) * mGuiWidth);

        // display line to indicate the average frame time for this profile
        g = *bIter;
        ++bIter;
        g->show();
        if(instance->history.totalCalls != 0)
        {
            if (mDisplayMode == DISPLAY_PERCENTAGE)
                g->setLeft(mBarIndent + (instance->history.totalTimePercent / instance->history.totalCalls) * mGuiWidth);
            else
                g->setLeft(mBarIndent + ((instance->history.totalTimeMillisecs / instance->history.totalCalls) / maxTimeMillisecs) * mGuiWidth);
        }
        else
            g->setLeft(mBarIndent);

        // display text
        g = *bIter;
        ++bIter;
        g->show();
        if (mDisplayMode == DISPLAY_PERCENTAGE)
        {
            g->setLeft(mBarIndent + instance->history.currentTimePercent * mGuiWidth + 2);
            g->setCaption(StringConverter::toString(instance->history.currentTimePercent * 100.0f, 3, 3) + "%");
        }
        else
        {
            g->setLeft(mBarIndent + (instance->history.currentTimeMillisecs / maxTimeMillisecs) * mGuiWidth + 2);
            g->setCaption(StringConverter::toString(instance->history.currentTimeMillisecs, 3, 3) + "ms");
        }

        // we set the height of the display with respect to the number of profiles displayed
        newGuiHeight += mBarHeight + mBarSpacing;

        ++profileCount;

        // display children
        ProfileInstance::ProfileChildren::const_iterator it = instance->children.begin(), endit = instance->children.end();
        for(;it != endit; ++it)
        {
            ProfileInstance* child = it->second;
            displayResults(child, bIter, maxTimeMillisecs, newGuiHeight, profileCount);
        }
    }