Unsolved Best practices for loading textures?

I would like to create a C++ plugin that is able to load textures from a directory and allow the user to drag/drop the textures into C4D for use in creating materials.

Is there a document that describes the best practices for accomplishing this task?

Hello @jpheneger,

Welcome to the forum and thank you for reaching out to us. Your question is a bit too broad and specific at the same time to be answered in a truly meaningful manner. Or in short, we neither do have a code example, nor a manual which covers this specific case. We also cannot guide each new user manually through the stages of creating a plugin. Or put absolutely, 'if necessary, we will provide code examples, but we will not provide full solutions or design applications', as stated in under scope of support in our forum guidelines.

I would however recommend reading these:

  • Plugin Development: Describes the technical requirements for building plugins with the Cinema 4D SDK.
  • CommandData: The plugin hook you probably want to implement here.
  • GeDialog: Represents a window which can be opened, closed, docked, and populated with GUI gadgets. Your CommandData will/can use such dialog to realize its GUI. You can find C++ GUI examples in general here. Most of them are a bit bloated, a smaller one is gedialog_gadgets which exemplifies both CommandData and GeDialog.
  • TreeViewFunctions and SimpleListView: These are the handler interfaces for GUIs specialized in displaying tree and lists of things which you might need here. See also ListView example and TreeView examples.
  • Resource File Manual: Describes how to describe GUIs with the classic API GUI markup of Cinema 4D, resource files.
  • Cinema 4D Threads Manual: Cinema 4D comes with threading restrictions especially regarding scene manipulation, one should be aware of them.

And last but not least, what you want to do, is largely covered by the Asset API - storing textures as reusable things, displaying them in a manager, etc. Depending on what you want to do, you could either simply open an Asset Browser popup for the existing asset sub type SubType_ENUM_MediaImage or write your own asset type wrapping textures. If you wanted to, you could also write your own "Asset Manager" with the techniques described above and only use the Asset API as a data layer.

You could also use WatchFolderAssetRepositoryInterface to store your assets in watch folders instead of the more abstract native database format.

  • Asset API Handbook: Demonstrates how to provide content as reusable assets served with the Cinema 4D Asset Browser.
  • Get asset from asset browser python: Thread here on the forum, I showed there how to create materials via asset textures with drag and drop in Python. I had to be a bit creative in some places due to the limitations of the Python API. In C++ you do not have to do this, but this might still be helpful.


MAXON SDK Specialist