UIWindow UIViewcontroller UIView and ogre - a guide

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
dowi
Halfling
Posts: 48
Joined: Wed Sep 07, 2011 3:37 am

UIWindow UIViewcontroller UIView and ogre - a guide

Post by dowi »

hi all

after hours of searching and trying i've managed to control the location of ogre in the hierarchy of my application and thought i'll share my experience (and thanks to masterflacon).

the steps are:

1. start a new project so that everything is attached in the MainWindow
2. add OgreDemoApp and OgreFramework fro the template
3. add a pointer to a new variable of type OgreDemoApp
4. instantiate your pointer wherever you want using 'mOgre = new DemoApp();'
4. copy the function "go" from the template
5. call go function to when you want to start rendering
6. dont forget to take the - (void)renderOneFrame:(id)sender and the rest of the 'application' functions you want from the AppDelegate class

if you want another viewcontroller on top of ogre: (for example for touch interface)
1. add a UIViewController
2. add the folowing

Code: Select all

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];  // of type uiwindow
    
mTouchViewController = [[TouchViewController alloc] initWithNibName:@"TouchViewController" bundle:nil delegate:self];
window.rootViewController = mTouchViewController; //if you want uiview it'l be [window addSubview:yourView];
to control the hierarchy of the windows:
1. get Ogre uiwindow via: (in OgreFramework::initOgre)

Code: Select all

..
m_pRenderWnd = m_pRoot->initialise(true, wndTitle);
..

RenderWindow *mWindow = Ogre::Root::getSingleton().getAutoCreatedWindow();
mWindow->getCustomAttribute("WINDOW", &mUIWindow);  //mUIWindow is of type UIWindow
now that you have (in this case 3) UIWindows you can control their levels :

Code: Select all

//window is a UIWindow
window.windowLevel = 3.0 ; // a float

to make Ogre's background transparent all i did was: (in OgreFramework::initOgre)

Code: Select all

UIView *view;
mWindow->getCustomAttribute("VIEW", &view);
view.layer.opaque = NO;
....
m_pViewport->setBackgroundColour(ColourValue(0.0f, 0.0f, 0.0f, 0.0f));
hope it'll help someone.

dowi