Select Preview Objects C++

Hi,

is there any way to select objects that are drawn as preview in the SC_PREDRAWOBJECTS Channel of the Conduit? Maybe by using some other display channel? I would guess it is not so easy because these geometries are not in the Rhino Document right? So they are not “selectable”?

I have this idea of “piercing” these objects …drawing a line from the camera location in the Viewport toward the point where the user clicks on the screen (of course after transferring screen to world coordinates) and looking for the intersection of this piercing line with the objects in order to find the “selected” one. And this should work fine…I just don`t know how long this “piercing” line should be so that it always works? Is there some fast way for me to determine a distance/length that would definitely be large enough? Is ZBuffer usable for something like this?

This “piercing” depth interests me not only for the preview objects but also for existing objects in the document…

Thanks!

Milos

Rhino’s object picking only work on objects in the document.

But, you can use CRhinoPickContext to build your own object picker. For more details on ```CRhinoPickContext``, see rhinoSdkPick.h.

Here is an example of using a CRhinoPickContext to pick objects (in the document).

But you can also use it to help pick objects that are not in the document.

I should add that this can take some work. But it is do-able. Gumball, for example, is picked in this manner.

Thanks Dale,

Ill try that. But in the case I dont want only to pick objects but to do the "piercing" - lets imagine I want to draw with my cursor over all shapes (surface/mesh) in the scene…what would be the appropriate depth of the piercing ray? I see in the example you sent me that there are Clipping Planes…can their information be used somehow? Is one of the ON_Viewport members helpful?

I am using the camera location to shoot the ray…how long should the ray be to reach (and pierce) every geometry in the scene for sure?

Greetings,
Milos

P.S. It really interests me how does Rhino select objects? Does it shoot rays? (or prisms for window selection) and looks for intersections, or am I missing a simpler and more obvious method?

Thanks!

Rhino uses a CRhinoPickContext object.