################################## SHELL ############################# baloon = NIL(); #### outer shell sections (inner & outer ) ###### bis = load("baloon_in"); bos = load("baloon_out"); # N - number of slices N = 12; # Translate sections to (0,0,0) bis = bis * TRANS(vector(-coord(ceval(bis, 0.0), 1), 0.0, 0.0)); bos = bos * TRANS(vector(-coord(ceval(bos, 0.0), 1), 0.0, 0.0)); slice_angle = 360 / N; bos = bos * roty(slice_angle / 2); bis1 = bis * roty(slice_angle); ###### Create section of inner shell by scaling ####### scale_factor = 0.98; scale_mat = SCALE(vector(scale_factor, scale_factor, scale_factor)); ibis = bis * scale_mat; ibis1 = bis1 * scale_mat; ibos = bos * scale_mat; ##### Create inner and outer slices by interpolation ######### slice = sfromcrvs(list(bis1, bos, bis), 3); islice = sfromcrvs(list(ibis, ibos, ibis1), 3); ##### Create shell by replication of slices ######## rotstep = roty(slice_angle); mat = roty(0); slist = list(slice); islist = list(islice); color(slice, 1); color(islice, 1); FOR ( a = 2, 1, N, mat = rotstep * mat: curs = slice * mat: icurs = islice * mat: color(curs, a): color(icurs, a): SNOC(curs, slist): SNOC(icurs, islist) ); bottom = ceval(bis, 1.0); #### create shell ring as torus ###### rope_radius = 0.005; bring_radius = COORD(bottom, 1); OurTorus = function(center, normal, Radius, mRadius) :circ:mCirc: circ = circle(vector(0,0,0), Radius) * ROTZ2V(normal) * TRANS(center): mCirc = circle(vector(0,0,0), mRadius): return = SWEEPSRF(mCirc, circ, OFF); ring = OurTorus(vector(0,COORD(bottom, 2), 0), vector(0,1,0), bring_radius, rope_radius); # shell = slist + list(ring); shell = slist + islist + list(ring); free(bis); free(bos); free(bis1); free(ibis); free(ibos); free(ibis1); free(mat); free(rotstep); free(slice); free(islice); ############################# BASKET #################################################### bl = 1.2; bw = 1; bh = 1.2; r = 0.25; hbw = bw / 2; ##### create basket as bi-cubic spline surface ##### mesh = list ( list( ctlpt(E3, r, bh, 0), ctlpt(E3, r, bh, 0), ctlpt(E3, r, bh, 0), ctlpt(E3, r, bh, 0), ctlpt(E3, bw-r, bh, 0), ctlpt(E3, bw-r, bh, 0), ctlpt(E3, bw-r, bh, 0), ctlpt(E3, bw-r, bh, 0)), list( ctlpt(E3, r, bh, 0), ctlpt(E3, r, bh, 0), ctlpt(E3, r, bh, 0), ctlpt(E3, r, r, 0), ctlpt(E3, bw-r, r, 0), ctlpt(E3, bw-r, bh, 0), ctlpt(E3, bw-r, bh, 0), ctlpt(E3, bw-r, bh, 0)), list( ctlpt(E3, 0, bh, 0), ctlpt(E3, 0, r, 0), ctlpt(E3, 0, 0, 0), ctlpt(E3, r, 0, 0), ctlpt(E3, bw-r, 0, 0), ctlpt(E3, bw, 0, 0), ctlpt(E3, bw, r, 0), ctlpt(E3, bw, bh, 0)), list( ctlpt(E3, 0, bh, r), ctlpt(E3, 0, r, r), ctlpt(E3, 0, 0, r), ctlpt(E3, r, 0, r), ctlpt(E3, bw-r, 0, r), ctlpt(E3, bw, 0, r), ctlpt(E3, bw, r, r), ctlpt(E3, bw, bh, r)), list( ctlpt(E3, 0, bh, bl-r), ctlpt(E3, 0, r, bl-r), ctlpt(E3, 0, 0, bl-r), ctlpt(E3, r, 0, bl-r), ctlpt(E3, bw-r, 0, bl-r), ctlpt(E3, bw, 0, bl-r), ctlpt(E3, bw, r, bl-r), ctlpt(E3, bw, bh, bl-r)), list( ctlpt(E3, 0, bh, bl), ctlpt(E3, 0, r, bl), ctlpt(E3, 0, 0, bl), ctlpt(E3, r, 0, bl), ctlpt(E3, bw-r, 0, bl), ctlpt(E3, bw, 0, bl), ctlpt(E3, bw, r, bl), ctlpt(E3, bw, bh, bl)), list( ctlpt(E3, r, bh, bl), ctlpt(E3, r, bh, bl), ctlpt(E3, r, bh, bl), ctlpt(E3, r, r, bl), ctlpt(E3, bw-r, r, bl), ctlpt(E3, bw-r, bh, bl), ctlpt(E3, bw-r, bh, bl), ctlpt(E3, bw-r, bh, bl)), list( ctlpt(E3, hbw, bh, bl), ctlpt(E3, hbw, bh, bl), ctlpt(E3, hbw, bh, bl), ctlpt(E3, hbw, bh, bl), ctlpt(E3, hbw, bh, bl), ctlpt(E3, hbw, bh, bl), ctlpt(E3, hbw, bh, bl), ctlpt(E3, hbw, bh, bl)) ); ib = SBSPLINE(3,3, mesh, list( list( KV_OPEN ), list(KV_OPEN) )); ### invert normals #### ob = ib * SCALE(vector(-1,1,1)) * TRANS(vector(bw,0,0)); ### recenter #### basket = ob * TRANS(vector(-bw/2,0,-bl/2)); ### create inner surface #### ib = ib * TRANS(vector(-bw/2,0,-bl/2)); bring_bottom = COORD(bottom, 2); ### scale basket ### sbratio = 0.8 * bring_radius / bw; basket_bottom = bring_bottom - 0.5; basket_trans = SCALE(vector(sbratio, sbratio, sbratio)) * TRANS(vector(0, basket_bottom, 0)); basket = basket * basket_trans; ib = ib * basket_trans; free(basket_trans); bl = bl * sbratio; bw = bw * sbratio; bh = bh * sbratio; r = r * sbratio; basket_top = basket_bottom + bh; hbw = bw / 2; hbl = bl / 2; xscale = (bw - 4 * rope_radius) / bw; yscale = (bh - 2 * rope_radius) / bh; zscale = (bl - 4 * rope_radius) / bl; ibasket = ib * SCALE(vector(xscale, yscale, zscale)) * TRANS(vector(0, basket_top - (basket_top * yscale), 0)); attrib(basket, "rgb", "187,107,0"); attrib(ibasket, "rgb", "187,107,0"); basket = list(basket, ibasket); free(ib); free(ob); free(ibasket); ### create connecting construction ### fring_radius = bw/2; fring_height = (bring_bottom + basket_top) * 0.5; fring = OurTorus(vector(0,fring_height, 0), vector(0,1,0), fring_radius, rope_radius); bcx = hbw - rope_radius; bcz = hbl - r; tmp = fring_radius / SQRT(bcx * bcx + bcz * bcz); tcx = bcx * tmp; tcz = bcz * tmp; rope = circle(vector(0,0,0), rope_radius); axis = CBEZIER( list( ctlpt(E3, -bcx, basket_top, -bcz), ctlpt(E3, -tcx, fring_height, -tcz))); hang1 = SWEEPSRF( rope, axis, OFF); axis = CBEZIER( list( ctlpt(E3, bcx, basket_top, -bcz), ctlpt(E3, tcx, fring_height, -tcz))); hang2 = SWEEPSRF( rope, axis, OFF); axis = CBEZIER( list( ctlpt(E3, bcx, basket_top, bcz), ctlpt(E3, tcx, fring_height, tcz))); hang3 = SWEEPSRF( rope, axis, OFF); axis = CBEZIER( list( ctlpt(E3, -bcx, basket_top, bcz), ctlpt(E3, -tcx, fring_height, tcz))); hang4 = SWEEPSRF( rope, axis, OFF); tmp = bring_radius / fring_radius; ttcx = tcx * tmp; ttcz = tcz * tmp; axis = CBEZIER( list( ctlpt(E3, -tcx, fring_height, -tcz), ctlpt(E3, -ttcx, bring_bottom, -ttcz))); thang1 = SWEEPSRF( rope, axis, OFF); axis = CBEZIER( list( ctlpt(E3, tcx, fring_height, -tcz), ctlpt(E3, ttcx, bring_bottom, -ttcz))); thang2 = SWEEPSRF( rope, axis, OFF); axis = CBEZIER( list( ctlpt(E3, tcx, fring_height, tcz), ctlpt(E3, ttcx, bring_bottom, ttcz))); thang3 = SWEEPSRF( rope, axis, OFF); axis = CBEZIER( list( ctlpt(E3, -tcx, fring_height, tcz), ctlpt(E3, -ttcx, bring_bottom, ttcz))); thang4 = SWEEPSRF( rope, axis, OFF); free(tcx); free(tcz); free(ttcx); free(ttcz); free(fring_radius); free(fring_height); free(bcx); free(bcz); ### create basket handle ### handlex = hbw - rope_radius; handlez = hbl - rope_radius; handler = r - rope_radius; handle_axis = CBSPLINE(3, list ( ctlpt(E3, 0, basket_top, -handlez), ctlpt(E3, handlex-handler, basket_top, -handlez), ctlpt(E3, handlex, basket_top, -handlez), ctlpt(E3, handlex, basket_top, -handlez+handler), ctlpt(E3, handlex, basket_top, handlez-handler), ctlpt(E3, handlex, basket_top, handlez), ctlpt(E3, handlex-handler, basket_top, handlez), ctlpt(E3, -handlex+handler, basket_top, handlez), ctlpt(E3, -handlex, basket_top, handlez), ctlpt(E3, -handlex, basket_top, handlez-handler), ctlpt(E3, -handlex, basket_top, -handlez+handler), ctlpt(E3, -handlex, basket_top, -handlez), ctlpt(E3, -handlex+handler, basket_top, -handlez), ctlpt(E3, 0, basket_top, -handlez)), list(KV_OPEN)); free(handlex);free(handlez);free(handler); handle = SWPSCLSRF( rope, handle_axis, 1.5, OFF, 2); attrib(handle, "rgb", "92,27,0"); basket = basket + list(handle); attrib(fring, "rgb", "180,180,180"); attrib(fring, "specular", "180,180,180"); attrib(hang1, "rgb", "180,180,180"); attrib(hang1, "specular", "180,180,180"); attrib(hang2, "rgb", "180,180,180"); attrib(hang2, "specular", "180,180,180"); attrib(hang3, "rgb", "180,180,180"); attrib(hang3, "specular", "180,180,180"); attrib(hang4, "rgb", "180,180,180"); attrib(hang4, "specular", "180,180,180"); attrib(thang1, "rgb", "180,180,180"); attrib(thang1, "specular", "180,180,180"); attrib(thang2, "rgb", "180,180,180"); attrib(thang2, "specular", "180,180,180"); attrib(thang3, "rgb", "180,180,180"); attrib(thang3, "specular", "180,180,180"); attrib(thang4, "rgb", "180,180,180"); attrib(thang4, "specular", "180,180,180"); connection = list(fring,hang1, hang2, hang3, hang4) + list(thang1, thang2, thang3, thang4); baloon = shell + basket + connection; free(handle_axis); free(fring); free(hang1); free(hang2); free(hang3); free(hang4); free(thang1); free(thang2); free(thang3); free(thang4); free(connection); free(shell); free(basket); ################################# BAGS ##################################### bag_section = load("bag.dat"); bag_section = bag_section * ROTX(90); ### create bag as revolution surface #### bag = SURFREV(bag_section); bag = bag * ROTX(-90); bag_width = 0.16; free(bag_section); bag_trans = ROTZ(10) * SCALE(vector(1/12, 1/9, 1/12)) * TRANS(vector(0,basket_top - bh * 0.45 ,0)); bag_ref = vector(0,0,0) * bag_trans; bag = bag * bag_trans; attrib(bag, "rgb", "60,60,60"); bags = NIL(); bag1_trans = TRANS(vector(bw/2 + bag_width * 1/12, 0,0)); bag1 = bag * bag1_trans; bag1_rope = SWEEPSRF(circle(vector(0,0,0), 0.03 / 12), CBEZIER(list (bag_ref*bag1_trans , ctlpt(E3, hbw-rope_radius,basket_top,0))), OFF); color(bag1_rope, BLACK); bag1 = list(bag1, bag1_rope); bags = bags + bag1; bag2_trans = TRANS(vector(-bw/2 - bag_width * 1/12, 0,0)); bag2 = bag * ROTY(180) * bag2_trans; bag2_rope = SWEEPSRF(circle(vector(0,0,0), 0.03 / 12), CBEZIER(list (bag_ref*bag2_trans , ctlpt(E3, -hbw + rope_radius,basket_top,0))), OFF); color(bag2_rope, BLACK); bag2 = list(bag2, bag2_rope); bags = bags + bag2; bag3_trans = TRANS(vector(0, 0,bl/2 + bag_width * 1/12)); bag3 = bag * ROTY(-90) * bag3_trans; bag3_rope = SWEEPSRF(circle(vector(0,0,0), 0.03 / 12), CBEZIER(list (bag_ref * bag3_trans , ctlpt(E3, 0,basket_top, hbl-rope_radius))), OFF); color(bag3_rope, BLACK); bag3 = list(bag3, bag3_rope); bags = bags + bag3; bag4_trans = TRANS(vector(0, 0, -bl/2 - bag_width * 1/12)); bag4 = bag * ROTY(90) * bag4_trans; bag4_rope = SWEEPSRF(circle(vector(0,0,0), 0.03 / 12), CBEZIER(list (bag_ref * bag4_trans , ctlpt(E3, 0,basket_top, -hbl+rope_radius))), OFF); color(bag4_rope, BLACK); bag4 = list(bag4, bag4_rope); bags = bags + bag4; free(bag_width); free(bag_ref); free(bag); free(bag1); free(bag2); free(bag3); free(bag4); free(bag_trans); free(bag1_trans); free(bag2_trans); free(bag3_trans); free(bag4_trans); free(bag1_rope); free(bag2_rope); free(bag3_rope); free(bag4_rope); ############################################################################################## baloon = baloon + bags; free(bags); interact(list (baloon , axes)); save("baloon", baloon); free(bh); free(bl); free(bw); free(hbw); free(hbl); free(r); free(rope_radius); free(rope); free(bring_radius); free(bring_bottom); free(basket_top); free(basket_bottom); free(tmp); free(axis); free(sbratio); free(scale_mat); free(handle); free(zscale); free(yscale); free(xscale); free(mesh); free(ring); free(bottom); free(a); free(icurs); free(curs); free(islist); free(slist); free(scale_factor); free(slice_angle); free(N); free(baloon);