[osg-users] Camera position not resetting
robert.osfield at gmail.com
Wed Sep 26 01:07:51 PDT 2007
The viewer doens't know that you want it to update the camera position
when you add/remove elements to the scene graph. You'll need to call
home/set home on the viewer. FYI pressing ' ' simply calls home on the
camera manipulator, the viewer.home() will do the same.
On 9/26/07, Mario Valle <mvalle at cscs.ch> wrote:
> I create and display an empty scene and later add my model to it.
> It works, but the camera position is not reset after adding the model,
> so half of it lies outside the screen. Pressing space obviously reset
> the camera position and all my model appears on the screen.
> What I'm doing is:
> sceneRoot = new osg::Group;
> ... and later after some GUI selection ...
> osg::ref_ptr<osg::Group> myscene = new osg::Group;
> ... fill myscene ...
> I tried various combination of dirtyBound() and computeBound() on
> sceneRoot and myscene without success.
> Also trying to explicitly set the camera position as below seems to have
> no effect: for example I change the eye position but the scene
> looks always the same.
> const osg::BoundingSphere& boundingSphere= scene->getBound();
> osg::Vec3 eye = boundingSphere._center+osg::Vec3(0.0f, -3.5f *
> boundingSphere._radius, 0.0f);
> osg::Vec3 center = boundingSphere._center;
> osg::Vec3 up = osg::Vec3(0.0f, 0.0f, 1.0f);
> viewer->getCamera()->setViewMatrixAsLookAt(eye, center, up);
> The only thing that makes a difference is to move the
> viewer->setSceneData(sceneRoot.get()); statement after my model load,
> but this does not works if I want an empty scene that is later filled.
> The application is derived from osgviewerWX on WinXP with osg 2.1.9
> Thanks for your suggestions!
> Ing. Mario Valle
> Visualization Group | http://www.cscs.ch/~mvalle
> Swiss National Supercomputing Centre (CSCS) | Tel: +41 (91) 610.82.60
> v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
> osg-users mailing list
> osg-users at lists.openscenegraph.org
More information about the osg-users