Re: [osg-users] Slave cameras in a view
Hi and thanks for the tip about where to look for code for the projectionOffset. I now have a slave camera with the expected projection offset next to the master camera. One thing that I found out was that the slave camera is drawn one frame after the master. Both cameras are drawn to the same graphics context. I can easily see this in the seam between the two cameras by moving my scene up or down at a constant speed. My slave camera is then drawn a at a constant distance behind my master camera. In the osgwindow example separate graphics contexts are used for master and slave cameras. Is that the way it should be done? And then why? If I set up the two cameras with different graphics contexts they draw within the same frame (when I use the thread per context threading model). Regards Karl On 10/15/07, Robert Osfield [EMAIL PROTECTED] wrote: Hi Karl, Have a look at the osgwindows example, or the View::setUpViewAcrossScreens() source code in src/osgViewer/Viewer.cpp. On 10/10/07, Karl Heijdenberg [EMAIL PROTECTED] wrote: Hi, I'm trying to add two cameras to one View in compositeViewer. The first camera is added as a master camera and the second as a slave camera. Frustums for the cameras: master={-50, 0, -40, 40} slave={0, 50, -40, 40} For the first camera I set the projectionMatrix with setProjectionMatrixAsFrustum. How do I calculate the projectionOffset for the slave camera? The offset is needed in call to addSlave(osg::Camera* camera,const osg::Matrix projectionOffset, const osg::Matrix viewOffset, bool useMastersSceneData=true); I've also tried to set the reference frame to ABSOLUTE_RF_INHERIT_VIEWPOINT and then call the setProjectionMatrixAsFrustum for both cameras. This test ended up in a black scene for the second camera. Am I missing something? Thanks, Karl ___ 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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Slave cameras in a view
Hi Karl, The master and slave cameras will be drawn in the same frame. If you see a difference then it must be down to the propagation of the settings from the master to the slave being out of sync. I don't know how you set the master, perhaps you are setting it after the sync point. The View::updateSlaves() method that does this sync is called from within Viewer::updateTraversals() so perhaps you are setting the master camera after this. Robert. On 10/17/07, Karl Heijdenberg [EMAIL PROTECTED] wrote: Hi and thanks for the tip about where to look for code for the projectionOffset. I now have a slave camera with the expected projection offset next to the master camera. One thing that I found out was that the slave camera is drawn one frame after the master. Both cameras are drawn to the same graphics context. I can easily see this in the seam between the two cameras by moving my scene up or down at a constant speed. My slave camera is then drawn a at a constant distance behind my master camera. In the osgwindow example separate graphics contexts are used for master and slave cameras. Is that the way it should be done? And then why? If I set up the two cameras with different graphics contexts they draw within the same frame (when I use the thread per context threading model). Regards Karl On 10/15/07, Robert Osfield [EMAIL PROTECTED] wrote: Hi Karl, Have a look at the osgwindows example, or the View::setUpViewAcrossScreens() source code in src/osgViewer/Viewer.cpp. On 10/10/07, Karl Heijdenberg [EMAIL PROTECTED] wrote: Hi, I'm trying to add two cameras to one View in compositeViewer. The first camera is added as a master camera and the second as a slave camera. Frustums for the cameras: master={-50, 0, -40, 40} slave={0, 50, -40, 40} For the first camera I set the projectionMatrix with setProjectionMatrixAsFrustum. How do I calculate the projectionOffset for the slave camera? The offset is needed in call to addSlave(osg::Camera* camera,const osg::Matrix projectionOffset, const osg::Matrix viewOffset, bool useMastersSceneData=true); I've also tried to set the reference frame to ABSOLUTE_RF_INHERIT_VIEWPOINT and then call the setProjectionMatrixAsFrustum for both cameras. This test ended up in a black scene for the second camera. Am I missing something? Thanks, Karl ___ 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 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
Re: [osg-users] Slave cameras in a view
Ah, thanks a lot :-) Of course that was the reason! Thats also explains why it worked with different contexts. Thanks Karl On 10/17/07, Robert Osfield [EMAIL PROTECTED] wrote: Hi Karl, The master and slave cameras will be drawn in the same frame. If you see a difference then it must be down to the propagation of the settings from the master to the slave being out of sync. I don't know how you set the master, perhaps you are setting it after the sync point. The View::updateSlaves() method that does this sync is called from within Viewer::updateTraversals() so perhaps you are setting the master camera after this. Robert. On 10/17/07, Karl Heijdenberg [EMAIL PROTECTED] wrote: Hi and thanks for the tip about where to look for code for the projectionOffset. I now have a slave camera with the expected projection offset next to the master camera. One thing that I found out was that the slave camera is drawn one frame after the master. Both cameras are drawn to the same graphics context. I can easily see this in the seam between the two cameras by moving my scene up or down at a constant speed. My slave camera is then drawn a at a constant distance behind my master camera. In the osgwindow example separate graphics contexts are used for master and slave cameras. Is that the way it should be done? And then why? If I set up the two cameras with different graphics contexts they draw within the same frame (when I use the thread per context threading model). Regards Karl On 10/15/07, Robert Osfield [EMAIL PROTECTED] wrote: Hi Karl, Have a look at the osgwindows example, or the View::setUpViewAcrossScreens() source code in src/osgViewer/Viewer.cpp. On 10/10/07, Karl Heijdenberg [EMAIL PROTECTED] wrote: Hi, I'm trying to add two cameras to one View in compositeViewer. The first camera is added as a master camera and the second as a slave camera. Frustums for the cameras: master={-50, 0, -40, 40} slave={0, 50, -40, 40} For the first camera I set the projectionMatrix with setProjectionMatrixAsFrustum. How do I calculate the projectionOffset for the slave camera? The offset is needed in call to addSlave(osg::Camera* camera,const osg::Matrix projectionOffset, const osg::Matrix viewOffset, bool useMastersSceneData=true); I've also tried to set the reference frame to ABSOLUTE_RF_INHERIT_VIEWPOINT and then call the setProjectionMatrixAsFrustum for both cameras. This test ended up in a black scene for the second camera. Am I missing something? Thanks, Karl ___ 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 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 mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Slave cameras in a view
Hi Karl, Have a look at the osgwindows example, or the View::setUpViewAcrossScreens() source code in src/osgViewer/Viewer.cpp. On 10/10/07, Karl Heijdenberg [EMAIL PROTECTED] wrote: Hi, I'm trying to add two cameras to one View in compositeViewer. The first camera is added as a master camera and the second as a slave camera. Frustums for the cameras: master={-50, 0, -40, 40} slave={0, 50, -40, 40} For the first camera I set the projectionMatrix with setProjectionMatrixAsFrustum. How do I calculate the projectionOffset for the slave camera? The offset is needed in call to addSlave(osg::Camera* camera,const osg::Matrix projectionOffset, const osg::Matrix viewOffset, bool useMastersSceneData=true); I've also tried to set the reference frame to ABSOLUTE_RF_INHERIT_VIEWPOINT and then call the setProjectionMatrixAsFrustum for both cameras. This test ended up in a black scene for the second camera. Am I missing something? Thanks, Karl ___ 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] Slave cameras in a view
Hi, I'm trying to add two cameras to one View in compositeViewer. The first camera is added as a master camera and the second as a slave camera. Frustums for the cameras: master={-50, 0, -40, 40} slave={0, 50, -40, 40} For the first camera I set the projectionMatrix with setProjectionMatrixAsFrustum. How do I calculate the projectionOffset for the slave camera? The offset is needed in call to addSlave(osg::Camera* camera,const osg::Matrix projectionOffset, const osg::Matrix viewOffset, bool useMastersSceneData=true); I've also tried to set the reference frame to ABSOLUTE_RF_INHERIT_VIEWPOINT and then call the setProjectionMatrixAsFrustum for both cameras. This test ended up in a black scene for the second camera. Am I missing something? Thanks, Karl ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Slave cameras in a view
Thanks David for your try to help. The reply didn't answer to the question about how to calculate the projectionOffset for slave cameras. How to? On 10/10/07, David Callu [EMAIL PROTECTED] wrote: Hi Karl 2007/10/10, Karl Heijdenberg [EMAIL PROTECTED]: Hi, I'm trying to add two cameras to one View in compositeViewer. The first camera is added as a master camera and the second as a slave camera. other correct me if I am wrong, frustum is map on interval [0, XWindowSize] and [0, YWindowSize] That is the interval values of the viewport for the camera in the view. Frustums for the cameras: master={-50, 0, -40, 40} slave={0, 50, -40, 40} I use near=1 and far=100 For the first camera I set the projectionMatrix with setProjectionMatrixAsFrustum. I give these required arguments to the setProjectionMatrixAsFrustum method (for the master cam): {left,right,bottom,top,near,far} = {tan(degToRad(-50)) * near, tan(degToRad(0)) * near, tan(degToRad(-40)) * near, tan(degToRad(40)) * near, near, far} How do I calculate the projectionOffset for the slave camera? This is the question I'm interested in a good answer to! during update of camera position, the projection matrix for slaveis compute as this slaveCamera-setProjectionMatrix( masterCamera-getProjectionMatrix() * slaveCamera-getProjectionOffset() ); idem for the view matrix and the viewOffset. The offset is needed in call to addSlave(osg::Camera* camera,const osg::Matrix projectionOffset, const osg::Matrix viewOffset, bool useMastersSceneData=true); I've also tried to set the reference frame to ABSOLUTE_RF_INHERIT_VIEWPOINT and then call the setProjectionMatrixAsFrustum for both cameras. This test ended up in a black scene for the second camera. Am I missing something? Thanks, Karl ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org HTH David ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org Regards Karl ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org