My very first Openframeworks work simple fractal trees

http://www.youtube.com/watch?v=yGl4fG3GcqY

Recursive fractal tree pre-calculation, stored in tree structure and then BFS algorithm for rendering (with some binned particle rendering at base of flame, because I liked the dust effect)

Reacting on the IR emitted by the flame.

best regards,
Karel.

3 Likes

its beautiful!

Amazing! Can you share the code, please. I’m a newbie and would like read it.

Best regards

David

Sure !
Which part are you interested in,
the tree drawing or the particles ?

I ask because I will need some time to comment things…
For you to be more usefull…

Hi Karel

I would be super nice to publish the tree drawing code.
I also have done a similar recursive tree pattern but than I got stuck when I wanted to make a solid data structure out of it which might be used for other interactions - like animating the branches / falling leaves etc… once the tree has been drawn. Do u save the data in a structure or just OpenGL-draw?

Thx a lot
Ninka

1 Like

Thanks for the interest !

I calculate the tree recursively first just like processing exemple of Daniel Shiffman I believe…
When calculating I put references in a Tree structure like this…

struct Tree{

Tree *ancestor;
Tree *branch1;
Tree *branch2;

}

Then I use a Breadth First Search Algorithm for rendering by marking the branches which will lead them to be progressively drawed…

If you want to animate things however I recommend you to use a verlet system which will be more appropriate…
I saw a nice example here made by rui madeira http://cargocollective.com/ruimadeira#64249/Parque

Maybe you can try to combine both a verlet system and a recursive approach…

You can use code, but you will need tbeta or tuio simulator for the trees to appear since
I didn’t had time to implement tree generating by mouse…

Ah and code is really more a draft than anything you can build things on,
don’t hesitate if you have questions trying to dig things out of this obscure set of lines…

Cheers,
Karel

src.zip

1 Like

Hi Karel

Thx a lot for your extensive reply! My approach for creating and rendering was the same but I also got stuck at the point of interaction :slight_smile:

Yes Rui Madeira’s Parque is just the best!

When I come back to my tree project I will let you know how I progress

Nice xmas holidays
Ninka

thanks you to :slight_smile:

Thanks a lot for sharing and your useful explanation. I’ll start to study your code!

Best regards

David

Thanks for posting this!
I’am working in something similar to this…
Did you posted the code somewhere?
I would like to see how you do the data storage of branches/nodes. (vector?)
Also I am looking for a good approach to move branches/nodes with physics.
Thanks

(zip link is not working here)

Hey Moebius,

Hey that’s 5 years ago, I will see if I can find the code somewhere on an old machine, not sure however if I still have it.
Basically, what you can do is using a recursive call to create the tree that you want and you store each node in a tree structure. Then you can render the tree using an iterative BFS exploration algo or/and use Box2D to add physical properties to each node of your tree http://www.box2d.org/forum/viewtopic.php?f=3&t=7723. Finally to get a nice trunk and branches and leafs, use a skinning technique or library. Start with a node in 2 dimensions first later you can go for 3 dimensions. Using box2d you can then make interact the tree with whatever force you want.

Cheers,
Karel.

Thanks a lot for the fast replay! :slight_smile: I�am beginer and this replay is very usefull to me.

I�ll check with attention what you say. So, box2d it�s a good way to introduce physics to the tree…; nice! i didn�t imagined this previously.

When you say �tree structue�, what do you mean in terms of 'data storing�? a C vector storing the points? or there�s another better way to store the knees/nodes/bifurcations.

(Now I�am storing all the branches: vector, angle, curve tensors, �etc; but it would be nice to reduce this data to enable the physics and mprove speed rendering.)

Best,
Manu

Hi! The particles are really good looking, what technique did you use to visualize them? Some kind of sprite?
Thank you!

Really good works.