I must be missing something then. When I set the master camera's view to be 95 
degrees, I get a 95 degree field of view across all three cameras. 

Also, whatever I set the offsets to, I just get really wacky results ( with an 
offset of 10 degrees, I get no overlap between cameras, and trackball rotations 
go in opposite directions for 2 out of the three camera ) 

Maybe someone with better eyes can see my mistake:

void
ViewingWindowQt::initializeCameras( int nCameras )
{
   numCameras = nCameras;
   widgets = new QWidget*[ numCameras ];
   
   _x_focal_length.resize( numCameras );
   _y_focal_length.resize( numCameras );
   _use_distortion.resize( numCameras );
   _bottom_texcoord.resize( numCameras );
   
   // Just added here to see what would happen
   // 95 degree view *across* all three cameras, not per camera
   getCamera()->setProjectionMatrixAsPerspective( 95.0f, 1.0, 0.1, 10000.0 );
   
   for ( int i = 0; i < numCameras; i++ )
   {
           _x_focal_length[i] = 1.0f;
           _y_focal_length[i] = 1.0f;
           _bottom_texcoord[i] = osg::Vec2( -0.5f, -0.5f );
           _use_distortion[i] = true;
      widgets[ i ] = addViewWidget( multipleWindowWithDistortion( true, i, 
numCameras ) );
   }
   
   for ( int i = 0; i < numCameras; i++ )
      widgets[ i ]->show();

   connect( &_timer, SIGNAL( timeout() ), this, SLOT( paintEvent() ) );
   _timer.start( 10 );
}

....

osg::Camera* 
ViewingWindowQt::multipleWindowWithDistortion( bool multipleScreens, int i, int 
numCameras )
{
   osg::GraphicsContext::WindowingSystemInterface* wsi = 
osg::GraphicsContext::getWindowingSystemInterface();
    
   osg::Node* sceneData = getSceneData();

   wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), _width, 
_height);

   double aspectRatioScale = (double)numCameras;
   double translate_x = double(numCameras)-1 + i * -2.0;
    
   osg::ref_ptr<osg::GraphicsContext::Traits> traits = new 
osg::GraphicsContext::Traits;
   traits->screenNum = multipleScreens ? i+1 : 0;
   traits->x = (i*_width)/numCameras;
   traits->y = 0;
   traits->width = _width/numCameras;
   traits->height = _height;
        
   traits->windowDecoration = false;
   traits->doubleBuffer = true;
   traits->sharedContext = 0;

   osg::ref_ptr<osg::Camera> camera = new osg::Camera;
   GraphicsWindowQt* gwqt = new GraphicsWindowQt( traits.get() );
   camera->setGraphicsContext( gwqt );
   camera->setClearColor( _clearColor );
   gwqt->setClearColor( _clearColor );
   gwqt->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   camera->setViewport(new osg::Viewport(0,0, (_width/numCameras), _height));
   GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
   camera->setDrawBuffer(buffer);
   camera->setReadBuffer(buffer);
   osg::Node* data = createDistortionSubgraph( i, sceneData, _clearColor );
   camera->addChild( data );
        
   // Original
   addSlave(camera.get(), osg::Matrix::scale(aspectRatioScale, 1.0, 1.0)*
            osg::Matrix::translate(translate_x, 0.0, 0.0), osg::Matrix(), false 
);

   // Tried this and various other combinations
//   addSlave(camera.get(), osg::Matrix::scale(aspectRatioScale, 1.0, 1.0), 
//                      osg::Matrix::rotate(-10.f + i*10.f, 0.f, 1.f, 0.f ), 
false );

   return camera.release();
}

Mark A. Bolstad
Scientific Computing
Janelia Farm Research Campus
Howard Hughes Medical Institute
19700 Helix Drive, Ashburn, VA  20147
email: [email protected]
office: +1.571.209.4623
web: http://www.hhmi.org/janelia/






On Nov 15, 2010, at 9:09 PM, Ulrich Hertlein wrote:

> On 16/11/10 12:54 , Bolstad, Mark wrote:
>> If I set the master camera's FOV, do the slaves inherit that value?
> 
> Yes, slave cameras inherit the master camera's view *and* projection matrices 
> (with
> optional offsets).
> 
> /ulrich
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to