<div dir="ltr">Hello Robert,<div><br></div><div style="">The thread is getting a little stale but shall I say not forgotten if gone. ;-y</div><div style=""><br></div><div style="">I wanted to only reply that the problem was due to the osg::camera as declared within my method from the code above as:</div><div style=""><br></div><div style=""><div style="font-size:13px"><span style="white-space:pre-wrap">    </span>// create a camera to set up the projection and model view matrices, and the subgraph to drawn in the HUD</div><div style="font-size:13px"><span style="white-space:pre-wrap">    osg::Camera* camera = new osg::Camera;</span></div><div style="font-size:13px"><span style="white-space:pre-wrap"><br></span></div><div style="font-size:13px"><span style="white-space:pre-wrap">simply needed to be declared on the heap as a member of the class and all worked perfectly fine there after. </span></div><div style="font-size:13px"><span style="white-space:pre-wrap"><br></span></div><div style="font-size:13px"><span style="white-space:pre-wrap">As a final note: I also changed the </span><span style="white-space:pre-wrap">code to use osgViewer::View for the osgViewer::CompositeViewer </span></div><div style="font-size:13px"><span style="white-space:pre-wrap">as well-- thanks very much for that guidance. All the Views were already declared as members of my class.</span></div><div style="font-size:13px"><span style="white-space:pre-wrap"><br></span></div><div style="font-size:13px"><span style="white-space:pre-wrap">-t</span></div><div style="font-size:13px"><span style="white-space:pre-wrap"><br></span></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 30, 2015 at 11:40 AM, Robert Osfield <span dir="ltr"><<a href="mailto:robert.osfield@gmail.com" target="_blank">robert.osfield@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Ted,<br><br></div>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.<br><br></div>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.<br><br></div><div>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.<br></div><div><br></div>Robert.<br><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On 30 November 2015 at 16:39, ted morris <span dir="ltr"><<a href="mailto:ted.morris@gmail.com" target="_blank">ted.morris@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><br><div>Greetings OSG'ers.</div><div><br></div><div>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. </div><div><br></div><div>It worked without a hitch  in an older version, 2.8.5 win32 of OpenSceneGraph (build with VisualStudio).</div><div><br></div><div>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.</div><div><br></div><div>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). <br></div><div><br></div><div>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</div><div>strange rendering order behavior resulted.</div><div> </div><div>Any advice or insights would be greatly appreciated,</div><div><br></div><div>thanks all,</div><div><br></div><div>ted</div><div><br></div><div><br></div><div><snip></div><div><div><span style="white-space:pre-wrap"> </span>.</div><div><span style="white-space:pre-wrap">        </span>.</div><div><span style="white-space:pre-wrap">        </span>.</div><div><span style="white-space:pre-wrap">        </span>// osgViewers decl on the heap</div><div><span style="white-space:pre-wrap">        osg::ref_ptr<osgViewer::Viewer>  m_viewer;</span></div><div><span style="white-space:pre-wrap"> </span>osg::ref_ptr<osgViewer::Viewer>  m_OVERLAYviewer;</div><div><span style="white-space:pre-wrap"> </span>osg::ref_ptr<osgViewer::CompositeViewer>  m_dualviewer;</div><div><span style="white-space:pre-wrap">   </span>osg::Camera  * m_HUDcam;<span style="white-space:pre-wrap">       </span></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>// view manipulators configured and constrained as appropriate...</div><div><span style="white-space:pre-wrap">        </span>// <-- code removed for brevity...></div><div><span style="white-space:pre-wrap">        </span>osgGA::NodeTrackerManipulator   * m_Camera_followcar;</div><div><span style="white-space:pre-wrap">   </span>osgGA::NodeTrackerManipulator::TrackerMode   m_trackerMode;</div><div><span style="white-space:pre-wrap">     </span>osgGA::NodeTrackerManipulator::RotationMode  m_rotationMode;</div><div><span style="white-space:pre-wrap">    </span>osgGA::TrackballManipulator  * m_tbm;</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">  </span>// NOTE: gw is a wxWidgets OpenGL context canvas set up earlier...</div><div><span style="white-space:pre-wrap">       </span>m_viewer->getCamera()->setGraphicsContext(gw);</div><div><span style="white-space:pre-wrap">     </span>m_viewer->getCamera()->setClearColor(osg::Vec4(153./0xff, 216./0xff, 238./0xff, 1.0));</div><div><span style="white-space:pre-wrap">     </span></div><div><span style="white-space:pre-wrap"> </span>// use CullMask to hide rendering of specific nodes in the scene</div><div><span style="white-space:pre-wrap"> </span>m_viewer->getCamera()->setCullMask(0x04); </div><div><span style="white-space:pre-wrap">        </span>m_viewer->getCamera()->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap"> </span>// create a camera to set up the projection and model view matrices, and the subgraph to drawn in the HUD</div><div><span style="white-space:pre-wrap">    osg::Camera* camera = new osg::Camera;</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    // set the projection matrix</span></div><div><span style="white-space:pre-wrap">    //camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1280,0,1024));</span></div><div><span style="white-space:pre-wrap">        </span>m_width_fraction_of_mainW  = 0.225;  // 0.25;</div><div><span style="white-space:pre-wrap">  </span>m_height_fraction_of_mainW = 0.275; //(1.0/3.0);</div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap"> </span>// ll => "lower left", ur => "upper right"</div><div><span style="white-space:pre-wrap">     </span>int xll = -(int)(m_width_fraction_of_mainW  * m_viewersize.GetX())/2;</div><div><span style="white-space:pre-wrap">   </span>int yll = -(int)(m_height_fraction_of_mainW * m_viewersize.GetY())/2;</div><div><span style="white-space:pre-wrap">    </span>int yur = -yll;</div><div><span style="white-space:pre-wrap">  </span>double left = (double)xll/(double)(yur-yll);</div><div><span style="white-space:pre-wrap">     </span>double right = -left;</div><div><span style="white-space:pre-wrap">    </span>double bottom = -0.5;</div><div><span style="white-space:pre-wrap">    </span>double top = 0.5;</div><div><span style="white-space:pre-wrap">        </span>double zfar = 13000.0; // make arbitrarily huge ... but not too big so for things like a skydome won't get clipped</div><div><span style="white-space:pre-wrap">   </span>double znear = 4.5;</div><div><span style="white-space:pre-wrap">      </span>// scale everything so clipping plane is about 0.25 meters</div><div><span style="white-space:pre-wrap">       </span>double scale_fac = 0.5/znear;</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">   </span>znear  *= scale_fac;</div><div><span style="white-space:pre-wrap">    </span>left   *= scale_fac;</div><div><span style="white-space:pre-wrap">    </span>right  *= scale_fac;</div><div><span style="white-space:pre-wrap">    </span>top    *= scale_fac;</div><div><span style="white-space:pre-wrap">   </span>bottom *= scale_fac;</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    </span>camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);</div><div><span style="white-space:pre-wrap">    // draw subgraph after main camera view.</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    // we don't want the camera to grab event focus from the viewers main camera(s).</span></div><div><span style="white-space:pre-wrap">    //camera->setAllowEventFocus(true);</span></div><div><span style="white-space:pre-wrap">    </span>camera->setAllowEventFocus(false);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">   </span>double cornerX0 = 1.0 - m_width_fraction_of_mainW;</div><div><span style="white-space:pre-wrap">       </span>double cornerY0 = 1.0 - m_height_fraction_of_mainW;</div><div><span style="white-space:pre-wrap">      </span>camera->setViewport( </div><div><span style="white-space:pre-wrap">                </span>                 (int)( cornerX0 * m_viewersize.GetX()+5 ),</div><div><span style="white-space:pre-wrap">              </span>                 (int)( cornerY0 * m_viewersize.GetY()+5 ),</div><div><span style="white-space:pre-wrap">                                              </span> (int)( m_width_fraction_of_mainW *  m_viewersize.GetX()-5 ),</div><div><span style="white-space:pre-wrap">                                           </span> (int)( m_height_fraction_of_mainW * m_viewersize.GetY()-5 ) </div><div><span style="white-space:pre-wrap">                                           </span>);</div><div><span style="white-space:pre-wrap">       </span>zfar = 10000;</div><div><span style="white-space:pre-wrap">    </span>camera->setProjectionMatrixAsFrustum(left,right, bottom, top, znear, zfar);</div><div><span style="white-space:pre-wrap">   </span>camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);</div><div><span style="white-space:pre-wrap">    </span>camera->setGraphicsContext(gw);</div><div><span style="white-space:pre-wrap">       </span>camera->setCullMask(0x02);</div><div><span style="white-space:pre-wrap">    </span>camera->setRenderOrder(osg::Camera::POST_RENDER,1);</div><div><span style="white-space:pre-wrap">   </span>// =false: we don't want the camera to grab event focus from the viewers main camera(s).</div><div><span style="white-space:pre-wrap">     </span>camera->setAllowEventFocus(true); //(false);</div><div><span style="white-space:pre-wrap">  </span>m_OVERLAYviewer->setCamera(camera);</div><div><span style="white-space:pre-wrap">   </span>m_OVERLAYviewer->getCamera()->setGraphicsContext(gw);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">     </span>// <!-- basic NodeTracker manipulator code removed for brevety... --></div><div><span style="white-space:pre-wrap">      </span>m_Camera_followcar = new osgGA::NodeTrackerManipulator;</div><div><span style="white-space:pre-wrap">  </span>.</div><div><span style="white-space:pre-wrap">        </span>.</div><div><span style="white-space:pre-wrap">        </span>.</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap"> </span>// set up the scene for the camera and camera view using the loaded scene</div><div><span style="white-space:pre-wrap">        </span>// model</div><div><span style="white-space:pre-wrap"> </span>m_OVERLAYviewer->setSceneData(themodel);</div><div><span style="white-space:pre-wrap">      </span></div><div><span style="white-space:pre-wrap"> </span>// try HUD slave cam for drawing a boarder</div><div><span style="white-space:pre-wrap">       </span>m_HUDcam = new osg::Camera;</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">     </span>//HUDcam->setProjectionMatrixAsOrtho(0.5*xll,0.5*xur,0.5*yll, 0.5*yur, -1000.0,1000.0);</div><div><span style="white-space:pre-wrap">       </span>m_HUDcam->setProjectionMatrix( osg::Matrix::ortho2D(0, m_viewersize.GetX(),0, m_viewersize.GetY()));</div><div><span style="white-space:pre-wrap">  </span>// don't let other cam influence this camera's transform view matrix    </div><div><span style="white-space:pre-wrap">    m_HUDcam->setReferenceFrame(osg::Transform::ABSOLUTE_RF);</span></div><div><span style="white-space:pre-wrap">    </span></div><div><span style="white-space:pre-wrap">    // only clear the depth buffer for HUD, so other pixels behind it don't get erased.</span></div><div><span style="white-space:pre-wrap">    m_HUDcam->setClearMask(GL_DEPTH_BUFFER_BIT);</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">       </span>// draw subgraph after main camera view.</div><div><span style="white-space:pre-wrap">    m_HUDcam->setRenderOrder(osg::Camera::POST_RENDER,0);</span></div><div><span style="white-space:pre-wrap">    </span>m_HUDcam->setAllowEventFocus(false);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap"> </span>// create the frame</div><div><span style="white-space:pre-wrap">      </span>osg::MatrixTransform * matrixtransfm = new osg::MatrixTransform;</div><div><span style="white-space:pre-wrap"> </span>matrixtransfm->setMatrix(osg::Matrix::identity());</div><div><span style="white-space:pre-wrap">    </span></div><div><span style="white-space:pre-wrap"> </span>// create the Geode (Geometry Node) to contain all our osg::Geometry objects.</div><div><span style="white-space:pre-wrap">    osg::Geode* geode = new osg::Geode();</span></div><div><span style="white-space:pre-wrap">  </span>osg::StateSet* stateset = geode->getOrCreateStateSet();</div><div><span style="white-space:pre-wrap">    stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);</span></div><div><span style="white-space:pre-wrap">       </span>matrixtransfm->addChild(geode);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">      </span>osg::ref_ptr<osg::Vec4Array> shared_colors = new osg::Vec4Array;</div><div><span style="white-space:pre-wrap">   </span>shared_colors->push_back(osg::Vec4(0.75f,0.75f,0.75f,1.0f));</div><div><span style="white-space:pre-wrap">  </span></div><div><span style="white-space:pre-wrap"> </span>// same trick for shared normal.</div><div><span style="white-space:pre-wrap">    osg::ref_ptr<osg::Vec3Array> shared_normals = new osg::Vec3Array;</span></div><div><span style="white-space:pre-wrap">    shared_normals->push_back(osg::Vec3(0.0f,-1.0f,0.0f));</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">      </span>// create POLYGON</div><div><span style="white-space:pre-wrap">        </span>{</div><div><span style="white-space:pre-wrap">        // create Geometry object to store all the vertices and lines primitive.</span></div><div><span style="white-space:pre-wrap">        osg::Geometry* polyGeom = new osg::Geometry();</span></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        // this time we'll a C arrays to initialize the vertices.</span></div><div><span style="white-space:pre-wrap">        // note, anticlockwise ordering.</span></div><div><span style="white-space:pre-wrap">        // note II, OpenGL polygons must be convex plan polygons, otherwise </span></div><div><span style="white-space:pre-wrap">        // undefined results will occur.  If you have concave polygons or ones</span></div><div><span style="white-space:pre-wrap">        // that cross over themselves then use the osgUtil::Tessellator to fix</span></div><div><span style="white-space:pre-wrap">        // the polygons into a set of valid polygons.</span></div><div><span style="white-space:pre-wrap">          </span>double xll =  -2.0;</div><div><span style="white-space:pre-wrap">             </span>double yll =  -2.0;</div><div><span style="white-space:pre-wrap">             </span>double xlr =  m_width_fraction_of_mainW  * m_viewersize.GetX()+2;</div><div><span style="white-space:pre-wrap">              </span>double yur =  m_height_fraction_of_mainW * m_viewersize.GetY()+2;</div><div><span style="white-space:pre-wrap">        osg::Vec3 myCoords[] =</span></div><div><span style="white-space:pre-wrap">        {</span></div><div><span style="white-space:pre-wrap">            osg::Vec3( xll,yll, 0),</span></div><div><span style="white-space:pre-wrap">            osg::Vec3( xlr, yll, 0),</span></div><div><span style="white-space:pre-wrap">            osg::Vec3( xlr, yur, 0),</span></div><div><span style="white-space:pre-wrap">            osg::Vec3(xll, yur, 0)</span></div><div><span style="white-space:pre-wrap">        };</span></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap">           </span>m_HUDxaxis = xlr - xll;</div><div><span style="white-space:pre-wrap">          </span>m_HUDyaxis = yur - yll;</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">        int numCoords = sizeof(myCoords)/sizeof(osg::Vec3);</span></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        osg::Vec3Array* vertices = new osg::Vec3Array(numCoords,myCoords);</span></div><div><span style="white-space:pre-wrap">       </span></div><div><span style="white-space:pre-wrap">        // pass the created vertex array to the points geometry object.</span></div><div><span style="white-space:pre-wrap">        polyGeom->setVertexArray(vertices);</span></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        // use the shared color array.</span></div><div><span style="white-space:pre-wrap">        polyGeom->setColorArray(shared_colors.get());</span></div><div><span style="white-space:pre-wrap">        polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL);</span></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">        // use the shared normal array.</span></div><div><span style="white-space:pre-wrap">        polyGeom->setNormalArray(shared_normals.get());</span></div><div><span style="white-space:pre-wrap">        polyGeom->setNormalBinding(osg::Geometry::BIND_OVERALL);</span></div><div><span style="white-space:pre-wrap"> </span></div><div><span style="white-space:pre-wrap">        // This time we simply use primitive, and hardwire the number of coords to use </span></div><div><span style="white-space:pre-wrap">        // since we know up front,</span></div><div><span style="white-space:pre-wrap">        polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::POLYGON,0,numCoords));</span></div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">        // add the points geometry to the geode.</span></div><div><span style="white-space:pre-wrap">        geode->addDrawable(polyGeom);</span></div><div><span style="white-space:pre-wrap">    }</span></div><div><span style="white-space:pre-wrap">   </span>matrixtransfm->setMatrix(osg::Matrix::translate(-200.0,-200.0,0.0));</div><div><span style="white-space:pre-wrap">  </span>m_HUDcam->addChild(matrixtransfm);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">   </span>m_HUDcam->setViewport(  0 ,0, m_viewersize.GetX(), m_viewersize.GetY());</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    </span>m_HUDcam->setGraphicsContext(gw);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    </span>m_viewer->addSlave(m_HUDcam, false);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap"> </span>// <!-- basic trackball manipulator code removed for brevety... --></div><div><span style="white-space:pre-wrap">        </span>m_tbm = new osgGA::TrackballManipulator;<span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap"> </span>.</div><div><span style="white-space:pre-wrap">        </span>.</div><div><span style="white-space:pre-wrap">        .</span></div><div><span style="white-space:pre-wrap">       </span>// take the loaded scene graph, "themodel" and associate with the 'main window' osgViewer</div><div><span style="white-space:pre-wrap">      </span>m_viewer->setSceneData(themodel);</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    </span>m_viewer->getCamera()->setViewport(0,0,m_viewersize.GetWidth(),m_viewersize.GetHeight());</div><div><span style="white-space:pre-wrap">  </span>m_viewer->addEventHandler(new osgViewer::StatsHandler);</div><div><span style="white-space:pre-wrap">    m_viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);</span></div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">    double zfocal = 1.5; // w.r.t normalized screen coords were min/max vertical= -0.5/+0.5</span></div><div><span style="white-space:pre-wrap">     </span>this->AdjustPerspective(zfocal);</div><div><span style="white-space:pre-wrap">      </span>int width = m_viewersize.GetWidth();</div><div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">    </span>m_dualviewer = new osgViewer::CompositeViewer;</div><div><span style="white-space:pre-wrap">   </span>m_dualviewer->addView(m_viewer);</div><div><span style="white-space:pre-wrap">      </span>m_dualviewer->addView(m_OVERLAYviewer);</div></div><div><snip></div></div>
<br></div></div>_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
<br></blockquote></div><br></div>