THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 10/10/2007 at 06:34, xxxxxxxx wrote:
Cinema 4D Version: 9.5
Platform: Windows ;
Language(s) : C++ ;
I am trying to write a plugin that is capable of setting several orthographic cameras into the scene, yet I think I don't really understand the basics!? I've been looking at the plugins in the c4dsdk and couldn't find clues of how to do this. My guess is that I don't understand the basic architecture of C4D to do this properly. Are there any resources that would speed up my efforts? I'm looking for any fundamental knowledge about writing plugins. Espacially the control and changing the model of the camera, setting and rendering multiple views (which might include animations).
On 23/10/2007 at 11:54, xxxxxxxx wrote:
I recently started working on my first plugin only a few months ago with no coding experience whatsoever. What worked for me was to play around with scripts in the COFFEE editor, where you can get immediate feedback rather than constantly compiling and checking the results. The COFFEE SDK also has a tutorial in it, so that should give you a place to start if you're trying to create a full-fledged plugin.
You'll have to relearn a few things when you switch to C++, but you'll at least have a fundamental understanding of what's going on under the hood of C4D at that point.
On 25/10/2007 at 00:53, xxxxxxxx wrote:
thank you bandini for the reply. At some point I will certainly use COFFEE to get a better grip on C4D. My problem (was) is that I had to do some things quickly (like creating and setting KeyFrames), which - as far as I understood - are not possible with COFFEE ...
Anyway I think I made some progress in copeing with some aspects of plugin-programming using the C++ SDK. All I know is piecework from the things I read in the forum or in the SDK's reference, so its far from rock solid, but I think here are some points worth telling:
Plugin Types and Behaviour
A reply by kuroyume0161 in a thread started by mfranke named "Object creation" helped me a lot:
some noteson plugin types
Adding C4D Objects
One can add primitives (e.g. Cube, Sphere,...) by calling the GeneratePrimitive() method. Here is an example creating a plane:
> BaseDocument* actdoc = GetActiveDocument();
> Plane_ = (PolygonObject* ) GeneratePrimitive(actdoc, Oplane, NULL, 0, FALSE);
> actdoc- >InsertObject(Plane_, NULL, NULL, TRUE);
Other objects can be added the same way using the BaseObject::Alloc() method. Here is an example adding a camera:
> Camera_ =
> (CameraObject* )BaseObject::Alloc(Ocamera);
> BaseDocument* actdoc = GetActiveDocument();
> actdoc->InsertObject(Camera_, NULL, NULL, TRUE);
Some objects have C++-Methods that can be used conveniently to control their attributes, like the SetName() routine used in the code example above. More oftenly I had to use the SetParameter() method to change parameters or object states. Here is an example how the camera's viewing volume can be changed:
> Real focus = ...;
> Real aparture = ...;
> Camera_- >SetParameter(DescID(CAMERA_FOCUS), GeData(focus), 0);
> Camera_->SetParameter(DescID(CAMERAOBJECT_APERTURE), GeData(aparture),0);
In order to use this method one has to identify the 'ID defines' (e.g. CAMERA_FOCUS ) for the parameter. These are located in the headers (*.h files) or the resource files (*.res files) belonging to the object under consideration. I found these files belonging to the C4D api in the resource\res\description subdirectory of the C4D installation. (I see there is even more information in the *.res files, which I can't read yet). The datum to be accessed can be the (sub)component of another object (for instance the x-component of a Vector ). This is handeled using the DescLevel class. The following DescID for instance allows to access the rotation of an object around the y-axis:
One should read the SDK reference to GeDialog and use the ResourceEditor plugin provided by Maxon - the saved time when building dialogs makes it priceless!
At this point a different thread in the forum, started by mozg with the topic "add keyframe" gave me all I needed. Last time I looked it could be found here:
mozg/kuroyume0161 add keyframe
I know this post does not go directly to the heart of my primary question but at least helped me to achive something. It also provides some implicit clues on how plugin-programming works , and I hope that if others also post their experiences we'll get a pretty collection of "fundamental knowledge" here.