Integrating a render engine in Rhinoceros 3D using RhinoCommon: MockingBird – Modal rendering (2/5)

This is part 2 in the series on render engine integration in Rhinoceros 3D using RhinoCommon (v6).

To implement a modal rendering solution for Rhinoceros 3D there are two particular pieces you’ll need to create, which will allow you to render into a separate render window: a custom implementation of a Rhino.Render.AsyncRenderContext , and a Rhino.Render.RenderPipeline.

The full source code of this plug-in can be found here.

The rendering will start when giving the Rhino command Render. This will result in a call into the Render()  of your Render plug-in implementation.

In our Render()  function we start by initialising our render context (line 4) and render pipeline (line 7). The render context will be essentially where our actual rendering code will be hosted. The render pipeline starts and stops our engine (context) as necessary.

In Render()  we also ensure we have a RenderWindow , set to the requested render resolution (lines 10-20).

As said, for the modal rendering to get hooked up  two classes need to be implemented. An implementation of a RenderPipeline is used to communicate start and stop events between Rhino and the second class, an implementation of AsyncRenderContext. The latter is essentially where a custom render engine will be hooked up to the Rhino world.

RenderPipeline requires several functions to be overridden. For our modal (production) render case we are interested mostly in OnRenderBegin() , OnRenderEnd()  and ContinueModal() .

On our implementation of AsyncRenderContext we need to override one function, StopRendering() . Obviously we have one extra function, which is the main entry to our rendering code, Renderer() .

 

4 thoughts on “Integrating a render engine in Rhinoceros 3D using RhinoCommon: MockingBird – Modal rendering (2/5)

  1. Hello Nathan,

    I look forward to part 4 in the series :) I am wondering how to share code between production rendering (modal) and viewport rendering.

Leave a Comment