[osg-users] MiniMap/PIP

2012-10-26 Thread David Smith
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( 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 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 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(traits->width)/static_cast(traits->height),
1.0f, 1.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


Re: [osg-users] Building a slimmed down static version of OSG

2012-06-21 Thread David Smith
Hi Preet,

Did you make any progress on this? I'm getting a similar error and I am 
stumped. I have a fedora 16 32bit machine with osg 3.0.1 where my code compiles 
fine and then I have a fedora 17 64bit machine also with osg 3.0.1 where I get 
this undefined reference.

I added a "virtual void requestRedraw(){} ;" to the GraphicsWindowEmbedded 
header file just to see what would happen and it compiles but I get a crash 
right away on an addChild in Qt land.

Thanks,
David

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





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


Re: [osg-users] OSG, QT, and QTabWidget

2012-05-12 Thread David Smith
Hi,

I have discovered this problem is not only because of the qtab but it happens 
depending on the qt layout.

I asked the question on StackOverflow, perhaps worded a little better and I 
have created a demo program to demonstrate the issue. Anyone have any ideas on 
whats wrong?
http://stackoverflow.com/questions/10560706/qt-and-osg-integration-issue-scene-graph-disappearing
http://mokon.net/ex/

Thanks,
David

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





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


[osg-users] OSG, QT, and QTabWidget

2012-05-10 Thread David Smith
Hi,

So I've had a working program that integrates OSG with QT and its been working 
nicely until today. I'm using a osgViewer and I repaint the osg graph with a 
timer which when expired does some things which possibly modify the scene graph 
and then I call the frame function. This has been working flawlessly until 
today. I added a QTabWidget to my qt code and the scene graph disappears. If I 
comment out that QTabWidget add everything comes back...

I saw this post:
  forum openscenegraph org viewtopic php?t=7239
(edited since I guess we can't post links here until two posts to prevent spam 
;-))

But I tried those changes but it doesn't work. I'm also not entirely sure I 
understand the key reasons on why those changes were needed. In fact I can 
confirm my repainting function is being called.

Any ideas what might be going wrong?

Thanks,
David

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





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


[osg-users] Drawing Line

2011-10-21 Thread David Smith
Hello,

I'm having trouble with drawing a line. 

A little background. I have a graph with vertices and edges represented in the 
boost graph library. I am using boost to find some coordinates for me to layout 
the graph graphically. For each vertex I then draw a model at its location. For 
each edge I then attempt to draw a line between the locations of the models. 
Problem is that doesn't work. The lines go from the origin to the vertices. It 
does not go from vertex to vertex. Now some code:


Code:

for ( ; it != end ; ++it ) {
 VertexID id = *it ;
 Vertex* vertex = &(*ng)[id] ;
 osg::ref_ptr cModel =
(osg::Node*)model->clone(osg::CopyOp::DEEP_COPY_NODES ) ;

 printf( "%d, x=%f, y=%f, z=%f\n", id, vertex->point[0], 0.0f, vertex->point[1] 
) ;
 osg::ref_ptr transform = new 
osg::PositionAttitudeTransform( )  ;
 transform->setPosition( osg::Vec3f( vertex->point[0], 0.0f, vertex->point[1] ) 
) ;
 transform->addChild( cModel ) ;

 root->addChild( transform ) ;
}

boost::tie( eit, eend ) = edges(*ng) ;
for( ; eit != eend ; ++eit ) {
 EdgeID ide = *eit ;
 Edge& edge = (*ng)[ide] ;
 VertexID srcId = source( ide, *ng ) ;
 VertexID dstId = target( ide, *ng ) ;
 Vertex* src = &(*ng)[srcId] ;
 Vertex* dst = &(*ng)[dstId] ;

 printf( "%d, x=%f, y=%f, z=%f\n", dstId, dst->point[0], 0.0f, dst->point[1] ) ;
 printf( "%d, x=%f, y=%f, z=%f\n", srcId, src->point[0], 0.0f, src->point[1] ) ;

 osg::Geometry* lg = new osg::Geometry( ) ;

 osg::Vec3Array* vs = new osg::Vec3Array( )  ;
 vs->push_back( osg::Vec3f( src->point[0], 0.0f, src->point[1] ) ) ;
 vs->push_back( osg::Vec3f( dst->point[0], 0.0f, dst->point[1] ) ) ;

 lg->setVertexArray( vs );

 osg::ref_ptr da = new osg::DrawArrays( 
osg::PrimitiveSet::LINES, 1, 2 ) ;
 lg->addPrimitiveSet( da ) ;
 osg::ref_ptr lgeode = new osg::Geode( ) ;

 lgeode->addDrawable( lg ) ;
 root->addChild( lgeode ) ;
}




Now consider these two vertices:
0, x=10.00, y=0.00, z=0.00
1, x=9.510565, y=0.00, z=3.090170

I add the model at each of them with a transform and then I draw a line from 
one point to another. No translations are done as seen in the code above.

So, what am I doing wrong? Do I need to draw a line and then translate it?

Thanks!

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





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