//Make some interesting recursive shapes, //Made by Spider, spider@bahnhof.se //Distribute freely, but theese lines stay on top of the file. //Version 1.0a //version history: // 1.0 : First release // 1.0a : bug fix, #declare/#local and N = 10. #debug "Commands are:\n" #debug "AddPoint(point, angle(to base, or to stem), length(in 3D) )\n" #debug "Draw(Level(how many copies),Radii(Radius of cylinder))\n" #debug "bugs/comments: spider@bahnhof.se\n" #debug "To get a textured example, uncummont the pigment in the Draw() macro\n" #ifndef(N) #warning "Max amount of segments(N) not declared, defaulting to 10\n" #declare N = 10; #end #declare arr = array[N][3] //Constants for data. #declare cPoint = 0; #declare cAngle = 1; #declare cLength = 2; //<0,0,0> doesn't work #declare noPoint = <-1.001,-1,-1>; #local I = 0; #while(I; #declare arr[I][cLength] = <0.001,0,0>; #local I = I + 1; #end #macro AddPoint(vPoint,vAngle, vLength) #local I = 0; #local Done = false; #while(Done!=true) #local H = arr[I][cPoint]; #if( (H.x=noPoint.x)& (H.y=noPoint.y)& (H.z=noPoint.z) ) #declare arr[I][cPoint] = vPoint; #declare arr[I][cAngle] = vAngle; #declare arr[I][cLength] = vLength; #local Done = true; #end #local I = I + 1; #if(I=10)//break loop #local Done = true; #end #end #end #macro Draw(iLevel,fRadii) #if(iLevel>0) union { #local I = 0; #while(I, arr[I][cLength], fRadii /* pigment { gradient arr[I][cLength] colour_map { [0 colour rgb <0,0,0> ] [1 colour rgb <2,0,0> ] } #local D = arr[I][cLength]; #if(D.x=0) #local D = D + x; #end #if(D.y=0) #local D = D + y; #end #if(D.z=0) #local D = D + z; #end scale D } */ rotate arr[I][cAngle] translate arr[I][cPoint] #if(I!=0) rotate arr[0][cAngle] #end } #if(iLevel != 1) object { Draw(iLevel-1,fRadii) translate arr[I][cLength] rotate arr[I][cAngle] translate arr[I][cPoint] #if(I!=0) rotate arr[0][cAngle] #end } #end //End level-check #end //End is object check #local I = I + 1; #end } #end #end /** Demo useage : AddPoint(<0,0,0>,<00,20,22>, <0,3,0>) AddPoint(<0,2,0>,<0,20,-42>, <0,1,0>) //The angle, first "unangle" against the main, then 20 more. AddPoint(<0,1,0>,<-15,10,20>, <1,1,0>) object { Draw(4, 0.07) texture { pigment { colour rgb <1,0,0> } finish { ambient <1,0,0> } } } **/