Hi,
more or less I have the same problem as Matteo ;)
Robert Osfield schrieb:
Hi Matteo,
A couple of methods of interest - Camera manipulators have a
setHomePosition(..) method on them. So set it like:
viewer->getCameraManipulator()->setHomePosition(...);
when I use this, my program crashes directly. Do I have to include
something important?
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(..);
for me this function not exists. Perhaps you meant
setViewMatrixAsLookAt? When I use this, nothing changes for me. My
camera is still the normal viewer camera position. I tried this with
osg::ref_ptr< osg::Camera > lightCam = viewer.getCamera();
lightCam->setViewMatrixAsLookAt( lightPosIn, osg::Vec3( 0.f, 0.f, 0.f ),
osg::Vec3( 0.f, 0.f, 1.f ) );
BTW: the sullivans osg tutorial page (
http://www.nps.navy.mil/cs/sullivan/osgtutorials/ ) seems to be down!
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/
--
----------------------------------------------------------------
Marcus Fritzen E-mail: [EMAIL PROTECTED]
University Koblenz Mobil: +491786867360
Triererstr. 105, 56072 Koblenz,
HIWI FB4 Herr Jackel
----------------------------------------------------------------
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/