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

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

When it comes to converting a 3dm document to a form our render engine understands there are two options: the hard way, or the easy way.

The hard way would be to just take the RhinoDoc  given in the Render()  function and then iterate over the many different tables with DocObjects  and do the conversion then and there. For geometry and render content it probably won’t be too hard, but when it comes to Blocks and Block instances it all becomes quite complex very quickly.

Since I don’t like complex I’ll just go with the easy way.

The code for this plug-in version can be found at the MockingBird Git repository.

ChangeQueue

The ChangeQueue  is a central way of getting the 3dm in an already pre-digested format. Among things it will handle Blocks and their instances all for you. The ChangeQueue  is also usable for both production (modal) rendering and interactive real-time rendering in the viewport. Even preview scene rendering can be done through the ChangeQueue  mechanism, meaning that preview rendering can be easily added without too much hassle. We’ll come to that later though.

Setting up the ChangeQueue  is pretty straight-forward. A class deriving from Rhino.Render.ChangeQueue.ChangeQueue  is needed and a set off Apply-functions need to be implemented.

The function in the given snippet are the most basic apply functions one should need to integrate a production render engine. The functions all have been provided with clear documenting comments.

An instance of this new MockingChangeQueue  will be created when the MockingRenderContext  is instantiated.

To use this new ChangeQueue  the Render() function needs to be adapted slightly – the CreateWorld()  function on our MockingChangeQueue  instance should be called once on the main thread. This is to ensure proper functionality of the ChangeQueue  mechanism.

Loading the 3dm test file and running the _Render  command will yield output something like:

 

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

Leave a Comment