We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexDiscussionExhibition › Trees
Page Index Toggle Pages: 1
Trees (Read 1819 times)
Trees
Nov 17th, 2005, 11:00pm
 
Would like comments on a project of mine.

It has spring, summer, fall, winter trees created with Processing. Check it out at http://www.stagnesphx.org/computerlab/quiz/trees/index.html
if you check out the source code you will see I give credit to Carlos Nazareno for his Fire and Forget Broccoli Tree Bomb program.

I wanted something for elementary school student to use to quickly draw trees for the four seasons so I modified his code for thicker trunks and changed the colors of background and leaves.

Any suggestions for improvements?

Re: Trees
Reply #1 - Nov 18th, 2005, 12:43am
 
Hehe.. I LOVE the clouds for some reason. Totally unexpected.

The trees need roots! <3
Re: Trees
Reply #2 - Nov 18th, 2005, 1:53am
 
What about using the zbuffer so trees in the background are drawn behind trees in the foreground?

Marcello
Re: Trees
Reply #3 - Nov 20th, 2005, 1:57am
 
Thanks for the comments, Mflux, glad you liked the clouds and I'll think about adding roots.

Good idea, Cello, about the tree futher away being put behind the foreground trees. I tell my students to put in the clouds first but it would be good to put them behind the foreground trees also. I don't know enough processing yet to figure out how to do that. Anyone want to volunteer an example for that portion of the code?
Re: Trees
Reply #4 - Nov 20th, 2005, 2:46am
 
The key ideas are change your code into orthographic 3d, then use the z coordinate to layer your various objects.

You can do the former by passing P3D into your size() function then calling the "ortho()" function.  Orthographic will disable perspective modes and prevent objects from automatically getting smaller (and approach the center) when they have a lower z value (alternatively, you could recode your entire program in full 3d, but it gets more complicated when converting mouse coordinates to a point in 3d space).

Then, before each tree/cloud draw to the screen, you could call resetMatrix() and translate(x,y,z) method to change the current transformation to the z position of your liking.  Since translate is relative, you would likely leave x and y at 0, and only set the z translation.

Marcello
Page Index Toggle Pages: 1