<div dir="ltr">Hi Chris,<div>I guess you want the scene to accept the IntersectionVisitor, not the camera.</div><div>Laurens.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 1, 2020 at 1:18 PM OpenSceneGraph Users <<a href="mailto:osg-users@lists.openscenegraph.org">osg-users@lists.openscenegraph.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>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:</div><div><br></div><div><div style="background-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px"><code><div><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,0,102)">Vec3d</span><span style="color:rgb(0,0,0)"> start</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,102,102)">0.0</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,102,102)">0.0</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,102,102)">100.0</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">);</span><span style="color:rgb(0,0,0)"><br> </span><span style="color:rgb(102,0,102)">Vec3d</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,136)">end</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,102,102)">0.0</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,102,102)">0.0</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">-</span><span style="color:rgb(0,102,102)">100.0</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">);</span><span style="color:rgb(0,0,0)"><br> ref_ptr</span><span style="color:rgb(102,102,0)"><</span><span style="color:rgb(102,0,102)">LineSegmentIntersector</span><span style="color:rgb(102,102,0)">></span><span style="color:rgb(0,0,0)"> intsec </span><span style="color:rgb(102,102,0)">=</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,136)">new</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,0,102)">LineSegmentIntersector</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,0,102)">Intersector</span><span style="color:rgb(102,102,0)">::</span><span style="color:rgb(0,0,0)">MODEL</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> start</span><span style="color:rgb(102,102,0)">,</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(0,0,136)">end</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">);</span><span style="color:rgb(0,0,0)"><br> </span><span style="color:rgb(102,0,102)">IntersectionVisitor</span><span style="color:rgb(0,0,0)"> iv</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)"> intsec</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,136)">get</span><span style="color:rgb(102,102,0)">()</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)">);</span><span style="color:rgb(0,0,0)"><br> viewer</span><span style="color:rgb(102,102,0)">.</span><span style="color:rgb(0,0,0)">getCamera</span><span style="color:rgb(102,102,0)">()-></span><span style="color:rgb(0,0,0)">accept</span><span style="color:rgb(102,102,0)">(</span><span style="color:rgb(0,0,0)"> iv </span><span style="color:rgb(102,102,0)">);</span><span style="color:rgb(0,0,0)"><br> cout </span><span style="color:rgb(102,102,0)"><<</span><span style="color:rgb(0,0,0)"> intsec</span><span style="color:rgb(102,102,0)">-></span><span style="color:rgb(0,0,0)">containsIntersections</span><span style="color:rgb(102,102,0)">()</span><span style="color:rgb(0,0,0)"> </span><span style="color:rgb(102,102,0)"><<</span><span style="color:rgb(0,0,0)"> endl</span><span style="color:rgb(102,102,0)">;</span></div></code></div><br>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.</div><div><br></div><div>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?</div><div><br></div><div> ~ Chris</div><div><br></div><div><br></div><div><br></div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups "OpenSceneGraph Users" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:osg-users+unsubscribe@googlegroups.com" target="_blank">osg-users+unsubscribe@googlegroups.com</a>.<br>
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/osg-users/58d20034-cb65-4bef-937f-f85a1fa92030%40googlegroups.com?utm_medium=email&utm_source=footer" target="_blank">https://groups.google.com/d/msgid/osg-users/58d20034-cb65-4bef-937f-f85a1fa92030%40googlegroups.com</a>.<br>
_______________________________________________<br>
osg-users mailing list<br>
<a href="mailto:osg-users@lists.openscenegraph.org" target="_blank">osg-users@lists.openscenegraph.org</a><br>
<a href="http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org" rel="noreferrer" target="_blank">http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org</a><br>
</blockquote></div>