Digit 7

Your source for XNA tutorials and 3D programming ideas.

Home     Shader Tutorials     XNA/C# Downloads     Links      
Blackjack Simulation
Heightmap Generator
Physics Simulator
Procedural Tree Generator
QuadTree
Swarm Intelligence
Matrix Solver
Massive Battle

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.
  1. 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.
  2. Minimum Children - Minimum number of child branches a branch can have
  3. Maximum Children - Maximum " "
  4. 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.
  5. Maximum Branch Start Distance - See above.
  6. 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.
  7. Trunk Length - The starting length of the trunk.
  8. 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.
  9. 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.
  10. Trunk Radius - Starting radius of the trunk.
  11. Radius Multiplier - How much the radius should taper off over the length of the branch.
  12. Gnarliness - A higher value gives a more twisted tree.
  13. Section Count - The number of sections that make up a branch.
  14. 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 HERE
DOWNLOAD ProceduralTree Executable HERE

Last Update: 8/26/09