Re: [osg-users] CompositeViewer Node render order problem Win32 osg 3.4
Hello Robert, The thread is getting a little stale but shall I say not forgotten if gone. ;-y I wanted to only reply that the problem was due to the osg::camera as declared within my method from the code above as: // create a camera to set up the projection and model view matrices, and the subgraph to drawn in the HUD osg::Camera* camera = new osg::Camera; simply needed to be declared on the heap as a member of the class and all worked perfectly fine there after. As a final note: I also changed the code to use osgViewer::View for the osgViewer::CompositeViewer as well-- thanks very much for that guidance. All the Views were already declared as members of my class. -t On Mon, Nov 30, 2015 at 11:40 AM, Robert Osfieldwrote: > Hi Ted, > > With a quick scan of your post I can't spot a reason for the redendering > order issue, in general I would expect that OSG-3.4 will be functioning > more correctly than OSG-2.8.x as there have been lots of improvements over > the years, sometimes fixes actually mean that something that worked by > fluke before no longer works as the OSG is actually doing what the settings > are telling it to rather than ignoring them. So spotting the undefined > elements may well be key. > > As a general note, osgViewer::CompositeViewer should have osgViewer::View > attached to it NOT osgViewer::Viewer as you are doing - it's a composite of > View's not composite of Viewer. If you look at all the OSG example they > illustrate the correct usage. It might be that this helps address the > problem you are seeing. > > If it doesn't then modifying an existing OSG example to illustrate your > usage case and share this as a complete example so that others can > reproduce the problem first hand. > > Robert. > > > On 30 November 2015 at 16:39, ted morris wrote: > >> >> Greetings OSG'ers. >> >> I have a program which utilizes CompositeViewer to render a "corner >> window" view of my scene graph, within a bigger main window view. To >> achieve a boarder effect around the corner window viewport, a HUD overlay >> used to render a grey box underneath the 2nd view corner window. >> >> It worked without a hitch in an older version, 2.8.5 win32 of >> OpenSceneGraph (build with VisualStudio). >> >> But when I recompiled the program with a later built version >> (CMake.exe/VS 2013), I get rather strange object rendering order problems >> with the objects in the same scene graph with the **2nd, corner window** >> of the osgCompositeViewer. The **first main window** renders perfectly >> fine. The essence of the code is below. A lot of extra code is used for >> determining the appropriate window and HUD boarder 'frame' dimensions and >> camera view frustums, but barring that, it is pretty straight forward and >> not much to it, I think. >> >> To simplify the code a little bit for brevity, I have the removed >> Trackball code because with much testing on various configurations this >> doesn't change the observed behavior anyway (nor does any lighting mode). >> >> I did try clone(osg::CopyOp::SHALLOW_COPY) of the entire scene graph >> model, and even re-creating parts ofit from scratch and the same >> strange rendering order behavior resulted. >> >> Any advice or insights would be greatly appreciated, >> >> thanks all, >> >> ted >> >> >> >> . >> . >> . >> // osgViewers decl on the heap >> osg::ref_ptr m_viewer; >> osg::ref_ptr m_OVERLAYviewer; >> osg::ref_ptr m_dualviewer; >> osg::Camera * m_HUDcam; >> // view manipulators configured and constrained as appropriate... >> // <-- code removed for brevity...> >> osgGA::NodeTrackerManipulator * m_Camera_followcar; >> osgGA::NodeTrackerManipulator::TrackerMode m_trackerMode; >> osgGA::NodeTrackerManipulator::RotationMode m_rotationMode; >> osgGA::TrackballManipulator * m_tbm; >> >> // NOTE: gw is a wxWidgets OpenGL context canvas set up earlier... >> m_viewer->getCamera()->setGraphicsContext(gw); >> m_viewer->getCamera()->setClearColor(osg::Vec4(153./0xff, 216./0xff, >> 238./0xff, 1.0)); >> // use CullMask to hide rendering of specific nodes in the scene >> m_viewer->getCamera()->setCullMask(0x04); >> >> m_viewer->getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); >> >> // create a camera to set up the projection and model view matrices, and >> the subgraph to drawn in the HUD >> osg::Camera* camera = new osg::Camera; >> >> // set the projection matrix >> //camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024)); >> m_width_fraction_of_mainW = 0.225; // 0.25; >> m_height_fraction_of_mainW = 0.275; //(1.0/3.0); >> // ll => "lower left", ur => "upper right" >> int xll = -(int)(m_width_fraction_of_mainW * m_viewersize.GetX())/2; >> int yll = -(int)(m_height_fraction_of_mainW * m_viewersize.GetY())/2; >> int yur = -yll; >> double left = (double)xll/(double)(yur-yll); >> double right = -left; >> double bottom = -0.5; >> double top = 0.5;
[osg-users] CompositeViewer Node render order problem Win32 osg 3.4
Greetings OSG'ers. I have a program which utilizes CompositeViewer to render a "corner window" view of my scene graph, within a bigger main window view. To achieve a boarder effect around the corner window viewport, a HUD overlay used to render a grey box underneath the 2nd view corner window. It worked without a hitch in an older version, 2.8.5 win32 of OpenSceneGraph (build with VisualStudio). But when I recompiled the program with a later built version (CMake.exe/VS 2013), I get rather strange object rendering order problems with the objects in the same scene graph with the **2nd, corner window** of the osgCompositeViewer. The **first main window** renders perfectly fine. The essence of the code is below. A lot of extra code is used for determining the appropriate window and HUD boarder 'frame' dimensions and camera view frustums, but barring that, it is pretty straight forward and not much to it, I think. To simplify the code a little bit for brevity, I have the removed Trackball code because with much testing on various configurations this doesn't change the observed behavior anyway (nor does any lighting mode). I did try clone(osg::CopyOp::SHALLOW_COPY) of the entire scene graph model, and even re-creating parts ofit from scratch and the same strange rendering order behavior resulted. Any advice or insights would be greatly appreciated, thanks all, ted . . . // osgViewers decl on the heap osg::ref_ptr m_viewer; osg::ref_ptr m_OVERLAYviewer; osg::ref_ptr m_dualviewer; osg::Camera * m_HUDcam; // view manipulators configured and constrained as appropriate... // <-- code removed for brevity...> osgGA::NodeTrackerManipulator * m_Camera_followcar; osgGA::NodeTrackerManipulator::TrackerMode m_trackerMode; osgGA::NodeTrackerManipulator::RotationMode m_rotationMode; osgGA::TrackballManipulator * m_tbm; // NOTE: gw is a wxWidgets OpenGL context canvas set up earlier... m_viewer->getCamera()->setGraphicsContext(gw); m_viewer->getCamera()->setClearColor(osg::Vec4(153./0xff, 216./0xff, 238./0xff, 1.0)); // use CullMask to hide rendering of specific nodes in the scene m_viewer->getCamera()->setCullMask(0x04); m_viewer->getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); // create a camera to set up the projection and model view matrices, and the subgraph to drawn in the HUD osg::Camera* camera = new osg::Camera; // set the projection matrix //camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024)); m_width_fraction_of_mainW = 0.225; // 0.25; m_height_fraction_of_mainW = 0.275; //(1.0/3.0); // ll => "lower left", ur => "upper right" int xll = -(int)(m_width_fraction_of_mainW * m_viewersize.GetX())/2; int yll = -(int)(m_height_fraction_of_mainW * m_viewersize.GetY())/2; int yur = -yll; double left = (double)xll/(double)(yur-yll); double right = -left; double bottom = -0.5; double top = 0.5; double zfar = 13000.0; // make arbitrarily huge ... but not too big so for things like a skydome won't get clipped double znear = 4.5; // scale everything so clipping plane is about 0.25 meters double scale_fac = 0.5/znear; znear *= scale_fac; left *= scale_fac; right *= scale_fac; top*= scale_fac; bottom *= scale_fac; camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // draw subgraph after main camera view. // we don't want the camera to grab event focus from the viewers main camera(s). //camera->setAllowEventFocus(true); camera->setAllowEventFocus(false); double cornerX0 = 1.0 - m_width_fraction_of_mainW; double cornerY0 = 1.0 - m_height_fraction_of_mainW; camera->setViewport( (int)( cornerX0 * m_viewersize.GetX()+5 ), (int)( cornerY0 * m_viewersize.GetY()+5 ), (int)( m_width_fraction_of_mainW * m_viewersize.GetX()-5 ), (int)( m_height_fraction_of_mainW * m_viewersize.GetY()-5 ) ); zfar = 1; camera->setProjectionMatrixAsFrustum(left,right, bottom, top, znear, zfar); camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); camera->setGraphicsContext(gw); camera->setCullMask(0x02); camera->setRenderOrder(osg::Camera::POST_RENDER,1); // =false: we don't want the camera to grab event focus from the viewers main camera(s). camera->setAllowEventFocus(true); //(false); m_OVERLAYviewer->setCamera(camera); m_OVERLAYviewer->getCamera()->setGraphicsContext(gw); // m_Camera_followcar = new osgGA::NodeTrackerManipulator; . . . // set up the scene for the camera and camera view using the loaded scene // model m_OVERLAYviewer->setSceneData(themodel); // try HUD slave cam for drawing a boarder m_HUDcam = new osg::Camera; //HUDcam->setProjectionMatrixAsOrtho(0.5*xll,0.5*xur,0.5*yll, 0.5*yur, -1000.0,1000.0); m_HUDcam->setProjectionMatrix( osg::Matrix::ortho2D(0, m_viewersize.GetX(),0, m_viewersize.GetY())); // don't let other cam influence this camera's transform view matrix m_HUDcam->setReferenceFrame(osg::Transform::ABSOLUTE_RF); // only clear the depth
Re: [osg-users] CompositeViewer Node render order problem Win32 osg 3.4
Hi Ted, With a quick scan of your post I can't spot a reason for the redendering order issue, in general I would expect that OSG-3.4 will be functioning more correctly than OSG-2.8.x as there have been lots of improvements over the years, sometimes fixes actually mean that something that worked by fluke before no longer works as the OSG is actually doing what the settings are telling it to rather than ignoring them. So spotting the undefined elements may well be key. As a general note, osgViewer::CompositeViewer should have osgViewer::View attached to it NOT osgViewer::Viewer as you are doing - it's a composite of View's not composite of Viewer. If you look at all the OSG example they illustrate the correct usage. It might be that this helps address the problem you are seeing. If it doesn't then modifying an existing OSG example to illustrate your usage case and share this as a complete example so that others can reproduce the problem first hand. Robert. On 30 November 2015 at 16:39, ted morriswrote: > > Greetings OSG'ers. > > I have a program which utilizes CompositeViewer to render a "corner > window" view of my scene graph, within a bigger main window view. To > achieve a boarder effect around the corner window viewport, a HUD overlay > used to render a grey box underneath the 2nd view corner window. > > It worked without a hitch in an older version, 2.8.5 win32 of > OpenSceneGraph (build with VisualStudio). > > But when I recompiled the program with a later built version (CMake.exe/VS > 2013), I get rather strange object rendering order problems with the > objects in the same scene graph with the **2nd, corner window** of the > osgCompositeViewer. The **first main window** renders perfectly fine. The > essence of the code is below. A lot of extra code is used for determining > the appropriate window and HUD boarder 'frame' dimensions and camera view > frustums, but barring that, it is pretty straight forward and not much to > it, I think. > > To simplify the code a little bit for brevity, I have the removed > Trackball code because with much testing on various configurations this > doesn't change the observed behavior anyway (nor does any lighting mode). > > I did try clone(osg::CopyOp::SHALLOW_COPY) of the entire scene graph > model, and even re-creating parts ofit from scratch and the same > strange rendering order behavior resulted. > > Any advice or insights would be greatly appreciated, > > thanks all, > > ted > > > > . > . > . > // osgViewers decl on the heap > osg::ref_ptr m_viewer; > osg::ref_ptr m_OVERLAYviewer; > osg::ref_ptr m_dualviewer; > osg::Camera * m_HUDcam; > // view manipulators configured and constrained as appropriate... > // <-- code removed for brevity...> > osgGA::NodeTrackerManipulator * m_Camera_followcar; > osgGA::NodeTrackerManipulator::TrackerMode m_trackerMode; > osgGA::NodeTrackerManipulator::RotationMode m_rotationMode; > osgGA::TrackballManipulator * m_tbm; > > // NOTE: gw is a wxWidgets OpenGL context canvas set up earlier... > m_viewer->getCamera()->setGraphicsContext(gw); > m_viewer->getCamera()->setClearColor(osg::Vec4(153./0xff, 216./0xff, > 238./0xff, 1.0)); > // use CullMask to hide rendering of specific nodes in the scene > m_viewer->getCamera()->setCullMask(0x04); > > m_viewer->getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); > > // create a camera to set up the projection and model view matrices, and > the subgraph to drawn in the HUD > osg::Camera* camera = new osg::Camera; > > // set the projection matrix > //camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024)); > m_width_fraction_of_mainW = 0.225; // 0.25; > m_height_fraction_of_mainW = 0.275; //(1.0/3.0); > // ll => "lower left", ur => "upper right" > int xll = -(int)(m_width_fraction_of_mainW * m_viewersize.GetX())/2; > int yll = -(int)(m_height_fraction_of_mainW * m_viewersize.GetY())/2; > int yur = -yll; > double left = (double)xll/(double)(yur-yll); > double right = -left; > double bottom = -0.5; > double top = 0.5; > double zfar = 13000.0; // make arbitrarily huge ... but not too big so for > things like a skydome won't get clipped > double znear = 4.5; > // scale everything so clipping plane is about 0.25 meters > double scale_fac = 0.5/znear; > > znear *= scale_fac; > left *= scale_fac; > right *= scale_fac; > top*= scale_fac; > bottom *= scale_fac; > > camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); > // draw subgraph after main camera view. > > // we don't want the camera to grab event focus from the viewers main > camera(s). > //camera->setAllowEventFocus(true); > camera->setAllowEventFocus(false); > > double cornerX0 = 1.0 - m_width_fraction_of_mainW; > double cornerY0 = 1.0 - m_height_fraction_of_mainW; > camera->setViewport( > (int)( cornerX0 * m_viewersize.GetX()+5 ), > (int)( cornerY0 * m_viewersize.GetY()+5 ), >