creating a 3D user interface.
Posted: Thu Oct 06, 2011 22:32
I was trying to render CEGUI to an Ogre render target in order to create a gui like monitor like in games like Quake 4, Prey and Deus Ex HR. This is how i tried to do it and i think it's pretty much how one would do it except since I needed a pointer to the render target to create the desired effect, i re-initionalized CEGUI with the pointer of the target (the original didn't use a target in the constructor as i was using the default window created by Ogre3D. anyways, i go to run it and i get a message the CEGUI is already initialized.
Ok, i can understand that but this way was the best way i could think of setting it up:
so, yea, hopefully someone knows how to get this to work.
Ok, i can understand that but this way was the best way i could think of setting it up:
Code: Select all
void GameState::create3DUI()
{
Ogre::Entity* screen = m_pSceneMgr->getEntity("Monitor");
// create a texture render target.
Ogre::TexturePtr UI = Ogre::TextureManager::getSingletonPtr()->createManual("user interface",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,Ogre::TEX_TYPE_2D,512,512,32,1,PF_FLOAT16_RGBA,TU_RENDERTARGET);
// Declare a renderable texture and get the pointer to the render target.
Ogre::RenderTexture* rUI = UI->getBuffer()->getRenderTarget();
Ogre::Camera* uiCam = m_pSceneMgr->createCamera("UI");
Ogre::Viewport* uiView = rUI->addViewport(uiCam);
uiView->setClearEveryFrame(true);
uiView->setOverlaysEnabled(false);
uiView->update();
// create a material to add to the entity.
Ogre::MaterialPtr uiMaterial = Ogre::MaterialManager::getSingletonPtr()->create("uiMaterial",Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
// get the default tech/pass.
Ogre::Technique* uiTech = uiMaterial->getTechnique(0);
Ogre::Pass* uiPass = uiTech->getPass(0);
uiPass->createTextureUnitState(UI->getName());
CEGUI::OgreRenderer* pUIRenderer = new CEGUI::OgreRenderer(CEGUI::OgreRenderer::bootstrapSystem(*uiView->getTarget()));
CEGUI::Imageset::setDefaultResourceGroup("Imagesets");
CEGUI::Font::setDefaultResourceGroup("Fonts");
CEGUI::Scheme::setDefaultResourceGroup("Schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("LookNFeel");
CEGUI::WindowManager::setDefaultResourceGroup("Layouts");
CEGUI::SchemeManager::getSingletonPtr()->create("TaharezLook.Scheme");
CEGUI::System::getSingletonPtr()->setDefaultMouseCursor("TaharezLook","MouseArrow");
// create a default window.
CEGUI::Window* DefaultWin = CEGUI::WindowManager::getSingletonPtr()->createWindow("Default","UI Window/");
// create a simple frame window.
CEGUI::FrameWindow* simFrame = reinterpret_cast<CEGUI::FrameWindow*>(CEGUI::WindowManager::getSingletonPtr()->createWindow("TaharezLook/FrameWindow","Frame"));
simFrame->setSize(CEGUI::UVector2
(CEGUI::UDim(0.15,0),CEGUI::UDim(0.20,0)));
DefaultWin->addChildWindow(simFrame);
OgreFramework::getSingletonPtr()->m_pSystem->setGUISheet(DefaultWin);
screen->setMaterial(uiMaterial);
}
so, yea, hopefully someone knows how to get this to work.