I've build a proof of concept project with very simple objects to understand how generators and modifiers work and then implement that workflow in my plugin. I miss a proper manual explaining how Generators and Deformers works in detail, it's been really time consuming learning curve, based on bits and pieces gathered from examples, api notes and forum posts.
My basic design is to have one base object, inside it one generator and a series of modifiers that will all act on a custom user data type, an in the end generate a spline or a polygon, depending on those modifiers. The generator reads a linked mesh and creates the initial custom data, which is passed from modifier to modifier. The last mod (or the base object) will then generate the spline or polygon. Looks like this (with borrowed icons from sdk examples):
Making this work raised many questions...
To pass down the user data, I thought I could just create a custom object containing the user data in TGenerator and pass down to the modifiers. But I discovered that only polygons and splines are cached and passed to modifiers. I solved that by creating an empty polygon, adding a tag with the custom data (empty splines won't go down either). My luck is that the cache preserved the tag, and I can read it on modifiers. Is there any way to cache custom objects, or preserve them in the cache? Is there an easier way to send custom user data to modifiers?
In my initial tests, when TObject was not generating anything, the modifiers were being consumed by TGenerator. When I added TGenerator as a dependency of TObject, the modifiers started being consumed by TObject, breaking that initial design. Now TGenerator cache is passed to TObject, and from there to the modifiers. This got too complicated and created many new problems. If I layout my objectes like this, everything works as I wish:
But to the user, the only difference from TGenerator and TModifiers is that generators comes first. If possible, I don't want to force that new hierarchy under TGenerator, and keep the workflow as simple as the first screenshot. In the original workflow, is there any way to force the modifiers to be consumed by TGenerator and not TObject?
You may suggest that TObject and TGenerator be one object, but I want to keep them separated because we can have different generators, and I wish to add some custom GUI to TObject to select and add new generators and modifiers, much like the new Group Field object.
Since the initial dummy polygon from TGenerator can change to a spline in the end, I found two options to do that. TObject just reads the final TGenerator cache and uses it (IDEAL), or TObject creates it anew from what we find in the final generator's cache. The achieve the first option, if a modifier receives a polygon, is it safe to delete it and add a spline instead?
If I generate a spline in TGenerator, modifiers receive the cache as a LineObject, and I can't modify it as spline anymore. How can I preserve the cache as a Spline?
I tried and failed to use Dependence lists on TObject to read the cache from TGenerator, so I'm using
GetAndCheckHierarchyClone()instead. How can I get the caches from the objects I added to the dependence lists? I tried using
GetDeformCache()on the added object, and it always returns null.
The Active Object Dialog plugin from the sdk example has been invaluable help to understand what's happening inside the objects, thanks for that!