Skip to main content
GameDev.net gamedev.net
🔒 Locked

Node-based interface: How to start from scratch?

Started by Red_falcon Oct 25, 2009 at 6:38 AM 1 replies 3.2k views
Original Post
Red_falcon
Red_falcon
Hello, for a couple of years i had the intention to write own node-based interface like Node Editor in Blender, Hypershade in Maya or MapZone. Now i finally got some spare time for it so the plan is to write in C# and visualize in WPF. But my first problem is, i cannot get my had wrapped around the data structures. I'm not that bad at programming, but this thing gives me headaches. I wrote a little test application to connect nodes between their pins and to check for data type of the connection. But it feels not really right. Base class Node for nodes and base class Pin for pins, also a Connection class exists. It looks all very simple, but if i look at other source code of similiar programs i have no idead why they look so complex and what my mistake is. Should it be done like an interface pattern? I would appreciate some suggestions or links how it's done.
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish
zyrolasting
zyrolasting
Hey Red Falcon!

Speaking from experience, I suggest you look at what others do, but don't worry about their code as much as the idea behind the code. You can infer on the system just from a GUI. It might help you to remember what you know, and look at where this topic becomes abstract.

What do we know about node based setups? Pretty much one thing: Each "node" can represent anything you want. A.I. Developers treat nodes as a section of a graph to navigate and Autodesk products use multiple nodes for multiple purposes. The only special thing about node based constructs is that something connects them all together. You could say you and I are nodes of the GDNet forum. Typically it's pointers to nodes IN a node structure that establish this connection. One of the simplest examples of a node based construct is a Linked List. I assume you know what this is... Pretty basic. [smile]

You can decide how the nodes connect. Linked Lists are bi-linear: They only care about what node comes before or after the currently selected one, if any.
Other setups like in Autodesk products are hierarchical. The nodes are aware of their siblings (Which can also be a bi-linear relationship) and children. Note how I use the word "aware". The more open connections you have for a node, the more maintenance you have to give for the whole system.

Quote:
Base class Node for nodes and base class Pin for pins, also a Connection class exists.


Personally I think going for more than 2 classes on one of these systems is too complicated already.

I can go further if you need me to, but I use C++. Just remember this: Recursive programming is a real plus here. Just make a struct of type A, and toss pointers in there of the same type that represent a certain relationship with an instance of a node.

I hope this helps.
Cheers!
-Zyro
Red_falcon
Red_falcon
Hey,

thanks for your answer, i will reflect on this later this day, cause other work wits for me. But it seems very helpful.

I will use such graph for different things, but since i'm OpenGL programmmer, it will be used to generate GLSL shader. Cause i couldn't find free editor which will give me all options i want and especially not for GLSL 1.40/1.50.

My nodes are only container for pins. Each output pin will hold the value (int, float, matrix, color) it should give to input pins they are connected. Evaluation of the container/pin that changed shouldn't be big hassle cause of the separation, in my opinion. I hope this idea is not too dumb.

Greetings
-----"Master! Apprentice! Heartborne, 7th Seeker Warrior! Disciple! In me the Wishmaster..." Wishmaster - Nightwish

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.