[osg-users] Eye position and 2nd slave camera

Robert Osfield robert.osfield at gmail.com
Tue Mar 31 02:33:11 PDT 2009


Hi Petr,

By default the slave camera's have their project and view matrices updated
relative to the master camera on each frame, this scheme allows the OSG to
do handle multiple screen setups seemlessly.  If you want a slave camera to
be entirely decoupled from the master then set the ReferenceFrame of the
camera to ABSOLTE_RF rather than the default of RELATIVE_RF.

If you have an entirely decoupled view on the scene(s) you might also be
better served by using two views in a CompositeViewer.

Robert,


On Tue, Mar 31, 2009 at 9:20 AM, petr srom <srom at jkzsim.cz> wrote:

> Hi,
>
> please, can you tell me why the camera_slave have got the same position
> (eye) as the camera_main? What I'am doing wrong? I cannot set different
> position and frustum than is in camera_main? The camera slave take (inherit)
> the setting of camera main? Here is the code:
>
> void MultiCameras::multipleCameras(osgViewer::Viewer *viewer)
> {
>        camera_main_create(viewer);
>        camera_slave_create(viewer);
> }
>
> void MultiCameras::camera_main_create(osgViewer::Viewer *viewer)
> {
>        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
>        camera->setGraphicsContext(gc);
>        camera->setViewport(0, 0, 650, 500);
>        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
>        camera->setDrawBuffer(buffer);
>        camera->setReadBuffer(buffer);
>        camera->setClearColor(mv4f_clearcolor);
>
>  camera->setProjectionMatrixAsFrustum(-2.0,2.0,-2.0,2.0,5.0,50.0);
>        mv3f_eye.set(20.0f,20.0f,3.0f);
>        camera->setViewMatrixAsLookAt(mv3f_eye, mv3f_center, mv3f_up);
>        viewer->setCamera( camera );
> }
>
> void MultiCameras::camera_slave_create(osgViewer::Viewer *viewer)
> {
>        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
>        camera->setGraphicsContext(gc);
>        camera->setViewport(0, 510, 650, 200);
>        GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT;
>        camera->setDrawBuffer(buffer);
>        camera->setReadBuffer(buffer);
>        camera->setClearColor(mv4f_clearcolor);
>        camera->setProjectionMatrixAsFrustum(-8.0,8.0,-2.0,2.0,5.0,50.0);
>        mv3f_eye.set(20.0f,5.0f,0.0f);  //it doesn't work ?
>        camera->setViewMatrixAsLookAt(mv3f_eye, mv3f_center, mv3f_up);
>        viewer->addSlave(camera.get());
> }
>
> Thank you.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=9479#9479
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20090331/fbed017f/attachment-0003.htm>


More information about the osg-users mailing list