CEGUI buttons on 2nd Ogre scene too?
Posted: Fri Sep 02, 2011 18:28
Hi All,
Ok, I've been staring and hacking for two weeks now, to no avail [CEGUI 0.7.4 Ogre 1.7.2]
(EDIT: Cross posted to the Ogre forums!)
Short: My goal is to have some CEGUI buttons/window rendered on top of a Viewport in a second Ogre Scene (which in turn is rendered to a texture).
Long:
To do this incrementally, to make sure everything is working, I've started by creating a second SceneManager with a viewport and camera, which I Render-to-texture. This texture, I subsequently show by setting the texture name of a TextureUnitState of an already existing material, to my "RTTName"-string. To make sure I'm seeing the right things, I set up a SkyDome (animated texture) and made the camera rotate in the XZ-plane. All this works. I also get the standard Ogre App Overlay on that second Scene/Viewport (which surprised me a bit). You know, FPS stat box and large OGRE text. So I see a "window into a different world with a moving sky and a rotating camera, and an Ogre Overlay...".
Finally I wanted to see a CEGUI FrameWindow on top of that scene. Nope. That didn't work. Here's the code. Note, I am already showing CEGUI windows and buttons in my SceneManager1/Viewport1.
and once a frame I move the camera. At set up, I do a where sImageName is "R2TTex".
What about
or
?
setTargetSceneManager doesn't exist anymore I think. I have no interesting errors or exceptions in log files etc, so my CEGUI windows and objects exist.
I think I have managed to miss some sort of CEGUI->Ogre connection. Any ideas?
Thanks!!! /Linus
Ok, I've been staring and hacking for two weeks now, to no avail [CEGUI 0.7.4 Ogre 1.7.2]
(EDIT: Cross posted to the Ogre forums!)
Short: My goal is to have some CEGUI buttons/window rendered on top of a Viewport in a second Ogre Scene (which in turn is rendered to a texture).
Long:
To do this incrementally, to make sure everything is working, I've started by creating a second SceneManager with a viewport and camera, which I Render-to-texture. This texture, I subsequently show by setting the texture name of a TextureUnitState of an already existing material, to my "RTTName"-string. To make sure I'm seeing the right things, I set up a SkyDome (animated texture) and made the camera rotate in the XZ-plane. All this works. I also get the standard Ogre App Overlay on that second Scene/Viewport (which surprised me a bit). You know, FPS stat box and large OGRE text. So I see a "window into a different world with a moving sky and a rotating camera, and an Ogre Overlay...".
Finally I wanted to see a CEGUI FrameWindow on top of that scene. Nope. That didn't work. Here's the code. Note, I am already showing CEGUI windows and buttons in my SceneManager1/Viewport1.
Code: Select all
void CMMNode::setupOverlayRTT()
{
USES_CONVERSION;
CEGUI::WindowManager& wmgr = CEGUI::WindowManager::getSingleton();
CEGUI::Window *myRTTRoot = wmgr.createWindow("DefaultWindow", "rtt_root");
CEGUI::String sLocalName = STRING_CUBE_TO_CEGUI(m_sOverlayName);
CEGUI::Window *pRealRoot = CEGUI::System::getSingleton().setGUISheet(myRTTRoot);
m_OverlaySceneMgr = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "RTTSceneMgr");
{
bool bEnable = true;
float fCurvature = 8.0f;
float fTiling = 0.3f;
float fDistance = 100.0f;
m_OverlaySceneMgr->setSkyDome(bEnable, "Environment/SunilSky", fCurvature, fTiling, fDistance,
true,
Ogre::Quaternion::IDENTITY,
24, 24);
}
m_pMyOverlay = static_cast<CEGUI::FrameWindow*>(wmgr.getWindow(sLocalName)); // for example "Overlay_Album"
m_pMyOverlay->setProperty("AutoRenderingSurface", "True");
m_pMyOverlay->show();
m_pMyOverlay->isVisible();
m_pMyOverlay->isActive();
myRTTRoot->addChildWindow(m_pMyOverlay);
myRTTRoot->setProperty("AutoRenderingSurface", "True");
myRTTRoot->show();
myRTTRoot->isVisible();
myRTTRoot->isActive();
m_OverlayCam = m_OverlaySceneMgr->createCamera("OverlayRTTCam");
m_OverlayCam->setPosition(0, 0, 100);
m_OverlayCam->lookAt(0, 0, 0);
m_OverlayCam->setNearClipDistance(1.5f);
m_OverlayCam->setFarClipDistance(3000.0f);
m_OverlayCam->setAspectRatio(1.0f);
const Ogre::String rttTexName = "R2TTex";
const CEGUI::String rttImgName = "R2TImage";
Ogre::TexturePtr cTex = Ogre::TextureManager::getSingleton().createManual(rttTexName,
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
Ogre::TEX_TYPE_2D, 512, 512, 0,
Ogre::PF_R8G8B8,
Ogre::TU_RENDERTARGET);
Ogre::RenderTexture *RTTRenderTarget = cTex->getBuffer()->getRenderTarget();
RTTRenderTarget->addListener(this);
CEGUI::OgreRenderer& myRenderer = CEGUI::OgreRenderer::create(static_cast<Ogre::RenderTarget&>(*RTTRenderTarget));
Ogre::Viewport *m_overlayViewport = RTTRenderTarget->addViewport(m_OverlayCam, 110);
m_overlayViewport->setOverlaysEnabled(true);
m_overlayViewport->setClearEveryFrame(false);
m_overlayViewport->setBackgroundColour(Ogre::ColourValue::Red);
/* Not sure if I need this...
CEGUI::Texture& aRttTexture = myRenderer.createTexture(cTex);
CEGUI::Imageset& imageSet = CEGUI::ImagesetManager::getSingleton().create((CEGUI::utf8*)"R2TImageset", aRttTexture);
imageSet.defineImage(rttImgName,
CEGUI::Point(0.0f, 0.0f),
CEGUI::Size(aRttTexture.getSize()),
CEGUI::Point(0.0f,0.0f));
Ogre::CompositorManager::getSingleton().addCompositor( m_overlayViewport, "Ogre/Scene" ) ; // was Comp/GuiAlpha
Ogre::CompositorManager::getSingleton().setCompositorEnabled( m_overlayViewport, "Ogre/Scene", true ) ; // was Comp/GuiAlpha
*/
CEGUI::System::getSingleton().setGUISheet(pRealRoot);
}
and once a frame I move the camera. At set up, I do a
Code: Select all
pTUS->setTextureName(sImageName);
What about
Code: Select all
// myRenderer->setDefaultRootRenderTarget(*RTTRenderTarget);
Code: Select all
// myRenderer->setTargetSceneManager(mySceneManager);
setTargetSceneManager doesn't exist anymore I think. I have no interesting errors or exceptions in log files etc, so my CEGUI windows and objects exist.
I think I have managed to miss some sort of CEGUI->Ogre connection. Any ideas?
Thanks!!! /Linus