If you want to add some extra parameters with custom logic, you have to implement your own translator in a C4DtoA module (which is basically a normal C4D plugin with some extra functions).
Let's add a custom checkbox above param2. Enable and export param2 only if the checkbox is checked, otherwise, the color should be a default red.
To achieve this you must create your own C4D plugin, which will be a module of C4DtoA. First , you have to setup your project.
- Compile the C4D API. Project files are located in $C4D_INSTALL/resource/_api_lib in R15 or $C4D_INSTALL/frameworks/cinema.framework/project in R16.
- Create a new project (e.g. in Visual Studio or Xcode), include the C4D API headers and link with the compiled API lib. You can check the $C4D_INSTALL/plugins/cinema4dsdk example project.
- Include the C4DtoA API headers from $C4D_INSTALL/plugins/C4DtoA/api/include and link the c4dtoa_api.lib from $C4D_INSTALL/plugins/C4DtoA/api/lib.
Create your main plugin file (MyPlugin.cpp) where you register your C4DtoA module in MSG_C4DTOA_MODULE_START.
You have to create resource files, a node for your shader and a custom translator. Best way is to use the resource_generator tool.
Generate default resource and source files using the resource_generator tool of the API. Note that your shader library should be added to the ARNOLD_PLUGIN_PATH.
Resource files are generated at the 'output' folder by default You can specify any folder as the last parameter of the command.
Edit description/ainode_myshader.h and add an id to the new checkbox parameter. If you need a unique id in the application you can use the paramid_generator tool of the API. Note that a unique id is necessary if you want to use the description in a generic node (like the Arnold Material). In our case it's not necessary, but let's see how to use the tool.
Edit the layout in description/ainode_myshader.res.
Add a label to the checkbox in strings_us/description/ainode_myshader.str.
Set the default value of the checkbox (ArnoldMyshader.cpp).
Add logic to the Material node of enable / disable param2 by the checkbox value.
Obtain a unique id from Plugin Café and add this id to the ArnoldMyShader.h header.
Register your C4D material node in the main plugin file (MyPlugin.cpp).
To use the description defined with your node you have to add your node id to the meta data file (myshader.mtd).
Register your custom translator in the main plugin file (MyPlugin.cpp), as in the previous example.
Add export logic to the translator (ArnoldMyshaderTranslator.cpp).
- Compile your project and copy the res folder and the plugin binary (cdl64 on Windows, dylib on OSX) to $C4D_INSTALL/plugins/MyPlugin folder.
The source code for the example is attached here.
On Windows you just have to copy the folder to your C4D plugins folder and open the Visual Studio solution (myshader_example.sln) to build. Select the configuration of your C4Dd version (R15, R16 or R17). You can also change the path of your C4D folder in projectsettings.props.