|
![](/i/fill.gif) |
In article <web.3d69968af01f31b4d02c7b870@news.povray.org>,
"Rohan Bernett" <rox### [at] yahoo com> wrote:
> I'm no good at writing recursive functions. :-( I've used them a couple of
> times in c++ in my uni assignments, but I always find them a pain in the
> arse to write.
It isn't too difficult, and there are many examples of this technique in
the various plant generator include files.
> Okay, enough grumbling, can anyone give me some advice (or better still a
> code exaple) on how to make a tree using recursive functions. My best
> vaugly recursive attempt at making a tree involved making several objects
> of different levels of the tree and adding them at different levels. i.e.
> one level with leaves, then one using branches with 3 leaves on them, then
> one using 3 branches from the one before and so on. It does look like a
> tree, but not very realistic.
You need to use more randomness...real plants don't branch precisely a
certain number of times at exact intervals with straight stems in
between. In my systems, I only branch every once in a while, each
recursion has a certain probability of branching. I also added various
forces such as gravity, wind, light, etc. Start out with a simple
framework and add rules and tweaks to it.
Also, be aware that POV can only recurse a certain number of levels, my
technique recurses very deeply so I hit this limit hard. You can mimic
virtually unlimited recursion by using something more like a particle
system where each particle traces out the path of a limb and splits into
two particles to branch. I've been playing with this, but my system is
written in Sapphire, not POV.
--
Christopher James Huff <cja### [at] earthlink net>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tag povray org
http://tag.povray.org/
Post a reply to this message
|
![](/i/fill.gif) |