Hi Ke Li,

I'm confused by your code and what you are trying to do.

The matrix stack methods in IntersectionVisitor are there for internal
usage during the traversal of the scene graph, as the traversal goes
down matrices are pushed on the respective stacks, and on the return
up these matrices are popped.  Once the traversal is complete the
stacks will be empty unless you've pushed ones on yourself.

So the quesition still has to be what are you trying to do?  What do
you need the matrices for?

Robert.


On Fri, Mar 14, 2008 at 9:31 PM, Ke Li <[EMAIL PROTECTED]> wrote:
>
> Dear all,
>
> I'm trying to obtain the model matrix, the view matrix, the projection
> matrix and the window matrix. I used the following piece of code in my pick
> event handler.
>
> protected unsafe bool pick(OsgGA.GUIEventAdapter ea, OsgViewer.Viewer
> viewer)
> {
>     ......
>     picker = new
> OsgUtil.LineSegmentIntersector(OsgUtil.Intersector.CoordinateFrame.PROJECTION,
>                     ea.getXnormalized(), ea.getYnormalized());
>     OsgUtil.IntersectionVisitor iv = new
> OsgUtil.IntersectionVisitor(picker);
>     viewer.getCamera().accept(iv);
>
>     Osg.Matrix VPW = new Matrix();
>     if (iv.getWindowMatrix()!=null)
>                 {
>                     Osg.Matrix mm = new
> Osg.Matrix(iv.getWindowMatrix().ptr());
>                     VPW.preMult(mm);
>                 }
>     if (iv.getProjectionMatrix() != null)
>                 {
>                     Osg.Matrix mm = new
> Osg.Matrix(iv.getProjectionMatrix().ptr());
>                     VPW.preMult(mm);
>                 }
>     if (iv.getViewMatrix() != null)
>                 {
>                     Osg.Matrix mm = new
> Osg.Matrix(iv.getViewMatrix().ptr());
>                     VPW.preMult(mm);
>                 }
>     if (iv.getModelMatrix() != null)
>                 {
>                     Osg.Matrix mm = new
> Osg.Matrix(iv.getModelMatrix().ptr());
>                     VPW.preMult(mm);
>                 }
> ......
> }
>
> But the iv object could never return any matrix and all the Boolean
> expression in the if statement always equal to false.
>
> I'm wondering what is wrong here. Is there any thing else that I need to do
> before I can obtain the matrices?
>
> Any help is appreciated!
>
> Regards,
>
> Ke Li
>
>
>
> ________________________________
> Connect and share in new ways with Windows Live. Get it now!
> _______________________________________________
>  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