Tree Macros
These are the tree macros developed by Robert J Becraft... They create a very rudimentary tree and tree canopy.
LEAF CLUSTER MACRO | |
#macro LeafCluster(X1,Y1,Z1,Y2,Y3,X2,LC,L1) // X1,Y1,Z1 = cluster origin // Y2,Y3 = lowest height/greatest height respectively // X2 = distance leaf can be from X1,Y1,Z1 // LC = leaf count // L1 = Leaf pattern #local C1=1; // counter #while (C1<=LC) #local XX=rand(R1)*X2; #local YY=rand(R1)*(Y3-Y2); #local YR=rand(R1)*360; // rotate final leaf in 3-d #local CO=int(rand(R1)*5+1); #local XOR=rand(R1)*360; #local YOR=rand(R1)*360; #local ZOR=rand(R1)*360; #local Sc=rand(R1)*.75+.5; object{L1 rotate<XOR,YOR,ZOR> scale Sc translate<XX,YY,0> rotate<0,YR,0> translate<X1,Y1,Z1> texture{pigment{color #switch (CO) #case (1) DarkOliveGreen #break #case (2) DarkOliveGreen1 #break #case (3) DarkOliveGreen2 #break #case (4) DarkOliveGreen3 #break #case (5) DarkOliveGreen4 #break #case (6) DarkOliveGreen5 #break #case (7) DarkGreenCopper #break #case (8) DarkGreen #break #case (9) DarkGreen1 #break #end // switch }} } #local C1=C1+1; #end #end // macro LeafCluster |
TREE BRANCH MACRO | |
#macro BranchGroup (BC,X,Y,Z,Xmax,Ymax,Zmax,Diam,L) // BC = Branch Count // X,Y,Z = Origin of branch group // Xmax,Ymax,Zmax = outer limits of branch group (+ or -) // Diam = branch diameters. #local C1=1; #while (C1<BC) #local RX=rand(R1)*Xmax-(Xmax/2); #local RY=rand(R1)*Ymax/2+(Ymax/2); #local RZ=rand(R1)*Zmax-(Zmax/2); #local DD=rand(R1)*Diam/2+(Diam/2); cone{<X,Y,Z>DD <X+RX,Y+RY,Z+RZ> DD/3 texture{TreeTrunkTexture}} #if (L=1) BranchGroup (3,X+RX,Y+RY,Z+RZ, Xmax, Ymax, Zmax, Diam/3,0) #end #local C1=C1+1; #end #end // macro BranchGroup |
Finally, to build a tree, you need something to start things out.
TREE Driver Code | |
#declare TreeTrunkTexture = texture { pigment { granite color_map { [0.1 color White] [0.2 color Gray10] [0.4 color Gray30] [0.6 color Gray] [0.8 color DarkBrown] [0.9 color DarkGreen] } } scale <.051,.75,.051> normal{granite .05} } cone{<0,0,0> .3 <0,1,0> 0 texture{TreeTrunkTexture}} cone{<0,0,0> .2 <0,5,0> .1 texture{TreeTrunkTexture}} #declare R1=seed(748); #declare Canopy1=union{ |
© 1999, Robert J Becraft, All Rights Reserved.