[osg-users] Mirrored camera

Joakim Simonsson joakim at autosim.no
Mon Mar 2 05:42:11 PST 2009


Hi all,

I have created a slave camera. It should represent a rear mirror on a  
vehicle.

It uses the master camera's scene data.

Its projectionMatrix offset is osg::Matrixd::scale(-1.0, 1.0, 1.0), so  
that its view is mirrored.

But by using this offset projection matrix, every polygon's back face is  
rendered instead of their front face.

I can modify the stateset of the master camera, such that double sided  
rendering is enabled:

viewer->getCamera()->getOrCreateStateSet()->setMode(GL_CULL_FACE,  
osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);

However, this results in rendering double sided polygons for all my  
cameras.

Trying to modify the stateset of a slave camera does not seems to affect  
the scene:

viewer->getSlave(0)._camera->getOrCreateStateSet()->setMode(GL_CULL_FACE,  
osg::StateAttribute::OVERRIDE | osg::StateAttribute::OFF);

So my question is:

Is it possible to use two cameras, where one is mirrored, that share the  
same scene?


-- 
Joakim



More information about the osg-users mailing list