[osg-users] Preprocessing Viewer

Robert Osfield robert.osfield at gmail.com
Tue Aug 25 07:44:29 PDT 2015


HI Michael,

It looks like you are over complicating things - creating and destroying
views it almost certainly not the way to do it, most likely you'll want a
solution that uses an osg::Camera in the scene graph or attached as a slave
Camera that has it's RenderOrder set to PRE_RENDER.  You can use a NodeMask
or Switch to toggle on/off such Camera's so have them only rendered when
needed.  Another approach might be to use a RealizerOperation.

Could you roll back a little in your explanation of what you are trying to
achieve so we can provide advice on how best to achieve it.  Specifically,
what is that you need to do in your pre-processing?

Robert.


On 25 August 2015 at 11:59, Michael May <michael_beham at gmx.net> wrote:

> Hi,
>
> I want to add a pre-processing step for rendering several environment
> maps. The environment maps are used for rendering the scene later.
> How does it work?
>
> Using multiple (composite)viewers does not work. So, I create a view for
> preprocessing. The view is then rendered using frame().
> After render the preprocess view, I remove it and create the view for
> rendering the scene. Note, both views has several camera slaves.
>
>
> Code:
>
> //Scene Loading, creating cameras, and so on
> ...
> osg::ArgumentParser psr(&argc, argv);
> osgViewer::CompositeViewer* viewer2 = new osgViewer::CompositeViewer(psr);
>
> osgViewer::View* view2 = new osgViewer::View();
> view2->setCamera(m_camera2);
> view2->setSceneData( scene_obj);
> scene_manager->createPreprocess(graphic_context, view2); //Creates camera
> slaves for pre-processing
> viewer2->addView(view2);
> viewer2->frame();
> viewer2->removeView(view2);
>
> osgViewer::View* view = new osgViewer::View();
> view->setCamera(m_camera);
> view->setSceneData( scene_obj);
>
> scene_manager->setSlaveCameras(view, graphic_context); //creates camera
> slaves for scene rendering
>
> //Add Event Handler and so on...
> ...
>
> while(!viewer2->done())
> {
> if(!view->getCameraManipulator() &&
> view->getCamera()->getAllowEventFocus())
> view->setCameraManipulator(new osgGA::TrackballManipulator());
> viewer2->setReleaseContextAtEndOfFrameHint(false);
> if(_firstFrame)
> {
> view->init();
> if(!viewer2->isRealized())
> viewer2->realize();
>
> _firstFrame = false;
> }
>
> viewer2->advance(USE_REFERENCE_TIME);
> viewer2->eventTraversal();
> viewer2->updateTraversal();
> viewer2->renderingTraversals();
> }
>
>
>
>
>
>
> This technique works, but the frame-rate decreses dramatically.
> Does anybody have an idea?
>
> Thank you!
>
> Cheers,
> Michael
>
> I am using Osg 3.4 rc-2 with GL3.0 profile.
> Code:
>
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=64889#64889
>
>
>
>
>
> _______________________________________________
> 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/20150825/ba541b42/attachment-0003.htm>


More information about the osg-users mailing list