Jörn Teuber
2014-11-25 14:48:18 UTC
Hello everybody,
I have a seemingly simple problem with OpenSG 1.8 (yes, I have to use
that version...) which I don't know how to solve:
I want to use a zSpace Monitor to render in 3D, so I need quad buffered
stereo. No problem I thought, just use the StereoBufferedViewport with a
Camera with two ShearedStereoCameraDecorator. But it does give me any
3D. I still only get a 2D version of my scene even though the monitor is
clearly in 3D mode. I can even disable one of the buffers of the
Viewport to get a nice flickering window. What did I miss here?
Now a snippet of the relevant code I use (the original got some calls to
the zSpace API, but I don't think they matter here):
initialisation:
[...]
m_pCamera = osg::PerspectiveCamera::create();
osg::beginEditCP(m_pCamera);
m_pCamera->setBeacon(m_pCamBeacon);
m_pCamera->setFov(osg::deg2rad(60));
m_pCamera->setNear(0.1);
m_pCamera->setFar(100);
osg::endEditCP(m_pCamera);
osg::ShearedStereoCameraDecoratorPtr cameraDecoratorLeft,
cameraDecoratorRight;
cameraDecoratorLeft = osg::ShearedStereoCameraDecorator::create();
osg::beginEditCP(cameraDecoratorLeft);
cameraDecoratorLeft->setLeftEye(true);
cameraDecoratorLeft->setEyeSeparation( fEyeSeperation );
cameraDecoratorLeft->setDecoratee(m_pCamera);
cameraDecoratorLeft->setZeroParallaxDistance(
fZeroParallaxDist );
osg::endEditCP(cameraDecoratorLeft);
cameraDecoratorRight = osg::ShearedStereoCameraDecorator::create();
osg::beginEditCP(cameraDecoratorRight);
cameraDecoratorRight->setLeftEye(false);
cameraDecoratorRight->setEyeSeparation( fEyeSeperation );
cameraDecoratorRight->setDecoratee(m_pCamera);
cameraDecoratorRight->setZeroParallaxDistance(
fZeroParallaxDist );
osg::endEditCP(cameraDecoratorRight);
m_pViewport = osg::StereoBufferViewport::create();
osg::beginEditCP(m_pViewport);
m_pViewportLeft->setCamera( m_pCamera );
m_pViewportLeft->setBackground( background );
m_pViewportLeft->setRoot(pRoot);
m_pViewportLeft->setSize(0,0,1,1);
osg::endEditCP(m_pViewport);
m_pWindow = osg::GLUTWindow::create();
osg::beginEditCP(m_pWindow);
m_pWindow->setId(winid);
m_pWindow->addPort(m_pViewport);
m_pWindow->setSize( m_iWindowWidth, m_iWindowHeight);
m_pWindow->init();
osg::endEditCP(m_pWindow);
rendering: a simple
void render( osg::RenderAction* pRenderAction )
{
m_pWindow->render( pRenderAction );
}
Thank you so much for any help with this!
Best regards
Jörn Teuber
I have a seemingly simple problem with OpenSG 1.8 (yes, I have to use
that version...) which I don't know how to solve:
I want to use a zSpace Monitor to render in 3D, so I need quad buffered
stereo. No problem I thought, just use the StereoBufferedViewport with a
Camera with two ShearedStereoCameraDecorator. But it does give me any
3D. I still only get a 2D version of my scene even though the monitor is
clearly in 3D mode. I can even disable one of the buffers of the
Viewport to get a nice flickering window. What did I miss here?
Now a snippet of the relevant code I use (the original got some calls to
the zSpace API, but I don't think they matter here):
initialisation:
[...]
m_pCamera = osg::PerspectiveCamera::create();
osg::beginEditCP(m_pCamera);
m_pCamera->setBeacon(m_pCamBeacon);
m_pCamera->setFov(osg::deg2rad(60));
m_pCamera->setNear(0.1);
m_pCamera->setFar(100);
osg::endEditCP(m_pCamera);
osg::ShearedStereoCameraDecoratorPtr cameraDecoratorLeft,
cameraDecoratorRight;
cameraDecoratorLeft = osg::ShearedStereoCameraDecorator::create();
osg::beginEditCP(cameraDecoratorLeft);
cameraDecoratorLeft->setLeftEye(true);
cameraDecoratorLeft->setEyeSeparation( fEyeSeperation );
cameraDecoratorLeft->setDecoratee(m_pCamera);
cameraDecoratorLeft->setZeroParallaxDistance(
fZeroParallaxDist );
osg::endEditCP(cameraDecoratorLeft);
cameraDecoratorRight = osg::ShearedStereoCameraDecorator::create();
osg::beginEditCP(cameraDecoratorRight);
cameraDecoratorRight->setLeftEye(false);
cameraDecoratorRight->setEyeSeparation( fEyeSeperation );
cameraDecoratorRight->setDecoratee(m_pCamera);
cameraDecoratorRight->setZeroParallaxDistance(
fZeroParallaxDist );
osg::endEditCP(cameraDecoratorRight);
m_pViewport = osg::StereoBufferViewport::create();
osg::beginEditCP(m_pViewport);
m_pViewportLeft->setCamera( m_pCamera );
m_pViewportLeft->setBackground( background );
m_pViewportLeft->setRoot(pRoot);
m_pViewportLeft->setSize(0,0,1,1);
osg::endEditCP(m_pViewport);
m_pWindow = osg::GLUTWindow::create();
osg::beginEditCP(m_pWindow);
m_pWindow->setId(winid);
m_pWindow->addPort(m_pViewport);
m_pWindow->setSize( m_iWindowWidth, m_iWindowHeight);
m_pWindow->init();
osg::endEditCP(m_pWindow);
rendering: a simple
void render( osg::RenderAction* pRenderAction )
{
m_pWindow->render( pRenderAction );
}
Thank you so much for any help with this!
Best regards
Jörn Teuber