TreeSim
Todd Bertorelli
Description

TreeSim is a program that can render plants from a given LSystem.

The program applies a given ruleset to an axiom a specified number of times. Then, it applies user-defined rules for each resulting term, such as moving the vertex cursor or placing a vertex.

The program fills in the resulting tree by constructing a parent-child relationship between the vertices that were placed. Mass springs are added between each child, parent, and grandparent to simulate structural forces. Wind and gravity forces can be controlled by the user during the simulation, and the tree's structure will respond to these changes.

The images on this page showcase this L-System:

Pythagoras Tree
  • Axiom: 0
  • Terms:
    • 0
      • Move cursor forward 0.1 units.
      • Reduce cursor mass to 95% of current.
      • Reduce cursor radius to 95% of current.
      • Reduce restoring force to 90% of current.
      • Place a tree vertex with the current cursor state.
    • 1
      • Same cursor operations as rule 0.
    • [
      • Push the cursors state onto its stack.
      • Turn the cursor left 30 degrees.
    • ]
      • Pop the cursors state off its stack.
      • Turn the cursor right 30 degrees.
  • Rules:
    • 0 -> 1[0]0
    • 1 -> 11
A Pythagoras Tree with 3 rule applications.
The same Pythagoras Tree as above, but with 4 rule applications.
Features
  • LSystem Expansion and Turtle Graphics
    • Supports expanding any user-defined L-System
    • Supports user-defined terms that modify a drawing cursor, with a state stack.
  • Implicit mass-spring physics
  • Wind/Gravity force simulation
    • Wind and gravity are controlled by user input.
    • Wind can also be toggled to have variable velocity to simulate gusts.

To increase structural integrity of the tree, the user may also add a restoring force to certain parts of the tree. The mass of the resulting vertex can also be controlled. These features allow certain parts of the tree, such as the trunk, to stay more rigid under gravity and wind forces.

A simple two-dimensional mesh is generated on the fly after the LSystem's result is computed. This mesh connects the vertices together based on their radii and is updated as the tree responds to forces.

The level 4 Pythagoras Tree responds to a strong wind to the left.
A level 5 Pythagoras Tree responds to a lighter wind to the right.