本文整理汇总了C++中ogre::Overlay::add2D方法的典型用法代码示例。如果您正苦于以下问题:C++ Overlay::add2D方法的具体用法?C++ Overlay::add2D怎么用?C++ Overlay::add2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::Overlay
的用法示例。
在下文中一共展示了Overlay::add2D方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
void cStateEndRun::Init(){
printf("cStateMenu: Init\n");
MenuSet[0] = "MenuOpt1";
MenuSet[1] = "MenuOpt2";
MenuSet[2] = "MenuOpt3";
MenuSet[3] = "MenuOpt4";
MenuSet[4] = "MenuOpt5";
m_pOverlayMgr = Ogre::OverlayManager::getSingletonPtr();
//m_pProgLPanel = static_cast<Ogre::OverlayContainer*>(m_pOverlayMgr->createOverlayElement("Panel","ProgLPanel"));
//m_pProgLPanel->setMetricsMode(Ogre::GMM_PIXELS);
//m_pProgLPanel->setPosition(10, 10);
//m_pProgLPanel->setDimensions(32, 32);
//m_pProgLPanel->setMaterialName( "Programs/Crash" );
//m_pProgRPanel = static_cast<Ogre::OverlayContainer*>(m_pOverlayMgr->createOverlayElement("Panel","ProgRPanel"));
//m_pProgRPanel->setMetricsMode(Ogre::GMM_PIXELS);
//m_pProgRPanel->setPosition(900, 10);
//m_pProgRPanel->setDimensions(32, 32);
//m_pProgRPanel->setMaterialName( "Programs/Validate" );
m_pMenuPanel = static_cast<Ogre::OverlayContainer*>(m_pOverlayMgr->createOverlayElement("Panel","MenuP"));
m_pMenuPanel->setMetricsMode(Ogre::GMM_PIXELS);
m_pMenuPanel->setPosition(400, 200);
m_pMenuPanel->setDimensions(200, 200);
m_pMenuPanel->setMaterialName( "BaseWhite" );
TextRenderer::getSingleton().addLTextBox( MenuSet[0], "MenuP", "Controls", 10, 10, 100, 40, Ogre::ColourValue::Red);
TextRenderer::getSingleton().addLTextBox( MenuSet[1], "MenuP", "Video", 10, 50, 100, 40, Ogre::ColourValue::Black);
TextRenderer::getSingleton().addLTextBox( MenuSet[2], "MenuP", "Audio", 10, 90, 100, 40, Ogre::ColourValue::Black);
TextRenderer::getSingleton().addLTextBox( MenuSet[3], "MenuP", "OPP", 10, 130, 100, 40, Ogre::ColourValue::Black);
TextRenderer::getSingleton().addLTextBox( MenuSet[4], "MenuP", "About", 10, 170, 100, 40, Ogre::ColourValue::Black);
m_pDeckPanel = static_cast<Ogre::OverlayContainer*>(m_pOverlayMgr->createOverlayElement("Panel","DeckP"));
m_pDeckPanel->setMetricsMode(Ogre::GMM_PIXELS);
m_pDeckPanel->setPosition(500, 300);
m_pDeckPanel->setDimensions(400, 400);
m_pDeckPanel->setMaterialName( "BaseWhite" );
m_pActionPanel = static_cast<Ogre::OverlayContainer*>(m_pOverlayMgr->createOverlayElement("Panel","ActionP"));
m_pActionPanel->setMetricsMode(Ogre::GMM_PIXELS);
m_pActionPanel->setPosition(300, 200);
m_pActionPanel->setDimensions(200, 400);
m_pActionPanel->setMaterialName( "BaseWhite" );
Ogre::Overlay* overlay = m_pOverlayMgr->getByName("overlay1");
overlay->add2D(m_pMenuPanel);
overlay->add2D(m_pDeckPanel);
overlay->add2D(m_pActionPanel);
if(m_pMenuPanel->isVisible() == true) m_pMenuPanel->hide();
if(m_pDeckPanel->isVisible() == true) m_pDeckPanel->hide();
if(m_pActionPanel->isVisible() == true) m_pActionPanel->hide();
//m_pMainPanel->addChild(m_pProgLPanel);
//m_pMainPanel->addChild(m_pProgRPanel);
//TextRenderer::getSingleton().addTextBox("txtGreeting", "container1", "Hello", 10, 10, 100, 20, Ogre::ColourValue::Green);
}
示例2: createTextArea
// Create text area for SkyX parameters
void createTextArea()
{
// Create a panel
Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
OverlayManager::getSingleton().createOverlayElement("Panel", "SkyXParametersPanel"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setPosition(10, 10);
panel->setDimensions(400, 400);
// Create a text area
mTextArea = static_cast<Ogre::TextAreaOverlayElement*>(
OverlayManager::getSingleton().createOverlayElement("TextArea", "SkyXParametersTextArea"));
mTextArea->setMetricsMode(Ogre::GMM_PIXELS);
mTextArea->setPosition(0, 0);
mTextArea->setDimensions(100, 100);
mTextArea->setCaption("SkyX plugin demo");
mTextArea->setCharHeight(16);
mTextArea->setFontName("BlueHighway");
mTextArea->setColourBottom(ColourValue(0.3, 0.5, 0.3));
mTextArea->setColourTop(ColourValue(0.5, 0.7, 0.5));
// Create an overlay, and add the panel
Ogre::Overlay* overlay = OverlayManager::getSingleton().create("OverlayName");
overlay->add2D(panel);
// Add the text area to the panel
panel->addChild(mTextArea);
// Show the overlay
overlay->show();
}
示例3: createOverlay
// create overlay uv test
void Test::createOverlay(void)
{
// load the fade
mFader = 0;
Ogre::MaterialPtr mFaderMaterial;
Ogre::TextureUnitState *mTexture = 0;
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
mFader = static_cast<Ogre::PanelOverlayElement*>(
overlayManager.createOverlayElement("Panel", "Fader"));
mFader->setMetricsMode(Ogre::GMM_RELATIVE);
mFader->setPosition(0, 0);
mFader->setDimensions(0.25f, 0.25f);
mFader->setMaterialName("BotonTest"); // Optional background material
// Ensures that the material exists
mFader->setUV(0,0,0.5,1);
// show the fade
mFader->show();
// Create an overlay, and add the panel
Ogre::Overlay *mOverlay = 0;
mOverlay = overlayManager.create("FaderOverlay");
mOverlay->add2D(mFader);
mOverlay->show();
}
示例4: createScene
void OgreApp::createScene()
{
sceneMgr->setSkyBox(true, "Sky", 5, 8, 4000);
sceneMgr->setAmbientLight(ColourValue(0.5f, 0.5f, 0.5f));
sceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);
node = sceneMgr->getRootSceneNode()->createChildSceneNode("OgreHead");
ent = sceneMgr->createEntity("Ogre", "ogrehead.mesh");
node->attachObject(ent);
node->setPosition(0, 50, 0);
OgreAL::Sound *bgSound = soundManager->createSound("5.1 Test", "6chan.ogg", true);
bgSound->setGain(2);
bgSound->setRelativeToListener(true);
bgSound->play();
node = sceneMgr->getRootSceneNode()->createChildSceneNode("CameraNode");
node->setPosition(0, 100, 100);
node = node->createChildSceneNode("PitchNode");
node->attachObject(camera);
node->attachObject(soundManager->getListener());
node->pitch(Ogre::Degree(-30));
// Create a ground plane
Plane plane(Vector3::UNIT_Y, 0);
MeshManager::getSingleton().createPlane("ground",
ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
15000,15000,20,20,true,1,5,5,Vector3::UNIT_Z);
ent = sceneMgr->createEntity("GroundEntity", "ground");
sceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(ent);
ent->setMaterialName("Ground");
ent->setCastShadows(false);
light = sceneMgr->createLight("sun");
light->setType(Light::LT_DIRECTIONAL);
light->setDirection(-1,-1,-1);
OverlayManager& overlayMgr = OverlayManager::getSingleton();
Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(
overlayMgr.createOverlayElement("Panel", "PanelName"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setPosition(10, 10);
panel->setDimensions(100, 100);
TextAreaOverlayElement* textArea = static_cast<TextAreaOverlayElement*>(
overlayMgr.createOverlayElement("TextArea", "TextAreaName"));
textArea->setMetricsMode(Ogre::GMM_PIXELS);
textArea->setPosition(0, 0);
textArea->setDimensions(100, 100);
textArea->setCharHeight(16);
textArea->setFontName("Arial");
textArea->setCaption("Hello, World!");
Ogre::Overlay* overlay = overlayMgr.create("AverageFps");
overlay->add2D(panel);
panel->addChild(textArea);
overlay->show();
}
示例5: createCanvasOverlay
void OgreAppLogic::createCanvasOverlay()
{
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
Ogre::Overlay* overlay = overlayManager.create("Canvas/Overlay");
Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "CanvasClock1/Panel"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setMaterialName("CanvasClock1");
panel->setDimensions(150.0f, 150.0f);
panel->setPosition(0, 0);
overlay->add2D(panel);
panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "CanvasClock2/Panel"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setMaterialName("CanvasClock2");
panel->setDimensions(150.0f, 150.0f);
panel->setPosition(mApplication->getRenderWindow()->getWidth()-150.0f, 0);
overlay->add2D(panel);
overlay->show();
}
示例6: createInput
void BasisManager::createInput() // создаем систему ввода
{
Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
mWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
mInputManager = OIS::InputManager::createInputSystem( pl );
mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
mKeyboard->setEventCallback(this);
mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
mMouse->setEventCallback(this);
mRoot->addFrameListener(this);
windowResized(mWindow); // инициализация
Ogre::WindowEventUtilities::addWindowEventListener(mWindow, this);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().getByName("wallpaper");
if (false == material.isNull()) {
Ogre::OverlayManager & manager = Ogre::OverlayManager::getSingleton();
Ogre::Overlay * overlay = manager.create("wallpaper");
overlay->setZOrder(0);
overlay->show();
Ogre::PanelOverlayElement * panel = static_cast<Ogre::PanelOverlayElement*>(manager.createOverlayElement("Panel", "wallpaper"));
panel->setDimensions(1, 1);
/*Ogre::FontPtr mpFont = Ogre::FontManager::getSingleton().getByName("MyGUI_font");
mpFont->load();
if (!mpFont.isNull()) {
const Ogre::MaterialPtr & material2 = mpFont->getMaterial();
panel->setMaterialName(material2->getName());
}*/
panel->setMaterialName(material->getName());
overlay->add2D(panel);
}
}
示例7: createCanvasOverlay
void OgreAppLogic::createCanvasOverlay()
{
//create Texture
mTexture = new Ogre::Canvas::Texture("Canvas", 640, 480, true, 0);
//create Material
mTexture->createMaterial();
//create Overlay
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
Ogre::Overlay* overlay = overlayManager.create("Canvas/Overlay");
mPanel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "Canvas/Panel"));
mPanel->setMetricsMode(Ogre::GMM_PIXELS);
mPanel->setMaterialName("Canvas");
mPanel->setDimensions(640, 480);
mPanel->setPosition(0, 0);
overlay->add2D(mPanel);
overlay->show();
}
示例8: createBrowser
void SalamancerApplication::createBrowser(){
Ogre::TexturePtr renderTexture = Ogre::TextureManager::getSingleton().createManual(
"texture",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, mWindow->getWidth(), mWindow->getHeight(), 0, Ogre::PF_A8R8G8B8, Ogre::TU_WRITE_ONLY);
Ogre::MaterialPtr material = Ogre::MaterialManager::getSingletonPtr()->create("BrowserMaterial", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->setCullingMode(Ogre::CULL_CLOCKWISE); // print both sides of the polygones
material->getTechnique(0)->getPass(0)->createTextureUnitState("texture");
material->getTechnique(0)->getPass(0)->setSceneBlending(SBT_TRANSPARENT_ALPHA);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
Ogre::Overlay *overlay = Ogre::OverlayManager::getSingletonPtr()->create("BrowserOverlay");
Ogre::OverlayContainer* panel = static_cast<OverlayContainer*>(Ogre::OverlayManager::getSingletonPtr()->createOverlayElement("Panel", "BrowserPanel"));
panel->setPosition(0.0, 0.0);
panel->setDimensions(1.0, 1.0);
panel->setMaterialName("BrowserMaterial");
overlay->add2D(panel);
overlay->show();
this->windowInfo.SetAsWindowless(0, true);
this->clientHandler = new ClientHandler(renderTexture, this->mRoot->getAutoCreatedWindow(), mMouse, this->mCamera, this->mSceneMgr, this->world, this->context);
browserSettings.web_security = STATE_DISABLED;
this->browser = CefBrowserHost::CreateBrowserSync(windowInfo, this->clientHandler.get(),
"file:///home/nathan/Projects/salamancer/dist/bin/hud/index.html",
browserSettings,
NULL);
this->clientHandler->SetBrowser(this->browser);
mRoot->addFrameListener(this->clientHandler.get());
}
示例9: initOverlay
void OgreEngine::initOverlay() {
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(overlayManager.createOverlayElement("Panel", "PanelName"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setPosition(10, 10);
panel->setDimensions(100, 100);
Ogre::TextAreaOverlayElement* textArea = static_cast<Ogre::TextAreaOverlayElement*>(
overlayManager.createOverlayElement("TextArea", "worldName"));
textArea->setMetricsMode(Ogre::GMM_PIXELS);
textArea->setPosition(10, 10);
textArea->setDimensions(100, 200);
textArea->setFontName("StarWars");
//textArea->setCaption(this->data["name"].toString().toStdString());
textArea->setCharHeight(16);
textArea->setColourBottom(Ogre::ColourValue(1, 1, 1));
textArea->setColourTop(Ogre::ColourValue(1, 1, 1));
Ogre::TextAreaOverlayElement* textArea2 = static_cast<Ogre::TextAreaOverlayElement*>(
overlayManager.createOverlayElement("TextArea", "timeArea"));
textArea2->setMetricsMode(Ogre::GMM_PIXELS);
textArea2->setPosition(10, 30);
textArea2->setDimensions(100, 200);
textArea2->setFontName("StarWars");
textArea2->setCaption("0min 0sec");
textArea2->setCharHeight(16);
textArea2->setColourBottom(Ogre::ColourValue(1, 1, 1));
textArea2->setColourTop(Ogre::ColourValue(1, 1, 1));
Ogre::Overlay* overlay = overlayManager.create("OverlayName");
overlay->add2D(panel);
panel->addChild(textArea);
panel->addChild(textArea2);
overlay->show();
}
示例10: test
void test()
{
Ogre::Root* pOgre = new Ogre::Root("", "");
pOgre->loadPlugin(RENDER_SYSTEM);
pOgre->setRenderSystem(pOgre->getAvailableRenderers().front());
pOgre->initialise(false);
Ogre::NameValuePairList lArgs;
//lArgs["externalWindowHandle"] = bk::format("%d", (bk::uint)l_window.get_handle()).astr;
Ogre::RenderWindow* pWindow = pOgre->createRenderWindow("Heart|Dockyard", 1024, 768, false, &lArgs);
Ogre::SceneManager* pSceneManager = pOgre->createSceneManager(Ogre::ST_GENERIC,"SceneManager");
pSceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE);
pSceneManager->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(new Ogre::FocusedShadowCameraSetup()));
pSceneManager->setAmbientLight(Ogre::ColourValue(0.1f, 0.1f, 0.1f));
Ogre::Camera* pCamera = pSceneManager->createCamera("Camera");
pCamera->setFixedYawAxis(true, Ogre::Vector3::UNIT_Z);
pCamera->setPosition(Ogre::Vector3(0.0f, 50.0f, 20.0f));
pCamera->lookAt(Ogre::Vector3(0.0f, 0.0f, 0.0f));
pCamera->setNearClipDistance(0.1f);
pCamera->setFarClipDistance(100.0f);
Ogre::Viewport* pViewport = pWindow->addViewport(pCamera);
pViewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f));
pCamera->setAspectRatio(Ogre::Real(pViewport->getActualWidth()) / Ogre::Real(pViewport->getActualHeight()));
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("../data/dockyard.zip", "Zip", "Dockyard", true);
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
Ogre::MeshManager::getSingleton().createPlane("GroundPlane", "Dockyard", Ogre::Plane(0.0f, 0.0f, 1.0f, 0.0f), 100.0f, 100.0f, 100, 100, true, 1, 3.0f, 3.0f);
Ogre::Entity* pGroundEntity = pSceneManager->createEntity("GroundPlane");
pGroundEntity->setMaterialName("Examples/Rockwall");
pGroundEntity->setCastShadows(false);
pGroundEntity->getSubEntity(0)->getMaterial()->setShadingMode(Ogre::SO_PHONG);
Ogre::SceneNode* pGroundNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
pGroundNode->attachObject(pGroundEntity);
Ogre::Entity* pCubeEntity = pSceneManager->createEntity("Cube", Ogre::SceneManager::PT_CUBE);
pCubeEntity->setMaterialName("Examples/10PointBlock");
pCubeEntity->setCastShadows(true);
Ogre::SceneNode* pCubeNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
pCubeNode->attachObject(pCubeEntity);
pCubeNode->setPosition(0.0f, 0.0f, 5.f);
pCubeNode->setScale(0.1f, 0.1f, 0.1f);
Ogre::ColourValue lColour1(1.0f, 1.0f, 1.0f);
Ogre::ColourValue lColour2(1.0f, 1.0f, 1.0f);
Ogre::ColourValue lColour3(1.0f, 1.0f, 1.0f);
Ogre::Light* pLight1 = pSceneManager->createLight();
pLight1->setType(Ogre::Light::LT_SPOTLIGHT);
pLight1->setPosition(30.0f, 30.0f, 30.0f);
pLight1->setDirection(-1.0f, -1.0f, -1.0f);
pLight1->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight1->setDiffuseColour(lColour1 * 0.5f);
Ogre::Light* pLight2 = pSceneManager->createLight();
pLight2->setType(Ogre::Light::LT_SPOTLIGHT);
pLight2->setPosition(-30.0f, 30.0f, 30.0f);
pLight2->setDirection(1.0f, -1.0f, -1.0f);
pLight2->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight2->setDiffuseColour(lColour2 * 0.5f);
Ogre::Light* pLight3 = pSceneManager->createLight();
pLight3->setType(Ogre::Light::LT_SPOTLIGHT);
pLight3->setPosition(30.0f, -30.0f, 30.0f);
pLight3->setDirection(-1.0f, 1.0f, -1.0f);
pLight3->setSpotlightRange(Ogre::Degree(30), Ogre::Degree(50));
pLight3->setDiffuseColour(lColour3 * 0.5f);
Ogre::Overlay* pMenuOverlay = Ogre::OverlayManager::getSingleton().create("Menu");
Ogre::OverlayElement* pMenu = Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "Menu");
pMenu->setMetricsMode(Ogre::GMM_PIXELS);
pMenu->setWidth(200);
pMenu->setHeight(200);
pMenu->setTop(30);
pMenu->setLeft(30);
pMenu->setMaterialName("Examples/BumpyMetal");
if (pMenu->isContainer()) pMenuOverlay->add2D(static_cast<Ogre::OverlayContainer*>(pMenu));
pMenuOverlay->show();
pOgre->startRendering();
}
示例11: showQuestLog
void Menu::showQuestLog(const bool visible)
{
Ogre::OverlayManager* om = Ogre::OverlayManager::getSingletonPtr();
if (om==NULL) return;
//Do we actually need to do something?
if (visible==isQuestLogVisible()) return;
if (visible)
{
//show it
// -- create basic overlay
Ogre::Overlay* ol = om->create(cQuestLogOverlay);
// -- create container - panel
Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>(
om->createOverlayElement("Panel", cQuestLogOverlay+"/Panel"));
panel->setMetricsMode(Ogre::GMM_RELATIVE);
panel->setPosition(0.0, 0.0);
panel->setDimensions(1.0, 1.0);
/*set material via panel->setMaterialName(...)?*/
panel->setMaterialName("QuestLog/Transparency");
//add panel to overlay
ol->add2D(panel);
//create elements
// -- "vorwärts blättern"
Ogre::TextAreaOverlayElement* text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
om->createOverlayElement("TextArea", cQuestLogOverlay+"/Plus"));
text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
text_elem->setPosition(0.125, 0.9);
text_elem->setDimensions(0.25, 0.1);
text_elem->setCaption("+ (Next)");
text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
text_elem->setFontName("Console");
text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
text_elem->setCharHeight(cQuestLogCharHeight);
panel->addChild(text_elem);
//-- "rückwärts blättern"
text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
om->createOverlayElement("TextArea", cQuestLogOverlay+"/Minus"));
text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
text_elem->setPosition(0.425, 0.9);
text_elem->setDimensions(0.25, 0.1);
text_elem->setCaption("- (Previous)");
text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
text_elem->setFontName("Console");
text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
text_elem->setCharHeight(cQuestLogCharHeight);
panel->addChild(text_elem);
//lists all entries that fit onto the page
showQuestLogEntries();
// -- page number
text_elem = static_cast<Ogre::TextAreaOverlayElement*>(
om->createOverlayElement("TextArea", cQuestLogOverlay+"/Page"));
text_elem->setMetricsMode(Ogre::GMM_RELATIVE);
text_elem->setPosition(0.725, 0.9);
text_elem->setDimensions(0.25, 0.1);
text_elem->setCaption("Page "+IntToString(m_QuestLogOffset/cQuestLogEntriesPerPage+1));
text_elem->setAlignment(Ogre::TextAreaOverlayElement::Center);
text_elem->setFontName("Console");
text_elem->setColour(Ogre::ColourValue(1.0, 0.5, 0.0));
text_elem->setCharHeight(cQuestLogCharHeight);
panel->addChild(text_elem);
//show the overlay
ol->show();
}//if visible
else
{
//destroy all elements
unsigned int i;
// destroy entries
for (i=0; i<m_QuestLogEntryCount; ++i)
{
om->destroyOverlayElement(cQuestLogOverlay+"/"+IntToString(i));
}//for
m_QuestLogEntryCount = 0;
//destroy navigation elements
om->destroyOverlayElement(cQuestLogOverlay+"/Plus");
om->destroyOverlayElement(cQuestLogOverlay+"/Minus");
om->destroyOverlayElement(cQuestLogOverlay+"/Page");
//destroy panel
om->destroyOverlayElement(cQuestLogOverlay+"/Panel");
//destroy overlay
om->destroy(cQuestLogOverlay);
}//else
}//function
示例12: createKinectOverlay
void OgreAppLogic::createKinectOverlay(const std::string& colorTextureName, const std::string& depthTextureName, const std::string& coloredDepthTextureName)
{
//Create Color Overlay
{
//Create Overlay
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
Ogre::Overlay* overlay = overlayManager.create("KinectColorOverlay");
//Create Material
const std::string materialName = "KinectColorMaterial";
Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->createTextureUnitState(colorTextureName);
//Create Panel
Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "KinectColorPanel"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setMaterialName(materialName);
panel->setDimensions((float)Kinect::colorWidth/4, (float)Kinect::colorHeight/4);
panel->setPosition(0.0f, 0.0f);
overlay->add2D(panel);
overlay->setZOrder(300);
overlay->show();
}
//Create Depth Overlay
{
//Create Overlay
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
Ogre::Overlay* overlay = overlayManager.create("KinectDepthOverlay");
//Create Material
const std::string materialName = "KinectDepthMaterial";
Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->setAlphaRejectSettings(CMPF_GREATER, 127);
material->getTechnique(0)->getPass(0)->createTextureUnitState(depthTextureName);
//material->getTechnique(0)->getPass(0)->setVertexProgram("Ogre/Compositor/StdQuad_vp");
//material->getTechnique(0)->getPass(0)->setFragmentProgram("KinectDepth");
//Create Panel
Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "KinectDepthPanel"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setMaterialName(materialName);
panel->setDimensions((float)Kinect::depthWidth/4, (float)Kinect::depthHeight/4);
panel->setPosition((float)640.0f/4, 0.0f);
overlay->add2D(panel);
overlay->setZOrder(310);
overlay->show();
}
//Create Colored Depth Overlay
{
//Create Overlay
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
Ogre::Overlay* overlay = overlayManager.create("KinectColoredDepthOverlay");
//Create Material
const std::string materialName = "KinectColoredDepthMaterial";
Ogre::MaterialPtr material = MaterialManager::getSingleton().create(materialName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
material->getTechnique(0)->getPass(0)->setLightingEnabled(false);
material->getTechnique(0)->getPass(0)->setDepthWriteEnabled(false);
material->getTechnique(0)->getPass(0)->createTextureUnitState(coloredDepthTextureName);
//Create Panel
Ogre::PanelOverlayElement* panel = static_cast<Ogre::PanelOverlayElement*>(overlayManager.createOverlayElement("Panel", "KinectColoredDepthPanel"));
panel->setMetricsMode(Ogre::GMM_PIXELS);
panel->setMaterialName(materialName);
panel->setDimensions((float)Kinect::depthWidth/4, (float)Kinect::depthHeight/4);
panel->setPosition((float)1280.0f/4, 0.0f);
overlay->add2D(panel);
overlay->setZOrder(320);
overlay->show();
}
}
示例13: InitStartScene
static void InitStartScene()
{
if(app.state.CurentState > 0)
{
return;
}
Ogre::RTShader::ShaderGenerator::initialize();
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->setTargetLanguage("glsles");
gMatListener = new Ogre::ShaderGeneratorTechniqueResolverListener();
Ogre::MaterialManager::getSingleton().addListener(gMatListener);
LOGW("Create SceneManager");
gSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->addSceneManager(gSceneMgr);
camera = gSceneMgr->createCamera("MyCam");
camera->setNearClipDistance(1.0f);
camera->setFarClipDistance(100000.0f);
camera->setPosition(0,0,20.0f);
camera->lookAt(0,0,0);
camera->setAutoAspectRatio(true);
vp = gRenderWnd->addViewport(camera);
vp->setBackgroundColour(Ogre::ColourValue(1.0f, 1.0f, 1.0f));
vp->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME);
/**
* http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Creating+Overlays+via+Code
* http://www.ogre3d.org/forums/viewtopic.php?f=2&t=78278#p492027
*/
LOGW("Create OverlaySystem");
Ogre::OverlaySystem *mOverlaySystem = OGRE_NEW Ogre::OverlaySystem();
gSceneMgr->addRenderQueueListener(mOverlaySystem);
LOGW("Create overlayManager");
Ogre::OverlayManager& overlayManager = Ogre::OverlayManager::getSingleton();
loadResources("resources.cfg");
Ogre::ResourceGroupManager::getSingletonPtr()->initialiseResourceGroup("Start");
LOGW("Create a img overlay panel");
Ogre::OverlayContainer* panel = static_cast<Ogre::OverlayContainer*>( overlayManager.createOverlayElement( "Panel", "PanelLogo" ) );
panel->setPosition( vp->getActualWidth()/2 - 64, vp->getActualHeight()/2 - 64 - 20 );
panel->setDimensions( 128, 64 );
panel->setMaterialName("overlay_image_material");
panel->setMetricsMode(Ogre::GMM_PIXELS);
Ogre::Overlay* LogoOverlay = overlayManager.create( "OverlayLogo" );
LogoOverlay->add2D( panel );
LogoOverlay->show();
LOGW("Create a text overlay panel");
textArea = static_cast<Ogre::TextAreaOverlayElement*>(overlayManager.createOverlayElement("TextArea", "TextAreaName"));
textArea->setMetricsMode(Ogre::GMM_PIXELS);
textArea->setPosition(0, 0);
textArea->setDimensions(100, 100);
textArea->setCaption("Hello, World!");
textArea->setCharHeight(48);
textArea->setFontName("QWcuckoo");
textArea->setColourBottom(Ogre::ColourValue(0.0f, 0.0f, 1.0f));
textArea->setColourTop(Ogre::ColourValue(1.0f, 0.0f, 0.0f));
Ogre::OverlayContainer* TextPanel = static_cast<Ogre::OverlayContainer*>( overlayManager.createOverlayElement( "Panel", "PanelText" ) );
TextPanel->setPosition( vp->getActualWidth()/2 - 128, vp->getActualHeight()/2 + 20 );
TextPanel->setDimensions( 256, 64 );
TextPanel->setMaterialName("overlay_text_material");
TextPanel->setMetricsMode(Ogre::GMM_PIXELS);
TextPanel->addChild(textArea);
Ogre::Overlay* TextOverlay = overlayManager.create( "OverlayText" );
TextOverlay->add2D( TextPanel );
TextOverlay->show();
app.state.CurentState = 1;
}