#include <nodematerialexchange.h>
MaterialExchangeInterface defines the external representation of a node material. If not specifically defined for a node space, all node materials are assumed to be gray dielectric materials for viewport and export purposes.
You may derive from this interface and indicate support for particular material types in your node space the following:
Currently, the material types are declared in the file "datadescription_node_spaces.h" as port bundles As of R21.1, only the "maxon::NODESPACE::EXCHANGE::BUNDLE::VIEWPORTMATERIAL" is used, solely for viewport representation. However, this may change in the future, we may export the delivered parameters into various output formats such as OBJ or FBX without any further requirements from the component. In addition, we may consider supporting differing bundle types that will enhance the visual quality by the viewport, for example Disney Principled BRDF, Standard Surface, or USD Preview Surface. Furthermore, we may offer the ability the extend this material collection dynamically to offer a quality-optimized export to a particular output format, e.g. GLTF.
The lifetime of MaterialExchangeRef instances is managed by C4D. Generally, a space-specific instance is constructed for each node material. However, it may be rather short-living.
The instance is released if a space is switched from, or created respectively when toggling the active space in the GUI.
It is also released and recreated if the topology of the material changes, for example enabling the solo mode on a node flushes all cached textures and results in a new MaterialExchangeRef instantiation.
The MaterialExchangeRef is kept alive over parameter changes. Effectively, such a change is assumed to be a gradual / continuous change from the previously displayed state of the material.
Public Member Functions | |
MAXON_METHOD Result< void > | Initialize (const Id &intent, const Id &materialType, const NodesGraphModelRef &graph, const NodePath &endNodePath, const NodePath &soloNodePath) |
MAXON_METHOD Result< DataDictionary > | GetMaterialParameters () |
MAXON_METHOD Result< void > | ConfigureTextureProviderRequest (DataDictionaryObjectRef request) |
Static Public Member Functions | |
template<typename TYPE , typename KEY > | |
static Result< TypedMaterialParameter< TYPE > > | Extract (const DataDictionaryInterface ¶meters, KEY &&id) |
template<typename TYPE , typename KEY > | |
static Result< TypedMaterialParameter< TYPE > > | Extract (const DataDictionary ¶meters, KEY &&id) |
template<typename T , typename KEY > | |
static Result< void > | Insert (DataDictionary ¶meters, KEY &&id, T &&value, Bool isConstant, UInt dynamicTimestamp) |
template<typename KEY > | |
static Result< void > | InsertData (DataDictionary ¶meters, KEY &&id, Data &&dataValue, Bool isConstant, UInt dynamicTimestamp) |
static MAXON_METHOD Result< DataDictionary > | LoadMaterialDefaults (const Id &materialType) |
Private Member Functions | |
MAXON_INTERFACE (MaterialExchangeInterface, MAXON_REFERENCE_NORMAL, "net.maxon.nodes.interface.materialexchangeinterface") | |
|
private |
|
static |
Extracts / gets an typed parameter from a DataDictionaryInterface object with type check between the requested value type and the attribute's type.
TYPE | The value type of the parameter. |
KEY | The type of the key attribute. |
[in] | parameters | The DataDictionary holding the parameter. |
[in] | id | The parameter's attribute id. |
|
static |
Extracts / gets an typed parameter from a DataDictionary with type check between the requested value type and the attribute's type.
TYPE | The value type of the parameter. |
KEY | The type of the key attribute. |
[in] | parameters | The DataDictionary holding the parameter. |
[in] | id | The parameter's attribute id. |
|
static |
Inserts a typed parameter into the provided DataDictionary with type check between the provided value and the attribute's type.
KEY | The type of the key attribute. |
[out] | parameters | The DataDictionary to hold on the parameter. |
[in] | id | The parameter's attribute id. |
[in] | value | The typed constant / default value of the parameter. |
[in] | isConstant | True if the parameter is constant (and requires no texture-driven representation). |
[in] | dynamicTimestamp | The timestamp of the texture-driven representation. |
|
static |
Inserts an opaque parameter into the provided DataDictionary.
KEY | The type of the key attribute. |
[out] | parameters | The DataDictionary to hold on the parameter. |
[in] | id | The parameter's attribute id. |
[in] | dataValue | The opaque constant / default value of the parameter. |
[in] | isConstant | True if the parameter is constant (and requires no texture-driven representation). |
[in] | dynamicTimestamp | The timestamp of the texture-driven representation. |
|
static |
Loads and parses the data description of material and inserts the defined default values into a DataDictionary. This method caches once-loaded description for performance.
[in] | materialType | The (bundle) type of the material representation. |
MAXON_METHOD Result<void> Initialize | ( | const Id & | intent, |
const Id & | materialType, | ||
const NodesGraphModelRef & | graph, | ||
const NodePath & | endNodePath, | ||
const NodePath & | soloNodePath | ||
) |
Initializes the exchange representation for a node material. This method is called immediately after a change to the node graph by the viewport. In this method it is safe to access the original node graph.
[in] | intent | The intention behind the material exchange request. |
[in] | materialType | The (bundle) type of the external material representation. |
[in] | graph | The node graph of the node material. |
[in] | endNodePath | The path to the end node as it is known to C4D. |
[in] | soloNodePath | The path to the solo node as it is known to C4D. |
MAXON_METHOD Result<DataDictionary> GetMaterialParameters | ( | ) |
Fetches the parameters for the external material representation. The returned container is expected to be populated with the appropriate configuration for all bundle members. Parameters that are marked as non-constant may result in a texture baking request through ConfigureTextureProviderRequest() later on if demanded by the viewport, or by the export functionality. In this method it is safe to access the original node graph.
MAXON_METHOD Result<void> ConfigureTextureProviderRequest | ( | DataDictionaryObjectRef | request | ) |
Offers configuration of the preview request. The call to this function is made during viewport redraw if any non-constant texture-driven value is demanded.
In this method it is not safe to access the original node graph.
It expected that the attribute maxon::nodes::PREVIEWIMAGEREQUEST::PROVIDER is defined, e.g.
[in,out] | request | The data container of the preview request that is handed over to the PreviewImageProviderInterface::Initialize() method. |