Ogre + CEGUI + StaticImage

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

MajinSephiroth
Just popping in
Just popping in
Posts: 4
Joined: Wed Jan 10, 2007 00:50

Ogre + CEGUI + StaticImage

Postby MajinSephiroth » Thu Jan 18, 2007 00:00

I'm running into a small issue here, I am using a static image as a background in som game states, but whenever I try to display an entity it hides behind the static image.

I'm sure this is something stupid that I have overlooked, but as it stands no solution comes to mind.

This is what I use to create images:

Code: Select all

void GUIManager::createImage(char* winName, char* imageFile, float x, float y, float w, float h) {
   if(imageFile) {
      StaticImage* newWindow = (StaticImage*)mWmgr->createWindow("TaharezLook/StaticImage", winName);
      loadTextureImageSet(imageFile, imageFile);
      applyTexture(winName, imageFile);
      mRoot->addChildWindow(newWindow);
      //turn off the taharezlook frame
      newWindow->setFrameEnabled(false);
      //use pixels rather than fractions
      newWindow->setMetricsMode((CEGUI::MetricsMode)0);
      //set the image position to x, y, in pixels
      newWindow->setPosition(Point(x,y));
      //check if width and/or height is 0.  if so, use the image width
      float width, height;
      if(w==0)
         width = ImagesetManager::getSingleton().getImageset(imageFile)->getImageWidth(imageFile) / mGUIRenderer->getWidth();
      else
         width = w;
      if(h==0)
         height = ImagesetManager::getSingleton().getImageset(imageFile)->getImageHeight(imageFile) / mGUIRenderer->getHeight();
      else
         height = h;
      newWindow->setSize(Size(width,height));
      newWindow->setRiseOnClickEnabled(false);
      newWindow->setBackgroundEnabled(false);
   } else {
      Window* newWindow = mWmgr->createWindow("DefaultWindow", winName);
      mRoot->addChildWindow(newWindow);
      newWindow->setMetricsMode((CEGUI::MetricsMode)0);
      newWindow->setPosition(Point(x,y));
      newWindow->setSize(Size(w,h));
   }
}

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

Postby spannerman » Thu Jan 18, 2007 10:23

I cant see in this function where you are pushing the StaticImage to the background of your scene...what are you doing to attempt this?

MajinSephiroth
Just popping in
Just popping in
Posts: 4
Joined: Wed Jan 10, 2007 00:50

Postby MajinSephiroth » Thu Jan 18, 2007 19:43

At first I thought

Code: Select all

newWindow->setBackgroundEnabled(true);
would take care of it, but I was wrong.

I also tried

Code: Select all

newWindow->setAlwaysOnTop(false);
thinking that it was auto-setting it to on-top, but to no avail.

Another thing I tried was

Code: Select all

newWindow->setBackgroundImage(CEGUI::ImagesetManager::getSingleton().getImageset(imageFile)->getName(),CEGUI::ImagesetManager::getSingleton().getImageset(imageFile)->getImage(imageFile).getName());
and that did a whole lot of nothing...

Any thoughts?

LennyH
Quite a regular
Quite a regular
Posts: 92
Joined: Thu Nov 30, 2006 20:50

Postby LennyH » Thu Jan 18, 2007 20:11

What do you mean by entities?

As far as I know - and I could be completely wrong here, so just take what I say as a thought - CEGUI is simply drawn on top of your game scene. This makes intuitive sense, because the GUI is ( or should be ) the top most thing of any game. So when you have a background image that covers your whole view, you are essentially blocking out that view.

What you can try to see if this is the case or not is pretty simple: set the alpha of your background image StaticImage window to be translucent or transparent. If you then can see your entities ( assuming you mean something about your game scene ) then I would assume that CEGUI is being drawn as the top most layer of everything rendered.

Where you go from this point, I am currently not sure...

MajinSephiroth
Just popping in
Just popping in
Posts: 4
Joined: Wed Jan 10, 2007 00:50

Postby MajinSephiroth » Thu Jan 18, 2007 20:34

Hm I see what you mean. That is indeed the case, alpha does seem to provide a temporary fix to this. Maybe I should just "cheat" and create a viewport on top of it to look at the entity.

What I meant by Entity, was an Ogre::Entity. Basically I have a spindle that was created in 3DS and I was hoping to have it for the menu system (by spindle I mean a box with the game options textured on each of it's sides).

Now I know I am complicating myself because it would be alot easier to use textboxes or animated text for the options, but I wanted something different.

Any other thoughts other than setting the alpha?

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Postby martignasse » Thu Jan 18, 2007 20:51

hi,

if i anderstand correctly, another way to achieve what you want could be to use a render to texture of you'r ogre object and use it as a static image in CEGUI.

i believe there is some exemples in the ogre wiki.

hope it help

MajinSephiroth
Just popping in
Just popping in
Posts: 4
Joined: Wed Jan 10, 2007 00:50

Postby MajinSephiroth » Thu Jan 18, 2007 21:56

I haven't done a render-to-texture before for a mesh, so I'm not exactly sure how well that would work.

I'm guessing that the only options you have in my situation is either render-to-texture and setting the alpha?


Return to “Help”

Who is online

Users browsing this forum: Bing [Bot] and 19 guests