The Camera's View matrix contains the eye position, if that's what
you're trying to obtain:
osg::Matrix m( getCamera()->getViewMatrix() );
osg::Vec3 eye( m(3,0), m(3,1), m(3.2) );
(OK, I might have row versus column order messed up, so swap the row and
column parameters if needed.)
-Paul
Volker Poplawski wrote:
Hi everyone.
I'm trying to calculate the line-of-sight line in world space, which involves
mapping from window space. My approach works in principal,
however the resulting positions are allways off by a small amount.
Inside a osg::View I have:
Matrixd m;
m.preMult(getCamera()->getViewport()->computeWindowMatrix());
m.preMult(getCamera()->getProjectionMatrix());
m.preMult(getCamera()->getViewMatrix());
Matrixd inv;
inv.invert(m);
For example: I exspect
Vec3d( winWidth/2, winHeight/2, 0.0 ) * inv ;
to yield the camera/eye position. However the x,y,z coords differ in about
0.5% from the eyepos of getCamera()->getViewMatrixAsLookAt(). (Unless the
camera is positioned in world origin)
Do I miss something?
Regards
......Volker
_______________________________________________
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