I have a scene built with a few objects loaded, the most pertinent one being a large plane surface centered at the origin. I want to cast a ray from a particular point at a particular angle inside the scene and get a list of everything it intersects—both the point of intersection and the Node object. Most examples of using intersectors involve picking from the window, so I haven't seen exactly what I wanted. But from what I've read, the following should at least be close:
Vec3d start( 0.0, 0.0, 100.0 );
Vec3d end( 0.0, 0.0, -100.0 );
ref_ptr<LineSegmentIntersector> intsec = new LineSegmentIntersector( Intersector::MODEL, start, end );
IntersectionVisitor iv( intsec.get() );
viewer.getCamera()->accept( iv );
cout << intsec->containsIntersections() << endl;
My start and end points in this snippet are well above and well below the surface object. So that plane object should definitely be intersected by a line running between them. However the containsIntersections function always returns false.
Immediately after making this preliminary test pick, the program calls viewer.run() so I know everything is arranged as expected in the scene. So my guess is that I'm missunderstanding how the visitor works. Perhaps the accept() function is not what I should be using to execute the intersector?
~ Chris