History: Ogre iPhone FAQ
Preview of version: 5
Issues and Troubleshooting
- Viewport::SetOrientation must be called after a frame is rendered to take effect. For example to change to Viewport::OR_PORTRAIT:
Copy to clipboard
mRoot->renderOneFrame(); mCamera->getViewport()->setOrientation(Viewport::OR_PORTRAIT);
- Current state of Viewport::OR_LANDSCAPELEFT (default value) has known issues related with camera frustum, that deliver early entity clipping and problems with getCameraToViewportRay. Change to OR_PORTRAIT while this problem is resolved.
Until the issue is fixed here is a workaround. As a side effect of this, the x and y values of input will be swapped. Your code will need to take this into account.
Copy to clipboard
Ogre::Camera *camera = mCameraMan->getCamera(); if (camera) { int width = camera->getViewport()->getActualWidth(); int height = camera->getViewport()->getActualHeight(); camera->setProjectionType(Ogre::PT_ORTHOGRAPHIC); camera->setAspectRatio(Ogre::Real(width) / Ogre::Real(height)); // Use PORTRAIT and rotate the projection matrix camera->getViewport()->setOrientation(Viewport::OR_PORTRAIT); camera->setOrthoWindowWidth(block_dim*(num_blocks_y+1)); Matrix4 proj = camera->getProjectionMatrix(); proj = proj * Quaternion(Degree(-90), Vector3::UNIT_Z); camera->setCustomProjectionMatrix(true, proj); }