Home | Lehre | Videos | Texte | Vorträge | Software | Person | Impressum, Datenschutzerklärung | Blog
Introduction to C++ Plug-in Programming with Cinema 4D
-
Plugincafe
-
Library of Plugins
-
Documentation (SDK is already included with the installed software!)
-
Forum (with answers from Mikael Sterner)
-
Tools (Resource Editor etc.)
-
Plug-in ID numbers
-
Plug-in types
-
Command (within a menu)
-
Tag ("expressions", appended data, ...)
-
Object (parametric objekt, deformer, ...)
-
Tool
-
Shaders (channel shaders, volumetric materials)
-
Video post-effect
-
Export/import
-
Preferences
-
...
-
C++ and all that
-
C++: standard way to write plug-ins for Cinema 4D; can be compiled for
both Windows (a DLL named *.cdl) and Mac OS (a SO named *.xdl) without
change because the differences are encapsulated
-
COFFEE: a scripting language, needs not be compiled and thus is platform-neutral;
only for small and slow tasks
-
XPRESSO: a graphical programming system for automated behavior etc.
-
Directory structure of a C++ plug-in
-
Starting and ending plug-ins
-
Initially, Cinema 4D knows only functions like PluginStart.
-
Plug-ins have to register using a unique ID from Plugincafe. This is used
e.g. to identify the data of a plug-in inside a *.c4d file.
-
One DLL may contain and register several plug-ins, as does the SDK example
that is included in Cinema 4D.
-
Compiling a plug-in
-
Basics of the SDK:
-
plattform-neutral
-
proprietary types: LONG, Real, Bool (TRUE, FALSE)
-
proprietary memory allocation: gNew, gDelete (sets pointer to 0), for Arrays:
bNew, bDelete (sets pointer to 0)
-
Debugging
-
Using the standard debugger of Visual Studio
-
Output to built-in console with LongToString etc.
-
Debug mode with memory leak control: place a file c4d_debug.txt in the
working directory.
-
Special Features of the SDK
-
Dialogs with layout management
-
Ressource files, ressource editor
-
Attribute manager, "descriptions"
-
Internationalization
-
Interesting Classes
-
BaseContainer: universal storage for settings etc.
-
Vector for postions, colors, etc.
-
Bitmap
-
MovieSaver
-
Thread
-
Neighbor
-
Object-oriented concepts in the SDK
-
The first important class hierarchy: Atom <-- GeListNode <-- BaseList2D.
All 3D objects, materials, etc. inherit from BaseList2D and have to be
managed using Alloc and Free. Every Atom (and by inheritance all of its
descendants) knows its "type", which is a LONG number. The type of plug-in
3D objects, materials, etc. equals the corresponding registered ID number.
-
The second important class hierarchy: BaseData <-- NodeData <-- ObjectData
etc. The plug-ins themselves are no actual 3D objects, materials,
etc. but only accompany those. A plug-in inherits from the corresponding
class like ObjectData. What you would typically do with constructor, destructor,
and copy constructor is done with the regular methods Init, Free, and CopyTo.
-
By default, Cinema 4D stores, loads, and animates settings automatically.
BaseList2D::GetDataInstance returns a pointer to the container with the
current settings.
-
Attribute Manager
-
Generate user interface for settings from "Descriptions", which are similar
to resource files
-
Bind user interface elements to object data automatically
-
Animate settings
-
Default behavior can be overriden with functions such as NodeData::GetDEnabling.
-
Data types:
-
value with or without slider
-
color
-
file name
-
reference to an object (with drag & drop)
-
...