This document will describe briefly how the C4D specific classes (for example objects and documents) are used, and how the C4D messaging system works.
This section is an attempt to describe how a C4D scene is represented in C.O.F.F.E.E. For more information about each level, just follow the links.
A scene is represented by the class BaseDocument
. The document class is inherited from BaseList2D
, which means that the open documents are stored in a 2D linked list. Such lists can be traversed using the GetNext()
and GetPrev()
functions.
Each document stores a reference to the first object in the scene that may be accessed by the GetFirstObject()
function. Objects are inherited from the class BaseObject. This class is inherited from BaseList4D, which adds another dimension to the linked list. Thus a hierarchy similar to the one in the Object Manager is created. With GetUp()
and GetDown()
you can get the parent and the first child of an object, and with the inherited GetNext()
and GetPrev()
functions you can get the surrounding siblings. You can also get an object by its name, using the FindObject()
function in the document.
Each object then stores a reference to its first tag, accessed with GetFirstTag()
. Tags are inherited from the BaseTag
class, and are linked together in a 2D list in the order they appear in the Object Manager (though there are also invisble tags).
Objects also store a reference to their first animation track, accessed with GetFirstTrack()
. Tracks are inherited from the BaseTrack
class, and like tags they are in a 2D linked list as seen in the Time Line. Each track in turn has a 2D linked list of sequence, inherited from the BaseSequence
class, the first item of which can be accessed with GetFirstSequence()
.
From the sequence you can then get a linked list of keys, with GetFirstKey()
, and time control keys, with GetFirstTimeKey()
. You mustn't change the chronological order of the keys, so you should only add keys using the InsertKey()
and InsertTimeKey()
functions of the sequence, unless you know that they are in the right order (this also applies to inserting sequences, considering the disastrous possibility of overlapping sequences).
Let's return to document again before we're done. In addition to the object list it contains a list of all document materials, accessed with GetFirstMaterial()
. Materials are inherited from the class BaseMaterial
. The reference between a TextureTag
and its material is by a link: tag#TEXTURETAG_MATERIAL
.
Finally the document class also contains a 2D list of all render settings. These are of the class RenderData
and are accessed with the GetFirstRenderData()
function.
Please note that we've only dealt with the base classes here. The real objects, tags and tracks etc. of course contains other functions. For a full list of all classes see the Reference page.
Each class inherited from BaseList2D
has its own message port. You can send messages to this message port with the BaseList2D::Message()
function. An example is when you've moved a point of a polygon object. Then you have to call obj->Message(MSG_UPDATE)
so that the object can update its bounding box etc. More messages are available at the above link.
The BaseObject
and the BaseDocument
classes also has the functions BaseObject::MultiMessage()
and BaseDocument::MultiMessage()
. The former passes the message along to all the tags and animation tracks of the object and the latter calls MultiMessage()
of each object in the document. So in the above example one should really call obj->MultiMessage(MSG_UPDATE)
, to be sure that the objects tags can be updated as well.
The is also a core message channel that is global to the C4D application. Core messages can be received in non-modal dialogs with the GeDialog::CoreMessage()
. For example, the RotateIt.cof plugin listens for core messages that say that there's a new object active, and then updates its fields accordingly.
Plugins are not allowed to send core messages directly. Instead there is the EventAdd()
function. It is used to notify C4D of more major changes in the scene or globally, for example removing or adding objects or switching to another document.