// condenced Hf functions // 02:52:29 PM Wednesday March 15,2023 //-----------------------helper macros---------------------- #macro Pat(A) // place patterns #if(A="Ag") agate #local i=99;#end #if(A="Gr") granite #local i=99;#end #if(A="Bo") bozo #local i=99;#end #if(A="Ce") cells #local i=99;#end #if(A="Cr") crackle #local i=99;#end #if(A="Le") leopard #local i=99;#end #if(A="Ri") ripples #local i=99;#end #if(A="Wa") waves #local i=99;#end #ifndef(i) granite #end #end #macro Fat(A) //place functions #if(A="Ag") f_agate #local i=99;#end #if(A="Gr") f_granite #local i=99;#end #if(A="Bo") f_bozo #local i=99;#end #if(A="Cr") f_crackle #local i=99;#end #if(A="Le") f_Leopard #local i=99;#end #if(A="Ri") f_ripples #local i=99;#end #if(A="Wa") f_waves #local i=99;#end #ifndef(i) #warning "Fat macro missing Function :: using Default f_granite \n" f_granite #end #end #macro Wav(A) //place Waveforms #if(A=5) #ifndef(poly_wave_Val) #local poly_wave_Val=2; #warning "Wav macro needs poly_wave_Val defined outside macro :: using Default 2\n" #end #end #switch(A) #case(0) sine_wave #break #case(1) cubic_wave #break #case(2) scallop_wave #break #case(3) triangle_wave #break #case(4) ramp_wave #break #case(5) poly_wave poly_wave_Val #break // A>5 no added Waveforms #end #end //------------------------main-macros------------------------- //#macro YB_Pat(P,W,p,f,r,s,m) // P = Pigment ID String used in macro Pat // W = Waveform number . 0-5 used in macro Wav // p = phase value // f = frequency value // r = rotate pattern value (rotate around z only) // s = scale pattern vector // m = move pattern vector // based on YesBirds functions // I put poly_wave_Val outside this macro to keep number of inputs down // it is only used for the one Waveform poly_wave any way #macro YB_Pat(P,W,p,f,r,s,m) #local Fo=function { pattern {Pat(P) Wav(W) phase p frequency f translate -m scale s rotate z*r translate <.5,.5,0>}} function(x,y){Fo(x,y,0)} #end // #macro Gf_Fat(P,r,s,m)//my function patterns // P = Pigment ID String used in macro Pat // r = rotate pattern value (rotate around z only) // s = scale pattern vector // m = move pattern (translate)vector // base on my function patterns #macro Gf_Fat(P,r,s,m) #local g=radians(r); #local h=s*<1,1,1>; #local c=h.x; #local d=h.z; #local h=m*<1,1,1>; #local X=h.x; #local Y=h.y; #local Z=h.z; function(x,z) {Fat(P)(((x+X)*cos(g)-(z+Z)*sin(g))*c,Y,((x+X)*sin(g) + (z+Z)*cos(g))*d)} #end //----------------special macro functions---------------------------- // Sf_Inv(F1) // Sf_Ave(F1,F2) // Sf_Sub(F1,F2) // Sf_Add(F1,F2) // Sf_Div(F1,F2) // Sf_Mul(F1,F2) // Sf_Min(F1,F2) // Sf_Max(F1,F2) // Sf_object(Object,a,h1,h0) #macro Sf_Inv(F1) //inverse ground values function(x,z){1-F1(x,z)} #end #macro Sf_Ave(F1,F2) //averge ground/mat values function(x,z){(F1(x,z)+F2(x,z))/2} #end #macro Sf_Sub(F1,F2) //subtract F1-F2 ground/mat values #local FA=function(x,z){F1(x,z)-F2(x,z)} #local FB=function(x,z){select(FA(x,z),0,FA(x,z))} function(x,z){FB(x,z)} #end #macro Sf_Add(F1,F2) //add F1+F2 ground/mat values #local F0=function(x,z){F1(x,z)+F2(x,z)} #local FB=function(x,z){min(1,F0(x,z))} function(x,z){FB(x,z)} #end #macro Sf_Div(F1,F2) //divide F1/F2 ground/mat values #local F0=function(x,z){F2(x,z)} #local FA=function(x,z){min(1,F1(x,z)/F2(x,z))} #local FB=function(x,z){select(F0(x,z),0,0,FA(x,z))} function(x,z){FB(x,z)} #end #macro Sf_Mul(F1,F2) //multiply F1*F2 ground/mat values function(x,z){F1(x,z)*F2(x,z)} #end #macro Sf_Min(F1,F2) //Min test F1,F2 returns F1orF2 ground/mat values #local FB=function(x,z){min(F1(x,z),F2(x,z))} function(x,z){FB(x,z)} #end #macro Sf_Max(F1,F2) //Max test F1,F2 returns F1orF2 ground/mat values #local FB=function(x,z){max(F1(x,z),F2(x,z))} function(x,z){FB(x,z)} #end #macro Sf_object(Object,a,h1,h0) // a= edge adjust h1-background canbe <0 h0-object height #local Mx=max_extent(Thing); // cabe use either as Mf or Gf function #local Mn=min_extent(Thing); #local Mc=(Mx+Mn)/2; #local Sz=Mx-Mn+a; //#debug concat("V= <",vstr(3,Sz,",",3,3),">\n") #local Obj=object{Object translate -Mc scale 1/Sz translate <.5,0,.5> } #local PigFO=function{pigment{ object {Obj rgb h1 rgb h0}}} function(x,z){PigFO(x,0,z).hf} #end