POV-Ray : Newsgroups : povray.newusers : Add leaf on my tree : Add leaf on my tree Server Time
30 Jul 2024 02:17:28 EDT (-0400)
  Add leaf on my tree  
From: sap
Date: 23 Oct 2004 02:46:48
Message: <4179fe58@news.povray.org>
Hello;

I have made a tree macro and would like to add leaf on my tree. You can see 
the result in the p.b.i.

So how to translate some object along all cylinder and orient them like an 
umbrella ?


#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

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