Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Creating node material presets for custom node space

    Cinema 4D SDK
    c++ sdk
    2
    5
    798
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Deyan
      last edited by

      Hi, is it possible to define custom node material presets for a custom node space?
      node_presets.png

      It seems that the node material presets are empty for the "Example" node space, and I couldn't find anything related to adding such presets in the SDK (or the examples).
      If there is a way - is it also possible to instantiate such a preset with a command plugin?

      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by

        Hi,

        I've asked the dev about how to do that and to clarify some points about that. I'll be right back once I got more information.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • ManuelM
          Manuel
          last edited by

          Hi,

          I've got some informations. It's not possible to insert your own material presets in that menu.

          Cheers,
          Manuel.

          MAXON SDK Specialist

          MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • D
            Deyan
            last edited by

            OK, thanks for the answer.

            About my second question - what is the proper way of creating a node material instance and modifying its graph to a "preset". I want to define several such presets as commands.
            There is no example for this and there seems to be no direct function for getting a mutable graph instance. From browsing the interface of NodeMaterial it seems the steps for achieving this are:

            1. Create a NodeMaterial instance.
            2. Add the desired node space to the material.
            3. Get the immutable version of the graph for the node space with NodeMaterial::GetGraph(..).
            4. Get the mutable node system from the immutable graph with NodesGraphModelInterface::GetMutableNodeSystem(..)
            5. Do modifications.

            Is my assumption correct and is this the expected way of achieving this?

            1 Reply Last reply Reply Quote 0
            • ManuelM
              Manuel
              last edited by

              Hi,

              you can create those preset with a commandData sure.

              When you add the graph to your node material it will call the function you defined in maxon::nodes::NODESPACE::CREATEMATERIALGRAPHFUNC See Proving Default Graph Setup for more information. So be sure to remove the nodes added by this function if they are not needed.

              You must create a NodeMaterial, insert it in the document, add the graph for the right nodespace and retrieve the graph itself (by first retrieving the nimbusref). We got an example on this page: Reading and Modifying Node
              This page also contains an introduction to Transaction. maxon::GraphModelInterface::BeginTransaction must be used if you want to modify the graph. You can than Commit your changes, which will ensure the graph is in a correct state. You can have a look a nodespace_impl.cpp, you will find the function CreateMaterialGraphDefaultSetup. remarque: this function doesn't need transactions to modify the graph.
              In this handbook, we are using transaction to modify some port's value inside a graph. With both examples, you will understand how to add nodes, connect them, and sets values.

              Cheers,
              Manuel.

              MAXON SDK Specialist

              MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • First post
                Last post