Hi,

So I am trying to create a mini-map/PIP. I have an existing program with scene 
that runs inside a Qt Widget. I have a class, NetworkViewer, which extends 
CompositeViewer. In NetworkViewer's constructor I call the following function. 
Notice the root is the scene which is populated elsewhere.


Code:

void NetworkViewer::init() {
  root = new osg::Group() ;

  viewer = new osgViewer::View( );
  viewer->setSceneData( root ) ;

  osg::Camera* camera ;
  camera = createCamera(0,0,100,100) ;
  viewer->setCamera( camera );
  viewer->addEventHandler( new NetworkGUIHandler( (GUI*)view ) ) ;
  viewer->setCameraManipulator(new osgGA::TrackballManipulator) ;
  viewer->getCamera()->setClearColor(
    osg::Vec4( LIGHT_CLOUD_BLUE_F,0.0f));
  addView( viewer );

  osgQt::GraphicsWindowQt* gw =
    dynamic_cast<osgQt::GraphicsWindowQt*>( camera->getGraphicsContext() );
  QWidget* widget = gw ? gw->getGLWidget() : NULL;

  QGridLayout* grid = new QGridLayout( ) ;
  grid->addWidget( widget );
  grid->setSpacing(1);
  grid->setMargin(1);
  setLayout( grid );

  initHUD( ) ;
}





The create camera function is as follows:


Code:
osg::Camera* createCamera( int x, int y, int w, int h ) {
  osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
  osg::ref_ptr<osg::GraphicsContext::Traits> traits
    = new osg::GraphicsContext::Traits;
  traits->windowName = "" ;
  traits->windowDecoration = false ;
  traits->x = x;
  traits->y = y;
  traits->width = w;
  traits->height = h;
  traits->doubleBuffer = true;
  traits->alpha = ds->getMinimumNumAlphaBits();
  traits->stencil = ds->getMinimumNumStencilBits();
  traits->sampleBuffers = ds->getMultiSamples();
  traits->samples = ds->getNumMultiSamples();

  osg::ref_ptr<osg::Camera> camera = new osg::Camera;
  camera->setGraphicsContext( new osgQt::GraphicsWindowQt(traits.get()) );

  camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) );
  camera->setViewMatrix(osg::Matrix::translate(-10.0f,-10.0f,-30.0f));
  camera->setProjectionMatrixAsPerspective(
    20.0f,
    static_cast<double>(traits->width)/static_cast<double>(traits->height),
    1.0f, 10000.0f );
  return camera.release();
}




I have been looking at several camera examples and searching for a solution for 
a while to no avail. What I am really looking for is the background being my 
main camera which takes up most of the screen and displays the scene graph 
while my mini-map appears in the bottom right. It has the same scene as the 
main camera but is overlaid on top of it and has its own set of controls for 
selection etc since it will have different functionality. 

I was thinking that perhaps by adding another camera as a slave I would be able 
to do this:


Code:
  camera = createCamera(40,40,50,50) ;
  viewer->addSlave(camera) ;



But this doesn't seem to work. If I disable the other camera I do see a clear 
area that it appears this camera was suppose to be rendering in (its viewport) 
but that doesn't help. I've played around with rendering order thinking it 
could be that to no avail. 

Any ideas? What it the best way to do such a minimap is? What am I doing wrong? 
Also anyway to make the rendering of the minimap circular instead of 
rectangular?

Thanks,
David

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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to