When i was watching Dan's tutorials on the force chapter which involve applying forces such as wind and gravity to the object. I suddenly thought of the scene where Japanese cherry blossoms fell. So I want to use P5 to describe the scene of petals falling after the breeze blows the tree. But as the web page showed, I did not succeed.



In the last class, Dan told us about recursive functions, which caused my curiosity. Functions call the function itself directly or indirectly, which is an excellent application for spanning tree forks. At the same time I Googled a case of Recursive Tree as a reference.


After generating the complete tree, I tried adding wind to the tree, adding wind and downward gravity to the flowers. However, I found that the function of the spanning tree is obtained by continuously panning the canvas, so when the depth reaches the set maximum value, the position of the petal is (0, 0), but I cannot get its actual position. At the same time, I applied downward acceleration to the petals, and it did not produce dynamic movement. The function was executed very fast, and the canvas was always translated during the execution.So I'm confused how to track the the current branch ’s position and rotation while calling the recursive function,and give them forces to make them dynamic.

Here is my code:



I recently found a sketch of a dynamic tree, which is close to the effect I want in my mind, but I need more time to digest his ideas.


©2020 by Siyuan Zan. Proudly created with Wix.com