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);
}

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.
maxon
The maxon namespace contains all declarations of the MAXON API.
Definition: c4d_basedocument.h:15
iferr_return
#define iferr_return
Definition: resultbase.h:1465
maxon::Color
Col3< Float, 1 > Color
Definition: vector.h:80
maxon::material::MaterialImportInterface::CreateMaterial
MAXON_METHOD Result< BaseMaterial * > CreateMaterial(const MaterialExchangeData &materialData, BaseDocument &baseDocument, const DataDictionary &config)
maxon::material::MaterialExchangeData
Definition: materialparameter.h:112
maxon::material::MaterialExchangeData::_parameters
DataDictionary _parameters
Definition: materialparameter.h:132
CheckState
#define CheckState(condition,...)
Definition: errorbase.h:502
maxon::material::MaterialExchangeData::_materialTypeId
Id _materialTypeId
Definition: materialparameter.h:125
maxon::material::ParameterStorageInterface::LoadDefaults
static MAXON_METHOD Result< DataDictionary > LoadDefaults(const Id &materialType)
BaseMaterial
Definition: c4d_basematerial.h:27