POV-Ray : Newsgroups : povray.newusers : a realistic algorithm for making a tree : Re: a realistic algorithm for making a tree Server Time
4 Sep 2024 18:11:37 EDT (-0400)
  Re: a realistic algorithm for making a tree  
From: Tim Nikias
Date: 14 Oct 2002 01:17:45
Message: <3daa5379@news.povray.org>
Regarding your iso, I can't help. Have no clue of
them yet as well.

Regarding your scripting of trees:
In order to make branches, you could use loops. Determine
(using some random value) how many branches you want,
and then run a loop with some parameters that "memorize"
the forking position and width at that point, perhaps even
the direction of the tree there.

Another approach would be using recursive macros, which
are designed to call themselves, if another set of branches is
to be made. I guess this would be the easiest approach,
cause I'm not too sure how to set up the above mentioned loops
to cover branches up to X-number of depth.

When using both these approaches, all you need to know, is
when you're placing your last branches, you'll want to stick
the leaves to those. For the recursion approach, just check in
which depth you're calculating, and then use the appropriate
depth. For the loops, its just about the same.

And if this is just way ahead of you (if you don't have a
clue what I'm talking about with loops and recursion etc) I
suggest you download some of those tree-programms and
look at their code to learn. Its good reference, and its a
working example (which I couldn't cook up right at this
moment without writing my own tree generator).

Regards,
Tim


--
Tim Nikias
Homepage: http://www.digitaltwilight.de/no_lights/index.html
Email: Tim### [at] gmxde

> I'm trying to figure out how to code the trunk and branching structure of
a
> normal deciduous tree. I took a look at some of the existing trees out
> there, and it seems that using blobs is the way to go. I think I want to
> use an isosurface with blob-like combinations, so that I can use a pigment
> with the function to easily roughen the surface of it.
>
> Well, there is a point to this post. I am stuck on a few things, so I want
> to ask for some suggestions:
>
> What is a good size for the individual pieces of the iso-blob relative to
> the width of the trunk?
>
> When I get to a fork in a branch, and have it go calculate one path off
the
> fork, how do I get it to go back to the fork to draw the other branch?
> (This is the part I am the most confused over, and it seems even more
> difficult when I get to the end of a branch that may be 4 or 5 "levels of
> forks" down from the main trunk.)
>
> When I add leaves, how can I place them to be relative to where the
branches
> are? (I'm not going to know ahead of time where the branches end, since
> that'll be up to random variables, so that I can use this to create
several
> trees in the same scene that aren't the same).
>
> I know there are existing tree macros out there, but I'm just the sort
that
> likes to make my own stuff.
>
> Also, I am trying to get a feel for using blob-like combinations in an
> isosurface, but the following code won't work. What am I doing wrong?
>
> isosurface
> {
>   #declare Blob_Threshold = .05;
>   #declare iter = 0;
>   function
>   {
>     (1+Blob_Threshold)
>     #while(iter < 50)
>  -pow(Blob_Threshold,f_sphere(x-(rand(Seed)+.5),y-(iter/2),z-(rand(Seed)+.
5),.3))
>       #declare iter = iter + 1;
>     #end
>   }
>   contained_by { box { -30,30 } }
>   max_gradient 2.4
>   texture
>   {
>     pigment
>     {
>       color rgb .9
>     }
>   }
> }
>
>


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.