[osg-users] LineSegmentIntersector and MODEL Frame

OpenSceneGraph Users osg-users at lists.openscenegraph.org
Mon Feb 3 10:04:10 PST 2020


Thanks. I had thought to apply the visitor to the scene, but GetScene() 
didn't have Accept(). With your confirmation that using the scene was 
correct, I found that viewer.getSceneData()->accept( iv ) did exist.

However, calling that line just results in a segfault. The rest of the code 
is the same as before. I'm going to search to see if I'm doing something 
obviously wrong, but in case I got the above line incorrect, I wanted to 
post my failed results here for further comment.


On Monday, February 3, 2020 at 3:06:33 AM UTC-5, OpenSceneGraph Users wrote:
>
> Hi Chris,
> I guess you want the scene to accept the IntersectionVisitor, not the 
> camera.
> Laurens.
>
> On Sat, Feb 1, 2020 at 1:18 PM OpenSceneGraph Users <
> osg-... at lists.openscenegraph.org <javascript:>> wrote:
>
>> 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
>>
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "OpenSceneGraph Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to osg-... at googlegroups.com <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/osg-users/58d20034-cb65-4bef-937f-f85a1fa92030%40googlegroups.com 
>> <https://groups.google.com/d/msgid/osg-users/58d20034-cb65-4bef-937f-f85a1fa92030%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> _______________________________________________
>> osg-users mailing list
>> osg-... at lists.openscenegraph.org <javascript:>
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>

-- 
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to osg-users+unsubscribe at googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/osg-users/36f90789-908b-452a-b629-19c7bd55d43a%40googlegroups.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20200203/9e2ea5c8/attachment.html>


More information about the osg-users mailing list