// 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(); }
void PendulumTest::handleInput(opal::real elapsedRealTime, const SimulationEngine& engine) { OIS::Keyboard* keyboard = engine.getKeyboard(); // This variable can be used to keep keys from repeating too fast. static Ogre::Real toggleTimer = 0; if (toggleTimer >= 0) { toggleTimer -= elapsedRealTime; } // Toggle GUI. if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0) { Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton(). getByName("Verve/TrialNumber"); if (debugOverlay->isVisible()) { debugOverlay->hide(); mAgentDebugger->setDisplayEnabled(false); } else { debugOverlay->show(); mAgentDebugger->setDisplayEnabled(true); } toggleTimer = 0.5; } }
void FrameListener::showDebugOverlay(bool show) { Ogre::Overlay *overlay = Ogre::OverlayManager::getSingleton().getByName("Core/DebugOverlay"); if (show) overlay->show(); else overlay->hide(); }
// 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(); }
void setVisible(bool bShow) { if (bShow) { m_pOverlay->show(); } else { m_pOverlay->hide(); } }
void Menu::showDialogue(const std::string& first, const std::vector<std::string>& options) { Ogre::OverlayManager& om = Ogre::OverlayManager::getSingleton(); std::cout << "getByName(overlay)\n"; Ogre::Overlay* dialOverlay = om.getByName(cDialogueOverlay); if (dialOverlay == NULL) { std::cout << "create(overlay)\n"; dialOverlay = om.create(cDialogueOverlay); } Ogre::OverlayContainer* dialCont = NULL; std::cout << "getOE(Box)\n"; dialCont = static_cast<Ogre::OverlayContainer*> (om.getOverlayElement(cDialogueOverlay+"/Box")); if (dialCont == NULL) { std::cout << "createOE(Box)\n"; dialCont = static_cast<Ogre::OverlayContainer*> (om.createOverlayElement("Panel", cDialogueOverlay+"/Box")); dialCont->setPosition(0.0, 0.75); dialCont->setDimensions(1.0, 0.25); dialCont->setMaterialName("Dusk/Dialogue/Black"); } std::cout << "getOE(Box/First)\n"; Ogre::OverlayElement* dialElem; dialElem = om.getOverlayElement(cDialogueOverlay+"/Box/First"); if (dialElem==NULL) { std::cout << "createOE(Box/First)\n"; dialElem = om.createOverlayElement("TextArea", cDialogueOverlay+"/Box/First"); dialElem->setDimensions(1.0, 0.0625); dialElem->setPosition(0.0, 0.0); dialElem->setMaterialName("Dusk/Dialogue/Element"); dialCont->addChild(dialElem); } dialElem->setCaption(first); dialElem->show(); unsigned int elemCount = options.size(); if (elemCount > cMaxDialogueOptions) { elemCount = cMaxDialogueOptions; } killDialogueOverlayLines(); unsigned int i; const float elemHeight = 0.8/(float)elemCount; for (i=0; i<elemCount; i=i+1) { //dialElem = om.createOverlayElement("TextArea", cDialogueOverlay+"/Box/Line"+IntToString(i)); dialElem = om.createOverlayElementFromTemplate(cDialogueOverlay+"/LineTemplate", "TextArea", cDialogueOverlay+"/Box/Line"+IntToString(i)); dialElem->setPosition(0.1, dialCont->getHeight()*(0.2+i*elemHeight)); dialElem->setDimensions(0.8, elemHeight*dialCont->getHeight()); dialElem->setCaption(IntToString(i+1)+": "+options[i]); dialElem->show(); dialCont->addChild(dialElem); m_DialogueLineCount = i+1; }//for dialOverlay->show(); }
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(); }
void startFadeIn(Ogre::Real fDuration) { if (fDuration < 0) fDuration = -fDuration; m_fAlpha = 1.0; m_fTotalDuration = fDuration; m_fCurrentDuration = fDuration; m_eFadeOperation = FADE_IN; m_pOverlay->show(); }
void MenuState::createOverlay() { unsigned int width, height, depth; int left, top; Ogre::Overlay *overlay = _overlayManager->getByName("Menu"); _root->getAutoCreatedWindow()->getMetrics(width, height, depth, left, top); overlay->setScale(((float(width) / 100) / 1024) * 100, ((float(height) / 100) / 768) * 100); overlay->show(); // _fader->startFadeIn(0); }
void Gui::createGui(Ogre::SceneManager* p_scene_manager, OgreBites::SdkTrayManager* p_tray_manager){ m_tray_manager = p_tray_manager; m_button = m_tray_manager->createButton(OgreBites::TL_TOPLEFT, "MyButton", "Click me!"); if(m_button->getName() == "MyButton"){ int p = 0; } // Load layout Ogre::ResourceGroupManager::getSingletonPtr(); Ogre::OverlayManager* mg = Ogre::OverlayManager::getSingletonPtr(); Ogre::Overlay* ov = mg->getByName("testOverlay"); ov->show(); }
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); } }
void Game::initRendering() { #ifdef _DEBUG const char* plugin_file = "plugins_d.cfg"; #else const char* plugin_file = "plugins.cfg"; #endif m_ogreRoot = new Ogre::Root(plugin_file); m_ogreRoot->showConfigDialog(); m_ogreRoot->initialise(true); m_renderWindow = m_ogreRoot->getAutoCreatedWindow(); //createRenderWindow("mkdemo", 800, 600, false); m_ogreSceneMgr = m_ogreRoot->createSceneManager(Ogre::ST_GENERIC); m_ogreCamera = m_ogreSceneMgr->createCamera("main_cam"); Ogre::Viewport* viewport = m_renderWindow->addViewport(m_ogreCamera); m_ogreCamera->setAspectRatio(viewport->getActualWidth() / (float)viewport->getActualHeight()); // DebugDrawer singleton new DebugDrawer(m_ogreSceneMgr, .75f); loadOgreResources(); // overlay Ogre::Overlay* hud = Ogre::OverlayManager::getSingleton().getByName("Game/HUD"); hud->show(); if (m_disableShadows) m_ogreSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_NONE); else m_ogreSceneMgr->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); m_ogreCamera->setNearClipDistance(0.1f); if (!m_startWithFreelook) m_playerCam = new CameraTPP(m_ogreCamera, NULL); else m_playerCam = new CameraFPP(m_ogreCamera, NULL); m_ogreSceneMgr->setAmbientLight(Ogre::ColourValue(0.3f, 0.3f, 0.3f)); // please note it's usually changed on level deserialization with RenderSettingsSetter }
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(); }
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(); }
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()); }
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(); }
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(); }
bit GameVisualScene::init( Game* game ) { game->visualSystem.lockThread(); game->visualSystem.loadResources("InGame"); Ogre::Viewport* vp = game->visualSystem.getPrimaryRenderWindow()->getViewport(0); Ogre::CompositorManager* compositorMgr = Ogre::CompositorManager::getSingletonPtr(); Ogre::CompositorInstance* compositor = compositorMgr->addCompositor(vp,"LuminanceBloom"); compositorMgr->setCompositorEnabled(vp,"LuminanceBloom",true); VisualScene::init(game); Ogre::Light* light = game->visualSystem.getSceneMgr()->createLight("MainLight"); light->setType(Ogre::Light::LT_DIRECTIONAL); light->setPosition(800,900,-550); Ogre::Vector3 dir = -light->getPosition(); dir.normalise(); light->setDirection(dir); light->setSpecularColour(1.0f,1.0f,1.0f); light->setDiffuseColour(0.8f,0.8f,0.8f); //light->setSpotlightRange(Ogre::Degree(50), Ogre::Degree(75)); light->setPowerScale(1.0f); light->setCastShadows(true); //Ogre::LiSPSMShadowCameraSetup* cameraSetup = new Ogre::LiSPSMShadowCameraSetup; //game->visualSystem.getSceneMgr()->setShadowCameraSetup(Ogre::ShadowCameraSetupPtr(cameraSetup)); game->visualSystem.getSceneMgr()->getRootSceneNode()->attachObject(light); game->visualSystem.getSceneMgr()->setAmbientLight(Ogre::ColourValue(0.1,0.90,0.75)); //game->visualSystem.getSceneMgr()->setShadowTechnique(Ogre::SHADOWTYPE_TEXTURE_ADDITIVE); game->visualSystem.getSceneMgr()->setShadowTextureSize(1024); //game->visualSystem.getSceneMgr()->setShadowTextureSettings(1024,2); game->visualSystem.getSceneMgr()->setShadowFarDistance(24); game->visualSystem.getSceneMgr()->setShadowDirLightTextureOffset(0.05); game->visualSystem.getSceneMgr()->setShadowTextureSelfShadow(false); game->visualSystem.getSceneMgr()->setShadowColour( Ogre::ColourValue(0.75f, 0.75f, 0.75f) ); game->visualSystem.getSceneMgr()->setSkyBox(true,"skybox",1000); game->visualSystem.getSceneMgr()->setShadowTextureCasterMaterial("depthShadowMapCasterMaterial"); //game->visualSystem.getSceneMgr()->setShadowTextureCasterMaterial("VarianceShadowMapping/ShadowCaster"); game->visualSystem.getSceneMgr()->setShadowTexturePixelFormat(PF_FLOAT32_R); game->visualSystem.getSceneMgr()->setShadowCasterRenderBackFaces(true); game->visualSystem.getSceneMgr()->setShadowTechnique(SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED); Bridge* bridge = new Bridge(game); bridge->init("bridge"); RoadBarrier* barrier[20]; for(u32 i=0 ; i<20 ; i++) { barrier[i] = new RoadBarrier(game); barrier[i]->init("barrier"+IntToStr(i)); } hkQuaternion q; q.setAxisAngle(hkVector4(0,1,0),Deg2Rad(90)); barrier[0]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-50.0),q); barrier[1]->getPhysicsEntity()->setPositionAndRotation(hkVector4(4.5,0.51f,-40.0),q); barrier[2]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-30.0),q); barrier[3]->getPhysicsEntity()->setPositionAndRotation(hkVector4(1.5,0.51f,-20.0),q); barrier[4]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-10.0),q); barrier[5]->getPhysicsEntity()->setPositionAndRotation(hkVector4(2.5,0.51f,-70.0),q); barrier[6]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,-90.0),q); barrier[7]->getPhysicsEntity()->setPositionAndRotation(hkVector4(0.5,0.51f,100.0),q); barrier[8]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,110.0),q); barrier[9]->getPhysicsEntity()->setPositionAndRotation(hkVector4(5.5,0.51f,40.0),q); barrier[10]->getPhysicsEntity()->setPositionAndRotation(hkVector4(1.5,0.51f,50.0),q); barrier[11]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,60.0),q); barrier[12]->getPhysicsEntity()->setPositionAndRotation(hkVector4(5.5,0.51f,70.0),q); barrier[13]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,80.0),q); barrier[14]->getPhysicsEntity()->setPositionAndRotation(hkVector4(3.5,0.51f,90.0),q); barrier[15]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-5.5,0.51f,100.0),q); barrier[16]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-2.5,0.51f,110.0),q); barrier[17]->getPhysicsEntity()->setPositionAndRotation(hkVector4(-0.5,0.51f,120.0),q); barrier[18]->getPhysicsEntity()->setPositionAndRotation(hkVector4(2.5,0.51f,130.0),q); barrier[19]->getPhysicsEntity()->setPositionAndRotation(hkVector4(5.5,0.51f,140.0),q); Crate* crate[32]; for(u32 i=0 ; i<32 ; i++) { crate[i] = new Crate(game); crate[i]->init("crate"+IntToStr(i)); } crate[0]->getPhysicsEntity()->setPosition(hkVector4(-1.25,0.0f,20.75)); crate[1]->getPhysicsEntity()->setPosition(hkVector4(-2 ,0.0f,20.75)); crate[2]->getPhysicsEntity()->setPosition(hkVector4(-2,0.0f,20.75)); crate[3]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.0f,20.0)); crate[4]->getPhysicsEntity()->setPosition(hkVector4(-2 ,0.0f,20.0)); crate[5]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.0f,20.0)); crate[6]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.0f,20.75)); crate[7]->getPhysicsEntity()->setPosition(hkVector4(-2 ,0.0f,20.75)); crate[8]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.0f,20.75)); crate[9]->getPhysicsEntity()->setPosition(hkVector4(-1.25,0.5f,20.75)); crate[10]->getPhysicsEntity()->setPosition(hkVector4(-2 ,0.5f,20.75)); crate[11]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.5f,20.75)); crate[12]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.5f,20.0)); crate[13]->getPhysicsEntity()->setPosition(hkVector4(-2 ,0.5f,20.0)); crate[14]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.5f,20.0)); crate[15]->getPhysicsEntity()->setPosition(hkVector4(-1,25,0.5f,20.750)); crate[16]->getPhysicsEntity()->setPosition(hkVector4(-2 ,0.5f,20.750)); crate[17]->getPhysicsEntity()->setPosition(hkVector4(-2.75,0.5f,20.750)); crate[18]->getPhysicsEntity()->setPosition(hkVector4(-1.25,1.0f,20.75)); crate[19]->getPhysicsEntity()->setPosition(hkVector4(-2 ,1.0f,20.75)); crate[20]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.0f,20.75)); crate[21]->getPhysicsEntity()->setPosition(hkVector4(-1,25,1.0f,20.0)); crate[22]->getPhysicsEntity()->setPosition(hkVector4(-2 ,1.0f,20.0)); crate[23]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.0f,20.0)); crate[24]->getPhysicsEntity()->setPosition(hkVector4(-1,25,1.0f,20.75)); crate[25]->getPhysicsEntity()->setPosition(hkVector4(-2 ,1.0f,20.75)); crate[26]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.0f,20.75)); crate[27]->getPhysicsEntity()->setPosition(hkVector4(-1.25,1.5f,-20.75)); crate[28]->getPhysicsEntity()->setPosition(hkVector4(-20 ,1.5f,-20.75)); crate[29]->getPhysicsEntity()->setPosition(hkVector4(-2.75,1.5f,-20.75)); crate[30]->getPhysicsEntity()->setPosition(hkVector4(-1,25,1.5f,-20.0)); crate[31]->getPhysicsEntity()->setPosition(hkVector4(-2 ,1.5f,-20.0)); //RoadBarrier* barrier = new RoadBarrier(game); //barrier->init("barrier"); //barrier->getPhysicsEntity()->setPosition(hkVector4(-5.5,0.25f,0.0f)); Ogre::OverlayManager* overlayManager = Ogre::OverlayManager::getSingletonPtr(); Ogre::Overlay* overlay = overlayManager->getByName("debugText"); overlay->show(); debugTextOverlay = (Ogre::TextAreaOverlayElement*)overlayManager->getOverlayElement("debugTextArea"); debugTextOverlay->show(); updateCamera(); game->visualSystem.unlockThread(); return true; }
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(); } }
void MyApp::createOverlay() { _overlayManager = Ogre::OverlayManager::getSingletonPtr(); Ogre::Overlay *overlay = _overlayManager->getByName("Info"); overlay->show(); }
void RoR::GfxEnvmap::SetupEnvMap() { m_rtt_texture = Ogre::TextureManager::getSingleton().getByName("EnvironmentTexture"); for (int face = 0; face < NUM_FACES; face++) { m_render_targets[face] = m_rtt_texture->getBuffer(face)->getRenderTarget(); m_cameras[face] = gEnv->sceneManager->createCamera("EnvironmentCamera-" + TOSTRING(face)); m_cameras[face]->setAspectRatio(1.0); m_cameras[face]->setProjectionType(Ogre::PT_PERSPECTIVE); m_cameras[face]->setFixedYawAxis(false); m_cameras[face]->setFOVy(Ogre::Degree(90)); m_cameras[face]->setNearClipDistance(0.1f); m_cameras[face]->setFarClipDistance(gEnv->mainCamera->getFarClipDistance()); Ogre::Viewport* v = m_render_targets[face]->addViewport(m_cameras[face]); v->setOverlaysEnabled(false); v->setClearEveryFrame(true); v->setBackgroundColour(gEnv->mainCamera->getViewport()->getBackgroundColour()); m_render_targets[face]->setAutoUpdated(false); } m_cameras[0]->setDirection(+Ogre::Vector3::UNIT_X); m_cameras[1]->setDirection(-Ogre::Vector3::UNIT_X); m_cameras[2]->setDirection(+Ogre::Vector3::UNIT_Y); m_cameras[3]->setDirection(-Ogre::Vector3::UNIT_Y); m_cameras[4]->setDirection(-Ogre::Vector3::UNIT_Z); m_cameras[5]->setDirection(+Ogre::Vector3::UNIT_Z); if (App::diag_envmap.GetActive()) { // create fancy mesh for debugging the envmap Ogre::Overlay* overlay = Ogre::OverlayManager::getSingleton().create("EnvMapDebugOverlay"); if (overlay) { Ogre::Vector3 position = Ogre::Vector3::ZERO; float scale = 1.0f; Ogre::MeshPtr mesh = Ogre::MeshManager::getSingletonPtr()->createManual("cubeMapDebug", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); // create sub mesh Ogre::SubMesh* sub = mesh->createSubMesh(); // Initialize render operation sub->operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST; // sub->useSharedVertices = true; mesh->sharedVertexData = new Ogre::VertexData; sub->indexData = new Ogre::IndexData; // Create vertex declaration size_t offset = 0; mesh->sharedVertexData->vertexDeclaration->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_POSITION); offset += Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT3); mesh->sharedVertexData->vertexDeclaration->addElement(0, offset, Ogre::VET_FLOAT3, Ogre::VES_TEXTURE_COORDINATES); // Create and bind vertex buffer mesh->sharedVertexData->vertexCount = 14; Ogre::HardwareVertexBufferSharedPtr vertexBuffer = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer( mesh->sharedVertexData->vertexDeclaration->getVertexSize(0), mesh->sharedVertexData->vertexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY); mesh->sharedVertexData->vertexBufferBinding->setBinding(0, vertexBuffer); // Vertex data static const float vertexData[] = { // Position Texture coordinates // Index 0.0, 2.0, -1.0, 1.0, 1.0, // 0 0.0, 1.0, -1.0, -1.0, 1.0, // 1 1.0, 2.0, -1.0, 1.0, -1.0, // 2 1.0, 1.0, -1.0, -1.0, -1.0, // 3 2.0, 2.0, 1.0, 1.0, -1.0, // 4 2.0, 1.0, 1.0, -1.0, -1.0, // 5 3.0, 2.0, 1.0, 1.0, 1.0, // 6 3.0, 1.0, 1.0, -1.0, 1.0, // 7 4.0, 2.0, -1.0, 1.0, 1.0, // 8 4.0, 1.0, -1.0, -1.0, 1.0, // 9 1.0, 3.0, -1.0, 1.0, 1.0, // 10 2.0, 3.0, 1.0, 1.0, 1.0, // 11 1.0, 0.0, -1.0, -1.0, 1.0, // 12 2.0, 0.0, 1.0, -1.0, 1.0, // 13 }; // Fill vertex buffer float* pData = static_cast<float*>(vertexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD)); for (size_t vertex = 0, i = 0; vertex < mesh->sharedVertexData->vertexCount; vertex++) { // Position *pData++ = position.x + scale * vertexData[i++]; *pData++ = position.y + scale * vertexData[i++]; *pData++ = 0.0; // Texture coordinates *pData++ = vertexData[i++]; *pData++ = vertexData[i++]; *pData++ = vertexData[i++]; } vertexBuffer->unlock(); // Create index buffer sub->indexData->indexCount = 36; Ogre::HardwareIndexBufferSharedPtr indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer( Ogre::HardwareIndexBuffer::IT_16BIT, sub->indexData->indexCount, Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY); sub->indexData->indexBuffer = indexBuffer; // Index data static const Ogre::uint16 indexData[] = { // Indices // Face 0, 1, 2, // 0 2, 1, 3, // 1 2, 3, 4, // 2 4, 3, 5, // 3 4, 5, 6, // 4 6, 5, 7, // 5 6, 7, 8, // 6 8, 7, 9, // 7 10, 2, 11, // 8 11, 2, 4, // 9 3, 12, 5, // 10 5, 12, 13, // 11 }; // Fill index buffer indexBuffer->writeData(0, indexBuffer->getSizeInBytes(), indexData, true); mesh->_setBounds(Ogre::AxisAlignedBox::BOX_INFINITE); mesh->_setBoundingSphereRadius(10); mesh->load(); Ogre::Entity* e = gEnv->sceneManager->createEntity(mesh->getName()); e->setCastShadows(false); e->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - 1); e->setVisible(true); e->setMaterialName("tracks/EnvMapDebug"); Ogre::SceneNode* mDebugSceneNode = new Ogre::SceneNode(gEnv->sceneManager); mDebugSceneNode->attachObject(e); mDebugSceneNode->setPosition(Ogre::Vector3(0, 0, -5)); mDebugSceneNode->setFixedYawAxis(true, Ogre::Vector3::UNIT_Y); mDebugSceneNode->setVisible(true); mDebugSceneNode->_update(true, true); mDebugSceneNode->_updateBounds(); overlay->add3D(mDebugSceneNode); overlay->show(); } } }
void handleInput(Ogre::Real elapsedRealTime) { // This variable can be used to keep keys from repeating too fast. static Ogre::Real toggleTimer = 0; if (toggleTimer >= 0) { toggleTimer -= elapsedRealTime; } OIS::Keyboard* keyboard = gEngine.getKeyboard(); if (keyboard->isKeyDown(OIS::KC_W)) { gCar->forward(); } else if (keyboard->isKeyDown(OIS::KC_S)) { gCar->reverse(); } else { gCar->idle(); } if (keyboard->isKeyDown(OIS::KC_A)) { gCar->setSteering(-1); } else if (keyboard->isKeyDown(OIS::KC_D)) { gCar->setSteering(1); } else { gCar->setSteering(0); } // If available, get data from the game controller. if (gGamePad) { // Update the game controller state. SDL_JoystickUpdate(); Ogre::Real joy0X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 0) / (Ogre::Real)32768; Ogre::Real joy0Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 1) / (Ogre::Real)32768; Ogre::Real joy1X = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 4) / (Ogre::Real)32768; Ogre::Real joy1Y = (Ogre::Real)SDL_JoystickGetAxis(gGamePad, 3) / (Ogre::Real)32768; if (fabs(joy0Y) > 0.1) { gCar->setThrottle(-joy0Y); } else { gCar->idle(); } if (fabs(joy0X) > 0.1) { gCar->setSteering(joy0X); } else { gCar->setSteering(0); } if (joy1X > 0.2 || joy1X < -0.2) { Ogre::Degree rotAroundY = -Ogre::Degree(joy1X); gEngine.getCamera()->yawRelative(rotAroundY.valueDegrees()); } if (joy1Y > 0.2 || joy1Y < -0.2) { Ogre::Degree rotAroundX = -Ogre::Degree(joy1Y); gEngine.getCamera()->pitchRelative(rotAroundX.valueDegrees()); } } // Toggle GUI. if (keyboard->isKeyDown(OIS::KC_G) && toggleTimer <= 0) { Ogre::Overlay* debugOverlay = Ogre::OverlayManager::getSingleton(). getByName("Verve/Debug"); if (debugOverlay->isVisible()) { debugOverlay->hide(); gAgentDebugger->setDisplayEnabled(false); } else { debugOverlay->show(); gAgentDebugger->setDisplayEnabled(true); } toggleTimer = 0.5; } }
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
void PlaypenApp::createScene() { // Setup shadows. if (mUseShadows) { mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE); } else { mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE); } //mSceneMgr->showBoundingBoxes(true); //mSimulator->setStepSize(0.02); mSimulator->setGravity(opal::Vec3r(0, -30, 0)); // Set the ambient light level. mSceneMgr->setAmbientLight(ColourValue(0.3, 0.3, 0.3)); // Create a light source. Ogre::Light* light = mSceneMgr->createLight("light0"); light->setType(Ogre::Light::LT_POINT); light->setDiffuseColour(0.5, 0.5, 0.5); light->setSpecularColour(0.5, 0.5, 0.5); light->setPosition(100.0, 300.0, 100.0); // Create another light source. light = mSceneMgr->createLight("light1"); light->setType(Ogre::Light::LT_POINT); light->setDiffuseColour(0.5, 0.5, 0.5); light->setSpecularColour(0.5, 0.5, 0.5); light->setPosition(-100.0, 300.0, 100.0); light->setVisible(false); // Setup the initial camera position. mPhysicalCamera->setPosition(opal::Point3r(0, 20, 30)); mPhysicalCamera->lookAt(opal::Point3r(0, 0, 0)); // Create a skybox. mSceneMgr->setSkyBox(true, "Skyboxes/Gray", 5000); // Make a sphere used to show the grasp position. Ogre::SceneNode* sphereNode = mSceneMgr->getRootSceneNode()-> createChildSceneNode("pickingSphere0"); sphereNode->scale(0.3, 0.3, 0.3); Entity* sphereEntity = mSceneMgr->createEntity("pickingSphere", "sphere.mesh"); sphereEntity->setMaterialName("Unlit/Yellow"); sphereEntity->setCastShadows(false); sphereEntity->setVisible(false); sphereNode->attachObject(sphereEntity); // Make a "line" (scaled cylinder) to show the grasping spring. Ogre::SceneNode* lineNode = mSceneMgr->getRootSceneNode()-> createChildSceneNode("springLine"); Entity* lineEntity = mSceneMgr->createEntity("springLine", "cylinder.mesh"); lineEntity->setMaterialName("Unlit/White"); lineEntity->setCastShadows(false); lineEntity->setVisible(false); lineNode->attachObject(lineEntity); // Make a crosshairs for picking. Ogre::Overlay* overlay = OverlayManager::getSingleton().getByName("General/Crosshair"); overlay->show(); // Load models, create physical objects, etc. here. setupInitialPhysicalEntities(); }
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; }