Hi robert,

Views and HUD camera creation orders are as follows:
1- create main view. ( No overlays. just terrain and objects on terrain )


Code:

osgViewer::View* MyOsgQtGlCompositeViewer::createCompositeView( Group* pScene, 
bool bMainView /*= true*/, osg::Node* pNode /*= NULL*/ )
{
    osgViewer::View* pNewView = new osgViewer::View;
    pNewView = new osgViewer::View;
    pNewView->getCamera()->setGraphicsContext(this->getGraphicsWindow());
    pNewView->getCamera()->setProjectionMatrixAsPerspective(45.0f, 
        static_cast<double>(m_uiWidth)/static_cast<double>(m_uiHeight), 1.0, 
200000.0);

    if(bMainView)
    {
        pNewView->getCamera()->setViewport(new osg::Viewport(m_uiX, m_uiY, 
m_uiWidth, m_uiHeight));
     }
    else
    {
        m_uiX = m_uiWidth / 4;
        m_uiY = m_uiHeight / 3;
        unsigned int uiPortX = m_uiWidth-m_uiX;
        unsigned int uiPortY = m_uiHeight-(m_iZoomViewNum * m_uiY);
        pNewView->getCamera()->setViewport(new osg::Viewport(uiPortX, uiPortY, 
m_uiX, m_uiY));
    }

    pNewView->setSceneData(pScene); [b]// pScene is the Root group node.[/b]
    addView(pNewView);
    return pNewView;
}



2- create HUD cameras and display Ortographic overlay at top left side of main 
view when user picks an object on terrain. Multiple cameras are created and can 
be added to root object. Root object is where main camera and other views 
camera's starts to render. 


Code:
      void createHudInfo()
      {
          m_pCameraHUD = createHudInfoCamera(pSceneManager->get3DViewPort());
          pSceneManager->getRoot()->addChild(m_pCameraHUD);
      }





Code:
    osg::Camera* createHudInfoCamera(Viewport* pViewPort)
    {
        osg::ref_ptr<osg::Camera> camera = new osg::Camera;
        camera->setProjectionMatrix(osg::Matrix::ortho2D(int(pViewPort->x()), 
            int(pViewPort->width()), int(pViewPort->y()), 
int(pViewPort->height())));
        m_position.set(0, 280, 0);
        camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
        camera->setViewMatrix(osg::Matrix::identity());
        camera->setClearMask(GL_DEPTH_BUFFER_BIT);
        camera->setRenderOrder([b]osg::Camera::POST_RENDER[/b]);
        camera->setAllowEventFocus(false);
        camera->getOrCreateStateSet()->setMode(GL_LIGHTING, 
osg::StateAttribute::OFF);
        return camera.release();
    }



3- create a view when user wants to node track a flying object. At that time, a 
view is created at right top side of window. 2D ortographic overlay is being 
displayed on that view too. This is not a surprise becouse last view created 
renders same root which main view is set to render. So all overlays is also 
displayed on small views.


Code:

void MySceneManager::createMy3dViewPort( )
{
        osgViewer::View* pItesView = NULL;
        pItesView = 
m_pMyOsgCompositeViewer->[b]createCompositeView[/b](m_pOsgRoot, false, NULL);
        
pItesView->getCamera()->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT);

}



According to your comments where should i use 
camera->SetRenderOrder(..) ?
in small view's camera?

HUD camera is set to POST_RENDER to make itself render over 2D display. But i 
don't use any render order for small views created whenever user clicks an 
aircraft and requests a custom view. i can't put a screen shot becouse code is 
classified. But screen is like when an osg user clicks 'S' sequentially and 
Statistics overlays appear on top left side. Consider that all stats overlays 
appear on main view also appears on custom small views on top right side.

Thank you!

Regards..
Atilla

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





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to