/* Modifications by Tony[B] [bennetts@panama.c-com.net] 25-06-2000 -added support for trace() 26-06-2000 -added control over the normal angle at which to place grass 26/27-06-2000 -reduced memory consumption and sped up macro by tweaking here and there -implemented mesh to lower memory consumption 27-06-2000 -added second distribution method: circular -added control over eval_pigment pattern (and removed Gscale) -added control over curvature (sort of, still needs work) -added bounding to the mesh 28-06-2000 -eliminated redundant variables. GV1, GV2, GC, and GR are now G1 and G2 -added all the comments, and made things more readable 29-06-2000 -improved circular distribution, thanks to Josh English 01-07-2000 -changed G2 for method 1 to the form for specifying minimum radius and maximum radius Plans... -figure out some way of texturing the whole thing randomly -add a variable to control complexity of the blades, such as 0 = 1 triangle, 1 = 3 triangles, 2 = 5 triangles, 3 = 7 triangles (current), and 4 = 14 triangles (middle split) */ #version unofficial megapov .5; #macro Lum(col) col.x*.299+col.y*.587+col.z*.114 #end //method of distribution (0 is rect., 1 is circular) height to begin tracing from // corner 1 for method 0, center for method 1 object to trace // corner 2 for method 0, radius for method 1 max angle to test for // curvature of the stalk texture to use in eval_pigment #macro country_grass( Method, G1, G2, Gscale, Gbend, Gnum, Grange, Grotate, Maxheight, DispObject, NormMaxAngle, Tex ) %Gnorm = function {pigment {gradient y scale .3 translate -y/40 scallop_wave color_map {[0 rgb 0][1 rgb .25]}}} %Gtex = pigment {spherical scale <.075,1,.1> color_map {[0 rgb <.1 .8 .25>][.3 rgb <.1 1 .25>/2]}} %Gfinish = finish {diffuse .9 specular .3 roughness .1} %Rotra = transform {rotate x*Gbend translate y/4} //old improvement: 64,600,436 (note: disregard this number, it's from old tests, just note the improvement) /*%Gtex1 = texture {pigment {Gtex translate -y*.75} finish {Gfinish} normal {function Gnorm}} %Gtex2 = texture {pigment {Gtex translate -y/2} finish {Gfinish} normal {function Gnorm}} %Gtex3 = texture {pigment {Gtex translate -y/4} finish {Gfinish} normal {function Gnorm}} %Gtex4 = texture {pigment {Gtex} finish {Gfinish} normal {function Gnorm}} %Blade = union { triangle {x/20,-x/20,y/4 texture {Gtex1} transform Rotra transform Rotra transform Rotra} //box 1 box {x/20,-x/20+y/4 texture {Gtex2} transform Rotra transform Rotra} //box 2 box {x/20,-x/20+y/4 texture {Gtex3} transform Rotra} //box 3 box {x/20,-x/20+y/4 texture {Gtex4}} }*/ //new improvement: 46,335,384 (note: disregard this number, it's from old tests, just note the improvement) %Gtex1 = texture {pigment {Gtex translate -y*.75} finish {Gfinish} normal {function Gnorm} transform Rotra transform Rotra transform Rotra} %Gtex2 = texture {pigment {Gtex translate -y/2} finish {Gfinish} normal {function Gnorm} transform Rotra transform Rotra} %Gtex3 = texture {pigment {Gtex translate -y/4} finish {Gfinish} normal {function Gnorm} transform Rotra} %Gtex4 = texture {pigment {Gtex} finish {Gfinish} normal {function Gnorm}} %P1 = x/20; %P1a = vrotate(P1,x*Gbend)+y/4; %P1b = vrotate(P1a,x*Gbend)+y/4; %P1c = vrotate(P1b,x*Gbend)+y/4; %P2 = -x/20; %P2a = vrotate(P2,x*Gbend)+y/4; %P2b = vrotate(P2a,x*Gbend)+y/4; %P2c = vrotate(P2b,x*Gbend)+y/4; %P3 = y/4; %P3a = vrotate(P3,x*Gbend)+y/4; %P3b = vrotate(P3a,x*Gbend)+y/4; %P3c = vrotate(P3b,x*Gbend)+y/4; %P4 = x/20+y/4; %P4a = vrotate(P4,x*Gbend)+y/4; %P4b = vrotate(P4a,x*Gbend)+y/4; %P4c = vrotate(P4b,x*Gbend)+y/4; %P5 = -x/20+y/4; %P5a = vrotate(P5,x*Gbend)+y/4; %P5b = vrotate(P5a,x*Gbend)+y/4; %Bounder1 = -x/20; %Bounder2 = <1/20,max(max(P3a.y,P3b.y),P3c.y),max(max(P3a.z,P3b.z),P3c.z)>; %Blade = mesh { triangle {P1c,P2c,P3c texture {Gtex1}} //box 1 triangle {P1b,P2b,P5b texture {Gtex2}} triangle {P4b,P5b,P1b texture {Gtex2}} //box 2 triangle {P1a,P2a,P5a texture {Gtex3}} triangle {P4a,P5a,P1a texture {Gtex3}} //box 3 triangle {P1,P2,P5 texture {Gtex4}} triangle {P4,P5,P1 texture {Gtex4}} bounded_by {box {Bounder1,Bounder2}} } %R = seed(34959); %V = 0; #if(Method=0) union { %GW = G1.x-G2.x; %GD = G1.y-G2.y; #while(V)); %Norm = ; %Start = ; %Inter = trace(DispObject,Start,Norm-Start,Norm); #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0) %NormTest = acos(vdot(Norm,y)); #if (NormTest*Gscale rotate y*(Cv*Grange*2-Grange+Grotate)+(rand(R)*8-4) translate } %V = V + 1; //if you want to see a progress report, to make sure the loop is doing something //#if(mod(V,100)=0) //#debug concat(str(V,0,0)," blades placed.\n") //#end #end #end #end translate } #else union { #while(V)); %Norm = ; %Start = ; %Inter = trace(DispObject,Start,Norm-Start,Norm); #if (Norm.x != 0 | Norm.y != 0 | Norm.z != 0) %NormTest = acos(vdot(Norm,y)); #if (NormTest*Gscale rotate y*(Cv*Grange*2-Grange+Grotate)+(rand(R)*8-4) translate } %V = V + 1; //if you want to see a progress report, to make sure the loop is doing something //#if(mod(V,100)=0) //#debug concat(str(V,0,0)," blades placed.\n") //#end #end #end #end } #end #end