[osg-users] How to change "field of view"(FOV), distance.

Gianni Ambrosio g.ambrosio+osg at gmail.com
Mon Aug 21 04:42:54 PDT 2017


Hi Arfaa,
here is my implementation:

Code:
bool ViewerWidget::setMainCameraFieldOfView(double iFov)
{
   osg::Camera* camera = mainView()->getCamera();
   double fovy, aspectRatio, zNear, zFar;
   bool result = camera->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar);
   if (true == result) {
      camera->setProjectionMatrixAsPerspective(iFov, aspectRatio, zNear, zFar);
   }
   return result;
}



ViewerWidget inherits from osgViewer::CompositeViewer. Anyway what I notice on your code is that you use a CameraViewer while I set the FOV to a osg::Camera. You could try the code on a osg::Camera and if it works then I guess there is something to investigate on the CameraViewer side.

HTH, Gianni

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71467#71467







More information about the osg-users mailing list