r/processing • • Nov 09 '19

Tree generator

170 Upvotes

11 comments sorted by

View all comments

9

u/jimstalepants Nov 09 '19

Beautiful! Iโ€™d love to see the source code for this.

6

u/[deleted] Nov 10 '19 edited Nov 10 '19

I made one of these a while back. Iโ€™m pretty sure I can explain the basics of if so here we go:

Tree generators like this usually use a particle that starts out at a certain size and moves in a direction(usually up) using vectors. As the particle moves along it will split into multiple particles based on threshold values related to the current size of the particle, which decreases over time. There is also some randomness here so the branches get thinner as they get longer but not necessarily at the same rate. There is usually a bit of random noise added into the movement directions and threshold values to make everything more plant like and natural looking. The noise also increases with each split which results in a smooth and mostly straight trunk with wavy flowing branches further up the tree. I think I still have the source to my tree generator if you want to PM me. I also used this concept to make a semi-realistic looking lightning bolt generator.

P.S. I think I made my branch particles split after they reach 80% of the size they spawned with. Just thought that might be a helpful tip :-)

5

u/MrClacla Nov 10 '19

Ill copy it here later no problem๐Ÿ‘

2

u/[deleted] Nov 20 '19

Any updates? ๐Ÿ˜

1

u/MrClacla Nov 20 '19

On facebook page... i know fb sucks and blabla ๐Ÿ˜’

1

u/staintdk Nov 10 '19

Ye. The fractals (or How you made it) are so smooth. I too wanna play around with The source code :) Good job!