Integrating a render engine in Rhinoceros 3D using RhinoCommon – Introduction 1/5

Integrating a render engine in Rhinoceros 3D (Rhino WIP)

If you’re a render engine developer and you’re thinking of writing an integration plug-in for the upcoming Rhino 6 (still lovingly called Rhino WIP) then you definitely should keep reading on.

For this series I’ll be looking into how one would go about integrating a render engine using the RhinoCommon SDK.

The subject will be broken up into several parts:

For each part we’ll take a look at relevant parts of the integration plug-in for the Cycles render engine while doing several simple example plug-ins at the same time. The code for the example plug-ins will be stripped of (most) of the comments that are added by the template, so we can focus on the parts that matter. Source code for the sample project, dubbed MockingBird, is available on GitHub.

Creating Render Plug-in project

Install the RhinoCommon v6 template package

To make developing a new plug-in for Rhinoceros 3D easy McNeel has published a template packages for v6. Search for the string rhino and install the relevant package.

Install RhinoCommon v6 template package

 

Once the template package is installed we’re ready to write amazing plug-ins for Rhino 3D.

Create a new RhinoCommon v6 project

Create a new RhinoCommon plug-in project

Lets create a new plug-in now that the wizard is installed. Simply create a new project in Visual Studio, and from the Visual C# section under Templates select Rhinoceros. Pick RhinoCommon Plug-In for Rhinoceros 6 and give a name.

After you click on OK you’ll be presented with a wizard dialog where settings can be changed. For our case we select Render plug-in. If the wizard fails to recognize a Rhino 6 (Rhino WIP) installation path one can set the necessary paths before accepting the settings. Click on the Finish button when happy with the settings.

RhinoCommon render plug-in settings

 

The plug-in wizard will generate a set of files for the developer.

Adjust assembly configuration

Before diving into the deep it probably is a good idea to change the assembly information and plug-in description strings. I’d suggest at least some minimal contact information and a short description of what the plug-in is supposed to do.

The main part of the plug-in

We’ll ignore the the command class that the wizard also has added. For the purpose of this example plug-in it is not needed, so it could just be removed as well. This leaves the major entry point for the plug-in as our starting point.

Currently the wizard gives a public constructor that always assigns itself to the static Instance property. I think it is better to assign only when Instance is not set.

There are two mandatory functions to override. They have been added with default implementations that throw a NotImplementedException when called. For this example plug-in we are not going to bother with RenderWindow, so we’ll just return with a success code. For now we’ll do the same for Render(), but we’ll using that to hook up our render engine.

With these changes in the very first version of the plug-in can be compiled. This will create a .rhp file in the build folder.

Compiled Rhino 3D plug-in

 

Start a Debug session with Visual Studio, and drag-and-drop the .rhp file on the Rhino instance that opens. The Rhino command-line should tell that the plug-in has been loaded. The Current Renderer menu should show the newly-loaded plug-in as an entry as well.

Render plug-in loaded

The render engine can be selected, but it won’t do anything useful yet :)

With these steps completed the basics of the plug-in are done. It is time to have a proper look at integrating the render engine.

 

3 thoughts on “Integrating a render engine in Rhinoceros 3D using RhinoCommon – Introduction 1/5

Leave a Comment