creating a 3D user interface.

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

eggman3344
Just popping in
Just popping in
Posts: 10
Joined: Mon Aug 01, 2011 17:43

creating a 3D user interface.

Postby eggman3344 » 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:

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.

User avatar
Mikademus
CEGUI MVP
CEGUI MVP
Posts: 130
Joined: Wed Mar 18, 2009 19:14

Re: creating a 3D user interface.

Postby Mikademus » Sun Oct 09, 2011 15:22

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?

eggman3344
Just popping in
Just popping in
Posts: 10
Joined: Mon Aug 01, 2011 17:43

Re: creating a 3D user interface.

Postby eggman3344 » Mon Oct 10, 2011 19:20

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.

MarkR
Quite a regular
Quite a regular
Posts: 64
Joined: Thu Jul 15, 2010 06:55

Re: creating a 3D user interface.

Postby MarkR » Tue Oct 11, 2011 05:23

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.

eggman3344
Just popping in
Just popping in
Posts: 10
Joined: Mon Aug 01, 2011 17:43

Re: creating a 3D user interface.

Postby eggman3344 » Tue Oct 11, 2011 14:51

nope says can't access protected member like that. damn it

eggman3344
Just popping in
Just popping in
Posts: 10
Joined: Mon Aug 01, 2011 17:43

Re: creating a 3D user interface.

Postby eggman3344 » Tue Oct 11, 2011 16:04

Ok, i just tried this:

Code: Select all


   pUIRenderer->create(*uiView->getTarget());



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

MarkR
Quite a regular
Quite a regular
Posts: 64
Joined: Thu Jul 15, 2010 06:55

Re: creating a 3D user interface.

Postby MarkR » Wed Oct 12, 2011 06:36

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests