Hi, I got a problem when implementing code to transform from screen
coordinate to world coordinate.
Here is the code:

void ASDSPickHandler::pick(const osgGA::GUIEventAdapter &ea,
osgViewer::Viewer *viewer)
{
       ......
        osg::Vec3f primitivePosition(ea.getX(), ea.getY(), 0.0f);
        osg::Matrix viewMatrix = viewer->getCamera()->getViewMatrix();
        osg::Matrix projectionMatrix =
viewer->getCamera()->getProjectionMatrix();
        osg::Matrix windowMatrix =
viewer->getCamera()->getViewport()->computeWindowMatrix();
        osg::Matrix cameraMatrix = viewMatrix * projectionMatrix *
windowMatrix;

        osg::Matrix inverseCameraMatrix;
        inverseCameraMatrix.invert(cameraMatrix);

        primitivePosition = primitivePosition * inverseCameraMatrix;
       ......
}

Here, the output of "primitivePosition" seems not correct. Just don't know
what happened. Can you guys help me out? Thanks in advance!

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

Reply via email to