To export a custom Material definition (read ExchangeMapper Material Definition Manual), from your own custom Cinema 4D material, the next interfaces need to be implemented according to your need:
One material can have multiple maxon::material::MaterialExportInterface or maxon::nodes::NodeMaterialExportInterface implementations describing how the export process will work.
The export process provides automatic baking if a given material description is not handled by the maxon::material::MaterialExportInterface or maxon::nodes::NodeMaterialExportInterface implementations through the maxon::NODESPACE::EXCHANGE::BUNDLE::VIEWPORTMATERIAL material description.
As an example, if an FBX is exported but the implemented exporter only handles a VIEWPORTMATERIAL material definition for the given material, the VIEWPORTMATERIAL material description provided by the exporter will be mapped to an FBX material description automatically.
However, it's relevant to remind that this translation is a lossy translation, with data being sacrificed.
For better handling, it's instead suggested to directly output an FBX material definition. For more information read ExchangeMapper Material Definition Manual.
A maxon::material::MaterialExportInterface can be called at any time, e.g. from a SceneLoaderData but also from a regular CommandData or anything else.
A maxon::material::MaterialExportInterface provides few methods:
All MaterialExportInterface shall be registered using a maxon::material::MaterialExportDescription into the maxon::material::MaterialExporters registry.
A maxon::material::MaterialExportDescription links a given Classic API Plugin ID to a maxon::material::MaterialExportRef.
Example of an implementation using the SimpleMaterial from the Cinema 4D SDK as the source of the export process.
maxon::nodes::NodeMaterialExportInterface can be called at any time, e.g. from a SceneLoaderData but also from a regular CommandData or anything else.
A maxon::nodes::NodeMaterialExportInterface provides few methods:
To register a supported material definition, the maxon::nodes::NODESPACE::MATERIALEXCHANGEBUNDLEIDS attribute of the node space shall be filled with a maxon::BaseArray of material bundle maxon::Id.
To register the custom exporter, the maxon::nodes::NODESPACE::MATERIALEXCHANGECLASS attribute of the node space shall be filled with the maxon::nodes::NodeMaterialExportInterface maxon::Class object.
If no exporter is defined for a given node space, a fall-back is performed by the maxon::nodes::MaterialExchangeInterface to create a textured material of type maxon::NODESPACE::EXCHANGE::BUNDLE::VIEWPORTMATERIAL.