Storing Data for Custom Renderer

rhinocommon
unhandled

(Marton Parlagh) #1

What is the correct (preferred) way to store data for custom render engine?

As far I can see I have at least three options:

  1. Store it in a custom container and read/write it during plugin ReadDocument/WriteDocument functions.

  2. Store as UserData (Rhino.RhinoDoc.ActiveDoc.RenderSettings.UserData)

  3. And in the example “SampleCsCustomRednerSettingsSections” in the code it stores it in a data object (wich comes somehow from IRdkViewModel???):
    GetData(Rhino.UI.Controls.DataSource.ProviderIds.RhinoSettings, false, true) as RhinoSettings;

I am really not sure where it saves the data actually…

Thanks in Advance!

Márton


(jesterKing) #2

Hi, the simplest way is to use plug-in settings. Here is how the Raytraced mode saves settings for the Cycles render engine:

RcPlugin is the plug-in object for my plug-in:

While you are integrating your engine, please have a look at the ChangeQueue to build upon. This is the preferred way to start integrating your engine.


(Nathan 'jesterKing' Letwory) #3

Let me know if you have any further questions regarding render engine integration, we’ll happily assist you as much as we can. (Didn’t notice I was using my personal account when writing above reply).


(Marton Parlagh) #4

Ohhh, I didn’t realised that we have such a complex sample code.

This is Great!

Thank you.

Márton


(Nathan 'jesterKing' Letwory) #5

It is not only sample code, it is the entire implementation of the Raytraced mode (: a reference implementation for render engine integration, if you will.


(Marton Parlagh) #6

Sorry, yes, I wanted to admit it as it is - “sample” was a wrong word.


(Marton Parlagh) #7

And it seems I was not clear in my first question too.

I already use plugin.Settings to store persistent plugin data.

But what I would like to do is to store render setting data only for the actual scene (active document).

Like These: (Max bounces, Ray Offset, etc.)


(Nathan 'jesterKing' Letwory) #9

In that case you will want to marry the sample code https://github.com/mcneel/rhino-developer-samples/tree/6/rhinocommon/cs/SampleCsCustomRenderSettingsSections you mentioned for the UI and the user data on render settings.

The sample code more or less shows global settings (application-wide). You’ll have to come up with a model that uses custom UserData your plug-in knows how to handle. See https://github.com/mcneel/rhino-developer-samples/tree/6/rhinocommon/cs/SampleCsUserData for user custom user data sample code. Note then that you want to put them on the render settings as custom user data.

I hope this gives you the info you need.


(Marton Parlagh) #10

Yes, I think so I can follow this path. (We will see:) Thank you!


(Marton Parlagh) #12

It works on the UI part. But how can I make Rhino the update the RenderSettings user data with new UserData? (if possible with undo/redo stack)

I get the userData like tihs:
Rhino.RhinoDoc.ActiveDoc.RenderSettings.UserData.Find(…)

I change some value…

But how can I store it back to the RenderSettings?

Márton


(Nathan 'jesterKing' Letwory) #13

So you use RenderSettings.UserData.Find, then you can use RenderSettings.UserData.Add to set your data.


(Marton Parlagh) #14

Thanks you!!!

In case of cameras and objects it was not so simple, so I have forgotten to check this simplest way.

This works great. The only thing is - can it be part of the undo/redo system?

When I do it with a object I put the changes between BeginUndoRecord/EndUndoRecord.

Here it doesn’t work. Do I have to create an own undo step with this? AddCustomUndoEvent(…)


(Nathan 'jesterKing' Letwory) #15

I am not sure if this is part of the undo system.

@andy, @dale - any idea about changing UserData on RenderSettings and undo?


(Marton Parlagh) #16

If it is not handled automatically, is it safe to use?:
Document.AddCustomUndoEvent(…)

Márton