My L-System demo was written in C for the PlayStation Portable, using an official PSP Devkit. It is designed to simulate moving through a virtual forest environment, with trees growing/shrinking as the user/camera moves through the world. The camera can be manipulated on the fly, allowing users to pause, look around, and admire their surroundings â€“ if they so wish!
L-Systems (or Lindenmayer systems) were created by Hungarian biologist Aristid Lindenmayer to describe the development of simple multicellular organisms. They were later developed â€“ by PrzemysÅ‚aw Prusinkiewicz and others â€“ to describe more complex, branching structures. They are generated recursively, which leads to fractal-like self-similarity.
L-Systems are essentially a string of characters which can be represented graphically using a turtle interpretation of the string. Turtle graphics interprets each character/letter within the string as a command for an imaginary turtle with a position and orientation in the world. Commands include â€œmove forward and drawâ€, â€œturn leftâ€, and so on, which can be combined to create intricately complex systems.
My L-System demonstration features 6 unique L-Systems. Five of these are scholastic (semi-randomised), bracketed (branching) systems which represent “trees”, while the sixth is a simple DOL-system (deterministic, non-random) which resembles a grid and serves as the â€œfloorâ€ and â€œceilingâ€ of the virtual world.
Each scholastic L-System is generated using a selection of randomly-chosen rewriting rules, allowing for variations of the same basic L-system. This reduces the artificial regularity which would otherwise be evident in a scene with multiple copies of the same L-System. Each of these “trees” actually exists in a 2D plane is constantly rotated to face the camera at all times.
A new colour for the L-System is chosen from an indexed colour table at each branch of a “tree”, highlighting L-Systemâ€™s ability to accurately represent organic structures. Trees are then rendered gradually â€“ with the number of branches increasing/decreasing every frame to simulate organic growth. Trees constantly move forwards to simulate “walking” through a forest.
The entire demo utilizes exactly 4 KB of pre-linkage text (programming instructions) and 1 KB of static data. Unfortunately I cannot upload the source code in its current form due its use of PSP library code. I am, however, currently working on a cross-platform version of the project which will also run on Windows PCs via DirectX – the source code for which I do hope to upload.