Show
Ignore:
Timestamp:
10/19/04 15:52:46 (10 years ago)
Author:
robert
Message:

Move the setting of the camera horizontal field of view to after the realize()
to avoid the CameraGroup?'s Lens be set when its NULL.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgcluster/osgcluster.cpp

    r3230 r3511  
    127127    while (arguments.read("-n",socketNumber)) ; 
    128128 
    129     float camera_fov=45.0f; 
     129    float camera_fov=-1.0f; 
    130130    while (arguments.read("-f",camera_fov))  
    131131    { 
    132         std::cout << "setting lens perspective : original "<<viewer.getLensHorizontalFov()<<"  "<<viewer.getLensVerticalFov()<<std::endl; 
    133         viewer.setLensPerspective(camera_fov,camera_fov*viewer.getLensVerticalFov()/viewer.getLensHorizontalFov(),1.0f,1000.0f); 
    134         std::cout << "setting lens perspective : new "<<viewer.getLensHorizontalFov()<<"  "<<viewer.getLensVerticalFov()<<std::endl; 
    135132    } 
    136133 
     
    172169    // create the windows and run the threads. 
    173170    viewer.realize(); 
     171 
     172 
     173    // set up the lens after realize as the Producer lens is not set up properly before this.... will need to inveestigate this at a later date. 
     174    if (camera_fov>0.0f) 
     175    { 
     176        float aspectRatio = tan( osg::DegreesToRadians(viewer.getLensVerticalFov()*0.5)) / tan(osg::DegreesToRadians(viewer.getLensHorizontalFov()*0.5)); 
     177        float new_fovy = osg::RadiansToDegrees(atan( aspectRatio * tan( osg::DegreesToRadians(camera_fov*0.5))))*2.0f; 
     178        std::cout << "setting lens perspective : original "<<viewer.getLensHorizontalFov()<<"  "<<viewer.getLensVerticalFov()<<std::endl; 
     179        viewer.setLensPerspective(camera_fov,new_fovy,1.0f,1000.0f); 
     180        std::cout << "setting lens perspective : new "<<viewer.getLensHorizontalFov()<<"  "<<viewer.getLensVerticalFov()<<std::endl; 
     181    } 
     182 
    174183 
    175184    // objects for managing the broadcasting and recieving of camera packets.