Re: [osg-users] seamless perspectives with multiple (rotated/translated) osgViewer slaves

2007-10-19 Thread Robert Osfield
Hi Mike,

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
from this.

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.

Robert.

On 10/19/07, Mike Wozniewski <[EMAIL PROTECTED]> 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();
> nodeTracker->setTrackerMode(
> osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION );
> nodeTracker->setRotationMode(
> osgGA::NodeTrackerManipulator::ELEVATION_AZIM );
> nodeTracker->setHomePosition(osg::Vec3d(0,0,0), osg::Vec3d(0,1,0),
> osg::Vec3d(0,0,1));
>
> 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@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] seamless perspectives with multiple (rotated/translated) osgViewer slaves

2007-10-19 Thread Mike Wozniewski
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();
nodeTracker->setTrackerMode( 
osgGA::NodeTrackerManipulator::NODE_CENTER_AND_ROTATION );
nodeTracker->setRotationMode( 
osgGA::NodeTrackerManipulator::ELEVATION_AZIM );
nodeTracker->setHomePosition(osg::Vec3d(0,0,0), osg::Vec3d(0,1,0), 
osg::Vec3d(0,0,1));

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@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org