Found this recent thread on changing the camera position:

http://article.gmane.org/gmane.comp.graphics.openscenegraph.user/15567/match=change+camera+position

The solution mentionned goes like this:

-----------------------------------

From: Matteo Campana 
Subject: Re: Change camera position
Newsgroups: gmane.comp.graphics.openscenegraph.user
Date: 2007-06-21 13:50:19 GMT (9 weeks, 4 days, 19 hours and 6 minutes ago)
Thank you for reply…
..now I can change the position of the camera.

I write here how I change the position…hope it can help:

ChangePosition (osg::Node *node){
const osg::BoundingSphere& boundingSphere= node->getBound();
osg::Matrix myviewMatrix;
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);
myviewMatrix.makeLookAt(eye,center,up);
this->GetViewer()->setView(myviewMatrix);
}

Thanks!!! 

Matteo

-----------------------------------

Needless to say, it didn't work either...For starter, there's no such thing as 
osg::Viewer::setView(). I can't be the first person wanting to reset the camera 
manipulators after loading a file...

- Nick -

> 
> 
> OK,
> 
> I've tried redefining the manipulator directly and I tried with the main 
> camera. Both methods fail to actually update the trackball's center & radius.
> 
> Ex:
> 
> m_rpMainCamera->setViewMatrixAsLookAt( vnew_eye, vnew_center, vnew_up );
> 
>     or...
> 
> m_rpTerrainManipulator->setHomePosition( vnew_eye,v new_center, vnew_up ); 
> 
> What's the recommended way to do this?
> 
> Thanks,
> 
> - Nick -
> 
> > 
> > How can I make sure an object fits inside a camera view after loading a new 
> > scene. All the examples load scenes and Viewer/Camera at startup. I want to 
> > add nodes to an existing scene; not create a new one.
> > My OSG tree looks like this:
> >                                + File 1
> >                                |
> >              + Scene ----+ File 2
> >              |                |
> >              |                + File ...
> > Root ----+
> >              |
> >              + Grid
> >              |
> >              + Axis
> >              |
> >              + HUD Camera
> > (Both Root and Scene are Switch groups, so I can selectively show/hide 
> > their children)
> > The problem is that whenever I load a new file/node, it doesn't always show 
> > up on screen. My guess is that some objects are outside the view volume. I 
> > could write a simple function to update Scene's bounds and make sure they 
> > fall within the fustrum, but I'm sure there's an existing method to do 
> > this...
> > - Nick -
> 
> _________________________________________________________________
> Connect to the next generation of MSN Messenger 
> http://imagine-msn.com/messenger/launch80/default.aspx?locale=en-us&source=wlmailtagline
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to