I'm having trouble finding a way to convert the position of my tracking object (right now just a sphere) from its world coordinates to screen coordinates so I can use the xy coordinates to pick with.
I'm porting my environment over from a normal monitor setup (where I can use a mouse for picking and already have all the code written) to a 3 sided cave setup where a mouse does not work.
Im thinking of a hacky way to do it that I think would work if I knew how osg normalized mouse coordinates with osg::GUIEventAdapter::getXnormalized(), but I cannot for the life of me find the code for that function.
If anyone knows of a method to convert world coordinates back to screen coordinates without having to totally reimplement my picking system, that would be great. If anyone can point me to the code for getXnormalized or the method used (I've found some - but they don't lead to the exact same result), that would be great as well.
Thanks!
Luke
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30194#30194
_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> [...] osg::GUIEventAdapter::getXnormalized(), but I cannot for the life of me find the code for that function.
It's directly in the header (include/osgGA/GUIEventAdapter):
inline float getXnormalized() const { return
2.0f*(getX()-getXmin())/(getXmax()-getXmin())-1.0f; }
> If anyone knows of a method to convert world coordinates back to screen coordinates without having to totally reimplement my picking system, that would be great. If anyone can point me to the code for getXnormalized or the method used (I've found some - but they don't lead to the exact same result), that would be great as well.
Search the archives, I answered the opposite of this question not long
ago (how to convert a screen position to a world space position), which
should be easy to reverse to find out what you want to.
I'll even make it real easy for you:
http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/59941/focus=59966
But you'll have to do the work of taking those calculations and
reversing them to get from world space to screen space.
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay jean-seba...@cm-labs.com
http://www.cm-labs.com/
http://whitestar02.webhop.org/
Luke
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=30225#30225