Drawing order logic when overriding Dynamic Draw

Hello,

I’m overriding CRhinoGetXform to transform an object, and drawing the dynamic transform geometry in its DynamicDraw() method. The problem is that the dynamic geometry is drawn always at “top” place on screen, as you see in the pictures (dynamic geometry in red, in the second picture the red rectangle is incorrectly drawn over the grey one). How can I modify the order of drawing?

From posts about display conduits this is done via SC_POSTDRAWOBJECTS channel. How to access it from DynamicDraw()? (I draw the red object as a mesh with vp.m_dp->DrawShadedMesh(), with CRhinoViewport vp)

Many thanks,
Pablo

Hi @pagarcia

Dynamic drawing was not designed for depth buffering. For speed, dynamic drawing routines only draw directly to the so called “front buffer” and are executed inside Rhino’s Overlay channel. The overlay channel executes any time there are dynamic draw routines active, regardless of whether or not the frame buffer is updated (i.e. there was no middle ground processing whatsoever).

In order to draw anything shaded or depth buffered, it must happen inside the middle ground. And in order to do that, you must create a conduit that executes inside one of the middle ground channels. It’s most likely you will want to use the PostDrawObjects channel.

– Dale

Hi Dale,

Thanks for the explanation! I created a conduit instead and works perfectly.

Pablo