Intro to Maxon Cinema 4D SDK
Post by Andre Berg of Iris VFX
“We will kick it off with a brief tour of what’s included with the CINEMA 4D SDK.
Then I will show you two ways of accomplishing the same goal: setting up your very own plugin.
The first way will have me demonstrate briefly how to manually copy bits and pieces from the SDK examples such that you are left with a starting point for your own plugin.
The second way will allow me to show off how my recently released CINEMA 4D Plugin Wizard application makes this process even simpler and much quicker.
Once we set up our bare-bones template, I will then show you how to create your very own shader plugin:
a sexy turbulence-based noise shader.
A Few Notes
This episode serves as a bare minimum starting point from where we will expand on in future episodes.
I won’t be spending too much time on how exactly a plugin is put together. We will also not be coding much.
This episode accomplishes exactly two things:
It shows you the necessary steps to create your own bare-bones plugin template as painlessly as possible.
It gets a nice result quickly, to pique your interest so you may experience the motivation to embark on your own journey.
And finally: as my main means of recording is OS X based the video shows OS X. However, if you are on Windows don’t fret.
I do use Windows as well, and the main reason I am writing this blog post is that it provides me with an opportunity to attach screenshots for a Windows version of the tutorial.
Visual Studio and Xcode are very similar these days in their functionality. Sure, the feature may not have the exact same name but you can usually deduce what the equivalent is between both IDEs.If you do get stuck though, don’t hesitate to leave a comment. Either here or on the Vimeo page for the tutorial video.
Setting The Host Application In Visual Studio
Since the compiled plugin is not an executable program by itself it needs CINEMA 4D to actually be able to run. CINEMA 4D in this case is the plugin’s host application.
In the video I mention how to set up a host application in Xcode, so to complement this, here are the steps to set the host application in Visual Studio Express 2012:
Shader Plugin Template for R14
I was asked if the shader plugin template will work with CINEMA 4D R14.
Sadly, it won’t.
The SDK changed rather significantly between R14 and R15. Many base types got replaced, for example Float in R15 was called Real in R14, Int32 in R15 is LONG in R14. These are just a few of the many changes done with the R15 SDK.
The changes are so numerous in fact that a define was introduced, so you can compile plugins using the pre-R15 SDK types with the R15 SDK: if you define the preprocessor macro __LEGACY_API in your compiler settings, you can continue to use LONG et al. in your plugin’s code and still compile with the R15 SDK.
What does this mean for the shaderplugin template? Well, I need to adjust the one included with the Plugin Wizard so it uses the pre-R15 SDK types. You can download the adjusted template at the end of this paragraph.
To use it, drop the shaderplugin_r14 directory inside the c4dplugwiz_data/cpp folder included with the Plugin Wizard so it sits on the same level as the original shaderplugin template (actually, it doesn’t matter where you put it, I just think it’s nice to keep things tidy).
Here’s the template:
Here’s what needed changing:
Further customizing our result, we are going to be adding a slider to the user interface to control the octaves of the turbulence function. Along the way I am going to filling in a lot of the missing blanks I glossed over in the first episode.
I am going to be showing you what makes up our source files, our resource files and how it all comes together.
Here’s the graphic for the res folder contents as shown in the video. Licensed under a Creative-Commons-3.0-Attribution license.
Result for R14
If you were following along using the shaderplugin_r14 template that I previously attached to last installment’s post, here’s the final result for the R14 SDK.
In this episode we edit the resource definition files by hand. I find that when teaching, it is actually better to show the manual way of doing things first before showing the automated way. What is the automated way in this case?
Well, MAXON have created a plugin called ResEdit. This is a WYSIWYG user interface editor for CINEMA 4D resource files.
It has the ability to load and save resource files, it helps with creating and maintaining string tables and thus it can help you maintaining multiple tables when localizing your plugin.
I might do a little intermission episode covering the ResEdit workflow. If you want to see this video being made, please leave a comment below.
For now, know that ResEdit is available for free by going to MAXON’s developer support website.”
Follow these screenshots to get your download: