[osg-users] Deep cloning an active root scene node

Robert Lockyer robert.lockyer at avalonholographics.com
Fri Mar 1 03:56:05 PST 2019

Thanks Robert, that's actually what I tried initially and it renders fine,
however there's a usability issue. For more background I'm rendering light
fields. In order to do this I set up an array of thousands of slightly
offset cameras in a rectangular grid pattern. Because I'm capturing so many
views when I call osgViewer::Viewer::frame() it locks the main thread and
the application becomes unresponsive for a long time.

Ideally what I'd like is for the main application to continue rendering its
single 3d view, while I render these thousands of cameras to a texture in a
background thread. I'm rendering to a texture now without issue, but what's
eluded me so far is how I can run this process without locking up the

I'd like to have a snapshot of the scene graph for this background thread
so that the user can continue to use the main 3d view while the background
thread renders a static copy of the scene graph. This is why I've been
attempting to clone the root scene node recursively and pass it to my
thread. Any concerns with that approach?


Message: 9
Date: Thu, 28 Feb 2019 18:53:19 +0000
From: Robert Osfield <robert.osfield at gmail.com>
To: OpenSceneGraph Users <osg-users at lists.openscenegraph.org>
Subject: Re: [osg-users] Deep cloning an active root scene node
        <CAFN7Y+WMmVdWhgQJsnkoPvKo9zi3mWm149mrdGMhBUHxJpLtrw at mail.gmail.com>
Content-Type: text/plain; charset="UTF-8"

Hi Rob,

The OSG is design to allow you to rendering multiple views at once,
there is no need to clone the scene graph, you simply add another View
to a CompositeView to add the extra rendering.  You can toggle
optional View's on/off as you need them.


Message: 7
Date: Thu, 28 Feb 2019 14:20:46 -0330
From: Robert Lockyer <robert.lockyer at avalonholographics.com>
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] Deep cloning an active root scene node
        <CAGUte1dn64d=pcQXMrgQTShbQqDHKmdVcpd+09czFjNqb9JfZA at mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

Hi all, my name is Rob.

I'm currently writing a plugin for an OSG based application. I effectively
want to create a snapshot of the application's scene graph state and pass
it to another thread where I can render to a texture, while the main
rendering thread continues with minimal interruption.

I'd like to do this because blocking the main thread with a
osgViewer::Viewer::frame() call causes the application to lock up and
prevents me from displaying a progress dialog. The scene I render takes a
long time because I render many camera views to a single texture.

I'm currently trying to do this:

osg::Node* sceneCopy =

Then passing this to another thread where I run:

viewer_ = new osgViewer::Viewer();

However the behavior seems inconsistent. It either dies on a null reference
inside osgEarth somewhere or it renders an empty scene. I don't think I
fully understand the threading model of OSG, I've read a bit here and
there, but I think there's a lot I'm still missing.

Is there a safe way to copy the scene data and use it to run an isolated
viewer like this in parallel? Is it even safe to run two viewers in
parallel like this at all?


Robert Lockyer
Software Developer

Office: 1-709-701-0281
Email: robert.lockyer at avalonholographics.com

_This email and any attachments are confidential and may be privileged. Any 
unauthorized use, disclosure, copying or distribution of the information 
received is prohibited. If you are not the intended recipient please 
contact the sender immediately by return email confirming that you have and 
will delete all communications related to the email and any attachments 
sent to you in error._
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20190301/61907fbe/attachment.html>

More information about the osg-users mailing list