Page 1 of 1

creating a 3D user interface.

Posted: Thu Oct 06, 2011 22:32
by eggman3344
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:

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);

   // 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);


   CEGUI::OgreRenderer* pUIRenderer = new CEGUI::OgreRenderer(CEGUI::OgreRenderer::bootstrapSystem(*uiView->getTarget()));



   // 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"));




so, yea, hopefully someone knows how to get this to work.

Re: creating a 3D user interface.

Posted: Sun Oct 09, 2011 15:22
by Mikademus
Sometimes it can take a little time before anyone answers questions. Have you had any luck with this? Have you gotten an interface on a texture working yet?

Re: creating a 3D user interface.

Posted: Mon Oct 10, 2011 19:20
by eggman3344
no because the only way was to re-create the Ogre renderer with the texture in the constructor. and im alrteayy using it for the UI on the screen. but i wanted to add a UI like in DOOM3 or something else.

Re: creating a 3D user interface.

Posted: Tue Oct 11, 2011 05:23
by MarkR
I didn't play with the OgreRenderer before, but I think that the line

Code: Select all

CEGUI::OgreRenderer* pUIRenderer = new CEGUI::OgreRenderer(CEGUI::OgreRenderer::bootstrapSystem(*uiView->getTarget()));

should be replaced with

Code: Select all

CEGUI::OgreRenderer* pUIRenderer = &CEGUI::OgreRenderer::bootstrapSystem(*uiView->getTarget());

There should be no need to copyconstruct the renderer. I wonder why this is allowed anyway.

Re: creating a 3D user interface.

Posted: Tue Oct 11, 2011 14:51
by eggman3344
nope says can't access protected member like that. damn it

Re: creating a 3D user interface.

Posted: Tue Oct 11, 2011 16:04
by eggman3344
Ok, i just tried this:

Code: Select all


and thought that would actually work....but it didn't there HAS to be a way to get it to work........i'll work on it. It's not that important right now i just wanted to see if i could do it

Re: creating a 3D user interface.

Posted: Wed Oct 12, 2011 06:36
by MarkR
eggman3344 wrote:nope says can't access protected member like that. damn it

I'm confused. Which function is protected?
If the line
CEGUI::OgreRenderer* pUIRenderer = new CEGUI::OgreRenderer(CEGUI::OgreRenderer::bootstrapSystem(*uiView->getTarget()));

compiles, the same line without the copy constructor should compile, too.

In any way, the call to 'bootstrapSystem' creates a renderer, so you shouldn't allocate a second one.