Object Plugin framework [SOLVED]

On 01/05/2016 at 10:24, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   17 
Platform:   Windows  ;   
Language(s) :     C++  ;

Hello all,
I'm a seasoned C4D user, but very new to developing plug-ins for it. What I found is that the SDK documentation is rather... not beginner friendly.  So I thought I'd give the forums a try.

The plugin object I'm envisioning take a polygon object as a input, calculates a number of geometric properties, then generates another object. then that object can act as an input to another object.

The closest example in the SDK that I found is the Atom object, which takes the polygon object's vertices and edges and replaces them by spheres and cylinders respectively. What I particularly like is that you can use one Atom's output as a another Atom's input.

Now the problem i'm facing is understanding how exactly it all integrates with c4d... when i construct a class which functions need to be there for c4d to understand what i'm telling it to do? which functions are called by default by c4d when running the plugin, which are not? How exactly are the data structures accessed? and so on...

I've looked through some tutorials and sites mentioned elsewhere in this forum, but mostly they are, like the SDK documentation, descriptive and not explanatory.

So any help would be greatly appreciated. cheers

On 01/05/2016 at 11:36, xxxxxxxx wrote:

Hello an welcome to the plugincafe.

I think, you should start here:

After you read that (I guess, you already did),
take a look at the very basic Plugin entry points:

You probably want to start to create an ObjectData plugin which acts as a generator object.

You'll have to inherit your plugin from ObjectData and implement its virtual methods, which are automatically called by C4D.
Any other custom methods can then be called from the virtual implemented methods, as this is quite common in C++ to extend base classes.

I suppose that the guys from Maxon will probably give you a more qualified answer here.As for the documentation - I agree, it could be more beginner-friendly. :)

And by the way, the SDK examples are a fundamental source of how to use the SDK, so take a look at its examples if you don't understand something...

On 01/05/2016 at 11:43, xxxxxxxx wrote:


That's kind of a broad question.
But in a nutshell. If you look up the type of plugin you want to make (in this case ObjectData) in the docs. It shows you a bunch of virtual methods to use. These virtual methods are what communicates with C4D.

You can create your own classes & methods if you want.
But the output from them typically has to be piped into one of those virtual methods for C4D to use it. This is called "overriding".
If you are not familiar with virtual methods. Then it would be a good idea to do some tutorials on them. Because using any SDK (C4D,Maya,Max,Qt,etc..) relies very heavily on overriding virtual methods.

In addition to the virtual methods. There are also smaller things in the C4D SDK like ID's and BaseContainers that are hard coded to communicate with C4D.
There's a lot of these little things to learn about. But the virtual methods are probably the biggest ones to get a grip on first.


*Edit DOH!
mp5gosu's fingers were faster than mine:wink:

On 02/05/2016 at 01:45, xxxxxxxx wrote:

Hello and welcome,

as already mentioned the base class for object plugins is ObjectData. You create a new object plugin by implementing a custom class based on ObjectData and registering this class with RegisterObjectPlugin(). To understand this process you must be familiar with object orientated programming and inheritance.

Please also take a look at the relationship between plugin classes and Cinema classes e.g. the difference between ObjectData and BaseObject. See NodeData – what is it good for?.

A object in Cinema can do various things. If the specific object is supposed to be a generator you must set the flag OBJECT_GENERATOR with RegisterObjectPlugin(). Then Cinema will call the object's GetVirtualObjects(). If you implement this function you can define the virtual objects the generator creates. You can access the cache in this context using CheckCache().

If this generator should use its child objects as input objects the flag OBJECT_INPUT must be set. Then you can use various utility functions to handle and hide the child objects.

The most primitive way of handling the child input objects is the compination of IsDirty(), SetDirty() and Touch(). A more advanced workflow is to use a dependece list with NewDependenceList(), AddDependence(), CompareDependence() and TochDependenceList().

The most elegant way to handle the input child objects may be to use GetHierarchyClone().

Best wishes,

On 02/05/2016 at 21:39, xxxxxxxx wrote:

Thank you mp5gosu, ScottA and Sebastian. Sebastian, thank you for taking the time to explain in more detail what i assume to be the proper way to set up a plugin. It's becoming clearer now. cheers