[osg-users] [forum] add/remove nodes when rendering

Robert Osfield robert.osfield at gmail.com
Tue Apr 14 01:35:07 PDT 2015


Hi Sophie,

Are you simply looking to load databases in a background thread whilst the
main thread and rendering threads get on with update, culling and rendering
the scene?

The OSG has an database paging class call osgDB::DatabasePager that is
built into the osgViewer::Viewer/CompositeViewer that will automatically
load databases and merge them with the main scene graph during the update
traversal.  This is built around the osg::PagedLOD class, but you can also
use the osg::ProxyNode.

Robert.


On 14 April 2015 at 08:57, Sophie Audonneau <
sophie.audonneau1 at etu.univ-lorraine.fr> wrote:

> Hi,
>
> I work on a project for witch I need to remove/add nodes while
> OpenSceneGraph is rendering.
> I created a rendering window with OpenScenegraph and then I would like to
> be able to load/unload objects in it.
> I make the calls for OSG frame() function inside a draw function and I use
> a singleton to manage the creation of the viewer. That way I managed to
> have a single viewer and then load my OpenSceneGraph objects inside that
> same viewer.
> It seems fine but the problem is that I have to set camera and viewer
> parameters each time I call frame(). If I don't nothing is displayed,
> except OSG font colour.
> Ideally I would like to set the viewer parameters only when I load an OSG
> object for the first time.
>
> Currently when I load an OSG object I use my singleton to find the viewer
> and to add the loaded node to the root associated to my viewer.
> instance()->find_or_create_viewer(); //creates a viewer if none have been
> created yet
> instance()->addChild(loadedNode);
> viewer_ = instance()->viewer(); // return a pointer to the unique
> osgViewer::Viewer
>
> In my draw function I have to do the following :
> viewer_->setUpViewerAsEmbeddedInWindow(viewParams[0],viewParams[1],viewParams[2]
> ,viewParams[3]);
> viewer_->getCamera()->setProjectionMatrix( osg::Matrix(glMat_projection) );
> viewer_->getCamera()->setViewMatrix( osg::Matrix(glMat_modelview) );
> viewer_->frame();
>
> I have read that for dynamical rendering there was something to do about
> object's variance so I tried a few things but I didn't find how to solve my
> problem.
>
> Thank you!
>
> Cheers,
> Sophie
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=63377#63377
>
>
>
>
>
> _______________________________________________
> 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/20150414/75682d4f/attachment-0003.htm>


More information about the osg-users mailing list