Skip to main content

History: How to limit the pitch of a camera

Source of version: 6 (current)

Copy to clipboard
            This is just a code snippet taken from this post on the forums: [http://www.ogre3d.org/phpBB2/viewtopic.php?t=10325|Link to forum post]. Example here uses Example Frame Listener in Ogre/Samples/Common/include

{CODE(wrap="1", colors="c++")} 
iCamera->yaw(iRotX);
Ogre::Radian originalPitch = iCamera->getOrientation().getPitch();
Ogre::Radian newPitch = Ogre::Math::Abs(iRotY + originalPitch);
 
if(newPitch < Ogre::Radian(Ogre::Math::PI/2 - Offset) || newPitch > Ogre::Radian(Ogre::Math::PI/2 + Offset))
{
     iCamera->pitch(iRotY);         
}{CODE}

__Note:__ A correct offset value must be around 0.2 - 0.5.

---
Alias: (alias(How_to_limit_the_pitch_of_a_camera))