[osg-users] CompositeViewer with multiple view, and scene management

Julien Achard achard.ju at gmail.com
Tue Aug 28 06:15:22 PDT 2018


Hi All,

I'm struggling with the composite viewer and closing views.

What i need to do :
I have an application that simulate moving planes. I need to allow user to open window(s) on one or more selected plane(s), on demand. The views are camera at the plane position to display the pilot point of view.
So basically, i need a unique scene, with multiple cameras to render differents point of view on this scene in separate windows.
Add / Remove view on the fly.
Update of the scene node position on the fly (planes positions managed by the application).

What i tried :
Creation of a composite viewer, and two views, each one with the same sceneData.
Added the two views to the compositeViewer.
In the run function of a thread class (to avoid blocking my main application), i made a loop to first update my nodes, and then call frame on the composite viewer.

My problem is when i clic on close of one of the view, it is not closed, the refresh in it stops, then i need to clic again to close it. Sometimes i need to clic 3 times.
(on the first clic on close of the last view remaining, the compositeViewer considers he is done, and my thread leave the run loop even if the last view is not totally closed)

Is this the proper way to update the scene nodes during runtime ?

I use OSG 3.6.2 build from source, VS2013, Windows 7.


Code:

MyThread::MyThread() : ost::Thread(),
   m_pCompositeViewer(new osgViewer::CompositeViewer()),
   m_pRootNode(new osg::Group())
{
//...
//Some node creation in the m_pRootNode
//...

    // view one
    {
        osgViewer::View* view = new osgViewer::View;
        view->setName("View one");
        m_pCompositeViewer->addView(view);

        view->setUpViewInWindow(0, 100, 800, 600);
        view->setSceneData(m_pRootNode);
    }

    // view two
    {
        osgViewer::View* view = new osgViewer::View;
        view->setName("View two");
        m_pCompositeViewer->addView(view);

        view->setUpViewInWindow(1000, 100, 800, 600);
        view->setSceneData(m_pRootNode);
    }
}

void MyThread::run()
{
    m_pCompositeViewer->realize();
    while (!m_pCompositeViewer->done())
    {
// ...
// Some update on the nodes of my scene
// ...
        m_pCompositeViewer->frame();        
    }
}



... 

Thank you!

Cheers,
Julien

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=74613#74613







More information about the osg-users mailing list