Hi Matteo,
A couple of methods of interest - Camera manipulators have a
setHomePosition(..) method on them. So set it like:
viewer->getCameraManipulator()->setHomePosition(...);
You can reset the viewer to the home position vai:
viewer->home();
In cases where you don't use a camera manipulator and want to set the
camera directly you can do so via:
viewer->getCamera()->setProjectionMatrixAsLookAt(..);
Note, many methods in SceneView that'll you'll be used to are
available on Viewer or Camera.
On 6/20/07, Matteo Campana <[EMAIL PROTECTED]> 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/