Preview order logic / Display pipelines


(Paul Poinet) #1

Hi all,

I am currently developing (or trying to develop) a sort of user interface in Rhino/Grasshopper that let the user display the hierarchy of the layer table from a layer source (see image below). Ultimately, I would like to be able to click on the arcs portions (displayed here as polygons/meshes), enabling the user to hide/show or lock/unlock layers, and then select objects (I guess that would be the most challenging part).

As you can see, there is a lot of objects displayed, mostly curves, polygons and text.
Right now, I am scripting in python and use the Rhino.Display.CustomDisplay class from which I can add objects to the Rhino document with the sticky library and some cool hacky tricks introduced by @AndersDeleuran.
In my case, the large amount of objects displayed here lead to write painful additional lines of code just to lift the objects in the Z direction (since I work in 2D only), so I can manage the display order. See image below:

So I am considering some alternatives…

Contrary to ghPython, a DisplayPipeline is integrated within the C# component (I know that ghPython handles it as well in Rhino 6 WIP, but well… it’s WIP and I want to develop something in a stable environment), offering a wider range of options to draw different objects (much wider range than in Rhino.Display.CustomDisplay…), and enabling better display management of all my items situated on the same plane - at least I hope!

So I have been playing around a bit with C#, adding a bunch of preview objects to the viewport and see how i can manage the order of appearance. The only way I found to display objects of different types, by keeping the order appearance corresponding to the order I call them, was to disable/enable the DepthWriting between each type. On the image below you can see a series of circles, some mesh and a text dot, appearing on top of each other.

Long story short… my question is:
- What is the best way to deal with the preview order of multiple objects (of different types) displayed onto the same plane?

I also have quite a few side questions:

  • Is it actually faster to generate/display meshes or polygons within the display pipeline?
  • Ultimately I would like to click on a polygon/mesh and retrieve it’s meta data information (here a layer index for example). Is that possible? Maybe more feasible with a Mesh rather than with a Polygon? Any hint on interactive selection in the Rhino/Viewport? Where can I find useful information about that? I know that Kangaroo2 enables the direct dragging of particles with the mouse, for example…

Thanks for reading until here, any advice would be greatly appreciated!

Paul


Multiple instances of a custom preview gh component
Multiple instances of a custom preview gh component
(Steve Baer) #2

Turn depth testing off
http://developer.rhino3d.com/api/RhinoCommonWin/html/M_Rhino_Display_DisplayPipeline_EnableDepthTesting.htm


(Paul Poinet) #3

Well, I don’t know if you meant that exactly, I deleted all the inbetween DepthWritings functions and disabled depth testing. It does not work… The dot appears behind the circles, and if we follow the order, it should appear in front.

PS: Also I don’t get why there is a void for Meshes and Wires since it’s possible to display any type of object within the two functions!


(Steve Baer) #4

You’re right, sorry for the confusion. Shaded meshes can only really be drawn with depth testing enabled. Rhino buffers up similar geometry types during drawing as an optimization which is most likely why the circles are drawing on top of the text dot. There is no “FlushBuffers” function on the display pipeline class in RhinoCommon, but you can probably force a flush by turning depth testing off and then back on in between drawing of the circles and the dot (state changes like this typically force a flush of the buffers.)


(Paul Poinet) #5

Thanks! it works. I guess that’s why the first example i posted worked as well. But I can just delete all the enableDepthWriting I wrote.

I you or someone else finds time later, i would still be interested to get some answers from the last questions I asked above:[quote=“PaulPoinet, post:1, topic:43495”]
I also have quite a few side questions:

  • Is it actually faster to generate/display meshes or polygons within the display pipeline?
  • Ultimately I would like to click on a polygon/mesh and retrieve it’s meta data information (here a layer index for example). Is that possible? Maybe more feasible with a Mesh rather than with a Polygon? Any hint on interactive selection in the Rhino/Viewport? Where can I find useful information about that? I know that Kangaroo2 enables the direct dragging of particles with the mouse, for example…
    [/quote]

Cheers


(Luis Fraguada) #6

@PaulPoinet maybe this example by @stevebaer can help with regards to picking conduit objects: https://wiki.mcneel.com/developer/rhinocommonsamples/pickobject


(Paul Poinet) #7

Ah nice resource, thanks Luis! I will definitely have a look at it.