! The MBS function tree. ! ! Copyright 2001, Humaniora labs All Rights Reserved. ! This program may be used under the terms of the GPL License. GLOBAL GEOMETRY MODULE tree( VECTOR y_axes:=vec(0, 0, 0) > "y_axes of tree !"; VECTOR x_axes:=vec(0, 0, 0) > "x_axes of tree !"; VECTOR cent:=vec(0, 0, 0) > "Centre of tree !"; FLOAT leng:=100.0 > "length of tree !"; INT deg:=0 > "deg of tree!"; FLOAT y:=0 > "turn of y!"; FLOAT x:=0 > "turn of x!" ); INT i; ! Stack overflow if degl > 7; CONSTANT INT degl=6; /* reflecsive*/ FLOAT branch(3, 3); BEGINMODULE csys_1p(#300,"base", cent, 0, 0, 0:BLANK=1); mode_local(#300); if deg > 0 then csys_3p(#200,"transform", vec(0,0,0), x_axes-y_axes, cent-y_axes:BLANK=1); mode_local(#200); endif; csys_1p(#100,"turny", vec(0,0,0), 0, y, 0:BLANK=1); mode_local(#100); csys_1p(#400,"turnx", vec(0,0,0), x, 0, 0:BLANK=1); mode_local(#400); branch(1, 1):= 0.65; branch(1, 2):= 60.0; branch(1, 3):= 30.0; branch(2, 1):= 0.75; branch(2, 2):= 180.0; branch(2, 3):= 30.0; branch(3, 1):= 0.7; branch(3, 2):= 300.0; branch(3, 3):= 30.0; if deg <= degl then poi_free(#1,vec(0, 0, 0) :BLANK=1); poi_free(#2,vec(0, leng, 0):BLANK=1); poi_free(#3,on(#1,0)+vec(1,0,0):BLANK=1); mode_global(); part(#7, cylinder(on(#1), on(#2), (1+degl-deg)*.7, 12):pen=10); for i:=1 to 3 do part(#5,tree(on(#1), on(#3), on(#2), branch(i, 1)*leng, deg+1, branch(i, 2), branch(i, 3))); endfor; else b_plane(#6, vec(0,0,0), vec(-3,9,0), vec(0,20,0), vec(3,9,0):pen=3); endif; ENDMODULE