Hi Brett, Kim,

I am actually trying the program of callback in osg quick start guide which 
rotates the cow using a node callback.

when I change code viewer.run() to while(!viewer.done())
{
        viewer.frame();
}
I am unable to see the models on the screen.What is the diffrence between the 
two??

Please check you've done viewer.realize(). viewer.run() includes realizing step.

Actually, osgViewer::ViewerBase::frame() will call realize() if it hasn't been called yet. So that's not the problem.

You can check the source code (in this case osgViewer::ViewerBase contains run() and frame() methods, and osgViewer::Viewer overrides the run() method) to see exactly what the difference is.

In your case, the difference you're seeing is simply that osgViewer::run() automatically adds an osgGA::TrackballManipulator to the viewer, while just calling viewer.frame() yourself doesn't.

  int Viewer::run()
  {
      if (!getCameraManipulator() && getCamera()->getAllowEventFocus())
      {
          setCameraManipulator(new osgGA::TrackballManipulator());
      }

      setReleaseContextAtEndOfFrameHint(false);

      return ViewerBase::run();
  }

And the TrackballManipulator centers itself on your scene's contents by default on the first frame. So the effect you're seeing is just that the camera is not pointing towards your objects in the viewer.frame() case.

You could add a TrackballManipulator (or some other subclass of osgGA::MatrixManipulator) to the viewer yourself to get the same behavior as using run(). Or you could set the camera's view matrix manually in your frame loop before viewer.frame() so that the camera is where you want it to be for your objects to be visible. It's your choice.

That's one of the nice things with OSG development... No black box. You can see what everything does and how it's done, and most of the time it's coded in a way that's understandable by mere mortals like us (as opposed to some other libraries like boost :-) ).

Hope this helps,

J-S
--
______________________________________________________
Jean-Sebastien Guay    jean-sebastien.g...@cm-labs.com
                               http://www.cm-labs.com/
                        http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to