Hi Thomas,

Il 6/11/2010 3:45 AM, Thomas Canipel ha scritto:
its normal that when you set an osg::Group as the SceneData that when you add a 
child the viewer is notify and update the graphic, imaging that you have to 
create 1000 of objects, if you have to recreate a  a root and set it to the 
viewer each time its a pain...

Well, that's clear of course ;)

,  for the detail you can lok the function insertCHild() of osg::Group , you 
will see that there is a a call to a callback to traverse the new scene updated.

OK, a sort of Observer pattern then.

  THe problem you get with the manipulator is pretty odd , can you give more 
detail ?

Basically that's the real problem I'm experiencing. To reproduce it, I just modified a little bit the "example_osgviewerQT" shipped with the osg distribution. That example uses osgDB::readNodeFiles to load a node from file (and it works correctly). Then the original code simply does as follows:

      ViewerQT* viewer = new ViewerQT;
      viewer->setCameraManipulator(new osgGA::TrackballManipulator);
*      viewer->setSceneData(loadedModel.get());
*
I modified that lines with the following code:

      ViewerQT* viewer = new ViewerQT;
      viewer->setCameraManipulator(new osgGA::TrackballManipulator);
*      osg::ref_ptr<osg::Group> root = new osg::Group;
      viewer->setSceneData(root);
      root->addChild(loadedModel.get());
*
As you can see I simply created a Group node, set it as the scene data of the viewer and then added the loaded node to the Group.

With this code I can see two problems. First of all the loaded object is not fitted in the viewer. Then using the mouse to rotate (leftmouse+move), translate (middle mouse+move) or zoom (right mouse+move), I just can see the effect of rotation, while the loaded objet does not move in the viewer in the other two cases.

On the contrary if I use a slightly different code

      ViewerQT* viewer = new ViewerQT;
      viewer->setCameraManipulator(new osgGA::TrackballManipulator);
      osg::ref_ptr<osg::Group> root = new osg::Group;
*      root->addChild(loadedModel.get());
      viewer->setSceneData(root);
*
all works fine but of course I cannot set manually the scene data to a viewer each time an object is added to the scene, right? Can somebody help me please?


Regards
Gianni


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

Reply via email to