iPhone - Problem with autorotation to interface orientation

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
User avatar
BloodAxe
Gnoblar
Posts: 4
Joined: Thu May 13, 2010 7:19 pm
Location: Odessa, Ukraine

iPhone - Problem with autorotation to interface orientation

Post by BloodAxe »

Hi! I'm moderate experienced with Ogre, but can't manage following issue: Ogre viewport's dimensions are not correctly updated after the device orientation has changed. I'm using iOS UI orientation instead of rotating camera itself because there will be transparent UIView control with some UI-controls.

Screenshots:
1) Initial portrait orientation is correc. Portrait upside down is also correct:
Portrait orientation.png
2) Rotate to landscape right:
Landscape right.png
3) Landscape left also wrong:
Landscape left.png
So, my suggestion that viewport dimensions is incorrect.
OrientationChanged event delegate does the following code:

Code: Select all

-(void) receivedRotateEvent: (NSNotification*) notification
{
   UIDeviceOrientation interfaceOrientation = [[UIDevice currentDevice] orientation];
   if (interfaceOrientation != UIDeviceOrientationUnknown)
   {
      // mNSRenderingWindow is UIWindow* which represents Ogre rendering window.
      // marshalUIOrientationToOgreOrientation translate UIDeviceOrientation enum to Ogre::OrientationMode enum.
      mVisualizationContext.updateViewport
      (
         mUIRenderingWindow.bounds, 
         marshalUIOrientationToOgreOrientation(interfaceOrientation)
      );
   }
}
And in the updateViewport method i try to do:

Code: Select all

void OgreVisualizationContext::updateViewport(int windowWidth, int windowHeight, Ogre::OrientationMode orientation)
{
   mRenderWindow->resize(windowWidth, windowHeight);
}
also i've tried:

Code: Select all

void OgreVisualizationContext::updateViewport(int windowWidth, int windowHeight, Ogre::OrientationMode orientation)
{
   mRenderWindow->getViewport(0)->setOrientationMode(orientation, false);
}
and:

Code: Select all

void OgreVisualizationContext::updateViewport(int windowWidth, int windowHeight, Ogre::OrientationMode orientation)
{
   mRenderWindow->windowMovedOrResized();
}
Neither of these snippets works correct. I've googled on this forum and wiki for similar problem but didn't found the solution.
Can you point me to correct viewport dimensions update snippet code?

PS: Working with Ogre 1.8.0 from SVN (r2457), iPhone 3GS iOS 4.1.
You do not have the required permissions to view the files attached to this post.
I use Ogre for Augmented Reality - Computer Vision Talks
User avatar
masterfalcon
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 4270
Joined: Sun Feb 25, 2007 4:56 am
Location: Bloomington, MN
x 126

Re: iPhone - Problem with autorotation to interface orientat

Post by masterfalcon »

Try it without resizing the render window. The viewport orientation is done by applying a rotation to the camera and updating the viewport dimensions. But the window is always the same size.
User avatar
BloodAxe
Gnoblar
Posts: 4
Joined: Thu May 13, 2010 7:19 pm
Location: Odessa, Ukraine

Re: iPhone - Problem with autorotation to interface orientat

Post by BloodAxe »

Hello. Thanks for the fast reply. Unfortunately, your suggestion has no effect.
So, i do not resize render window, but rotate viewport using setOrientationMode method of the Ogre::Viewport class:
Screenshot - With orientation.png
As you can see on screenshot - the render window has white area, and the orientation of the rendered elements is wrong (this is because actually two rotations is applied - rotations of the screen itself (UIKit) and render viewport rotation (Ogre)).

And another intersesting thing - no viewport orientation at all! Just interface orientation according to the device orientation:
Screenshot - without orientation.png
At this screenshot we see the same problem - render area is cropped, but the orientation of the 3d model is correct.

So, my opinion that it's the problem of the resizing EAGLVIew (i've found very similar problem with the cocos2d library).

My temporary solution - disable automatic interface orientation, catch device rotation events and rotate ogre viewport manually. This works well, but in this case we lose those nice eye-catching rotation animation and we have to do some manual rotation of the overlay UIKit views.
You do not have the required permissions to view the files attached to this post.
I use Ogre for Augmented Reality - Computer Vision Talks
mono2k
Gnoblar
Posts: 19
Joined: Mon Mar 15, 2010 8:02 am

Re: iPhone - Problem with autorotation to interface orientat

Post by mono2k »

AFAIK, viewport orientation on iphone is horribly broken at all. It works well only once, at startup.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Re: iPhone - Problem with autorotation to interface orientat

Post by Brocan »

Uhms, i'm having the same problem described in the first post. Any one knowns how to deal with it?

Edit: Ok, i left the window resize, solved :lol: