本文整理汇总了C++中OverlayElement类的典型用法代码示例。如果您正苦于以下问题:C++ OverlayElement类的具体用法?C++ OverlayElement怎么用?C++ OverlayElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OverlayElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createOverlayElement
//---------------------------------------------------------------------
OverlayElement* OverlayManager::createOverlayElementFromTemplate(const String& templateName, const String& typeName, const String& instanceName, bool isATemplate)
{
OverlayElement* newObj = NULL;
if (templateName.empty())
{
newObj = createOverlayElement(typeName, instanceName, isATemplate);
}
else
{
// no template
OverlayElement* templateGui = getOverlayElement(templateName, true);
String typeNameToCreate;
if (typeName.empty())
{
typeNameToCreate = templateGui->getTypeName();
}
else
{
typeNameToCreate = typeName;
}
newObj = createOverlayElement(typeNameToCreate, instanceName, isATemplate);
((OverlayContainer*)newObj)->copyFromTemplate(templateGui);
}
return newObj;
}
示例2: updateStats
// -------------------------------------------------------------------------
void OgreBulletListener::updateStats(void)
{
// update stats when necessary
if (mFpsStaticText)
{
const RenderTarget::FrameStats& stats = mWindow->getStatistics();
static String avgFps = "Average FPS: ";
static String currFps = "Current FPS: ";
static String tris = "Triangle Count: ";
mFpsStaticText->setValue
(
avgFps + StringConverter::toString(stats.avgFPS) + " / " +
currFps + StringConverter::toString(stats.lastFPS) + " / " +
tris + StringConverter::toString(stats.triangleCount)
);
}
try {
OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
guiDbg->setCaption(mDebugText);
}
catch(...) {}
}
示例3: initialisation
/** Show the loading bar and start listening.
@param window The window to update
@param numGroupsInit The number of groups you're going to be initialising
@param numGroupsLoad The number of groups you're going to be loading
@param initProportion The proportion of the progress which will be taken
up by initialisation (ie script parsing etc). Defaults to 0.7 since
script parsing can often take the majority of the time.
*/
void LoadingBar::
start(RenderWindow* window, unsigned short numGroupsInit ,
unsigned short numGroupsLoad, Real initProportion)
{
mWindow = window;
mNumGroupsInit = numGroupsInit;
mNumGroupsLoad = numGroupsLoad;
mInitProportion = initProportion;
// We need to pre-initialise the 'Bootstrap' group so we can use
// the basic contents in the loading screen
ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");
OverlayManager& omgr = OverlayManager::getSingleton();
mLoadOverlay = (Overlay*)omgr.getByName("Core/LoadOverlay");
if (!mLoadOverlay)
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
"Cannot find loading overlay", "ExampleLoadingBar::start");
}
mLoadOverlay->show();
// Save links to the bar and to the loading text, for updates as we go
mLoadingBarElement = omgr.getOverlayElement("Core/LoadPanel/Bar/Progress");
mLoadingCommentElement = omgr.getOverlayElement("Core/LoadPanel/Comment");
mLoadingDescriptionElement = omgr.getOverlayElement("Core/LoadPanel/Description");
OverlayElement* barContainer = omgr.getOverlayElement("Core/LoadPanel/Bar");
mProgressBarMaxSize = barContainer->getWidth();
mLoadingBarElement->setWidth(0);
// self is listener
ResourceGroupManager::getSingleton().addResourceGroupListener(this);
}
示例4: getChildIterator
OverlayElement* OverlayContainer::findElementAt(Real x, Real y) // relative to parent
{
OverlayElement* ret = NULL;
int currZ = -1;
if (mVisible)
{
ret = OverlayElement::findElementAt(x,y); //default to the current container if no others are found
if (ret && mChildrenProcessEvents)
{
ChildIterator it = getChildIterator();
while (it.hasMoreElements())
{
OverlayElement* currentOverlayElement = it.getNext();
if (currentOverlayElement->isVisible() && currentOverlayElement->isEnabled())
{
int z = currentOverlayElement->getZOrder();
if (z > currZ)
{
OverlayElement* elementFound = currentOverlayElement->findElementAt(x ,y );
if (elementFound)
{
currZ = z;
ret = elementFound;
}
}
}
}
}
}
return ret;
}
示例5: addTextureDebugOverlay
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 );
}
示例6: while
//---------------------------------------------------------------------
void OverlayManager::destroyAllOverlayElementsImpl(ElementMap& elementMap)
{
ElementMap::iterator i;
while ((i = elementMap.begin()) != elementMap.end())
{
OverlayElement* element = i->second;
// Get factory to delete
FactoryMap::iterator fi = mFactories.find(element->getTypeName());
if (fi == mFactories.end())
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Cannot locate factory for element "
+ element->getName(),
"OverlayManager::destroyAllOverlayElements");
}
// remove from parent, if any
OverlayContainer* parent;
if ((parent = element->getParent()) != 0)
{
parent->_removeChild(element->getName());
}
// children of containers will be auto-removed when container is destroyed.
// destroy the element and remove it from the list
fi->second->destroyOverlayElement(element);
elementMap.erase(i);
}
}
示例7: checkOverflow
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);
}
}
示例8: _setOverlay
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();
}
示例9: frameEnded
bool frameEnded(const FrameEvent &evt)
{
// Fill Here -----------------------------------------------
static Ogre::DisplayString currFps = L"현재 FPS: ";
static Ogre::DisplayString avgFps = L"평균 FPS: ";
static Ogre::DisplayString bestFps = L"최고 FPS: ";
static Ogre::DisplayString worstFps = L"최저 FPS: ";
OverlayElement* guiAvg =
OverlayManager::getSingleton().getOverlayElement("AverageFps");
OverlayElement* guiCurr =
OverlayManager::getSingleton().getOverlayElement("CurrFps");
OverlayElement* guiBest =
OverlayManager::getSingleton().getOverlayElement("BestFps");
OverlayElement* guiWorst =
OverlayManager::getSingleton().getOverlayElement("WorstFps");
const RenderTarget::FrameStats& stats =
mRoot->getAutoCreatedWindow()->getStatistics();
guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS));
guiCurr->setCaption(currFps + StringConverter::toString(stats.lastFPS));
guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS));
guiWorst->setCaption(worstFps + StringConverter::toString(stats.worstFPS));
// ---------------------------------------------------------
return mContinue;
}
示例10: QGraphicsScene
OgreQtOverlay::OgreQtOverlay(Ogre::Root *root, Ogre::RenderWindow *window, Ogre::uint w, Ogre::uint h, QObject *parent)
: QGraphicsScene(parent), _width(w), _height(h)
{
_root = root;
_window = window;
_time.start(); //start a timer for key events
//Connect redraw signal to this class
QObject::connect(this,SIGNAL(changed(QList<QRectF>)),this,SLOT(sceneChanged(QList<QRectF>)));
//qDebug() << "WIDTH:" << _width << "HEIGHT:" << _height;
//create a texture the size of the screen to draw into
_texture = TextureManager::getSingleton().createManual("OgreQtTexture",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME
,TEX_TYPE_2D,_width,_height,0,PF_A8R8G8B8,TU_DYNAMIC_WRITE_ONLY).getPointer();
//save texture buffer for later
_buffer = _texture->getBuffer().getPointer();
//Create a material
MaterialPtr material = MaterialManager::getSingleton().create("DynamicTextureMaterial",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->createTextureUnitState("OgreQtTexture");
material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
//Load overlay
_overlay = OverlayManager::getSingleton().getByName("MyOverlays/OgreQt");
OverlayElement *element = OverlayManager::getSingleton().getOverlayElement("MyOverlayElements/QtPanel");
element->setMaterialName("DynamicTextureMaterial");
//set the screen rect for the graphicsscene
float ratio = (float)_width / (float)_height;
setSceneRect(QRectF(0.0,0.0,_width,_height));
//Create Cursor Pixmap
_cursor = addPixmap(QPixmap(POINTER_FILE));
_cursor->scale(POINTER_SCALE_X,POINTER_SCALE_Y);
_cursor->setZValue(POINTER_Z);
//set some default values
_modifiers = Qt::NoModifier;
_lastkeytime=0;
_repeating=false;
_lastclicktime = 0;
_visible=false;
_overlay->hide();
}
示例11: OGRE_EXCEPT
//---------------------------------------------------------------------
void OverlayContainer::_removeChild(const String& name)
{
ChildMap::iterator i = mChildren.find(name);
if (i == mChildren.end())
{
OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND, "Child with name " + name +
" not found.", "OverlayContainer::removeChild");
}
OverlayElement* element = i->second;
mChildren.erase(i);
// Remove from container list (if found)
ChildContainerMap::iterator j = mChildContainers.find(name);
if (j != mChildContainers.end())
mChildContainers.erase(j);
element->_setParent(0);
}
示例12: findElementAt
//---------------------------------------------------------------------
OverlayElement* Overlay::findElementAt(Real x, Real y)
{
OverlayElement* ret = NULL;
int currZ = -1;
OverlayContainerList::iterator i, iend;
iend = m2DElements.end();
for (i = m2DElements.begin(); i != iend; ++i)
{
int z = (*i)->getZOrder();
if (z > currZ)
{
OverlayElement* elementFound = (*i)->findElementAt(x,y);
if(elementFound)
{
currZ = elementFound->getZOrder();
ret = elementFound;
}
}
}
return ret;
}
示例13: while
//-----------------------------------------------------------------------
void OverlayProfileSessionListener::finializeSession()
{
OverlayContainer* container = dynamic_cast<OverlayContainer*>(mProfileGui);
if (container)
{
OverlayContainer::ChildIterator children = container->getChildIterator();
while (children.hasMoreElements())
{
OverlayElement* element = children.getNext();
OverlayContainer* parent = element->getParent();
if (parent) parent->removeChild(element->getName());
OverlayManager::getSingleton().destroyOverlayElement(element);
}
}
if(mProfileGui)
OverlayManager::getSingleton().destroyOverlayElement(mProfileGui);
if(mOverlay)
OverlayManager::getSingleton().destroy(mOverlay);
mProfileBars.clear();
}
示例14: updateStats
void DebugText::updateStats(Ogre::String text)
{
static String currFps = "Current FPS: ";
//static String avgFps = "Average FPS: ";
//static String bestFps = "Best FPS: ";
//static String worstFps = "Worst FPS: ";
//static String tris = "Triangle Count: ";
// update stats when necessary
OverlayElement* guiAvg = OverlayManager::getSingleton().getOverlayElement("Core/AverageFps");
OverlayElement* guiCurr = OverlayManager::getSingleton().getOverlayElement("Core/CurrFps");
OverlayElement* guiBest = OverlayManager::getSingleton().getOverlayElement("Core/BestFps");
OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
guiAvg->hide();
//guiCurr->hide();
guiBest->hide();
guiWorst->hide();
//OverlayElement* guiWorst = OverlayManager::getSingleton().getOverlayElement("Core/WorstFps");
/*guiAvg->setCaption(avgFps + StringConverter::toString(mWindow->getAverageFPS()));*/
guiCurr->setCaption(currFps + StringConverter::toString(mWindow->getLastFPS()));
//guiBest->setCaption(bestFps + StringConverter::toString(mWindow->getBestFPS())
// +" "+StringConverter::toString(mWindow->getBestFrameTime())+" ms");
//guiWorst->setCaption(worstFps + StringConverter::toString(mWindow->getWorstFPS())
// +" "+StringConverter::toString(mWindow->getWorstFrameTime())+" ms");
//OverlayElement* guiTris = OverlayManager::getSingleton().getOverlayElement("Core/NumTris");
//guiTris->setCaption(tris + StringConverter::toString(mWindow->getTriangleCount()));
OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText");
guiDbg->setCaption(text);
//guiDbg->setPosition(0,0);
//mDebugOverlay->
}
示例15: initialize
//-----------------------------------------------------------------------
void Profiler::setEnabled(bool enabled)
{
if (!mInitialized && enabled)
{
// the user wants to enable the Profiler for the first time
// so we initialize the GUI stuff
initialize();
mInitialized = true;
}
else
{
OverlayContainer* container = dynamic_cast<OverlayContainer*>(mProfileGui);
if (container)
{
OverlayContainer::ChildIterator children = container->getChildIterator();
while (children.hasMoreElements())
{
OverlayElement* element = children.getNext();
OverlayContainer* parent = element->getParent();
if (parent) parent->removeChild(element->getName());
OverlayManager::getSingleton().destroyOverlayElement(element);
}
}
if(mProfileGui)
OverlayManager::getSingleton().destroyOverlayElement(mProfileGui);
if(mOverlay)
OverlayManager::getSingleton().destroy(mOverlay);
mProfileBars.clear();
mInitialized = false;
mEnabled = false;
}
// We store this enable/disable request until the frame ends
// (don't want to screw up any open profiles!)
mNewEnableState = enabled;
}