Procedural Tree Generator
How to Use
The
procedural tree generator is a pretty simple application: it generates
tree models. There's fourteen different parameters you can modify. I'll
explain them all here since some of the names aren't super descriptive.
- Max
Levels - the maximum number of times the branches "branch" out. In
other words, if you set this to three, you get a branch out of the
trunk, then a branch out of that branch, then one more branch out of
that branch. 3 levels of branching.
- Minimum Children - Minimum number of child branches a branch can have
- Maximum Children - Maximum " "
- Minimum
Branch Start Distance - This specifies how high up branches start
growing. It's a floating point between 0 and 1. If you specify .5, then
the branches can sprout at the lowest halfway up the branch.
- Maximum Branch Start Distance - See above.
- Branch
Sweep - A lower angle sweep means the branches point straighter. This
will give you a tree with tighter grouped branches and a thin look. If
you have a high angle sweep, then the branches angle away from their
parent branch. This gives a full feel to the tree, since branches point
off in all directions. The tree pictured above has a fairly high angle
sweep.
- Trunk Length - The starting length of the trunk.
- Length
Variance - How much a branch can vary from it's "calculated length". A
number between 0 and 1. If you specify .1, the branch can vary 10%
shorter or longer than its calculated length.
- Length Multiplier
- How much a child branch decreases in length compared to its parent
branch. If you specify .8, the length of the child branch before angle
variance is applied will be 80% of the parent branch's length.
- Trunk Radius - Starting radius of the trunk.
- Radius Multiplier - How much the radius should taper off over the length of the branch.
- Gnarliness - A higher value gives a more twisted tree.
- Section Count - The number of sections that make up a branch.
- Section Vertex Count - A higher value will make the circumference of the tree smoother and less jagged.
What's Missing
There are two major components of this application that are missing:
- The ability to export a generated tree model.
- Leaves
Why didn't I write these things? Simple: not enough motivation or
desire to code them. If I did manage to do those, I would probably be
trying to sell this rather than post the code for free. But alas,
that's the price of laziness. If someone out there manages to implement
both of those and would be so kind as to re-share it with the
community, that would be wonderful. But if you wouldn't be willing to
give that away, I can't really blame you.
I've provided both the XNA project and executable below in case some of
you visiting the site don't have XNA installed. All of the key binds
are displayed for you so it should all be pretty self explanatory. If
you have any questions, email me at
dan@digitseven.com.
DOWNLOAD ProceduralTree XNA Project HEREDOWNLOAD ProceduralTree Executable HERELast Update: 8/26/09