NodeSpaceInterface Implementation

Table of Contents

About

An implementation of maxon::nodes::NodeSpaceInterface allows to define and customize a node space. This node space defines how the node material will behave, e.g., defining the preview image generation, viewport representation, etc.

An implementation of maxon::nodes::NodeSpaceInterface references further implementations of these interfaces:

Description

The resource data type describing the node space must have the attribute "net.maxon.nodespace.base". The name of the node space is defined with "net.maxon.object.base.name".

Implementation

An implementation must define the Init() method:

Further methods are:

Within the Init() method, the properties of the node space are configured and stored in the given maxon::DataDictionary.

Further components are registered with:

See maxon::nodes::NODESPACE.

Note
The maxon::nodes::NodeSystemClass instance is stored as a member variable of the implementation class.

The creation of the default node setup is defined in a function:

  • maxon::nodes::NODESPACE::CREATEMATERIALGRAPHFUNC: Callback to a function creating the default node graph.

Material (end) nodes are registered with:

  • maxon::nodes::NODESPACE::MATERIALENDNODEIDS: List with the IDs of this material's end nodes.

Certain nodes may require different preview scenes:

  • maxon::nodes::NODESPACE::MATERIALPREVIEWIDS: List of nodes that require a right-click menu for scene choices. The selected scene type is then stored as PREVIEWIMAGEREQUEST::SCENETYPE (see maxon::nodes::PRVIEW::SCENETYPE).

The Ids of the renderers, supported by this node space, are defined in a BaseArray stored at:

  • maxon::nodes::NODESPACE::RENDERERS: List of all supported renderers.

A special texture node can be registered. This texture node will automatically be created when a texture is dropped onto the Node Editor window.

  • maxon::nodes::NODESPACE::IMAGENODEASSETID: Defines the ID of an image node.
  • maxon::nodes::NODESPACE::IMAGENODEPORTIDS: Defines the ports of the image node.

Further settings are:

  • maxon::nodes::NODESPACE::SPACEID: The node space ID.
  • maxon::nodes::NODESPACE::SPACENAME: the node space name.
class ExampleNodeSpaceImpl : public maxon::Component<ExampleNodeSpaceImpl, maxon::nodes::NodeSpaceInterface>
{
MAXON_COMPONENT(NORMAL, maxon::nodes::NodeSpaceBaseClass);
public:
static maxon::Result<void> CreateMaterialGraph(const maxon::nodes::NodesGraphModelRef& graph)
{
// Instantiate a node that only has a description, but no process function.
maxon::nodes::NodeTemplate userNodeSystem = maxon::nodes::NodesLib::LoadTemplate(maxon::AssetInterface::GetBuiltinRepository(), maxon::Id("net.maxonexample.nodes.docexample.endnode")) iferr_return;
maxon::GraphNode userGraphNode = graph.AddChild(maxon::Id("user node instance"), userNodeSystem) iferr_return;
return maxon::OK;
}
static maxon::Result<void> ConfigurePreviewImageRequest(maxon::DataDictionaryObjectRef request)
{
request.Set(maxon::nodes::PREVIEWIMAGEREQUEST::PROVIDER, ExampleImageProviderImpl::GetClass()) iferr_return;
return maxon::OK;
}
MAXON_METHOD maxon::Result<void> Init(maxon::DataDictionary spaceData)
{
_class = ExampleNodeSystemClassImpl::GetClass().Create() iferr_return;
spaceData.Set(maxon::nodes::NODESPACE::CREATEMATERIALGRAPHFUNC, maxon::nodes::NODESPACE::CreateMaterialGraphFunc(CreateMaterialGraph)) iferr_return;
// define end-nodes
maxon::BaseArray<maxon::Id> materialEndNodeIds;
materialEndNodeIds.Append(maxon::Id("net.maxonexample.nodes.docexample.endnode")) iferr_return;
spaceData.Set(maxon::nodes::NODESPACE::MATERIALENDNODEIDS, std::move(materialEndNodeIds)) iferr_return;
// define nodes using preview scenes
maxon::BaseArray<maxon::Id> materialPreviewNodeIds;
materialPreviewNodeIds.Append(maxon::Id("net.maxonexample.nodes.docexample.endnode")) iferr_return;
spaceData.Set(maxon::nodes::NODESPACE::MATERIALPREVIEWIDS, std::move(materialPreviewNodeIds)) iferr_return;
spaceData.Set(maxon::nodes::NODESPACE::CONFIGUREPREVIEWIMAGEREQUESTFUNC, maxon::nodes::NODESPACE::ConfigurePreviewImageRequestFunc(ConfigurePreviewImageRequest)) iferr_return;
spaceData.Set(maxon::nodes::NODESPACE::NODESYSTEMCLASS, _class) iferr_return;
spaceData.Set(maxon::nodes::NODESPACE::IMAGENODEASSETID, maxon::Id()) iferr_return;
super.Init(spaceData) iferr_return;
return maxon::OK;
}
private:
maxon::nodes::NodeSystemClass _class;
};
MAXON_COMPONENT_OBJECT_REGISTER(ExampleNodeSpaceImpl, g_nodeSpaceExampleSpaceID);
MESSAGERESULT::OK
@ OK
Ok.
maxon::ComponentWithBase
Definition: objectbase.h:2604
MAXON_COMPONENT_OBJECT_REGISTER
#define MAXON_COMPONENT_OBJECT_REGISTER(C,...)
Definition: objectbase.h:2427
maxon
The maxon namespace contains all declarations of the MAXON API.
Definition: c4d_basedocument.h:15
MAXON_COMPONENT
#define MAXON_COMPONENT(KIND,...)
Definition: objectbase.h:2166
maxon::AssetInterface::GetBuiltinRepository
static const MAXON_METHOD AssetRepositoryRef & GetBuiltinRepository()
maxon::OK
return OK
Definition: apibase.h:2546
maxon::Id
Definition: apibaseid.h:250
iferr_return
#define iferr_return
Definition: resultbase.h:1465
maxon::BaseArray< maxon::Id >
maxon::Result< void >
MAXON_METHOD
#define MAXON_METHOD
Definition: interfacebase.h:877
maxon::BaseArray::Append
MAXON_ATTRIBUTE_FORCE_INLINE ResultRef< T > Append()
Definition: basearray.h:569
iferr_scope
#define iferr_scope
Definition: resultbase.h:1374
maxon::nodes::NodesLib::LoadTemplate
static MAXON_METHOD Result< NodeTemplate > LoadTemplate(const AssetRepositoryRef &repo, const Id &assetId)
SCULPTBRUSHMODE::NORMAL
@ NORMAL
Samples the surface as the user moves over it the SculptObject and returns a new hit point and normal...
maxon::Delegate
Definition: delegate.h:235