POV-Ray : Newsgroups : povray.newusers : a realistic algorithm for making a tree : a realistic algorithm for making a tree Server Time
4 Nov 2024 21:22:58 EST (-0500)
  a realistic algorithm for making a tree  
From: Justin Smith
Date: 14 Oct 2002 00:25:03
Message: <web.3daa4414952fe8767dde8b6f0@news.povray.org>
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.