Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / [DBP] L-System Fractal Plant

Author
Message
enderleit
16
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 23rd Aug 2009 01:36
Hey guys,

In the process of my recent mania with procedurally created content I came across an interesting system called an L-System, which can be used to generate all sorts of organic things using simple rules applied to an L-System string.

I'm not going to try and explain exactly how it works because I suck at explaining such things...
Suffice it to say that L-Systems can be used for many many things in procedural content generation.

Plants, trees, city roads, and many more things... Using the right rules for your system ofcourse.

For an example check out Introversions progress on their next game "Subversion":
http://www.introversion.co.uk/subversion/
They use modified L-Systems for, amoungst other things, the street grid generation. Looks amazing!

For a better explanation of L-Systems, check out the info on wikipedia:
http://en.wikipedia.org/wiki/L-system

And without further delay, here is my snippet which demonstrates some of the more basic L-System Strings:
Algae system (not displayed graphicaly, but it's in the source)
Koch Curve system
Fractal Plant system (the most visually interesting one)



Have fun experimenting!

- enderleit
[href]www.eleit.dk[/href]
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 23rd Aug 2009 05:29
I love L-Systems. In a world where using strings to store structured data is unacceptable, L-Systems get away with it. You know why? Because they are AWESOMELOL!
Softwizz
14
Years of Service
User Offline
Joined: 14th May 2009
Location: U.K.
Posted: 23rd Aug 2009 15:17
That is super cool.
I will mess with this to get it to create a city scape like 'Subversion'

Nothing to see here, move along please.
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 24th Aug 2009 09:20 Edited at: 24th Aug 2009 09:23
Wow, that's great!

your post launched me into a web browsing frenzy. This is by far the coolest site i found: http://www.mh-portfolio.com/lsystems.html
and this image explaining the basic process:


Here's a cool one i found for making 3d L systems:
http://www.alesdar.org/oldSite/IS/chap4-4.html

aaand here's an image i made of the bush L system using your program



On generation 6, a huge amount of the "plant" is above the screen.


This is awesome stuff XD, it'll definitely keep me occupied tomorrow.

[edit]
the rule for the bush system is F=FF-[-F+F+F]+[+F-F-F] and the anglechange is set to 22.5
enderleit
16
Years of Service
User Offline
Joined: 30th May 2007
Location: Denmark
Posted: 24th Aug 2009 09:53
I'm glad you guys liked it, and the bush looks pretty cool.

I'm gonna have to read some more on that site you found...

- enderleit
[href]www.eleit.dk[/href]
Softwizz
14
Years of Service
User Offline
Joined: 14th May 2009
Location: U.K.
Posted: 24th Aug 2009 18:19 Edited at: 24th Aug 2009 18:19
Here is something I have been messing with, uses the plantgenerator code and I have made it place a cube at the new x,y co-ords (there isnt a 3D line command)
If you put a terrain under this you could make it place the cubes at the terrain height.



Keys to move camera:
cursor keys
Q A move camera vertically up / down
W S rotate camera up/down



Nothing to see here, move along please.

Attachments

Login to view attachments
Neuro Fuzzy
16
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 25th Aug 2009 06:09
I wonder what the fastest way to calcuate an L system in DBPro is? Maybe an array of bytes?
Libervurto
17
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Sep 2009 21:33
thanks for posting. I haven't been able to test but the subject is really interesting.

TGC Forum - converting error messages into sarcasm since 2002.

Login to post a reply

Server time is: 2024-05-05 04:07:20
Your offset time is: 2024-05-05 04:07:20