Hi J-S,

Here's what I'm doing:

Code:

        unsigned int width, height;
        osg::GraphicsContext::WindowingSystemInterface* wsi = 
osg::GraphicsContext::getWindowingSystemInterface();
        wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), 
width, height);

        viewer->getCamera()->setProjectionMatrixAsPerspective(45., 
width/height, 1.,2.);
        viewer->getCamera()->setViewMatrixAsLookAt(osg::Vec3(0.,0.,-5.), 
osg::Vec3(0.,0.,0.),   osg::Vec3(0.,1.,0.));
        viewer->getCamera()->setViewport(0,0,width,height);
        viewer->getCamera()->setClearColor(osg::Vec4(0.f,0.f,0.f,1.f));
        
        osg::Matrix MVPW( viewer_->getCamera()->getViewMatrix() *
                viewer_->getCamera()->getProjectionMatrix() *
                viewer_->getCamera()->getViewport()->computeWindowMatrix());

        osg::Matrixd inverseMVPW = osg::Matrixd::inverse(MVPW);

        osg::Vec3 near_point = osg::Vec3(obj->getX(),(1-obj->getY()), 0.f) * 
inverseMVPW;


        pat_marker->setPosition(near_point);




Where the obj->getX and getY is already normalized, the values range between 0 
and 1. Anyway, when I try to draw objects on the four corners of the screen, I 
only get one on the middle bottom. 

Now, IF i multiply the normalized values by the size of the screen 
("unnormalizing" them), AND set the near plane of the perspective matrix to at 
least 100, i can see all the markers on the screen, although they are really 
small and not exactly on the four corners.

Sorry to bother you so much with this J-S but I just can't figure out what am I 
doing wrong! I'm sure it's something really simple!

Thanks a lot... again!

Cheers,
Theo

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=29829#29829





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

Reply via email to