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 COverlay::createChildPanel(const std::string& name, float left, float top, float width, float height, const std::string& material) { assert( !_overlayManager->hasOverlayElement(name) && "Ya existe un elemento hijo con el mismo nombre" ); Ogre::OverlayElement* newChild = createChildElement(TChildType::PANEL, name, left, top, width, height); if(material.length() > 0) newChild->setMaterialName(material); _overlay->add2D( static_cast<Ogre::OverlayContainer*>(newChild) ); } //createChildPanel
void ResourceGroupReloader::UpdateMaterialRenderableVisitor::visit( Ogre::Renderable *rend, Ogre::ushort lodIndex, bool isDebug, Ogre::Any *pAny) { const Ogre::MaterialPtr mat = rend->getMaterial(); if(!mat.isNull()) { std::string newMatName = mat->getName(); Ogre::MaterialPtr newMat = Ogre::MaterialManager::getSingleton().getByName(newMatName); if(newMat.isNull()) { // this can happen if there was error during the reloading of the material. // in that case, we keep the ancient one. // Ice::Log::Instance().LogMessage(newMatName+" : new material is null!"); return; } // unfortunately, the renderable gives access only to a const MaterialPtr. // and there is no 'setMaterial' or 'setMaterialName' method on renderables. // so I have to try to down cast with known classes... { Ogre::SubEntity* lRend = dynamic_cast<Ogre::SubEntity*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } { Ogre::SimpleRenderable* lRend = dynamic_cast<Ogre::SimpleRenderable*>(rend); if(lRend){lRend->setMaterial(newMatName);return;} } { Ogre::ShadowRenderable* lRend = dynamic_cast<Ogre::ShadowRenderable*>(rend); if(lRend){lRend->setMaterial(newMat);return;} } { Ogre::BillboardChain* lRend = dynamic_cast<Ogre::BillboardChain*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } { Ogre::BillboardSet* lRend = dynamic_cast<Ogre::BillboardSet*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } { Ogre::OverlayElement* lRend = dynamic_cast<Ogre::OverlayElement*>(rend); if(lRend){lRend->setMaterialName(newMatName);return;} } }else{ // was there for debug... // Ice::Log::Instance().LogMessage("material of renderable is null!"); } }
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(); }