Show
Ignore:
Timestamp:
11/24/08 17:02:20 (6 years ago)
Author:
robert
Message:

Improved the set of the master + slave cameras

Files:
1 modified

Legend:

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

    r9229 r9232  
    167167    wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height); 
    168168 
     169 
     170 
    169171    // Not fullscreen 
    170172    width /= 2; 
     
    195197    } 
    196198 
    197     double aspectRatioScale = 1.0; 
    198199 
    199200    osg::Camera* master = viewer.getCamera(); 
     201 
     202    // get the default settings for the camera 
    200203    double fovy, aspectRatio, zNear, zFar; 
    201204    master->getProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); 
    202     master->setProjectionResizePolicy(osg::Camera::VERTICAL); 
    203     fovy = 90; 
    204     aspectRatio = 1; 
    205     master->setProjectionMatrixAsPerspective(fovy, aspectRatio, zNear, zFar); 
    206  
    207     double h = osg::absolute(tan(osg::DegreesToRadians(fovy / 2))); 
    208     double w = h * aspectRatio; 
    209     double fovx = osg::absolute(osg::RadiansToDegrees(atan(w)) * 2); 
     205 
     206    // reset this for the actual apsect ratio of out created window 
     207    double windowAspectRatio = double(width)/double(height); 
     208    master->setProjectionMatrixAsPerspective(fovy, windowAspectRatio, 1.0, 10000.0); 
    210209 
    211210    master->setName("MasterCam"); 
     
    219218    camera->setDrawBuffer(buffer); 
    220219    camera->setReadBuffer(buffer); 
    221     viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd()); 
     220    viewer.addSlave(camera.get(), osg::Matrixd::scale(1.0,0.5,1.0), osg::Matrixd()); 
    222221 
    223222    camera = new osg::Camera; 
     
    229228    camera->setDrawBuffer(buffer); 
    230229    camera->setReadBuffer(buffer); 
    231     viewer.addSlave(camera.get(), osg::Matrixd(), osg::Matrixd()); 
     230    viewer.addSlave(camera.get(), osg::Matrixd::scale(1.0,0.5,1.0), osg::Matrixd()); 
    232231} 
    233232