OpenGL Recursive Trees

Henry Thiemann


Fractal Tree Screenshots

Concept

After looking at the Wikipedia page for L-systems, I decided to do something like that for my assignment. Because I wanted the trees to look somewhat natural, I used a random number generator within a certain range for basically every property of the trees. The season-changing feature was originally just to satisfy the multiple-color requirement, but I was surprised how cool it looked when I rendered the trees (especially Winter).

Implementation

The main funtionality of the program (drawing a random tree) uses a recursive function that draws branches (GL_LINES) up to a certain recursive level. Each tree starts as two branches, then two more branches are added at the end of each branch until the final recursive level, at which leaves (GL_TRIANGLES) are added instead. The length and angle of each branch and the size of the leaves are all randomly generated, and before every tree is drawn, the random number generator is initialized with a seed. Using a seed makes it possible to draw the same tree multiple times, so that a tree can be drawn in multiple seasons. In "Winter", the leaves are drawn at the y-coordinate of the base of the tree, but still at the same x-coordinate as the branch that generated them, making it look like they fell from the tree (and there was zero wind).