Specialization: Tree Generator

I made a tree generator in the specialization course at TGA. We had 5 weeks where we worked 4 hours a day. My goal with the project was to be able to generate different types of trees made up of primitive shapes like cubes and cylinders.

L-System

The trees get their rough shape with Lindermayer system. There is a text string of characters that have predetermined effects on an imaginary pencil. If you draw the tree with only this system, it can look like the tree in the picture. However, it is not very lively. The pattern is repetetive and this case is also completely symmetrical. And all trees of this type will also be identical. I have therefore added in some randomness and other parameters that decide what the tree will look like.

Branches Get Thinner

When the tree splits, the new branches together have the same cross-sectional area as below the split.

Randomness

This makes the trees different from each other. I added random rotation and length to the branches, and sometimes a branch may be skipped.

Thinner Equals Shorter

The parameters affect the branches differently depending on their thickness and where in the hierarchy they are. Here you can see that they become shorter further away from the trunk.

Leaves

Finally some leaves. All end branches get two cubes with random rotations, one of which is slightly transparent and brighter.

The Inspector

Here are the values that generate the tree above. In addition to those already described, there are values that make it possible to have a trunk with small branches instead of all branches becoming equally thick when they split. This makes it possible to make pine-like trees. You can also choose how long the trunk should be before the branches grow out, and you can choose how much the tree should grow upwards. It is also possible to set how many subdivisions the cylinders get.

Thoughts of the Project

I am very happy with the end result of this project, as it turned out almost exactly as I had imagined. If I had more time, I would have made it so that the cylinders that build up the tree could have hard shading on their edges. Though that would take a little extra time because I would have to change the way the cylinders are generated for it to work.

In the future, it would also be interesting to see how I could merge the cylinders info one coherent mesh. However, I want to experiment with cutting down the trees in games and that would lead to extra problems with collision detection and other calculations.