FlashTerrain – Trees

Trees

This part was the reason I started all this. It’s thanks to the work of  Den Ivanov and an experiment of his: http://www.cleoag.ru/labs/flex/plant3d/. To create 3d-objects manually in papervision3D is a little bit to advanced for me, so thanks for sharing once again. I added some features and made it possible to customize it. Here is some samples:

I used 3d studio max to create the different leafs.  You can  adjust the leaf with various settings like width, height and bend-modifier ( credits to Bartek DrozdzAS3mod is great!).  It would be cool to create leaf manually by drawing a outline, adding vertices, triangulate and upload textures in runtime. But I have to experiment with  triangulation and uv-mapping first. The rules for generating the tree is stored in a 2d-array like this:

_branchMap = [
[0, 0, 2, 2, 1, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 1, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ]

This trunk uses 2 levels of recursive depths. One trunk and two levels of branches. Each array decide in which joint a new branch is growing while we iterate through the segments. The stored value is how many new branches there will be at that joint. The length of each array reflects how many segments there will be in that level. Oops, I got carried away with boring details… I’m not even pleased with this solution.  I think I have to use a completely different approach. A L-system maybe?  But there is a lot of things that I want to first, so I put it on hold for now. Still, you can get a lot of different trees by adjusting the few settings available.

There is pretty much research around, for example:

http://algorithmicbotany.org/papers/colonization.egwnp2007.html
http://algorithmicbotany.org/papers/#abop
http://www.cs.duke.edu/courses/cps124/fall02/resources/p119-weber.pdf

Tree Designer

I quickly put together a standalone tool so you can try to change the settings available. Some parameters in the building process  has random values (like branch-rotation), so when changing the branch and trunk settings the tree will be different every time.

Open Tree Designer

Future improvements:
- Leaf editor.
- New tree generation algorithm.
- Different tree-characteristics depending of the value of the normalmap when distributing on the mesh.
- More types of vegetation like grass, bushes.

Have you seen the previous posts about creating terrain with flash? Check them out here: http://www.inear.se/?cat=6

Comments (4)

  1. Hi, this is quite simply amazing. Especially the “life” setting, and how smoothly it works. I’d love to put something like this in my C++ game engine; to have dynamically growing forests with instancing. Any chance you could you provide tips/source for doing this? I’d love to port and attempt to optimise it with shaders. ~Chris

  2. Thanks! This example is really simple compared to real L-systems. The recursive branching is kind of limited. Since every branch is in a separate container and parenting the one before I had some trouble position them in world space in a natural way. But thanks to that it’s easy to animate the tree. Every root-branch has a simple tween. When rotating the tree or upon changing the settings a tween is triggered on the leaf-nodes as well. I guess a more optimized way would be to create all the geometry in the same container and do the animation through a vertex shader . I send you the source for the tree, but I doubt that you will find any use of it. Let me know if you do though. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>