Hello World !
Ive spent a few hours on taking a look at the pynode api, creating some basic gameplay noodles for the blender game engine. Main motivation is from ue4’s allmighty kismet that any preschool child can use.
I created with some simple nodes for the sake of the proof of concept :
Events nodes
- Event Tick (fired at each frame)
- Event KeyDown (fired while your finger is holding the key)
Motion Nodes
- Object Rotate (performs some awesome rotation on the selected object)
I just wanted to see how complicated it would be to get something working ASAP.
With these 3 nodes i did a good start.
I implemented the 3 nodes using the custom nodes template. And did some ninja research on ui layouts.
I made a simple scene with a floor plane, a spot lamp, and a cube (the most amazing scene i could imagine, but unforunately i forgot to add a monkey head, im sorry)
After creating an amazing graph featuring the rotational super powers of the Cube i wanted to read the nodes inside the bge.
Sadly i discovered that the bge couldnt access the nodes… :’(
I had to find a way to export the nodes so that the bge could use them damnit !
I first thought about a json solution but when i looked at my screen, my hands already had coded an xml exporter, so xml imposed itself by speed (see ya next time J-son)
Temp xml structure example for the sake of this demo
<?xml version="1.0"?>
<data>
<nodetree name="NodeTree">
<node type="NodeEvtTick" name="Event Tick.001">
<output name="Exec">
<link to_socket="Exec" to_node="Object Motion.001"/>
</output>
</node>
<node type="NodeObjectRotate" name="Object Motion.001">
<object name="Lamp"/>
<rotation x="0.0" y="0.0" z="0.009999999776482582"/>
<input name="Exec">
<link from_socket="Exec" from_node="Event Tick.001"/>
</input>
<output name="Exec">
</output>
</node>
<node type="NodeObjectRotate" name="Object Motion">
<object name="Cube"/>
<rotation x="0.0" y="0.0" z="0.009999999776482582"/>
<input name="Exec">
<link from_socket="Exec" from_node="Event KeyDown"/>
</input>
<output name="Exec">
</output>
</node>
<node type="NodeEvtKeyDown" name="Event KeyDown">
<key id="D"/>
<input name="Key">
</input>
<output name="Exec">
<link to_socket="Exec" to_node="Object Motion"/>
</output>
</node>
<node type="NodeObjectRotate" name="Object Motion.002">
<object name="Cube"/>
<rotation x="0.0" y="0.0" z="-0.009999999776482582"/>
<input name="Exec">
<link from_socket="Exec" from_node="Event KeyDown.001"/>
</input>
<output name="Exec">
</output>
</node>
<node type="NodeEvtKeyDown" name="Event KeyDown.001">
<key id="Q"/>
<input name="Key">
</input>
<output name="Exec">
<link to_socket="Exec" to_node="Object Motion.002"/>
</output>
</node>
<node type="NodeObjectRotate" name="Object Motion.003">
<object name="Cube"/>
<rotation x="0.009999999776482582" y="0.0" z="0.0"/>
<input name="Exec">
<link from_socket="Exec" from_node="Event KeyDown.002"/>
</input>
<output name="Exec">
</output>
</node>
<node type="NodeEvtKeyDown" name="Event KeyDown.002">
<key id="Z"/>
<input name="Key">
</input>
<output name="Exec">
<link to_socket="Exec" to_node="Object Motion.003"/>
</output>
</node>
<node type="NodeObjectRotate" name="Object Motion.004">
<object name="Cube"/>
<rotation x="-0.009999999776482582" y="0.0" z="0.0"/>
<input name="Exec">
<link from_socket="Exec" from_node="Event KeyDown.003"/>
</input>
<output name="Exec">
</output>
</node>
<node type="NodeEvtKeyDown" name="Event KeyDown.003">
<key id="S"/>
<input name="Key">
</input>
<output name="Exec">
<link to_socket="Exec" to_node="Object Motion.004"/>
</output>
</node>
</nodetree>
</data>
When i saw this xml i was afraid, because as it is the bge couldnt do anything with it and it meant i had to code some classes to replicate the nodes behaviors in the bge (damnit !)
So, i coded the base classes, socket, node, Event nodes, and the full featured ~Object rotation node~
Then i coded a simple runtime wich captures the different events that should occur in the game (tick, keydown) and executes the corresponding nodes.
After 600 lines of code in 3 python files :
- Nodes.py (custom node tree and nodes for the node editor)
- PlayNodesCompile.py (xml exporter)
- bge runtime (PlayNodesRuntime.py)
I pressed Alt+P and BÂM ! It worked, the damn Cube was rotating at will in any axis !!!
Whatever you want to rotate in your scene will rotate !!!
Nodes.py allows you to create the gameplay nodes in the node editor.
PlayNodesCompile.py exports the xml representation of the nodes you created
You generate any number of gameplay graphs for any purpose, they will all be processed by the runtime.
****.xml
*****.xml
PlayNodesRuntime.py is the only file you would need in your project to play the game.
Dear bge users, can you tell me if you would be interested in this easy to use nodal logic system for the bge.
It is still compatible with the rest of the logic bricks.
Thx to pynodes, it is very easy to create the node gameplay system of our dreams in blender 2.6+, without the use of external libs or custom blender build.
I believe this could be an awesome way to create gameplay. There have been projects on nodal systems for the bge, the last one is the hive system, i find it a bit complicated to use and not user-friendly.
To unleash the full power of the bge there would be a trillion nodes to add in the PlayNodes system and it would take time.
Have you ever used unreal’s Kismet or cryengine’s flow graph or even threenodes.js ?!
http://udn.epicgames.com/Three/KismetReference.html#Actions
http://docs.cryengine.com/display/SDKDOC2/Flow+Graph+Editor
http://idflood.github.io/ThreeNodes.js/public/index.html
Blender Game Engine must have this feature now !