MaterialImportInterface Class Reference

#include <materialimport.h>

Inheritance diagram for MaterialImportInterface:

Detailed Description

A MaterialImport defines an import factory of a custom-defined material derived from BaseMaterial. The importer may be called on user-triggered file import operations. An import instance is created for every single material import operation and provided with the parsed material data, e.g. the parameter values that were parsed from FbxProperty types.

The importers are expected to be registered in MaterialImporters under a user-readable name may be used in user dialogs.

An importer can be used in the following manner:

maxon::DataDictionary importConfig;
importConfig.Set(maxon::material::IMPORT::CONFIG::NODESPACEID, C4DOS_Ge->GetActiveNodeSpaceId()) iferr_return;
// We create an almost default standard surface configuration.
materialData._materialTypeId = maxon::MATERIAL::PORTBUNDLE::STANDARDSURFACE::GetId();
maxon::material::ParameterStorageInterface::Insert(materialData._parameters, maxon::MATERIAL::PORTBUNDLE::STANDARDSURFACE::BASE_COLOR, maxon::Color(1, 0, 1), true, 0) iferr_return;
maxon::material::MaterialImportRef importer = importerClass.Create() iferr_return;
BaseMaterial* newMaterial = importer.CreateMaterial(materialData, baseDocument, importConfig) iferr_return;
CheckState(newMaterial != nullptr);
if (newMaterial->GetDocument() == nullptr)
{
baseDocument.InsertMaterial(newMaterial, nullptr, true);
}
Definition: c4d_basematerial.h:28
MAXON_METHOD Result< BaseMaterial * > CreateMaterial(const MaterialExchangeData &materialData, BaseDocument &baseDocument, const DataDictionary &config)
static MAXON_METHOD Result< DataDictionary > LoadDefaults(const Id &materialType)
static auto Create(ARGS &&... args)
Definition: apibase.h:2830
Col3< Float, 1 > Color
Definition: vector.h:84
#define CheckState(condition,...)
Definition: errorbase.h:510
The maxon namespace contains all declarations of the MAXON API.
Definition: autoweight.h:14
#define iferr_return
Definition: resultbase.h:1521
Definition: materialparameter.h:113
DataDictionary _parameters
Definition: materialparameter.h:132
Id _materialTypeId
Definition: materialparameter.h:125

Please note that an importer may not be able to handle the provided type of material and return an error.

Public Member Functions

MAXON_METHOD Result< BaseMaterial * > CreateMaterial (const MaterialExchangeData &materialData, BaseDocument &baseDocument, const DataDictionary &config)
 

Private Member Functions

 MAXON_INTERFACE (MaterialImportInterface, MAXON_REFERENCE_NORMAL, "net.maxon.material.interface.materialimport")
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( MaterialImportInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.material.interface.materialimport"   
)
private

◆ CreateMaterial()

MAXON_METHOD Result<BaseMaterial*> CreateMaterial ( const MaterialExchangeData materialData,
BaseDocument baseDocument,
const DataDictionary &  config 
)

Creates a material based on the provided material data. Configuration and destination BaseDocument are provided for context. The implementation is free to decide whether to insert the returned material into the document, or not.

Parameters
[in]materialDataThe material data to import from.
[in]baseDocumentThe destination scene of the creation.
[in]configThe import configuration.
Returns
The created material on success.