[osg-users] Viewing angle > 180 degrees

92 views
Skip to first unread message

Bolstad, Mark

unread,
Nov 15, 2010, 8:04:11 PM11/15/10
to osg-...@lists.openscenegraph.org
I've dug around in the lists and various other areas and have yet to come up with a solution.

We have a cylindrical display using 3 projectors with a viewing angle of 225 degrees. Most of the code is based off of osgdistortion, but I can't seem to get a very large FOV. I've tried several approaches:
1. Setting the viewing angle of the master camera to perspective with the large FOV. Works up to 140 degrees but after that the perspective is to distorted (as would be expected). Interestingly, at FOV > 180, the up vector flips and the FOV gets smaller (somewhat expected if you think about the math).
2. Setting the offset parameters in addSlave (strange results)

What I think I need is to set each one of the three views to have a viewing angle of 75 degrees,  and to rotate two of the views +/- 75 degrees from the center.

Any help/hints on setting this up would be appreciated.

Mark

Mark A. Bolstad
Scientific Computing
Janelia Farm Research Campus
Howard Hughes Medical Institute
19700 Helix Drive, Ashburn, VA  20147
email: bols...@janelia.hhmi.org

office: +1.571.209.4623
web: http://www.hhmi.org/janelia/






Paul Martz

unread,
Nov 15, 2010, 8:13:30 PM11/15/10
to OpenSceneGraph Users
On 11/15/2010 6:04 PM, Bolstad, Mark wrote:
> 2. Setting the offset parameters in addSlave (strange results)
>
> What I think I need is to set each one of the three views to have a viewing
> angle of 75 degrees, and to rotate two of the views +/- 75 degrees from the center.
>
> Any help/hints on setting this up would be appreciated.

It appears you've answered your own question here, as all you need to do is set
slave camera view matrix "offsets" (rotations, actually).

--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Bolstad, Mark

unread,
Nov 15, 2010, 8:54:32 PM11/15/10
to OpenSceneGraph Users
If I set the master camera's FOV, do the slaves inherit that value?


Mark A. Bolstad
Scientific Computing
Janelia Farm Research Campus
Howard Hughes Medical Institute
19700 Helix Drive, Ashburn, VA  20147
email: bols...@janelia.hhmi.org

office: +1.571.209.4623
web: http://www.hhmi.org/janelia/






Ulrich Hertlein

unread,
Nov 15, 2010, 9:09:40 PM11/15/10
to OpenSceneGraph Users
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

Bolstad, Mark

unread,
Nov 15, 2010, 10:01:21 PM11/15/10
to OpenSceneGraph Users
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: bols...@janelia.hhmi.org

office: +1.571.209.4623
web: http://www.hhmi.org/janelia/






Ulrich Hertlein

unread,
Nov 15, 2010, 10:39:44 PM11/15/10
to OpenSceneGraph Users
On 16/11/10 14:01 , Bolstad, Mark wrote:
> 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 )
>...

One thing to remember is to set the reference frame for the slave cameras to RELATIVE_RF
in order to use the master camera's matrices with offset.

Fabian Recktenwald

unread,
Nov 16, 2010, 11:20:39 AM11/16/10
to osg-...@lists.openscenegraph.org
Just two things I noticed:

- matrix::rotate uses radians (not degree) so use osg::DegreesToRadians()

- offsetting the projection matrix is a bit tricky (and I assume you didn't really want to do that). Probably you wanted something like this

addSlave( cam,
osg::Matrix::identity(),
osg::Matrix::rotate( osg::DegreesToRadians(xyz), 0,1,0 )

and set the master projection matrix such that it already fits.

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

Bolstad, Mark

unread,
Nov 16, 2010, 12:29:31 PM11/16/10
to osg-...@lists.openscenegraph.org
Yes, you were correct in that I was using degrees. I discovered it this morning and was to embarrassed to post a Doh!.


Mark A. Bolstad
Scientific Computing
Janelia Farm Research Campus
Howard Hughes Medical Institute
19700 Helix Drive, Ashburn, VA  20147
email: bols...@janelia.hhmi.org

office: +1.571.209.4623
web: http://www.hhmi.org/janelia/






Bolstad, Mark

unread,
Feb 7, 2011, 2:53:48 PM2/7/11
to OpenSceneGraph Users

I'm revisiting my old message here. I have in place a version that uses the view offset parameter of addSlave in viewer, but I'm getting some strange results (it appears like a three-point perspective, one per camera ). It's worked enough to get the system running, but the results are somewhat distracting. So rather than listing my code, could someone modify osgcamera to show the proper way to have 3 cameras with a FOV greater than 180 degrees?

Robert Osfield

unread,
Feb 7, 2011, 3:54:55 PM2/7/11
to OpenSceneGraph Users
Hi Mark,

The osgViewer::View::setUpViewFor3DSphericalDisplay(..) provides a
slave setup of 6 slave cameras that render to texture cube map and a
final slave camera that renders this cubmap to distortion correction
mesh. The cubemap rendering is for full 360 degree view, The source
code can be found at OpenSceneGraph/src/osgViewer/View.cpp. You can
also run osgviewer with the --3d-sd command line option and it'll run
with this view setup. The distortion correction is appropriate for
Pufferfish display that uses a single projector with a fish eye lens.

Robert.

Reply all
Reply to author
Forward
0 new messages