[osg-users] Deferring loading in an DB ReaderWriter plugin

Robert Osfield robert.osfield at gmail.com
Sat Nov 19 04:03:12 PST 2016

Hi James,

I'm afraid this particular usage case isn't common enough to have
support directly in the core OSG.

You can probably leverage existing component to get some way to doing
what you want.

The first issue is that most plugins are self contained, you just give
them a file to load and then go off and load it and then return it,
without any interaction during the loading process.

A subset of the plugins support reading from ostream rather than just
only files, in which case there is the possibility to implement your
own streambuffer based ostream that you manage the loading, this might
give you the load level ability to manage the loading process.  If you
want to add in internet access into the mix then you'd need to use
something like libcurl in a similar fashion to how the OSG's libcurl
plugin implements things - it utilizes the streambuffer approach.

At a high level the OSG has a ProxyNode class that can be used as a
placeholder as it has a filename handle.  Perhaps you could write your
own osgDB::ReadFileCallback that you assign to the osgDB::Registry to
intercept all read calls and then pass back a ProxyNode when you want
pause loading.

To get things working well I think it'll require a bit of very careful
desgin/implementation to make sure that threading works reliably and
the state of the scene graph is managed robustly.


On 18 November 2016 at 20:02, James Turner <zakalawe at mac.com> wrote:
> Hi,
> I’m looking for some advice on deferring / stalling a DB read request for a period of time and then resuming it. (Or some equivalent) This is for a download-on-demand thing - inside the readNode() implementation I can detect that a given set of files needs to be downloaded, which may take many seconds depending on the user’s Internet connection. The download system is already separately threaded, but I need a way to suspend the request (or simulate the same) and then resume it / resubmit it.
> I can imagine various solutions, eg returning a placeholder node and then when my download completes, re-running the load but passing in some special info including the placeholder as the parent. But I can also guess that this scenario is common enough to have some more explicit support in osgDB.
> I can also imagine the Pager / Database ’s internal load queue must basically do what I need, if I could manipulate it directly. (Cancel the current item, stash it somewhere and resubmit when some condition occurs) But I’ve not seen any examples of doing that (I am going to look for them now).
> So, any advice or thoughts are much appreciated.
> Kind regards,
> James
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

More information about the osg-users mailing list