<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; overflow-wrap: break-word;" class="prettyprint"><code class="prettyprint"><div class="subprettyprint"><span style="color: #000;" class="styled-by-prettify">    </span><span style="color: #606;" class="styled-by-prettify">Vec3d</span><span style="color: #000;" class="styled-by-prettify"> start</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #066;" class="styled-by-prettify">0.0</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #066;" class="styled-by-prettify">0.0</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #066;" class="styled-by-prettify">100.0</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br>    </span><span style="color: #606;" class="styled-by-prettify">Vec3d</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">end</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #066;" class="styled-by-prettify">0.0</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #066;" class="styled-by-prettify">0.0</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">-</span><span style="color: #066;" class="styled-by-prettify">100.0</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br>    ref_ptr</span><span style="color: #660;" class="styled-by-prettify"><</span><span style="color: #606;" class="styled-by-prettify">LineSegmentIntersector</span><span style="color: #660;" class="styled-by-prettify">></span><span style="color: #000;" class="styled-by-prettify"> intsec </span><span style="color: #660;" class="styled-by-prettify">=</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">new</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #606;" class="styled-by-prettify">LineSegmentIntersector</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #606;" class="styled-by-prettify">Intersector</span><span style="color: #660;" class="styled-by-prettify">::</span><span style="color: #000;" class="styled-by-prettify">MODEL</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> start</span><span style="color: #660;" class="styled-by-prettify">,</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #008;" class="styled-by-prettify">end</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br>    </span><span style="color: #606;" class="styled-by-prettify">IntersectionVisitor</span><span style="color: #000;" class="styled-by-prettify"> iv</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> intsec</span><span style="color: #660;" class="styled-by-prettify">.</span><span style="color: #008;" class="styled-by-prettify">get</span><span style="color: #660;" class="styled-by-prettify">()</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br>    viewer</span><span style="color: #660;" class="styled-by-prettify">.</span><span style="color: #000;" class="styled-by-prettify">getCamera</span><span style="color: #660;" class="styled-by-prettify">()-></span><span style="color: #000;" class="styled-by-prettify">accept</span><span style="color: #660;" class="styled-by-prettify">(</span><span style="color: #000;" class="styled-by-prettify"> iv </span><span style="color: #660;" class="styled-by-prettify">);</span><span style="color: #000;" class="styled-by-prettify"><br>    cout </span><span style="color: #660;" class="styled-by-prettify"><<</span><span style="color: #000;" class="styled-by-prettify"> intsec</span><span style="color: #660;" class="styled-by-prettify">-></span><span style="color: #000;" class="styled-by-prettify">containsIntersections</span><span style="color: #660;" class="styled-by-prettify">()</span><span style="color: #000;" class="styled-by-prettify"> </span><span style="color: #660;" class="styled-by-prettify"><<</span><span style="color: #000;" class="styled-by-prettify"> endl</span><span style="color: #660;" class="styled-by-prettify">;</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">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">https://groups.google.com/d/msgid/osg-users/58d20034-cb65-4bef-937f-f85a1fa92030%40googlegroups.com</a>.<br />