[osg-users] seamless perspectives with multiple (rotated/translated) osgViewer slaves
robert.osfield at gmail.com
Fri Oct 19 11:33:16 PDT 2007
I'd recommend setting the master camera's projection matrix so it
fills one side of the cube, then have the slave cameras just rotate
Have a look at how the View::setUpViewFor3DSphericalDisplay method is
set up. You won't need use render to texture of course or the final
slave camera that does the distortion correction.
On 10/19/07, Mike Wozniewski <mikewoz at sat.qc.ca> wrote:
> Hi All,
> I'm struggling to understand how to properly offset a slave in
> osgViewer, and still have the perspectives line up for tiled and
> CAVE-like displays.
> For example, I have one OSG window to render the "left corner" of a
> CAVE. The window has 2 cameras: The "left" camera has a viewport that
> covers the left half of the window and is rotated -90 degrees. The
> "center" camera has a viewport that covers the right half of the window
> and is not rotated.
> left camera:
> viewer.addSlave(camera.get(), pMatrix,
> osg::Matrix::rotate(osg::inDegrees(-90), 0,1,0));
> center camera:
> viewer.addSlave(camera.get(), pMatrix, osg::Matrix::());
> How do I compute the correct pMatrix to ensure that the frustums line up
> in a seamless fashion (ie, objects do not disappear or become duplicated)?
> Note that through trial and error, I have found a pMatrix that works:
> pMatrix = osg::Matrixd::scale( viewportWidthRatio * traits->width /
> 3150, 1, 1 );
> But I don't understand why I have to scale by 3150? It seems that it's
> related to the size of the viewport... so in my case my full window
> width is 2048, so I have: 0.5 * 2048 / 3150 = 0.325. Why this value?
> Also, in case it's important, the master camera is attached to a
> NodeTrackerManipulator that I define like this:
> nodeTracker = new osgGA::NodeTrackerManipulator();
> osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION );
> osgGA::NodeTrackerManipulator::ELEVATION_AZIM );
> nodeTracker->setHomePosition(osg::Vec3d(0,0,0), osg::Vec3d(0,1,0),
> The other question I have: what if the left view is not rotated, but
> planar to the center? ie, the eye looks directly forward through the
> center camera, and the left camera shows a translated and thus distorted
> view? What is the proper way to set my pMatrix for that? Obviously it's
> not just a scaling operation and requires skewing.
> Any insight would be greatly appreciated!
> Thanks in advance,
> -Mike Wozniewski
> osg-users mailing list
> osg-users at lists.openscenegraph.org
More information about the osg-users