What are nodes...?

I’ve heard a lot of people talk about nodes, generally in programming. I was reading the Panda3D manual, and they were mentioned. But, forgive me if I sound utterly retarded asking this, what are nodes?

Now, I’d like to say what I thought they were, just from reading up on wikipedia, so I know if I was close to having the right idea. Why? No reason :stuck_out_tongue:

So, nodes are like parents in a tree. For example, this is what I believe to be a tree of nodes:

(I apologise for my terrible, terrible drawing skills xD)

In maths, this is called a factor tree, I believe, but anyway.

As far as I can tell, they are all nodes of each other(except for the first parent node). Maybe a better example is a class that inherits something. Like, a subclass of an enemy would be a node of that enemy, correct? Or have I got it completely wrong? Knowing me, I’ve got it wrong xD

So, what exactly are nodes?


Seems like you have it correct, unless my knowledge of it is also flawed :slight_smile:

Its a good question, I’m also not sure what nodes are exactly, I just see them as leaves of a tree, I can pull off a leaf and move it elsewhere, I can move a branch which will move all the leaves below it, I can change the colour of that leaf etc

This page might help:
en.wikipedia.org/wiki/Tree_%28da … erminology

The idea is that each node inherits its state (texture, shader, etc) and its transformation (position, rotation, scale) from its parent. This means that when you reparent a captain model to a boat model, the position of the captain becomes relative to the boat, so that when the boat sails away the captain will sail along with it, and when you turn the boat, the captain will turn with it. (As a result, if the captain moves forward while the ship has turned 90 degrees, the captain will still still move forward with respect to the ship.)

Most operations you do to a particular node will affect the entire tree below it. For instance, if you have a large model that is made out of smaller components (child nodes), so if you hide the parent node all child nodes will also be hidden. Or, you can set the texture on the parent node, and the child nodes will also have the texture (but they can override properties from the parent node if configured to do so). In Panda, all these properties combine in magical ways, so having both a texture on the parent node and child node will mean that there are really two textures applied to that component that are combined according to the node’s properties.

Thanks everyone! I’ll check out those wikipedia pages. :smiley:

As a completely irrelevant tangent, the English word “node” has the same origin as the word “knot”, and is presumed to originally refer to the knots tied at the connections of ropes in a fishing net. Mathematically, the word “node” is used to refer to the connection points of any kind of graph; or conversely, you can define a “graph” as a set of nodes with connection lines between some of them. There are whole textbooks written about graphs as a mathematical concept (but these abstract concepts are mostly irrelevant to Panda).

In scene-graph based tools like Panda, the word “node” refers specifically to the connection points of the scene graph, which is a specialized graph made to define the spatial and rendering relationship of various objects, as rdb explains. In fact, rdb’s explanation is the most practical and useful concept of a node and the scene graph you need; none of the stuff I’m saying in this post is necessary to understand.

For the record, the picture you show above is called a tree. One use of such a tree would indeed be as a factor tree, but there are other uses for trees as well. Mathematically, a tree is a specific kind of graph in which each node has exactly one parent and any number of children (except for the top node which has no parents). All trees are graphs, but not all graphs are trees. The Panda scene graph is usually a tree, because it has a node at the top (render), and usually each other node has exactly one parent; but it is possible to use scene-graph instancing to give a node more than one parent, so it can be more general than a tree. Specifically, the Panda scene graph (and most scene graphs in similar tools) is called a “directed acyclic graph”, because the lines connecting the nodes imply a direction from parent to child, and because loops or cycles aren’t allowed (you can’t have a node be a parent or ancestor of itself).