Hi,all

    I am a new to osg and I use the following method to get the world  
coordinate by screen corrdiante and it works well: 
osg::Matrix VPW = viewer->getCamera()->getViewMatrix() *
viewer->getCamera()->getProjectionMatrix() *viewer->
getCamera()->getViewport()_>computeWindowMatrix();
osg::Matrix Inm = osg::Matrix::inverse(VPW);
osg::Vec3d world = (osg::Vec3d(pos.x(), pos.y(), 0)) * Inm;

My scene is quite sample,the root has only one child:
root->addchild(osgDB::readNodeFile("cow.osg"));


When i add a big sky shpere that surrounds the cow,scene changing to:
    root->addchild(osgDB::readNodeFile("cow.osg")); 
    osg::ref_ptr<osg::Drawable> drawable = new osg::ShapeDrawable(new 
osg::Sphere(osg::Vec3(0.0f, 0.0f, 0.0f), 100));
   osg::ref_ptr<osg::Geode> geode = new osg::Geode;
   geode->addDrawable(drawable.get());
   root->addchild(geode);

I cannot get the right world  coordinate when my camera move inside the sphere 
by the above method. 

Did I miss something?Is there some way to  ignore the sphere and then to get 
the world coordinate by screen coordinate?
 
If anyone could point me in the right direction with some simple code,it is 
very much appreciated. Thanks a lot!

Thank you!

Cheers,
Qi :D

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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to