[osg-users] Mirrored camera
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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Mirrored camera
On Monday 02 March 2009 14:42, Joakim Simonsson wrote: > I have created a slave camera. It should represent a rear mirror on a > vehicle. See osg::FrontFace and the the man page of glFrontFace. Greetings Mathias -- Dr. Mathias Fröhlich, science + computing ag, Software Solutions Hagellocher Weg 71-75, D-72070 Tuebingen, Germany Phone: +49 7071 9457-268, Fax: +49 7071 9457-511 -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Mirrored camera
I have created a slave camera. It should represent a rear mirror on a vehicle. See osg::FrontFace and the the man page of glFrontFace. Thank you for your tip, its much better to use that StateAttribute. But... I am not able to apply it just for one slave camera. As I wrote in my previous mail, I use two cameras that share the same scene (where one camera is mirrored) So, my question still is: Is it possible to use two cameras, where one is mirrored, that share the same scene? -- Joakim ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Mirrored camera
Hi, On Monday 02 March 2009 15:24, Joakim Simonsson wrote: > Is it possible to use two cameras, where one is mirrored, that share the > same scene? You should be able to have that attached either to the camera itself, the mirrored one (is this true, or are the StateSets at the camera something special - I dont remember by heart?). Or attach a group to the camera that is not shared , apply that state at this group and attach the shared graph to those two groups. This only works if there is either - no such state in the scenegraph below or - if you set that StateSttribute to StateAttribute::OVERRIDE. GReetings Mathias -- Dr. Mathias Fröhlich, science + computing ag, Software Solutions Hagellocher Weg 71-75, D-72070 Tuebingen, Germany Phone: +49 7071 9457-268, Fax: +49 7071 9457-511 -- Vorstand/Board of Management: Dr. Bernd Finkbeiner, Dr. Roland Niemeier, Dr. Arno Steitz, Dr. Ingrid Zech Vorsitzender des Aufsichtsrats/ Chairman of the Supervisory Board: Michel Lepert Sitz/Registered Office: Tuebingen Registergericht/Registration Court: Stuttgart Registernummer/Commercial Register No.: HRB 382196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Mirrored camera
On Mon, 02 Mar 2009 15:37:07 +0100, Mathias Fröhlich wrote: Hi, On Monday 02 March 2009 15:24, Joakim Simonsson wrote: Is it possible to use two cameras, where one is mirrored, that share the same scene? You should be able to have that attached either to the camera itself, the mirrored one (is this true, or are the StateSets at the camera something special - I dont remember by heart?). I tried to attach that stateattribute to the mirrored camera only. But it does not seem to work. Or attach a group to the camera that is not shared , apply that state at this group and attach the shared graph to those two groups. I'll go for the group approach. Thanks for your help. -- Joakim ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Mirrored camera
Hi Joakim, in examples osgcamera, in function: void multipleWindowMultipleCameras(osgViewer::Viewer& viewer, bool multipleScreens) i tried this code sample: if (i != 2) viewer.addSlave(camera.get(), osg::Matrix::scale(aspectRatioScale, 1.0, 1.0)*osg::Matrix::translate(translate_x, 0.0, 0.0), osg::Matrix() ); else viewer.addSlave(camera.get(), osg::Matrix::scale(-1.0 * aspectRatioScale, 1.0, 1.0)*osg::Matrix::translate(translate_x, 0.0, 0.0), osg::Matrix() ); camera which has id 2 become mirrored. is it something that you want? On Mon, Mar 2, 2009 at 4:46 PM, Joakim Simonsson wrote: > On Mon, 02 Mar 2009 15:37:07 +0100, Mathias Fröhlich < > m.froehl...@science-computing.de> wrote: > > >> Hi, >> >> On Monday 02 March 2009 15:24, Joakim Simonsson wrote: >> >>> Is it possible to use two cameras, where one is mirrored, that share the >>> same scene? >>> >> You should be able to have that attached either to the camera itself, the >> mirrored one (is this true, or are the StateSets at the camera something >> special - I dont remember by heart?). >> > > I tried to attach that stateattribute to the mirrored camera only. But it > does not seem to work. > > Or attach a group to the camera that is >> not shared , apply that state at this group and attach the shared graph to >> those two groups. >> > > I'll go for the group approach. > > > Thanks for your help. > > > -- > Joakim > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > -- Ufuk ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Mirrored camera
On Mon, 02 Mar 2009 15:50:41 +0100, Ufuk wrote: Hi Joakim, in examples osgcamera, in function: void multipleWindowMultipleCameras(osgViewer::Viewer& viewer, bool multipleScreens) i tried this code sample: if (i != 2) viewer.addSlave(camera.get(), osg::Matrix::scale(aspectRatioScale, 1.0, 1.0)*osg::Matrix::translate(translate_x, 0.0, 0.0), osg::Matrix() ); else viewer.addSlave(camera.get(), osg::Matrix::scale(-1.0 * aspectRatioScale, 1.0, 1.0)*osg::Matrix::translate(translate_x, 0.0, 0.0), osg::Matrix() ); camera which has id 2 become mirrored. is it something that you want? Yes, and I have done this in my app as well. But the thing is, cow.osg uses double sided polygons. If you edit cow.osg. On line 17: change GL_CULL_FACE OFF to GL_CULL_FACE ON Then you will render the front face only. If you then run your modded version of osgcamera, then you will see that the mirrored cameras render the backfaced polygons (i.e. the inside of the cow) So this is not a general solution. I will try to add unique groups that contains my shared scene graph for each camera, and give them different osg::FrontFace attributes. It seems that the stateset of the cameras are ignored for their underlying scenegraph. So adding groups for each camera, seems to be the only solution. On Mon, Mar 2, 2009 at 4:46 PM, Joakim Simonsson wrote: On Mon, 02 Mar 2009 15:37:07 +0100, Mathias Fröhlich < m.froehl...@science-computing.de> wrote: Hi, On Monday 02 March 2009 15:24, Joakim Simonsson wrote: Is it possible to use two cameras, where one is mirrored, that share the same scene? You should be able to have that attached either to the camera itself, the mirrored one (is this true, or are the StateSets at the camera something special - I dont remember by heart?). I tried to attach that stateattribute to the mirrored camera only. But it does not seem to work. Or attach a group to the camera that is not shared , apply that state at this group and attach the shared graph to those two groups. I'll go for the group approach. Thanks for your help. -- Joakim ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org