Hi Robert, It could simply be that your subclass from Viewer is interfering with the mechanism that applies the master's view and projection matrix to the slaves.
Requiring a subclass from Viewer just to implement so event handling is rather overkill, you should be able to catch the events in the main frame loop and pass these on to the viewer, or simply compute the viewer's master camera's view matrix on each frame and forgo the use of a camera manipulator. Robert. On Mon, Jan 24, 2011 at 6:32 PM, Robert Kern <[email protected]> wrote: > Hi, > > I've been having trouble implementing slave cameras for an application I'm > working on. The camera gets its position and orientation from a motion > tracking system or through joystick input. When I don't set up slave cameras, > the camera properly responds to input. However, when I implement slave > cameras, they do not update their position or orientation with input from the > motion tracking or joy stick. > > In the code below, if I comment out the code that sets up the slave cameras, > the viewer responds properly to input from the joystick or the motion > tracker. If it is not commented, the slave cameras will display, but they > will not respond to the motion tracker or joystick. If anyone could provide > any suggestions, they would be much appreciated. > > Thank you! > rjkern > > Code: > > viewer = new FLTViewer(arguments); //FLTViewer is and extension of the > osgViewer::Viewer class. It receives the camera position and orientation from > a server program. > > //Here is where I set up the slave camera > int xoffset = 40; > int yoffset = 40; > > // left window + left slave camera > { > osg::ref_ptr<osg::GraphicsContext::Traits> traits = new > osg::GraphicsContext::Traits; > traits->x = xoffset + 0; > traits->y = yoffset + 0; > traits->width = 600; > traits->height = 480; > traits->windowDecoration = true; > traits->doubleBuffer = true; > traits->sharedContext = 0; > > osg::ref_ptr<osg::GraphicsContext> gc = > osg::GraphicsContext::createGraphicsContext(traits.get()); > > osg::ref_ptr<osg::Camera> camera = new osg::Camera; > camera->setGraphicsContext(gc.get()); > camera->setViewport(new osg::Viewport(0,0, traits->width, > traits->height)); > GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; > camera->setDrawBuffer(buffer); > camera->setReadBuffer(buffer); > > // add this slave camera to the viewer, with a shift left of > the projection matrix > viewer->addSlave(camera.get(), > osg::Matrixd::translate(1.0,0.0,0.0), osg::Matrixd::rotate(45, Vec3f(1,0,0))); > } > > // right window + right slave camera > { > osg::ref_ptr<osg::GraphicsContext::Traits> traits = new > osg::GraphicsContext::Traits; > traits->x = xoffset + 600; > traits->y = yoffset + 0; > traits->width = 600; > traits->height = 480; > traits->windowDecoration = true; > traits->doubleBuffer = true; > traits->sharedContext = 0; > > osg::ref_ptr<osg::GraphicsContext> gc = > osg::GraphicsContext::createGraphicsContext(traits.get()); > > osg::ref_ptr<osg::Camera> camera = new osg::Camera; > camera->setGraphicsContext(gc.get()); > camera->setViewport(new osg::Viewport(0,0, traits->width, > traits->height)); > GLenum buffer = traits->doubleBuffer ? GL_BACK : GL_FRONT; > camera->setDrawBuffer(buffer); > camera->setReadBuffer(buffer); > > // add this slave camera to the viewer, with a shift right of > the projection matrix > //viewer->addSlave(camera.get(), > osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd()); > viewer->addSlave(camera.get(), > osg::Matrixd::translate(-1.0,0.0,0.0), osg::Matrixd::rotate(45, > Vec3f(1,0,0))); > } > > > //create socket and set up connections. > viewer->initRecvSocket(); > > //Load the scene model > viewer->setScene(viewer->file_name); > > osg::Group* rootnode; > > rootnode = viewer->getRootNode(); > if (!rootnode) > { > return -1; > } > > viewer->initPerspective(); //initialize the perspective > viewer->startDataTransfer(); > > viewer->setCamera(osg::Vec3(0,0,1),osg::Vec3(0,1,0),osg::Vec3(-1,0,0),osg::Vec3(0,0,1)); > > while( !viewer->done() ) > { > viewer->frame(); > } > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=35932#35932 > > > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

