Hi all,

 I'm encountering an inconsistency between OpenGL vertex manipulation
and OSG. It is almost sure that it's my own misuse of OSG so I will
present the issue and be glad to learn. J

 

I'm trying to force a point in orthographic projection to have a
specific z value.

Suppose z = 0.95

 

I know the world point is (xw,yw,zw)

 

So I calculate near/far planes in orthographic projection to be [0,
zw/z]

Then I create the projection matrix to be 

 

                                osg::Matrix new_proj =
osg::Matrix::ortho(-(width*0.5),width*0.5,-(height*0.5),height*0.5, 0,
zw/z); 

                                osg::Matrix new_view =
osg::Matrix::identity();

The model view matrix is identity.

Now, I create a dummy vertex to check the projection:

 

                                osg::Vec3 pt(0,0,zw/z);

                                osg::Vec3 s = new_proj.preMult(new_view
.preMult(pt));

 

I would expect s.z() to be 1 or a smaller number but very very close to
one.

What I get is 3. (width x height are 160x120. zw = 800)

 

When I use the utility function 

                                double x,y,z;

                                int success = gluProject(pt.x(), pt.y(),
pt.z(),new_view.ptr(), new_proj.ptr(), vp, &x, &y, &z);

 

z is very close to 1 (0.9997...) as was expected.

 

Can anyone explain?

 

Thanks,

 Guy L.

 

 

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

Reply via email to