L Systems (in Maya) : Python / C++

The L Systems used here are from the paper The Algorithmic Beauty of Plants by Przemyslaw Prusinkiewicz and Aristid Lindenmayer. The basic drawing commands are listed below:

F Move forward one step. Draw a segment.
f Move forward one step. Do not draw a segment.
+ Rotate around the Y axis by one step.
- Rotate backwards around the Y axis by one step.
& Rotate around the X axis by one step.
^ Rotate backwards around the X axis by one step.
\ Rotate around the Z axis by one step.
/ Rotate backwards around the Z axis by one step.
_ Rotate around the Y axis by 180.
[ Push the current state onto the stack, or SAVE current position.
] Pop the stack, or SET current position to last saved position.

L SYSTEMS IMPLEMENTATION   ————

This is a Maya plugin that contains two parts: a python / MEL plugin implementation of L Systems, and a C++ plugin implementation. The former can be seen in the first 2:09 seconds of the video — after activating the plugin item in the menu, a pop-up window appears that takes an L System grammar as input, either through loading a grammar file (a .txt file containing the grammar) or just typing out the grammar in the window. The number of iterations, default step size, default angle size, must be defined by the user before the L System is generated.

The second implementation takes the same arguments, but because it is built using a C++ node, the parameters can be modified and visualized even after the L System is generated. The number of iterations is tied to the current frame number in Maya, so it "grows" as you move along the timeline.

LSYSTEM INSTANCER   ————

This implementation of L Systems also includes the following additional grammar:

* Draw a flower.

There are two main "nodes" (both fully C++ implementation): a randomNode and an instancer.

  • The randomNode simply takes a piece of geometry and creates a set number of instances (In Num Points) scattered randomly from within the defined bounds (In Max and In Min).
  • The instancer similarly creates a series of instances from input geometry, but for this particular plugin, it's used as part of the backend for an L System instancer: one piece of input geometry is used to draw the main branches of the L System, and the second geometry is drawn whenever we have a flower.

There are four different functions supported by this instancer:

  1. RandomNode Default: This creates a polygon sphere and connects it to a randomNode.
  2. RandomNode Custom: This requires the user to select a single object, and throws an error if there is not exactly 1 object selected. This object is then connected to the randomNode, and the user can edit the properties of the randomNode.
  3. LSystem Default: This creates an LSystem with branches and flowers, which uses a polygon cube with an instancer for the branches, and a polygon sphere with a second instancer for the flowers. This has all the functionality of the original LSystem plugin.
  4. LSystem Custom: This again creates an LSystem with branches and flowers, but it requires the user to select two objects: the first is used for branches, and the second is used for flowers. This works similarly to the LSystem Default command, but allows the user to swap out the branch and flower geometry.