Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-17 Thread Glenn Waldron
On Tue, Jun 17, 2008 at 9:08 AM, Paul Martz <[EMAIL PROTECTED]> wrote:

> As others have mentioned, the DatabasePager might help, but the loading and
> unloading of models is controlled entirely by LOD logic (eye distance or
> pixel size) rather than your own logic. Below, you did not state that you
> wanted to load the models based on LOD logic.
>
> If you simply want to spawn a thread to load a model, I'm not sure OSG
> supports this -- Robert? Is there a built-in mechanism in OSG to load a
> model in an offline thread?


Can't you just use ProxyNode for this?
Glenn


-- 
Glenn Waldron : Pelican Mapping : http://pelicanmapping.com : 703-652-4791
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-17 Thread Paul Martz
As others have mentioned, the DatabasePager might help, but the loading and
unloading of models is controlled entirely by LOD logic (eye distance or
pixel size) rather than your own logic. Below, you did not state that you
wanted to load the models based on LOD logic.

If you simply want to spawn a thread to load a model, I'm not sure OSG
supports this -- Robert? Is there a built-in mechanism in OSG to load a
model in an offline thread? If not, it'd be straightforward to implement
this, and then you would use an update callback to attach the loaded model
to your scene graph. While the update callback does block the rendering
thread, the only work here would be a pointer assignment and bounds
recomputation -- a price you'll have to pay regardless of how you perform
this operation.
   -Paul

> 
> Thanks for your replies!
> 
> In my self-made thread I'm loading large 3d models and 
> attaching them as PATs to the scene graph (or removing them). 
> If I do this in the main loop, the loading process is 
> interrupting the image generation. That's why I created the 
> thread and so I need a sync so that the scene graph isn't 
> modified during cull and draw phase or the program will crash.
> 
> After the replies I think the best way for me is using the 
> mutex. I guess the UpdateCallback interrupts the image 
> generation, too (don't tested yet). I will also look into 
> osgterrain's multi-threaded code, may be I'll get some 
> further ideas...

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-17 Thread Robert Osfield
HI Andreas,

As Serge suggested, it might just be far more productive to use the
OSG's built in database paging support.  All you need to do is
decorate your subgraphs with a osg::PagedLOD or osg::ProxyNode, with
osg::PagedLOD being the method of choice as it'll do load balancing
for you - both loading new tiles on demand and deleting ones that are
no longer required, all automatically done by
osgDB::DatabasePager/osgViewer.

Robert.

On Tue, Jun 17, 2008 at 7:51 AM,  <[EMAIL PROTECTED]> wrote:
> Thanks for your replies!
>
> In my self-made thread I'm loading large 3d models and attaching them as PATs 
> to the scene graph (or removing them). If I do this in the main loop, the 
> loading process is interrupting the image generation. That's why I created 
> the thread and so I need a sync so that the scene graph isn't modified during 
> cull and draw phase or the program will crash.
>
> After the replies I think the best way for me is using the mutex. I guess the 
> UpdateCallback interrupts the image generation, too (don't tested yet). I 
> will also look into osgterrain's multi-threaded code, may be I'll get some 
> further ideas...
> --
> Andreas Richter
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-17 Thread Serge Lages
Did you looked at the DatabasePager ? It's made to load and unload models in
a separated thread and merge them to the scenegraph.

Take a look at osgDB::DatabasePager and osg::PagedLOD.

On Tue, Jun 17, 2008 at 8:51 AM, <[EMAIL PROTECTED]> wrote:

> Thanks for your replies!
>
> In my self-made thread I'm loading large 3d models and attaching them as
> PATs to the scene graph (or removing them). If I do this in the main loop,
> the loading process is interrupting the image generation. That's why I
> created the thread and so I need a sync so that the scene graph isn't
> modified during cull and draw phase or the program will crash.
>
> After the replies I think the best way for me is using the mutex. I guess
> the UpdateCallback interrupts the image generation, too (don't tested yet).
> I will also look into osgterrain's multi-threaded code, may be I'll get some
> further ideas...
> --
> Andreas Richter
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Serge Lages
http://www.tharsis-software.com
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-17 Thread Andreas.Richter
Thanks for your replies!

In my self-made thread I'm loading large 3d models and attaching them as PATs 
to the scene graph (or removing them). If I do this in the main loop, the 
loading process is interrupting the image generation. That's why I created the 
thread and so I need a sync so that the scene graph isn't modified during cull 
and draw phase or the program will crash.

After the replies I think the best way for me is using the mutex. I guess the 
UpdateCallback interrupts the image generation, too (don't tested yet). I will 
also look into osgterrain's multi-threaded code, may be I'll get some further 
ideas...
--  
Andreas Richter
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-16 Thread Robert Osfield
On Mon, Jun 16, 2008 at 3:33 PM, Paul Martz <[EMAIL PROTECTED]> wrote:
> As an example, you could use a Barrier in conjunction with a Camera
> post-draw callback. (Of course, that assumes you want to sync after the draw
> occurs; you didn't say where you want to sync, so I don't know...)

If you want to use barriers then you'd really need to use two, perhaps more.

Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-16 Thread Thrall, Bryan
[EMAIL PROTECTED] wrote on Monday, June 16, 2008 8:56 AM:
> Hello everybody!
> 
> I have an application using the osgViewer::Viewer (OSG 2.4) and a
> self-made thread, that has to modify the scene graph. To get no
> conflict I'm using a self made mutex to lock the add/remove and frame
> function calls.   
> 
> Now I want to know, if there is a built-in functionality to
> synchronize my thread with the OSG cull and draw threads so that I
> don't need the mutex anymore. I tried find hints in the wiki and the
> mailing list but did not find anything tangible. Can anybody give me
> an advice? Looking forward to hear from you!   

It should be safe to modify the scene graph from an UpdateCallback. If
you are modifying Drawables (adding/removing/changing geometry), you
should mark them DYNAMIC.

-- 
Bryan Thrall
FlightSafety International
[EMAIL PROTECTED]
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-16 Thread Robert Osfield
Hi Andreas,

Either put a mutex to do the sync before the call to
renderingTraversals() yourself or use a custom osg::Operation and
attach it to the viewer via viewer.addUpdateOpeation(). For the later
see the osgterrain's multi-threaded code path.

Robert.


On Mon, Jun 16, 2008 at 2:55 PM,  <[EMAIL PROTECTED]> wrote:
> Hello everybody!
>
> I have an application using the osgViewer::Viewer (OSG 2.4) and a self-made 
> thread, that has to modify the scene graph. To get no conflict I'm using a 
> self made mutex to lock the add/remove and frame function calls.
>
> Now I want to know, if there is a built-in functionality to synchronize my 
> thread with the OSG cull and draw threads so that I don't need the mutex 
> anymore. I tried find hints in the wiki and the mailing list but did not find 
> anything tangible.
> Can anybody give me an advice? Looking forward to hear from you!
> --
> Andreas Richter
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How to synchronize OSG and self-made threads?

2008-06-16 Thread Paul Martz
As an example, you could use a Barrier in conjunction with a Camera
post-draw callback. (Of course, that assumes you want to sync after the draw
occurs; you didn't say where you want to sync, so I don't know...)
   -Paul


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf 
> Of [EMAIL PROTECTED]
> Sent: Monday, June 16, 2008 7:56 AM
> To: osg-users@lists.openscenegraph.org
> Subject: [osg-users] How to synchronize OSG and self-made threads?
> 
> Hello everybody!
> 
> I have an application using the osgViewer::Viewer (OSG 2.4) 
> and a self-made thread, that has to modify the scene graph. 
> To get no conflict I'm using a self made mutex to lock the 
> add/remove and frame function calls.
> 
> Now I want to know, if there is a built-in functionality to 
> synchronize my thread with the OSG cull and draw threads so 
> that I don't need the mutex anymore. I tried find hints in 
> the wiki and the mailing list but did not find anything tangible.
> Can anybody give me an advice? Looking forward to hear from you!
> --
> Andreas Richter
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-opensce
negraph.org

___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org