|
![](/i/fill.gif) |
After a lot of try, i realesed a recursive
macro for make trees, just want to share it :)
#include "colors.inc"
#include "math.inc"
#include "rand.inc"
camera {
location <12, 2, -30>
direction 1.5*z
right x*image_width/image_height
look_at <10,1,0>
}
light_source{< 1000, 500,-1000> color White}
// p0: Origin position of the lower cylinder
// p1: Upper position of the lower cylinder
// L: recursion level (WARNING: after 5 or 6 a big pc needed)
// d: Rayon of the lower cylinder
#macro arbre(p0,p1,L,d)
#local nd=d-(d*0.5);
cylinder{p0,p1,nd}
sphere{p1,nd}
#local ang=VAngle(p0,p1);
#local Np0=vrotate(p1,ang);
#local Np1=Np0+< rand(Ra)/3,rand(Ra)/2, rand(Ra)/3>*3;
#local Np2=Np0+<-rand(Ra)/3,rand(Ra)/2,-rand(Ra)/3>*3;
#local Np3=Np0+< rand(Ra)/3,rand(Ra)/2,-rand(Ra)/3>*3;
#local Np4=Np0+<-rand(Ra)/3,rand(Ra)/2, rand(Ra)/3>*3;
cylinder{Np0,Np1,nd/2}
cylinder{Np0,Np2,nd/2}
cylinder{Np0,Np3,nd/2}
cylinder{Np0,Np4,nd/2}
sphere{Np1,nd/2}
sphere{Np2,nd/2}
sphere{Np3,nd/2}
sphere{Np4,nd/2}
#if(L>0)
#local NL=L-1;
arbre(Np0,Np1,NL,nd)
arbre(Np0,Np2,NL,nd)
arbre(Np0,Np3,NL,nd)
arbre(Np0,Np4,NL,nd)
#end
#end
#declare r=seed(0);
#declare a=0;
#while(a<4)
#declare b=0;
#while (b<4)
#declare Ra=seed(RRand(100,500,r));
union{
arbre(<0,0,0>,<RRand(-0.2,0.2,r),RRand(0.3,1.5,r),RRand(-0.2,0.2,r)>,3,0.3)
translate<RRand(3,8,int(Ra))*a,0,RRand(6,8,int(Ra))*b>
}
#declare b=b+1;
#end
#declare a=a+1;
#end
plane{y,0 pigment{rgb<0.5,0.9,0.4>}}
sky_sphere {
pigment {
gradient y
color_map { [0.0 color rgb <0.7,0.7,1.0>] [1.0 color blue 0.5] }
}
}
Post a reply to this message
Attachments:
Download 'arbre.png' (210 KB)
Preview of image 'arbre.png'
![arbre.png](/povray.binaries.images/attachment/%3C4176b727%40news.povray.org%3E/arbre.png?ttop=441697&toff=6000&preview=1)
|
![](/i/fill.gif) |