"""Moonwater islet spec for bridge/slbuild.py. Parcel Wych x32-48, y0-32; sea at z 20, seabed ~12. Root = the main sand dome at (40, 16, 19.9). Everything else is offset from it.""" import json, math, pathlib SAND = "8b7783c3-f120-92fa-ae80-b6a1db11ffe2" # sand_pale.png FROND = "0c9c399a-2597-ec83-eb4d-0ad023198408" GRASS = "3daf6b98-beef-3875-f55a-a08f1b94411e" BARK = "0fbd5c85-3eea-92a0-4b84-bfe11bc8db6c" STONE = "33c13e29-3fcb-9995-bffa-e271698d6351" SCULPTS = ["00f83037-495c-26ab-333d-1c70bf5730b1", "0dc88c68-24fc-b9f0-1a82-f22ce14b4903", "e2d464e5-ddea-986a-2a64-d65f4e370287"] ROOT = (40.0, 16.0, 19.9) def rel(x, y, z): return [round(x - ROOT[0], 3), round(y - ROOT[1], 3), round(z - ROOT[2], 3)] def sand(name, size, at, color="#ffffff", rep=None): rep = rep or [round(size[0] / 3.0, 1), round(size[1] / 3.0, 1)] return {"name": name, "shape": "sphere", "size": size, "pos": rel(*at), "texture": SAND, "repeats": rep, "color": color, "physics_shape": "prim"} def rock(i, size, at, zrot, tilt=(0, 0), color="#a29b90"): return {"name": "rock", "shape": "sculpt", "sculpt": {"map": SCULPTS[i % 3], "type": "sphere", "invert": True}, "size": size, "pos": rel(*at), "rot": [tilt[0], tilt[1], zrot], "texture": STONE, "repeats": [2, 1], "color": color, "bump": "stone", "physics_shape": "convex"} root = {"name": "Moonwater islet", "desc": "Made by Tessel the AI (Claude).", "shape": "sphere", "size": [14.5, 22.0, 2.4], "texture": SAND, "repeats": [5, 7], "color": "#ffffff"} prims = [ root, sand("lobe sw", [9.0, 9.0, 1.9], (37.2, 7.4, 19.85)), sand("lobe n", [8.0, 8.0, 1.7], (42.4, 25.6, 19.8)), # a soft dune crest so the top isn't one smooth dome sand("dune", [6.5, 10.0, 3.1], (40.8, 18.5, 19.75)), sand("dune sw", [4.5, 4.0, 2.4], (37.0, 7.0, 19.75)), # wet band at the waterline: a wider, thinner, darker dome just breaking the surface sand("wet sand", [15.6, 23.2, 0.62], (40.0, 16.0, 20.0), color="#cdbb98"), sand("wet sand sw", [10.0, 10.0, 0.6], (37.2, 7.4, 20.0), color="#cdbb98"), sand("wet sand n", [9.0, 9.0, 0.6], (42.4, 25.6, 20.0), color="#cdbb98"), # rock outcrop on the north-east, highest stone first rock(0, [3.0, 2.5, 2.4], (44.6, 27.4, 21.0), 20, (4, -6)), rock(1, [2.2, 1.9, 1.6], (42.6, 28.6, 20.8), 75, (-5, 3)), rock(2, [1.7, 1.5, 1.2], (46.0, 25.4, 20.6), 140, (6, 2)), rock(0, [1.1, 0.9, 0.7], (41.4, 27.0, 20.9), 200, (0, 8), color="#b0a99d"), rock(1, [1.3, 1.1, 0.8], (45.6, 29.4, 20.3), 310, (-4, 0)), # a lone stone on the SW lobe, half in the water rock(2, [1.4, 1.2, 0.9], (33.6, 5.2, 20.1), 45, (3, 5), color="#9a948a"), # driftwood log to sit on, along the west side facing the surf beach {"name": "driftwood", "shape": "cylinder", "size": [0.42, 0.42, 2.6], "pos": rel(36.4, 12.8, 20.98), "rot": [90, 0, 8], "texture": "blank", "color": "#9b8a74", "bump": "bark", "repeats": [1, 3], "physics_shape": "convex"}, ] def palm(base, height, lean_az, lean, seed, fronds=7): """Curved trunk of 5 tapering segments leaning toward compass azimuth lean_az (deg, 0 = north, 90 = east), then a crown of two-part drooping fronds and two coconuts.""" import random r = random.Random(seed) out = [] seg = height / 5 pos = list(base) la = math.radians(lean_az) ldir = (math.sin(la), math.cos(la)) # unit vector in x,y for i in range(5): tilt = lean * (0.35 + 0.65 * (i / 4) ** 1.5) # degrees from vertical, growing with height t = math.radians(tilt) d = (ldir[0] * math.sin(t), ldir[1] * math.sin(t), math.cos(t)) c = [pos[k] + d[k] * seg / 2 for k in range(3)] diam = 0.46 - 0.05 * i # rotate the cylinder's z axis onto d: pitch about the axis perpendicular to the lean in the xy plane out.append({"name": "palm trunk", "shape": "cylinder", "size": [diam, diam, seg * 1.04], "pos": rel(*c), "quat": axis_quat((-ldir[1], ldir[0], 0), t), "texture": BARK, "repeats": [1, round(seg / 0.7, 2)], "color": "#ffffff", "physics_shape": "convex"}) pos = [pos[k] + d[k] * seg for k in range(3)] crown = pos for j in range(fronds): az = j * 360 / fronds + r.uniform(-14, 14) L1, L2, W = 1.5 + r.uniform(-0.15, 0.15), 1.9 + r.uniform(-0.2, 0.2), 1.6 up, droop = -r.uniform(8, 22), r.uniform(28, 48) a = math.radians(az) dirh = (math.sin(a), math.cos(a)) def seg_box(start, length, pitch, u0, u1): p_ = math.radians(pitch) dv = (dirh[0] * math.cos(p_), dirh[1] * math.cos(p_), -math.sin(p_)) c = [start[k] + dv[k] * length / 2 for k in range(3)] rep = u1 - u0 return {"name": "frond", "shape": "box", "size": [length, W, 0.01], "pos": rel(*c), "quat": qmul(axis_quat((0, 0, 1), math.radians(90 - az)), axis_quat((0, 1, 0), p_)), "texture": "transparent", "faces": {"0,5": {"texture": FROND, "repeats": [rep, 1], "offsets": [round(u0 + rep / 2 - 0.5, 3), 0], "alpha_mode": ["mask", 100], "color": "#ffffff"}}, "physics_shape": "none"}, [start[k] + dv[k] * length for k in range(3)] b1, end1 = seg_box(crown, L1, up, 0.0, 0.45) b2, _ = seg_box(end1, L2, droop, 0.45, 1.0) out += [b1, b2] for k in range(2): a = math.radians(r.uniform(0, 360)) c = (crown[0] + 0.22 * math.sin(a), crown[1] + 0.22 * math.cos(a), crown[2] - 0.25) out.append({"name": "coconut", "shape": "sphere", "size": [0.26, 0.26, 0.3], "pos": rel(*c), "texture": "blank", "color": "#6b5a3a", "bump": "bark", "physics_shape": "none"}) return out def qmul(a, b): """Hamilton product a*b of [x, y, z, w] quaternions: rotate by b, then by a.""" ax, ay, az_, aw = a bx, by, bz, bw = b return [round(aw * bx + ax * bw + ay * bz - az_ * by, 5), round(aw * by - ax * bz + ay * bw + az_ * bx, 5), round(aw * bz + ax * by - ay * bx + az_ * bw, 5), round(aw * bw - ax * bx - ay * by - az_ * bz, 5)] def axis_quat(axis, ang): n = math.sqrt(sum(a * a for a in axis)) or 1 s_ = math.sin(ang / 2) return [round(axis[0] / n * s_, 5), round(axis[1] / n * s_, 5), round(axis[2] / n * s_, 5), round(math.cos(ang / 2), 5)] # 10-14 ~12:00: the prim palms (25 prims each) became mesh palms, separate objects: palm_mesh/ and coconut/palm_mesh.lsl # prims += palm((38.5, 19.5, 20.85), 6.6, 290, 16, 1, fronds=9) # prims += palm((36.4, 6.3, 20.75), 5.2, 220, 22, 2, fronds=8) SIGN = "a69c04ab-738f-98c8-23fc-c5069ab6e30a" def surface(x, y): """Top of the sand at x, y: highest sphere among the sand prims (sphere = ellipsoid).""" best = 20.0 for pr in prims: if pr.get("shape") != "sphere" or pr.get("texture") != SAND: continue c = [ROOT[k] + (pr.get("pos") or [0, 0, 0])[k] for k in range(3)] sx, sy, sz = [v / 2 for v in pr["size"]] q = 1 - ((x - c[0]) / sx) ** 2 - ((y - c[1]) / sy) ** 2 if q > 0: best = max(best, c[2] + sz * math.sqrt(q)) return best def grass(x, y, turn, h=0.75): z = surface(x, y) + h / 2 - 0.08 face = {"1,3": {"texture": GRASS, "alpha_mode": ["mask", 100], "color": "#ffffff"}} return [{"name": "grass", "shape": "box", "size": [1.0, 0.01, h], "pos": rel(x, y, z), "rot": [0, 0, turn + a], "texture": "transparent", "faces": face, "physics_shape": "none"} for a in (0, 90)] z = surface(43.8, 17.0) prims += [ {"name": "sign post", "shape": "cylinder", "size": [0.12, 0.12, 1.35], "pos": rel(43.8, 17.0, z + 0.57), "texture": "blank", "color": "#9b8a74", "bump": "bark", "physics_shape": "convex"}, {"name": "sign", "shape": "box", "size": [1.2, 0.05, 0.6], "pos": rel(43.8, 17.04, z + 1.02), "texture": "blank", "color": "#a89a86", "faces": {"1,3": {"texture": SIGN, "color": "#ffffff"}}, "physics_shape": "convex"}, ] z = surface(37.6, 16.0) prims += [ {"name": "lantern post", "shape": "cylinder", "size": [0.1, 0.1, 1.7], "pos": rel(37.6, 16.0, z + 0.75), "texture": "blank", "color": "#8d7c66", "bump": "bark", "physics_shape": "convex"}, {"name": "lantern arm", "shape": "box", "size": [0.42, 0.04, 0.04], "pos": rel(37.78, 16.0, z + 1.56), "texture": "blank", "color": "#5a4c3c", "physics_shape": "none"}, {"name": "lantern", "shape": "cylinder", "size": [0.18, 0.18, 0.26], "pos": rel(37.93, 16.0, z + 1.36), "texture": "blank", "color": "#ffcf88", "alpha": 0.75, "glow": 0.12, "fullbright": True, "light": {"color": "#ffc070", "intensity": 1.0, "radius": 9, "falloff": 0.8}, "physics_shape": "none"}, {"name": "lantern cap", "shape": "cylinder", "top_size": [0.0, 0.0], "size": [0.24, 0.24, 0.1], "pos": rel(37.93, 16.0, z + 1.53), "texture": "blank", "color": "#4a3e32", "physics_shape": "none"}, ] for gx, gy, t in [(35.4, 18.6, 10), (44.6, 12.6, 40), (38.6, 23.2, 70), (34.9, 8.6, 25), (43.2, 7.6, 55), (41.8, 21.4, 5)]: prims += grass(gx, gy, t) spec = {"name": "Moonwater islet", "desc": "Made by Tessel the AI (Claude).", "at": list(ROOT), "prims": prims} out = pathlib.Path(__file__).with_name("islet.json") out.write_text(json.dumps(spec, indent=1)) print(out, len(prims), "prims")