Open Search
    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);
    static MAXON_METHOD const AssetRepositoryRef & GetBuiltinRepository()
    MAXON_ATTRIBUTE_FORCE_INLINE ResultRef< T > Append(ARG &&x)
    Appends a new element at the end of the array and constructs it using the forwarded value.
    Definition: basearray.h:627
    Definition: objectbase.h:2672
    Definition: delegate.h:240
    Definition: apibaseid.h:243
    static MAXON_METHOD Result< NodeTemplate > LoadTemplate(const AssetRepositoryRef &repo, const Id &assetId)
    OK
    User has selected a font.
    Definition: customgui_fontchooser.h:0
    return OK
    Definition: apibase.h:2740
    #define MAXON_COMPONENT(KIND,...)
    Definition: objectbase.h:2229
    #define MAXON_METHOD
    Definition: interfacebase.h:1020
    #define MAXON_COMPONENT_OBJECT_REGISTER(C,...)
    Definition: objectbase.h:2490
    NORMAL
    Definition: lib_birender.h:2
    The maxon namespace contains all declarations of the Maxon API.
    Definition: autoweight.h:21
    #define iferr_scope
    Definition: resultbase.h:1396
    #define iferr_return
    Definition: resultbase.h:1531
    Definition: node.h:10