THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 25/10/2007 at 00:53, xxxxxxxx wrote:
Hi,
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);
> EventAdd();
> _
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);
> Camera_->SetName("MyCamera");
> BaseDocument* actdoc = GetActiveDocument();
> actdoc->InsertObject(Camera_, NULL, NULL, TRUE);
> EventAdd();
> _
Setting Parameters
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:
> _
> DescID(DescLevel(ID_BASEOBJECT_ROTATION,0,0),DescLevel(VECTOR_X,0,0))
> _
Building Dialogs
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!
Setting Keyframes
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.