Page 1 of 1

Ogre + CEGUI + StaticImage

Posted: Thu Jan 18, 2007 00:00
by MajinSephiroth
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));
   }
}

Posted: Thu Jan 18, 2007 10:23
by spannerman
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?

Posted: Thu Jan 18, 2007 19:43
by MajinSephiroth
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?

Posted: Thu Jan 18, 2007 20:11
by LennyH
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...

Posted: Thu Jan 18, 2007 20:34
by MajinSephiroth
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?

Posted: Thu Jan 18, 2007 20:51
by martignasse
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

Posted: Thu Jan 18, 2007 21:56
by MajinSephiroth
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?