Procedural Tree Generator

Engine: Unreal Engine 5 Developed: Solo Language: C++

The aim of this project was to combine 3 different programming concepts to create a tool for a game engine. I decided on using L-systems, randomness and graph theory to create a procedural tree generation tool for Unreal Engine 5.

My L-system class allows the user to input the axiom, generation and production rules as properties. After the L-system has been evaluated, CurrentString will show the final resulting string and Alphabet will show all elements in the system. These properties is set to visible only as they are displayed for debugging purposes only.

The elements of the L-system have the following functions:

+ = Turn right

- = Turn left

F = Draw forward

X = Do nothing (used for control of evolution curve)

[ = Add current branch to stack and create new branch

] = Load branch on top of stack and pop from stack

In my implementation, I decided to keep it simple and not support probability through the use of stochastic grammars. In the future I might come back to this project and add support for stochastic grammars to increase the variety in the base shape of the tree.

Pseudorandom number generators are used to quickly and easily generate variations of the same tree. This is done through the use of a seed which is defined by the user. This random number generator drives certain properties under the Tree and Twig categories. Examples include RandomAngleMax, BranchRollMax and TwigSpawnPerAvgSteps.

Graph theory was also used to calculate the distance of each branch segment from its furthest tip. This was calculated using a depth-first search algorithm and the resulting value is used to determine twig size. The closer to the tip, the shorter the twig becomes. The rate at which twig size grows as you move further from the tip is determined by the TwigScalePerSegment parameter.

Previous
Previous

MyChess

Next
Next

Shaders