Ying, I think your multiplication order is backwards; try

pos1 = P1 * modelviewMat * projectionMat;

Glenn Waldron / @glennwaldron


On Thu, Jul 24, 2014 at 10:01 AM, ying song <[email protected]> wrote:

> Hello everyone,
>
> To understand what is the clipping coordinates, I tested some points using
> the following code:
>
> osg::Matrixd modelviewMat= viewer->getCamera()->getViewMatrix();
> osg::Matrixd projectionMat= viewer->getCamera()->getProjectionMatrix();
> osg::Vec4 pos1 = projectionMat * modelviewMat * P1;
>
> According to the documents I found, the clipped coordinates
> (pos1.xyz()/pos1.w()) should be in the range of (-1,1). But some of the
> coordinates that I calculated is out the this range. For example, I got:
> pos1=[4.3364410, -0.95071518, -32.184357, 2.3291125], so pos.x/pos.w and
> pos.z/pos.w are out of the range.
>
> Also, I don't understand what is the z coordinate means in the clip
> coordinates. How could I get the window coordinates from the clip
> coordinates? Are the window coordinates equal to:
> [(pos.x/pos.w+1)/2*window_width,(pos.y/pos.w+1)/2*window_height] ?
>
> Thank you!
>
> Cheers,
> ying
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=60438#60438
>
>
>
>
>
> _______________________________________________
> 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

Reply via email to