Pyjea Blender Nodes

Python and Logic Nodes for Blender

Construct Blender scenes using a simple node abstraction layer, generate scenes and animation. Test logic, live-edit, preview, and export to THREE.js. Supports Blender 2.79 and newer. Requires Python2 and PyQt5. Platforms: Linux and Windows10.

Primitive Nodes


Primitives and Instance nodes must be given a unique name, all other input sockets are optional. By default the position of the node itself will be used to set the X and Y position of the object, use a Vector node if you want to override this and set another position.

Instance Node


Use the instance node to create an instance of a primitive, plug the object output socket of the primitive into the instance input socket of the instance node. Using instances will save on bandwidth when you export to THREE.js.

Modifier Nodes


Primitives can have a Modifier stack input. The example above has a Random node plugged into the width socket of the Bevel modifier.

Python Node


The Python node runs in the Blender process, and can call the bpy API. In the example above the object is rotated on its X axis. When the script is updated it is sent to the Blender process, and updates the Blender Text block of the same name. Note that in Blender the rotation vector is called rotation_euler, while in THREE.js its called rotation

Abstraction Variables

Abstraction variables are special latin characters that help you abstract away hard coded values from your script logic. This lets you write code that a game designer can safely plug values into, without touching your code directly. This works at both the Script Node, and Object Node levels. I originally wrote about this concept here. To create a new abstraction variable, press keys: F1-F12, with the Python Node selected.

Above, the first Abstraction Node is used to define the variable ʂ at the script-level. The Script Node is plugged into two mesh primitives, leaving the variable ʆ undefined. The extra Abstraction Nodes define different values of ʆ for each object. This demonstrates how to use both script-level and object-level abstraction variables. The concept is similar to classes and subclasses in programming - here a script is like a base class, it defines the shared variables, then each object subclasses the script and defines its own variables.
Note: when exporting to THREE.js using PyJS each abstract variable is translated to a node object that can be live edited. Note: when exporting to THREE.js using PyWASM, a C++ subclass will be generated for each set of abstract values.

Tile Node


testmap1.odt
testmap1.docx
The Tile Node allows you to define top down view maps using rich text format (RTF), this is a copy-and-paste compatible format used by LibreOffice, MS Office, web browsers.
You can directly use unicode symbols defined by plugins, and link any node based model to single letter variables (a-z) in the map. Use the Tile Abstraction Node to link a node to a variable in the tile map. Tile Node also contains its own micro language and syntax for calling functions and setting data: M(...) where M is the name of the variable or unicode symbol.

Tile Node Basic Syntax

The syntax M(*N) can be used to instance M, N times to the right. ProTip: use this syntax to copy a floor N times to the right, to fill in the space that a following command may take up. Note: you can use M(*NšŸŽ²) to create a random number of instances.

Maps can quickly become cluttered with commands, and space lost for placement of tiles. You can workaround this problem by using Header Macros. Header Macros are placed at the top of your map, and use C/C++ macro style syntax. Example:
#define FOO BAR
A Macro is then used in a function call like this M($FOO)

testmap2.odt
testmap2.docx

Tile Node Waypoint Syntax

You can define waypoints in your map using: šŸ…šŸ…‘šŸ…’šŸ…“šŸ…”šŸ…•šŸ…–šŸ…—šŸ…˜šŸ…™šŸ…ššŸ…›šŸ…œšŸ…šŸ…žšŸ…ŸšŸ… šŸ…”šŸ…¢šŸ…£šŸ…¤šŸ…„šŸ…¦šŸ…§šŸ…ØšŸ…©
Animate a model along those waypoints by using the syntax M(šŸ…...).
Each waypoint can also have its own options using šŸ…(...). A +number option will pause movement for N frames (integer) or N seconds (float). Example: šŸ…(+30)
If a +number option is followed by šŸŽ², then the pause time is randomized.
A +quoted string option will trigger a dialog window to appear over the object with the given text. Example: šŸ…(+'hello world')
By default the object will move along the waypoint path until it reaches the end, then reverse direction. To add a random chance of a direction switch at any waypoint use the question mark option. Example: šŸ…(?)

Tile Node Special Colors

Water is creating by setting the symbol background color (highlight color) to pure Blue. Depending on the symbol type, the object height may be lowered, or scaled down.
Plants are generated for tiles near water that are green.
testmap3.odt
testmap3.docx

The underscore symbol, and block symbols that are green (background or foreground colors), will generate Grease Pencil grass, the height of the grass is based on the intensity of green (more green is taller grass). This requires Blender2.8+ for proper rendering.
testmap4.odt
testmap4.docx


Armature Nodes

Above: the supported armature types. Drag and drop onto the workspace, give it a name (the first slot), then move the node (or connect its output to a print node).
Below: add a mesh to the bone children socket to instance that mesh for each bone, if no mesh is given cubes are the default.

Armature nodes create rigged characters that you can control with the keyboard and mouse, or a dual analog gamepads.

Keyboard: W key moves forward, S key moves backwards, A key step left, D key step right. Mouse: mouse look first person style control, right click jumps.
Gamepad: left analog moves forward and back, and turn left and right. D-pad: moves forward and back, left and right is step left and right. Buttons: jump and move other body parts. Second gamepad will control the face (if the character has face parts). Third gamepad will control head rotation and location.



Note: armature characters are not currently exported to THREE.js