Cannot reuse SkyNode with different Viewers

classic Classic list List threaded Threaded
3 messages Options
ceranco ceranco
Reply | Threaded
Open this post in threaded view
|

Cannot reuse SkyNode with different Viewers

Hello,

I am working on a project were the scene graph is persistent but Viewers are created and destroyed dynamically.
I'm keeping the root node in a ref_ptr, and whenever a new Viewer is created. I set it's scene data like so:
viewer.setSceneData(root.get());

I've come across a problem when using a SkyNode in the scene graph:
On the first Viewer, things work mostly as expected (Atmosphere, Sun and Moon work, but the Stars are not showing), but from the second Viewer and onward, the Atmosphere does not work, the Sun shows as a huge white planet, but weirdly the stars become visible.

I've been able to reproduce the problem on multiple Windows 7 computers with the following code:

ref_ptr<Group> root = new Group;
auto mapNode = new MapNode;
auto skyNode = SkyNode::create(mapNode);

root->addChild(skyNode);
skyNode->addChild(mapNode);

for(int i = 0; i < 3; i++)
{
        Viewer viewer;
        viewer.setSceneData(root.get());
        viewer.setCameraManipulator(new EarthManipulator);
       
        viewer.run();
}

I'm using OpenSceneGraph 3.6.0 and osgEarth 2.9, but have reproduced this problem on osgEarth master branch.

Also, if I create two Viewers together and share the scene graph, everything works okay until one is closed and then a new Viewer opened. It seems that the problem is somehow related to the Viewer closing.

Has anyone encountered such a problem before, or has an idea?
Eran Cohen
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Cannot reuse SkyNode with different Viewers

Eran,

Re-using nodes across viewers is indeed unsupported at this time. You will need to re-create the map node each time to create a new viewer.
Glenn Waldron / Pelican Mapping
ceranco ceranco
Reply | Threaded
Open this post in threaded view
|

Re: Cannot reuse SkyNode with different Viewers

Hi Glenn,
That is very interesting, is the same also true for Views (e.g. a CompositeViewer with multiple Views of the same scene graph)?
Eran Cohen