Hi all,

I'm trying to simply project any 3D point ,which is already in world space,
into screen space.

I know how to do it without osg :
screen space coords = bias matrix * camera projection matrix * camera view
matrix * world space coordinates
Those coordinates are in [0, 1] range, so multiply by viewport dimensions to
get window coordinates.

but i do not succeed doing it with osg because i m still not familiar with
it...
My current code is

*   osg::Camera * cam = _view->getCamera();
   osg::Matrix viewMatrix = cam->getViewMatrix();
   osg::Matrix projectionMatrix = cam->getProjectionMatrix();
   osg::Matrix windowMatrix = cam->getViewport()->computeWindowMatrix();

   osg::Vec4d screenCoords = windowMatrix.postMult
(projectionMatrix.postMult (viewMatrix.postMult (_refPoint)));*

I saw windowMatrix is the bias matrix and the viewport scale.
refPoint is a Vec4d with w = 1. ( the 3D point i want to project into screen
space )  and as operator * is not defined to multiply a Matrix with an
Vec4d, i use postMult function.

But i dont get a valid result... what did i missed ? :-x
Thanks for your attention

Regards,
Harold
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to