r/processing • • Nov 09 '19

Tree generator

170 Upvotes

11 comments sorted by

9

u/jimstalepants Nov 09 '19

Beautiful! I’d love to see the source code for this.

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!

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 :-)

2

u/caerbannogwhite Nov 12 '19

Really fine work!

1

u/MrClacla Nov 13 '19

Tnku🙌

2

u/Zoyl3 Nov 10 '19

Damn, that is so nice!

I did something similar, but not as pretty, basically just branching after some growth (prev. length*0.8), and making their color green and opacity lower after their length is below a certain limit.

This is like 6 levels up though, cheers!

1

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

I love tree generators like this! I made one myself about a year ago. Nice work.