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



---------- Initial Header -----------

>From      : [EMAIL PROTECTED]
To          : "osg users" [email protected]
Cc          :
Date      : Wed, 20 Jun 2007 16:29:35 +0200 (MEST)
Subject : Re: [osg-users] Change camera position

> Not sure if working on 2.0, but I' ve used:
>
> const osg::BoundingSphere& bs = _avatar->getBound();
> osg::Matrix myviewMatrix;
> myviewMatrix.makeLookAt(
> _curr_position + osg::Vec3(0.0,-4.0*bs.radius(),20.0f*bs.radius()),
> _curr_position,
> osg::Vec3(0.0f,0.0f,1.0f));
> _topviewCamera->setViewMatrix(myviewMatrix);
>
> To have a camera (_topviewCamera) following an object (_avatar) from
> sligtly above
>
> Hope it help
>
> Matteo Campana wrote:
>
> >Dear all...
> >I´m a new osg user and probably this is a topic yet discussed in the 
> >newsletter...I took a look in the archive but I did not solved my problem.
> >
> >I have a scene with lots of drawable...
> >I need to set the position of the camera in order to look at one single 
> >drawable....
> >as example...by a GUI I select the name of the drawable and it automatically 
> >should move to that object.
> >
> >Is there a camera function that automatically set the camera position simply 
> >passing the node of the object to be visualized?...or a sort of fly to 
> >function?
> >
> >My idea is to first get the bound of the node
> >
> >const osg::BoundingSphere& boundingSphere=animationNode->getBound();
> >
> >and then set the camera position using this bound....but...I exactly don´t 
> >know how to do that...
> >
> >This topic was discussed in the mail with title "Set camera position 
> >programatically".
> >In that mail the solution is to use this function
> >
> >osg::Camera* camera = SceneView()->getCamera();
> >camera->setLookAt( eye, center, up );
> >
> >and then  Go through all manipulators and update the camera position:
> >
> >    CameraManipList::iterator it;
> >    osgGLUT::GLUTEventAdapter ea;
> >
> >    ViewportList::iterator viewport = _viewportList.begin();
> >    for(;viewport != _viewportList.end(); viewport++) {
> >      for(it = (*viewport)._cameraManipList.begin(); it !=
> >(*viewport)._cameraManipList.end();it++) {
> >       osgGA::TrackballManipulator *tm =
> >dynamic_cast<osgGA::TrackballManipulator *>(it->get());
> >       if (tm)
> >         tm->init(ea, *this);
> >      }
> >    }
> >
> >This is exactly what I need...but the "setLookAt" method it doesn´t exist 
> >anymore in my osg version.
> >
> >How can I do that?..is this the only way?
> >
> >Thank you!!!!
> >
> >Matteo
> >
> >_______________________________________________
> >osg-users mailing list
> >[email protected]
> >http://openscenegraph.net/mailman/listinfo/osg-users
> >http://www.openscenegraph.org/
> >
> >
> >
> >
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
>
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to