|
![](/i/fill.gif) |
I've hit a bit of a rock I haven't been able to climb over. The recursive
macro below is *supposed* to generate a linear sphere_sweep, generating 10
sphere positions for the sweep. It then uses the last coordinate as the
starting point for two other sweeps.
The coordinate calculations have a random element added to them to visualize
a contorted cone, essentially the segment of a root. My final objective is
to generate a complex root system. I added a color element, taken from
Samuel Benge's altered pyramid.pov example, to differentiate recursion
levels.
The problem I've run into is that the first recursion runs through the
coordinates used to position the first sphere in the next sphere_sweep but
doesn't reset them for the subsequent recursion. As a result, when the root
"branches" the first branch will appear to connected to the original branch,
and it's first branch connected to it, but the second branch will appear at
the different position then the end of the former branch...
Sound confusing? Sorry, but it has me stumped... This pov file is ready to
render so it should explain the problem better then I. It's my first
toy-around with a recursive macro so any help would be appreciated.
Thanks,
-Chris-
#version unofficial MegaPov 0.5;
background{color rgb 1}
light_source{<200, 200, 200> color rgb<1, 1, 1>}
light_source{<-10, 8, 100> color rgb<1, 1, 1>}
camera{location<0, 0, 50> sky<0, 0, 1> right<-4/3, 0, 0> angle 50 look_at<0,
0, 0>}
//X,Y,Z - initial sphere positions
//R - initial radius
//L - recursion level
//Next - incrementer for sphere position while loop, higher the Next, longer
the sphere_sweep
#macro Tree_Root(X,Y,Z,R,L,Next)
#declare counter=0;
sphere_sweep {
linear_sphere_sweep,
10,
#while(Next>0)
<X,Y,Z>,R
#declare R=R/1.05;
#local X=X-rand(Rand01);
#local Y=Y-rand(Rand01);
#local Z=Z-rand(Rand01);
#declare Next=Next-1;
#declare counter=counter+1;
#end
}
#if(L>0)
#local New_L = L-1;
#local New_R=R;
#local PX=X;
#local PY=Y;
#local PZ=Z;
#local Co=1;#local Co=Co/L;
union{
union{//first recursion
Tree_Root(X,Y,Z,New_R,New_L,10) // first works
translate<-PX,-PY,-PZ>
rotate 35/L*z
translate<PX,PY,PZ>
}
union{//second recursion
Tree_Root(X,Y,Z,New_R,New_L,10) // secone doesn't work
translate<-PX,-PY,-PZ>
rotate -35/L*z
translate<PX,PY,PZ>
}
pigment{rgb<Co,Co,Co>}
}
#end
#end
union{
Tree_Root(0,0,0,2,2,10)
pigment{color rgb <1,1,0>}
}
Post a reply to this message
Attachments:
Download 'recursive.pov.txt' (2 KB)
|
![](/i/fill.gif) |