"""GRASS CUTTER - more for the meadow than trees and the purple-veined spires: SM_Boulders a cluster of round, weathered field stones (no veins), moss on the shady side SM_SlabStones flat lilac slabs tipped up out of the ground, like an old wall gone over SM_Crystals a clump of teal crystals growing out of a pale rock SM_Shrooms giant alien mushrooms: cream stems, coral and teal caps with pale spots SM_Stump a broken stump on its roots with a fallen log beside it SM_BulbPlants fat alien bulb plants with spines and a flower on top All stand on z = 0 with their origin at the middle of the foot; Ground places them on the ball and gives them a MeshCollider (except the plants, which are walked through). Front = -Y (Unity +Z). blender -b --factory-startup --python ArtSource/Blender/scripts/gc_up6_world.py -- [SM_Name ...] """ import sys, os sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from gc_up_kit import * # noqa: F401,F403 STONE, PALE, LILAC, WET = "M_Rock", "M_RockPale", "M_RockLilac", "M_RockWet" MOSS, BARK, WOOD = "M_LeafDark", "M_Bark", "M_Wood" def view(**kw): return dict(elev=14, azim=-35, bg=(0.62, 0.72, 0.84), **kw) def finish(P, name, ms=None, ang=35): for o in P: apply_xform(o) o = ffin(P, name, ang=ang, wn=False, ms=ms or {STONE: 0.6, PALE: 0.6, LILAC: 0.6, WET: 0.6}) return o def tilted(o, rx=0.0, ry=0.0, rz=0.0, t=(0, 0, 0)): return xf(o, rx=rx, ry=ry, rz=rz, t=t) # ======================================================================= stones def boulders(): rng = random.Random(61) P = [] for (x, y, r, sc) in ((0.0, 0.0, 1.25, (1.2, 1.0, 0.8)), (1.7, 0.6, 0.75, (1.1, 1.0, 0.85)), (-1.3, 0.9, 0.6, (1.0, 1.2, 0.8)), (0.6, -1.4, 0.45, (1.2, 0.9, 0.7)), (-0.7, -1.1, 0.3, (1, 1, 0.8))): m = PALE if r > 0.7 else STONE P.append(rock(r, (x, y, r * sc[2] * 0.55), seed=rng.randrange(999), sc=sc, m=m, sub=2, amp=0.13, name="stone")) # moss on the north side and the top if r > 0.5: P.append(rock(r * 0.62, (x - r * 0.15, y + r * 0.45, r * sc[2] * 0.95), seed=rng.randrange(999), sc=(1.3, 1.0, 0.35), m=MOSS, sub=1, amp=0.18, name="moss")) return P def slab_stones(): rng = random.Random(62) P = [] for k, (x, y, w, h, lean, yaw) in enumerate(((0.0, 0.0, 1.5, 2.2, 0.18, 0.1), (1.4, 0.5, 1.1, 1.5, -0.25, 0.4), (-1.3, 0.3, 1.0, 1.2, 0.32, -0.3), (0.5, -1.2, 0.9, 0.5, 1.2, 0.8))): o = rock(0.5, (0, 0, 0), seed=rng.randrange(999), sc=(w, 0.32, h), m=LILAC if k % 2 == 0 else WET, sub=2, amp=0.08, name="slab") P.append(tilted(o, rx=lean, rz=yaw, t=(x, y, h * 0.36))) for k in range(5): a = rng.uniform(0, 2 * PI) P.append(rock(rng.uniform(0.12, 0.22), (math.cos(a) * rng.uniform(1.2, 2.0), math.sin(a) * rng.uniform(1.0, 1.8), 0.05), seed=k + 20, sc=(1.2, 1, 0.6), m=STONE, sub=1, amp=0.2, name="pebble")) return P def crystals(): rng = random.Random(63) P = [rock(0.9, (0, 0, 0.25), seed=7, sc=(1.4, 1.2, 0.6), m=PALE, sub=2, amp=0.15, name="bed")] spec = [(0.0, 0.0, 0.3, 2.6, 0.0, 0.0), (0.45, 0.2, 0.22, 1.8, 0.35, 0.5), (-0.4, 0.25, 0.2, 1.6, -0.4, 0.2), (0.15, -0.45, 0.17, 1.2, 0.15, -0.6), (-0.25, -0.35, 0.14, 0.9, -0.5, -0.3), (0.65, -0.3, 0.12, 0.8, 0.6, -0.2), (-0.7, -0.05, 0.11, 0.7, -0.7, 0.1)] for k, (x, y, r, L, tx, ty) in enumerate(spec): m = "M_CrystalDeep" if k % 3 == 0 else "M_GlassTeal" if k % 3 == 1 else "M_PaintTeal" shaft = cz("crystal", r, 0.0, L * 0.78, 0, 0, m, v=6) tip = cz("tip", r, L * 0.78, L, 0, 0, m, v=6, r2=0.0) for o in (shaft, tip): P.append(tilted(o, rx=ty * 0.6, ry=tx * 0.6, rz=rng.uniform(0, 1), t=(x, y, 0.25))) return P # ======================================================================= plants def shrooms(): rng = random.Random(64) P = [] for k, (x, y, h, cr, lean) in enumerate(((0.0, 0.0, 2.6, 1.15, 0.05), (1.3, 0.5, 1.7, 0.8, -0.18), (-1.0, 0.7, 1.3, 0.62, 0.2), (0.6, -1.0, 0.8, 0.42, 0.12), (-0.5, -0.8, 0.5, 0.3, -0.2))): cap = "M_Coral" if k % 2 == 0 else "M_PaintTeal" parts = [cz("stem", h * 0.085, 0.0, h, 0, 0, "M_PaintCream", v=10, r2=h * 0.06), cz("skirt", h * 0.14, h * 0.62, h * 0.66, 0, 0, "M_PaintCream", v=10, r2=h * 0.09), sphere("cap", cr, (0, 0, h), seg=14, rings=7, m=cap, scale=(1, 1, 0.5)), cz("gill", cr * 0.92, h - 0.02, h + 0.02, 0, 0, "M_PaintCream", v=14)] for s in range(5 if cr > 0.5 else 3): a = rng.uniform(0, 2 * PI) rr = rng.uniform(0.3, 0.75) * cr parts.append(sphere("spot", cr * 0.12, (math.cos(a) * rr, math.sin(a) * rr, h + cr * 0.5 * math.sqrt(max(0.05, 1 - (rr / cr) ** 2))), seg=6, rings=3, m="M_PaintWhite", scale=(1, 1, 0.45))) for o in parts: P.append(tilted(o, rx=lean, ry=lean * 0.5, t=(x, y, 0))) return P def stump(): rng = random.Random(65) P = [cz("stump", 0.55, 0.0, 0.95, 0, 0, BARK, v=12, r2=0.48), cz("top", 0.49, 0.95, 0.99, 0, 0, WOOD, v=12)] # a jagged break: a few splinters standing up from the top for k in range(6): a = k / 6 * 2 * PI + rng.uniform(-0.2, 0.2) P.append(cyl_between("splinter", (math.cos(a) * 0.38, math.sin(a) * 0.38, 0.95), (math.cos(a) * 0.3, math.sin(a) * 0.3, 1.1 + rng.uniform(0, 0.35)), 0.09, WOOD, v=4, r2=0.01)) for k in range(5): a = k / 5 * 2 * PI + 0.3 P.append(cyl_between("root", (math.cos(a) * 0.35, math.sin(a) * 0.35, 0.35), (math.cos(a) * 1.05, math.sin(a) * 1.05, -0.05), 0.16, BARK, v=6, r2=0.05)) # the fallen top, lying beside it P.append(cyl_between("log", (0.8, -0.7, 0.32), (3.2, 0.4, 0.3), 0.36, BARK, v=10, r2=0.3)) P.append(cyl_between("end", (0.78, -0.71, 0.32), (0.81, -0.69, 0.32), 0.35, WOOD, v=10)) P.append(cyl_between("branch", (2.2, -0.05, 0.45), (2.6, -0.9, 1.1), 0.08, BARK, v=5, r2=0.03)) P.append(rock(0.45, (2.0, 0.15, 0.62), seed=3, sc=(1.4, 1.0, 0.35), m=MOSS, sub=1, amp=0.2, name="moss")) return P def bulb_plants(): rng = random.Random(66) P = [] for k, (x, y, s) in enumerate(((0.0, 0.0, 1.0), (0.9, 0.4, 0.7), (-0.75, 0.5, 0.6), (0.3, -0.8, 0.5))): body = "M_Plant" if k % 2 == 0 else "M_Leaves" P.append(sphere("bulb", 0.55 * s, (x, y, 0.5 * s), seg=12, rings=8, m=body, scale=(1, 1, 1.15))) P.append(sphere("neck", 0.3 * s, (x, y, 1.1 * s), seg=10, rings=6, m=body, scale=(1, 1, 1.2))) # ribs of spines for j in range(8): a = j / 8 * 2 * PI for z in (0.35, 0.65): p = Vector((x + math.cos(a) * 0.55 * s * 0.95, y + math.sin(a) * 0.55 * s * 0.95, z * s + 0.1 * s)) d = Vector((math.cos(a), math.sin(a), 0.4)).normalized() P.append(cyl_between("spine", p, p + d * 0.16 * s, 0.02 * s, "M_PaintCream", v=3, r2=0.0)) # a flower on top top = Vector((x, y, 1.45 * s)) for j in range(6): a = j / 6 * 2 * PI + rng.uniform(0, 0.3) P.append(sphere("petal", 0.14 * s, (top.x + math.cos(a) * 0.13 * s, top.y + math.sin(a) * 0.13 * s, top.z), seg=6, rings=4, m="M_PaintRed" if k % 2 else "M_PaintOrange", scale=(1.3, 0.7, 0.3))) P.append(sphere("heart", 0.08 * s, (top.x, top.y, top.z + 0.03 * s), seg=6, rings=4, m="M_PaintYellow")) return P def builder(fn, name, ang=35): def build(): finish(fn(), name, ang=ang) return view(man=(2.5, -2.0, 0.0), views=[("_close", dict(elev=10, azim=-25, dist_mul=0.8))]) return build BUILDERS = {"SM_Boulders": builder(boulders, "SM_Boulders"), "SM_SlabStones": builder(slab_stones, "SM_SlabStones", 30), "SM_Crystals": builder(crystals, "SM_Crystals", 20), "SM_Shrooms": builder(shrooms, "SM_Shrooms"), "SM_Stump": builder(stump, "SM_Stump"), "SM_BulbPlants": builder(bulb_plants, "SM_BulbPlants")} BUDGET = {"SM_Boulders": 2500, "SM_SlabStones": 1500, "SM_Crystals": 800, "SM_Shrooms": 3000, "SM_Stump": 1500, "SM_BulbPlants": 3000} if __name__ == "__main__": build_main(BUILDERS, BUDGET)