Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Straightforward example to add customized nodes? #3

Open
theshinyknight opened this issue Feb 7, 2017 · 4 comments
Open

Straightforward example to add customized nodes? #3

theshinyknight opened this issue Feb 7, 2017 · 4 comments

Comments

@theshinyknight
Copy link

Hi, Thanks for making this project public, I did try the example and it is perfect for generic usage.

Although I am having hard time to figure out exactly how do you create new nodes. Ideally I would like to have some guidance example, that show how did you make the nodes for the various operations; and what is the minimum viable code to actually get just the "work area" where to add nodes; and how to make nodes Input and Output.

The example that you made is really helpful but it is taking me some time to get to the basics; I know that you may not have time, but something step by step, that show starting from the inclusion of the control on the form, creation of a couple of different node types and how they interact with each other; would really be the fastest way to dive into your project.

Thanks for your efforts!

@komorra
Copy link
Owner

komorra commented Feb 7, 2017

Hi, take look at main readme file, section "Step 3 - Adding & extending Node Editor context type", especially look on the comments. Everything what is key here is the attributes around methods. I'm considering also to make short tutorial in some spare time. Thanks for the info.

@theshinyknight
Copy link
Author

Thanks for your reply; I did check the readme file, but it has bits and pieces about how to use the control.

I was looking for something more simple; like how to create a new node type (not yet on how to instantiate a node via right click menu; that would follow once you have designed and coded your nodes with input and output).

I will go through the example and see where did you declare the operations nodes; and start from there; but if you have time and can write something really simple in steps, about how to get started; I am sure that others will appreciate it too :)
Thanks!

@Luonnotar
Copy link

Hello, would it be possible to see examples on how to interact with custom editor?
How to read and write your node if you have a combobox, checkbox or a trackbar inside it?

 [Node("Trackbar", "Input", "Basic", "", false, false, typeof(TrackBar))]
        public void ParameterValue(string name, float input, float min, float max, float step, out float outValue)
        {
            outValue = input;
        }
        [Node("Combo", "Input", "Basic", "Choose output from combo", false, false, typeof(ComboBox))]
        public void InputValueCombo(float inValue, out float outValue)
        {
             outValue = inValue;
        }

Thanks!

@BlizzCrafter
Copy link

BlizzCrafter commented May 23, 2020

@Luonnotar it's simple:

In your custom control you should have something like this:

private void UpdateNodeContext()
{
    var node = (Tag as NodeVisual);
    if (node != null)
    {
        dynamic context = node.GetNodeContext();

        if (textureBoxRender.RenderTexture != null)
        {
            context.Texture = new NodeTexture2D(textureBoxRender.RenderTexture);
        }
        else if (!string.IsNullOrEmpty(context.Texture.GetTexturePath))
        {
            textureBoxRender.SetTexturePath(context.Texture.GetTexturePath);
        }
    }
}

Your Node(Visual) is set in the "Tag" property of your custom control. Take a look at how I get the dynamic context to access and use the node properties.

You only need to call "UpdateNodeContext()" from somwhere else. I'm sure you'll figure this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants