Hi Renan,
The answer to your problem can be found in the implementation of the
getViewMatrixAsLookAt(), note the last optional parameter.
/** Get to the position and orientation of a modelview matrix,
using the same convention as gluLookAt. */
void getViewMatrixAsLookAt(osg::Vec3d& eye,osg::Vec3d&
center,osg::Vec3d& up,double lookDistance=1.0);
Basically what the problem boils down to is that a view matrix doesn't
have enough information to recover all the look at parameters that
your input. It can recover the eye and up vectors accurately, but not
the center as the conversion to a matrix looses everything by the
direction vector between the eye and center. This is where
lookDistance comes in, if you provide the original lookDistance then
the method can compute the eye, up, and look direction, then using the
lookDistance compute the center.
Robert.
On Mon, Oct 27, 2008 at 1:46 PM, Renan Mendes <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am using these two methods: setViewMatrixAsLookAt(eye, center, up)
> and getViewMatrixAsLookAt(&eye, ¢er, &up) with the viewer's camera in
> this order and WITHOUT manipulating the camera elsewhere in my code. I don't
> have much experience with OSG but isn't the last method supposed to return
> in the eye, center and up objects the same parameters that I have used to
> set the view matrix before? I've made a simple test:
>
> viewer.getCamera()->setViewMatrixAsLookAt(osg::Vec3f(10., -10., 2.),
> osg::Vec3f(0., 0., 0.), osg::Z_AXIS);
>
> osg::Vec3f eye;
> osg::Vec3f center;
> osg::Vec3f up;
> viewer.getCamera()->getViewMatrixAsLookAt(eye, center, up);
>
> cout << "eye " << eye.x() << " " << eye.y() << " " << eye.z() << endl;
> cout << "center " << center.x() << " " << center.y() << " " <<
> center.z() << endl;
> cout << "up " << up.x() << " " << up.y() << " " << up.z() << endl;
>
> And what I've got from the cout's was:
>
> eye: 10 -10 2 (OK)
> center: 9.29986 -9.29986 1.85997
> up: -0.0990148 0.0990148 0.990148
>
> What am I doing wrong here? Did I misunderstand the purpose of the
> method?
>
> Renan M Z Mendes
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org