Got finally some more time to work on this…
New version 0.1.5 is on Github.
Change Notes:
-Previous nodes done by the converter will no longer work with this version. If that’s a problem for you, please send me the node code, so I can convert it. (I didn’t wrote any upgrade converter, since this is still in Alpha phase)
-The node interface is now like this:self.value_set(obj, attr, val)
self.value_get(obj, attr)
self.addNode(NodeType, **NodeAttributes)
self.delNode(Node)
self.addInput(SocketType, **SocketAttributes)
self.delInput(Socket)
self.addOutput(SocketType, **SocketAttributes)
self.delOutput(Socket)
self.addLink(Socket, Socket)
self.delLink(Link)
*nodes, *links, *inputs and *outputs are placed in the self., for convenience.
-It’s now possible to place the node in a different menu. You only need to have the following function:def menu_draw():
[INDENT=2]return Category.Identifier, Category.Name
[/INDENT]
If the function is not there then a default category will be created. And the same if there isn’t any Category with those properties.
(this is still incomplete and for now, the default order on the add menu may change if adding nodes to existing Categories)
If you want to block the internal nodetrees from appearing in the Add menu, you need to uncomment the configBlender() and revertBlender() in the register and unregister functions of the init.py
(I just left it like that because sometimes is usefull for looking inside the nodetrees, for debugging purposes)
For those who’ll look to the source code… there’s a call in the ShaderNodeBase to a ShaderNodeScript.compile method.
Consider it the Easter Egg!
That’s right! I’m writing a compiler. Most part of the ast generator is ready, as well as the lexer and the basic structures for the grammar.
This is because making a mathematical function by adding operators, then linking everything is a pain!!
But I stumbled in a small dilema, from wich I would like to ear from you.
Should I base the script language in Python or in OSL?
Note that lots of things from OSL and Python will not be present.
I was thinking in something like this for python:
def defaultNodeScript(*inputs, *outputs):
setattr(inputs, 'Metadata Attributes')
def functionA(*inputs, *outputs):
outputs=some function with the inputs
def functionB(*inputs, *outputs):
outputs=some function with the inputs
outputs=do something with the inputs and the functions
For OSL it would be more or less the same, but with only 4 types: float, float3, float4, Closure
Anyway I’m opened for discussions about this, as I clearly haven’t made my mind.
@Chukx_007, I told you something wrong a few posts ago… although the private nodetree is stored in the blend file, Blender itself doesn’t change the node by the nodetree. I’m still figuring the best way to do it, so for now one must change the nodes in all materials manually (maybe an option on saving?!)