OGRE+CEGUI (Must I use the same sceneMgr for GUI and GAME )

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

angela4et
Just popping in
Just popping in
Posts: 7
Joined: Mon Jul 03, 2006 06:36
Contact:

OGRE+CEGUI (Must I use the same sceneMgr for GUI and GAME )

Postby angela4et » Wed Nov 29, 2006 00:47

when i Initialize CEGUI for my game in game.cpp I created myGUIsceneMgr,

Code: Select all

   mUISceneMgr = mRoot->createSceneManager(Ogre::ST_GENERIC,"mUISceneMgr");



then in my testState class , i have another sceneMgr for it

Code: Select all

mSceneMgr = mRoot->createSceneManager (Ogre::ST_GENERIC, "TestSceneMgr");


and in TestState i show the ogre head

Code: Select all

   mSceneMgr->setAmbientLight (Ogre::ColourValue (0.7, 0.7, 0.7));

   // Create camera
   mCamera = mUISceneMgr->createCamera ("TestCam");
   // Position camera
   mCamera->setPosition (Ogre::Vector3 (0, 0, 500));
   mCamera->lookAt (Ogre::Vector3 (0, 0, -300));
   mCamera->setNearClipDistance (1);
   mCamera->setFarClipDistance (1000);
   mCamera->setAutoAspectRatio (true);


   // Set viewport
   mViewport = mWindow->addViewport (mCamera,1);
   mViewport->setBackgroundColour (Ogre::ColourValue (0.3f, 0.3f, 0.3f, 1.0f)); // Grey

   ogreHeadEnt = mSceneMgr->createEntity ("ogreHeadEnt", "ogrehead.mesh");
   ogreHeadNode = mSceneMgr->getRootSceneNode ()->createChildSceneNode ("ogreHeadNode");
   ogreHeadNode->attachObject (ogreHeadEnt);



when i create a framewindow get the myGUIsceneMgr from the initialization and then did the destroyAllCameras to show the gui ( get this from Practical Application - GUI don't know whether i got it correctly or not T_T )

Code: Select all

   mWindow = Game::getInstance()->getWindow();

   mUISceneMgr =  Game::getInstance()->getUI()->GetUISceneMgr();
   mGUISy= Game::getInstance()->getUI()->GetUISy();

   if (mWindow)
      mWindow->removeAllViewports();

   if (mUISceneMgr)
      mUISceneMgr->destroyAllCameras();

   mUICamera = mUISceneMgr->createCamera("UI");
   mUICamera->setPosition (Ogre::Vector3 (0, 0, 300));
   mUICamera->lookAt (Ogre::Vector3 (0, 0, 0));
   mUICamera->setAutoAspectRatio(true);
   mUIViewport = mWindow->addViewport(mUICamera,6);


   float width, height;
   width = height = 200;
   // Create a GUI Frame window
   CEGUI::WindowManager &winMgr = CEGUI::WindowManager::getSingleton(); // Get the CEGUI Managers
   CEGUI::FrameWindow* FWWin = (CEGUI::FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "MainFrameWindow");
   FWWin->setText("Test");
   FWWin->setWindowArea(CEGUI::URect(CEGUI::UVector2(CEGUI::UDim(0.0f,100), CEGUI::UDim(0.0f,100))
      , CEGUI::UVector2(CEGUI::UDim(0.0f, width), CEGUI::UDim(0.0f, height))));

   // Add GUI Frame window to the screens default sheet
   Game::getInstance()->getUI()->GetUISy()->getGUISheet()->addChildWindow(FWWin);




when i compile, the ogre scene is blocked by the GUI, so I guess it's the z buffer problem , so i changed the

Code: Select all

 mViewport = mWindow->addViewport (mCamera,1);


into

Code: Select all

 mViewport = mWindow->addViewport (mCamera,10);


now the ogre head appears but the cegui is gone...

How to solve this? Must i use the same scene manager for game scene and gui ?

Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 10 guests