Hi Jan,

The screen width, height and distance are used to set up the frustum
dimensions, which is basically the master cameras projection matrix.
Get the frustum right and stereo works sweetly as the projected image
dimensions are correct.

Below is the code segment from Present3D/src/present3D.cpp, this file
I've ported across to osgViewer a while back.  I haven't completed the
port yet though, still the below code segment might be useful:

void setViewer(osgViewer::Viewer& viewer, float width, float height,
float distance)
{
   unsigned int numCameras = viewer.getNumSlaves();
   if (numCameras==2)
   {
       // hardwire dual screen horizontal split screen up.

       osg::DisplaySettings* ds = osg::DisplaySettings::instance();
       if (ds->getStereoMode()==osg::DisplaySettings::HORIZONTAL_SPLIT
&& ds->getStereo())
       {
           osg::Matrix identity;

           osg::ref_ptr<osg::DisplaySettings> ds_left = new
osg::DisplaySettings(*ds);
           ds_left->setStereoMode(osg::DisplaySettings::LEFT_EYE);

           osg::ref_ptr<osg::DisplaySettings> ds_right = new
osg::DisplaySettings(*ds);
           ds_right->setStereoMode(osg::DisplaySettings::RIGHT_EYE);

           unsigned int leftCameraNum =
(ds->getSplitStereoHorizontalEyeMapping()==osg::DisplaySettings::LEFT_EYE_LEFT_VIEWPORT)
? 0 : 1;
           unsigned int rightCameraNum =
(ds->getSplitStereoHorizontalEyeMapping()==osg::DisplaySettings::LEFT_EYE_LEFT_VIEWPORT)
? 1 : 0;

           viewer.getSlave(leftCameraNum)._projectionOffset.makeIdentity();
           viewer.getSlave(leftCameraNum)._viewOffset.makeIdentity();
           // left to do.
           //osgUtil::SceneView* sv_left =
viewer.getSceneHandlerList()[leftCameraNum]->getSceneView();
           //sv_left->setDisplaySettings(ds_left);

           viewer.getSlave(rightCameraNum)._projectionOffset.makeIdentity();
           viewer.getSlave(rightCameraNum)._viewOffset.makeIdentity();
           // left to do.
           //osgUtil::SceneView* sv_right =
viewer.getSceneHandlerList()[rightCameraNum]->getSceneView();
           //sv_right->setDisplaySettings(ds_right);
       }
   }

   double vfov = osg::RadiansToDegrees(atan2(height/2.0f,distance)*2.0);
   double hfov = osg::RadiansToDegrees(atan2(width/2.0f,distance)*2.0);

   viewer.getCamera()->setProjectionMatrixAsPerspective( vfov,
width/height, 0.1, 1000.0);
   viewer.getCamera()->setCullMask(0xffffffff);
   viewer.getCamera()->setCullMaskLeft(0x00000001);
   viewer.getCamera()->setCullMaskRight(0x00000002);

}


Robert.

On 6/6/07, Jan Ciger <[EMAIL PROTECTED]> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Robert Osfield wrote:
> Hi Jan,
...
> Does osgproducerviewer work fine for you?  We just need to track down
> the relevant code and see how we can map it across.  I shouldn't be
> difficult, alternatively we just look at Present3D's code for doing
> this.

Yes, we are currently using it.

> You'll be able to set up the projection matrix yourself as you can do
> with Producer.

At the moment we are using env. variables or Producer camera file for this.

Hmm, strange thing - I have checked our production machine and the
values are actually not used anywhere in that code neither. However, we
are still getting a correct picture, because we are providing a Producer
camera config file where we have the horizontal and vertical opening
angles for the camera specified (BTW, how do I specify the window size
and the camera parameters with osgViewer? Only by manually changing the
settings from code?).

Weird - what were these values supposed to achieve? I recall that I had
to set them once to the size of our screen in order to remove the
distortion, however then we have have provided a config file for
Producer and I guess we didn't notice when they actually stopped
working. I will try to unset them tomorrow and check whether the
rendering on the wall is actually correct without them. If it is not,
then they are still used somewhere and we need to dig deeper.

Jan


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mandriva - http://enigmail.mozdev.org

iD8DBQFGZxi1n11XseNj94gRAsTeAKCHhatCv1w5h4mVMOVW5ZkwoiRpUwCfdP42
fUP6q1AYzfq2ozB3o4cRAQM=
=kUHw
-----END PGP SIGNATURE-----
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to