I've been going over the osgUtil::IntersectVisitor code trying to
understand it better. More specifically, I'm interested in how the
_intersectPoint is calculated. I've examined it and am seeing that a
_ratio value is set and that it is the linchpin to this, but I'm not
seeing where or how it is calculated (yes, it comes from thitr->first,
but where does that come from?).
The reason I ask is that I have some picking code I'm using that is
working fine, but I don't understand it as well as I'd like. Here's what
I'm doing:
osg::Vec3 np, fp, mp;
np = osg::Vec3(x,y,-1.0f) * inverseMVPW; //matrix calculated elsewhere
mp = osg::Vec3(x,y, 0.0) * inverseMVPW;
fp = osg::Vec3(x,y, 1.0f) * inverseMVPW;
std::cout << "np: " << np << std::endl;
std::cout << "mp: " << mp << std::endl;
std::cout << "fp: " << fp << std::endl;
osg::ref_ptr<osg::LineSegment> lineSegment =
new osg::LineSegment(np,fp);
...etc...
I then use the line segment to retrieve a list of intersection hits in
the scene. If I call getWorldIntersectPoint() on a given hit I get the
world coords - everything's perfect. I just don't see how it's deriving
those world coords for a given intersection.
A further mystery is that when I print out the near point, mid point,
and far point I get values that seem to have almost no relationship to
the world coords. I would expect these to have a somewhat linear
relationship with objects in the world but, again, they almost seem
independent of one another. What gives?
For example, I initially assumed that if, for my "mp" variable above
instead of feeding a depth of 0.0, I instead used the depth value of the
object in my intersection path, mp would have values that roughly
correspond with that object's world coords. However, it's starting to
look like that might not be the case. I'm assuming I'm missing some
coefficient or calculation somewhere, but I don't know what it is or how
to derive it.
I would like to understand these processes better so any insights are
appreciated.
thanks,
dave
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/