Hi Juan,

You need to stop threading before you remove or add views to a
CompositeViewer.  i.e.

    viewer.stopThreading();
    viewer.addView(view);
    viewer.startThreading();

The other thing you can do is toggle the cameras associated with the
view off by setting their  NodeMask to 0x0/0xffffffff to be off/on
respectively.

Robert.

On Fri, May 30, 2008 at 8:07 AM, Juan Casanueva <[EMAIL PROTECTED]> wrote:
> Hi,
> I am new to osg, so I apologise if this question seems trivial. I have
> looked through the examples and documentation with no luck.
>
> I am using a composite viewer, and have two views.
> I want to be able to let the user disable and enable one of the views
> using the keyboard keys.
>
> I have something like this:
>
> osgViewer::CompositeViewer viewer(arguments);
>
> // view one
> osgViewer::View* viewOne = new osgViewer::View;
> viewer.addView(viewOne);
> viewOne->setSceneData(scene.get());
> viewOne->getCamera()->setViewport(new osg::Viewport(0,0,
> traits->width/2, traits->height/2));
> viewOne->getCamera()->setGraphicsContext(gc.get());
>
> // view two
> osgViewer::View* viewTwo = new osgViewer::View;
> viewer.addView(viewTwo);
> viewTwo->setSceneData(scene.get());
> viewTwo->getCamera()->setViewport(new osg::Viewport(traits->width/2,0,
> traits->width/2, traits->height/2));
> viewTwo->getCamera()->setGraphicsContext(gc.get());
>
>
> So, when the user presses the "d" key, I want to disable view two, and
> when the user presses the "e" key, I want to enable back view two.
> I thought that just removing the view from the viewer should do it,
> i.e. something like:
>
> void disable()
> {
>  viewer.removeView(viewTwo));
> }
>
> void enable()
> {
>  viewer.addView(viewTwo);
> }
>
> but osg crashes when I disable the view. It looks like viewerTwo's
> camera is still on the GraphicsContext list of cameras?
>
> How does one disable/enable a view on the composite viewer?
>
> Thanks
> Juan
>
> _______________________________________________
> 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

Reply via email to