[Bug] Copying camera properties to another one

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
fantasian
Halfling
Posts: 81
Joined: Fri May 29, 2009 8:47 am
Location: Selanic, Greece
x 2
Contact:

[Bug] Copying camera properties to another one

Post by fantasian »

OK, this is trying to fix an inefficiency and stumbling on other bugs :-(

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() );
As soon as "sourceCam" was set to be autotracking, well, it wouldn't work. Also met that here: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=69040

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 );
			}
User avatar
fantasian
Halfling
Posts: 81
Joined: Fri May 29, 2009 8:47 am
Location: Selanic, Greece
x 2
Contact:

Re: [Bug] Copying camera properties to another one

Post by fantasian »

Bug fix to my code:
remove

Code: Select all

 viewCam->setDirection( sourceCam->getRealDirection() );
setOrientation does the job, this one does half-the-job.
Post Reply