I have added compositor effects to our game. The thing is (was) that we changed camera frequently. Re-enabling the compositors for every camera change was unacceptable; the game froze for 0.5 a second (at least on my machine).
So the solution was to ALWAYS have a single camera for the viewport, and copy all properties of wannabe-cameras to this default one.
This default camera wasn't even attached to a SceneNode, thus using world-coords. So this code worked for non-tracking wannabe-cameras:
Code: Select all
viewCam->setOrientation( sourceCam->getRealOrientation() );
viewCam->setDirection( sourceCam->getRealDirection() );
viewCam->setPosition( sourceCam->getRealPosition() );
viewCam->setFOVy( sourceCam->getFOVy() );
viewCam->setNearClipDistance( sourceCam->getNearClipDistance() );
viewCam->setFarClipDistance( sourceCam->getFarClipDistance() );
So, the ugly solution was to add this code below the above one:
Code: Select all
Ogre::SceneNode* autoTrackNode = sourceCam->getAutoTrackTarget();
if (autoTrackNode) {
Ogre::Vector3 lookAtPos = OgreAddOns::getDerivedPosition(autoTrackNode);
viewCam->lookAt( lookAtPos );
}