Howdy!
I’ve been tinkering with parametric L-systems, the simpler 0L flavor, and I was wondering if anyone has hit on a particularly good parsing strategy for them or any suggestions in general.
What I’ve done is more or less a recursive macro-like string replacement, and it works pretty well, but maybe there’s a better approach or one that’s just different and interesting. That’s really no biggie though, since it’s not a very time consuming process and it only needs to be done once for each tree.
If anyone has any ideas on generating a continuous mesh, that’d be sweet
Also I’d be very interested in any rules that create some nice trees and bushes. I may need to go to a 1L or 2L system to get the most convincing results, but I’ll resist that path as long as I can, in the interest of keeping things as simple as possible.
If you haven’t heard of these creatures, everything you need to know and more can be found in this book and website:
www.biologie.uni-hamburg.de/b-online/e28_3/lsys.html
www.algorithmicbotany.org
You can also read about them in Texturing & Modeling, A Procedural Approach, 3rd Ed.
Here’s a quick rub, if you’re interested.
A L-system is basically a grammar, like you would use to define a language in flex/bison for example. It’s a set of production rules for an input string, or axiom in L-system parlance. An example might look like this:
axiom: AB
rule A: B
rule B: BC
rule C: CA
Starting with the input string AB, we apply the production rules, one at a time, rewriting the original string at each step.
AB <- start string, apply rule A then rule B
BBC <- apply rule B, rule B, then rule C
BCBCCA <- and so on
BCCABCCACAB <- and so on ...
and so on. Lots and lots of data from a little input.
The difference with parametric L-systems is that the rules themselves can take parameters. So you could do something like this instead
axiom: A(5,6)
rule A(x,y): B(x,y)
rule B(x,y): B(x,y)C(y)
rule C(y): C(y)A(1,y)
Not that you’d want to. You can get even fancier by adding predicates (conditions) to the rules, so that they only kick in if certain patterns are matched. Like, match rule A, but only if preceded by B and followed by C, otherwise use another version of rule A. You can really go nuts with this stuff.
Anyways, the idea with L-systems is that you use turtle graphics commands instead of As, Bs and Cs in your input string, so you are left with a long string that represents the geometric and graphical structure of the trees. What I’m trying to come up with a cool way to turn these commands into a nice, smooth, continuous mesh (or meshes).
Preliminary results are encouraging. You can create some really nice looking trees, but my end-to-end cylinders, which I use to represent the trunk and branches, have got to go The trees look like they’re suffering from some strange tropical disease.
This stuff is way too fun to play with, so be warned!
Thanks!