Files
Hunter/blender/build_city_arena.py
T
2026-11-29 15:49:17 +03:00

417 lines
23 KiB
Python

"""Fresh Blender build for the Hunter 520 x 520 city arena.
One Blender unit is one Roblox stud. Run this file in Blender's Python console.
"""
import bpy, math, os, random
from mathutils import Vector
ROOT = r"C:\roblox\hunter"
BLEND_OUT = os.path.join(ROOT, "3D models", "game_zone", "Hunter_CityArena.blend")
RENDER_OUT = os.path.join(ROOT, "renders", "hunter_city_arena.png")
os.makedirs(os.path.dirname(BLEND_OUT), exist_ok=True)
os.makedirs(os.path.dirname(RENDER_OUT), exist_ok=True)
SEED = random.randrange(1, 2**31)
RNG = random.Random(SEED)
SIZE, CELL, RADIUS = 520.0, 40.0, 6
for old_scene in list(bpy.data.scenes):
if old_scene.name.startswith("Hunter City Arena"):
bpy.data.scenes.remove(old_scene, do_unlink=True)
scene = bpy.data.scenes.new("Hunter City Arena | 520 studs")
if bpy.context.window:
bpy.context.window.scene = scene
def coll(name):
c = bpy.data.collections.new(name)
scene.collection.children.link(c)
return c
FOUNDATION = coll("01 Foundation")
ROADS = coll("02 Streets and route loops")
BUILDINGS = coll("03 Modular city buildings")
ROOFS = coll("04 Rooftop routes")
LANDMARKS = coll("05 Plaza and landmarks")
PROPS = coll("06 Trees, lanterns and cover")
WALLS = coll("07 Perimeter and gates")
SETUP = coll("08 Lighting and camera")
def mat(name, color, rough=0.85, metal=0.0, emission=0.0):
m = bpy.data.materials.new(name)
m.diffuse_color = (*color, 1)
m.use_nodes = True
bsdf = next((node for node in m.node_tree.nodes if node.type == "BSDF_PRINCIPLED"), None)
if bsdf:
bsdf.inputs["Base Color"].default_value = (*color, 1)
bsdf.inputs["Roughness"].default_value = rough
bsdf.inputs["Metallic"].default_value = metal
if emission:
bsdf.inputs["Emission Color"].default_value = (*color, 1)
bsdf.inputs["Emission Strength"].default_value = emission
return m
paper = mat("Warm paper stone", (.83,.75,.69))
walk = mat("Pale chalk paving", (.92,.86,.80))
plaza_pink = mat("Rose paper plaza", (.85,.70,.73))
road = mat("Graphite blue asphalt", (.19,.23,.31), .96)
lane = mat("Worn road pencil", (.51,.53,.58))
ink = mat("Indigo pencil line", (.16,.18,.29))
seam = mat("Soft violet pencil seam", (.30,.34,.48))
lav = mat("Lavender plaster", (.59,.64,.83))
blue = mat("Blue chalk plaster", (.48,.68,.83))
peach = mat("Peach plaster", (.87,.59,.46))
rose = mat("Rose plaster", (.80,.49,.60))
cream = mat("Cream plaster", (.92,.82,.69))
slate = mat("Violet slate roof", (.25,.28,.44), .72)
slate2 = mat("Blue slate roof", (.39,.44,.62), .74)
orange = mat("Painted orange tile", (.94,.37,.22), .78)
orange_light = mat("Warm orange pencil highlight", (1.0,.59,.34))
wood = mat("Cedar brown", (.32,.21,.18))
glass = mat("Turquoise glass", (.27,.72,.81), .22, .1)
water = mat("Fountain water", (.12,.66,.85), .2, .12, .12)
green = mat("Garden green", (.30,.56,.38))
leaf = mat("Sage foliage", (.31,.64,.48))
blossom = mat("Cherry blossom pink", (.92,.48,.72))
gold = mat("Lantern glow", (1.0,.68,.29), .4, 0, .2)
metal = mat("Blue charcoal metal", (.13,.18,.27), .55, .3)
walls_palette = [lav, blue, peach, rose, cream]
roofs_palette = [slate, slate2, orange]
class Mesh:
def __init__(self, name, material, collection, parent=None):
self.name, self.material, self.collection, self.parent = name, material, collection, parent
self.v, self.f = [], []
def box(self, center, size, angle=0.0):
x,y,z = center; sx,sy,sz = size
c,s = math.cos(angle), math.sin(angle); base = len(self.v)
for a,b,d in [(-sx/2,-sy/2,-sz/2),(sx/2,-sy/2,-sz/2),(sx/2,sy/2,-sz/2),(-sx/2,sy/2,-sz/2),(-sx/2,-sy/2,sz/2),(sx/2,-sy/2,sz/2),(sx/2,sy/2,sz/2),(-sx/2,sy/2,sz/2)]:
self.v.append((x+a*c-b*s,y+a*s+b*c,z+d))
self.f += [tuple(base+i for i in face) for face in ((0,3,2,1),(4,5,6,7),(0,1,5,4),(1,2,6,5),(2,3,7,6),(3,0,4,7))]
def mesh(self, verts, faces):
base=len(self.v); self.v.extend(verts); self.f.extend(tuple(base+i for i in face) for face in faces)
def gable(self,w,d,z,rise,cx=0,cy=0,over=.5):
w+=2*over; d+=2*over
v=[(cx-w/2,cy-d/2,z),(cx+w/2,cy-d/2,z),(cx+w/2,cy+d/2,z),(cx-w/2,cy+d/2,z),(cx,cy-d/2,z+rise),(cx,cy+d/2,z+rise)]
self.mesh(v,[(0,1,4),(3,5,2),(0,4,5,3),(1,2,5,4),(0,3,2,1)])
def finish(self, bevel=0):
if not self.f: return None
me=bpy.data.meshes.new(self.name+" mesh"); me.from_pydata(self.v,[],self.f); me.materials.append(self.material); me.update()
ob=bpy.data.objects.new(self.name,me); self.collection.objects.link(ob)
if self.parent: ob.parent=self.parent
if bevel:
b=ob.modifiers.new("Soft cut paper edges","BEVEL"); b.width=bevel; b.segments=1; b.limit_method="ANGLE"
ob.modifiers.new("Weighted corner normals","WEIGHTED_NORMAL")
return ob
def root_obj(name, x,y,angle, props=None):
o=bpy.data.objects.new(name,None); o.empty_display_type="PLAIN_AXES"; o.empty_display_size=2
o.location=(x,y,0); o.rotation_euler[2]=angle; BUILDINGS.objects.link(o)
if props:
for k,v in props.items(): o[k]=v
return o
def cylinder(batch, center, r, depth, sides=24, rt=None):
x,y,z=center; rt=r if rt is None else rt; v=[]
for zz,rr in ((z-depth/2,r),(z+depth/2,rt)):
for i in range(sides):
a=2*math.pi*i/sides; v.append((x+rr*math.cos(a),y+rr*math.sin(a),zz))
f=[tuple(reversed(range(sides))),tuple(range(sides,2*sides))]
for i in range(sides): j=(i+1)%sides; f.append((i,j,sides+j,sides+i))
batch.mesh(v,f)
def ico(batch, center, r, seed, stretch=(1,1,1)):
rng=random.Random(seed); p=(1+math.sqrt(5))/2
raw=[(-1,p,0),(1,p,0),(-1,-p,0),(1,-p,0),(0,-1,p),(0,1,p),(0,-1,-p),(0,1,-p),(p,0,-1),(p,0,1),(-p,0,-1),(-p,0,1)]
faces=[(0,11,5),(0,5,1),(0,1,7),(0,7,10),(0,10,11),(1,5,9),(5,11,4),(11,10,2),(10,7,6),(7,1,8),(3,9,4),(3,4,2),(3,2,6),(3,6,8),(3,8,9),(4,9,5),(2,4,11),(6,2,10),(8,6,7),(9,8,1)]
verts=[]
for x,y,z in raw:
n=math.sqrt(x*x+y*y+z*z); j=rng.uniform(.93,1.07)
verts.append((center[0]+r*x/n*j*stretch[0],center[1]+r*y/n*j*stretch[1],center[2]+r*z/n*j*stretch[2]))
batch.mesh(verts,faces)
# One foundation underlay; route tiles have raised, non-overlapping walkable surfaces.
ground=Mesh("520 x 520 paper foundation",paper,FOUNDATION); ground.box((0,0,-1.0),(SIZE,SIZE,1.8)); ground.finish(.15)
def is_route(i): return i in (-3,0,3)
def road_tile(x,y,horizontal=False,cross=False):
asphalt=Mesh("Crossroads" if cross else "Street module",road,ROADS); asphalt.box((x,y,.14),(39.85,39.85,.28)); asphalt.finish()
side=Mesh("Sidewalk module",walk,ROADS)
if cross:
for sx in (-1,1):
for sy in (-1,1): side.box((x+sx*14.5,y+sy*14.5,.34),(11,11,.16))
side.finish(.025)
stripes=Mesh("Painted crosswalk",lane,ROADS)
for sgn in (-1,1):
for i in range(-2,3):
stripes.box((x+sgn*13,y+i*2.3,.30),(1.25,.62,.04))
stripes.box((x+i*2.3,y+sgn*13,.30),(.62,1.25,.04))
stripes.finish(); return
marks=Mesh("Dashed centerline",lane,ROADS)
if horizontal:
side.box((x,y-15,.34),(39.9,10,.16)); side.box((x,y+15,.34),(39.9,10,.16))
for dx in (-15,-5,5,15): marks.box((x+dx,y,.30),(4.0,.28,.04))
else:
side.box((x-15,y,.34),(10,39.9,.16)); side.box((x+15,y,.34),(10,39.9,.16))
for dy in (-15,-5,5,15): marks.box((x,y+dy,.30),(.28,4.0,.04))
side.finish(.025); marks.finish()
for row in range(-RADIUS,RADIUS+1):
for col in range(-RADIUS,RADIUS+1):
if abs(row)<=1 and abs(col)<=1: continue
h,v=is_route(row),is_route(col)
if h or v: road_tile(col*CELL,row*CELL,horizontal=h and not v,cross=h and v)
# A generous central concourse replaces the cramped four-way tile intersection.
plinth=Mesh("Central rose-stone concourse",plaza_pink,LANDMARKS); plinth.box((0,0,.13),(120,120,.25)); plinth.finish(.08)
spokes=Mesh("Four broad plaza approaches",walk,LANDMARKS)
for yy in (-39,39): spokes.box((0,yy,.31),(16,42,.12))
for xx in (-39,39): spokes.box((xx,0,.31),(42,16,.12))
spokes.finish()
loop=Mesh("Square promenade loop",orange_light,LANDMARKS)
loop.box((0,42,.37),(78,9,.12)); loop.box((0,-42,.37),(78,9,.12))
loop.box((42,0,.37),(9,76,.12)); loop.box((-42,0,.37),(9,76,.12)); loop.finish()
insets=Mesh("Plaza pencil mosaics",seam,LANDMARKS)
for s in (-1,1):
for t in (-1,1):
insets.box((s*28,t*28,.43),(4,4,.06)); insets.box((t*28,s*28,.43),(4,4,.06))
insets.finish()
basin=Mesh("Fountain basin and column",lav,LANDMARKS)
cylinder(basin,(0,0,1.05),11,1.4,28); cylinder(basin,(0,0,1.92),8.5,.24,28)
basin.box((0,0,4.0),(2.3,2.3,4.0)); cylinder(basin,(0,0,6.35),4.0,.65,24,2.4); cylinder(basin,(0,0,6.85),2.0,.25,24); basin.finish(.08)
water_top=Mesh("Bright fountain water",water,LANDMARKS); cylinder(water_top,(0,0,1.8),8.15,.06,32); water_top.finish()
# Reusable house: open ground-floor arcade, two walkable roof levels, gabled crown and pencil grid.
tree_trunks=Mesh("Tree trunks",wood,PROPS); tree_leaves=Mesh("Sage crowns",leaf,PROPS); tree_blossoms=Mesh("Cherry crowns",blossom,PROPS)
lamp_metal=Mesh("Lantern posts",metal,PROPS); lamp_light=Mesh("Lantern warm glass",gold,PROPS)
orange_cover=Mesh("Orange cover blocks",orange,PROPS); cover_ink=Mesh("Orange block linework",orange_light,PROPS)
planters=Mesh("Tree planters",lav,PROPS)
def tree(x,y,pink=False,scale=1):
trunks=10*scale; tree_trunks.box((x,y,trunks/2+.22),(2*scale,2*scale,trunks))
b=tree_blossoms if pink else tree_leaves
ico(b,(x,y,12.4*scale),6.5*scale,int(x*19+y*27+1000))
ico(b,(x-3.2*scale,y+1.3*scale,11*scale),5*scale,int(x*11-y*17+2000))
ico(b,(x+3.3*scale,y-1.1*scale,11.5*scale),4.8*scale,int(x*23+y*9+3000))
planters.box((x,y,.42),(8*scale,8*scale,.5))
def lamp(x,y):
lamp_metal.box((x,y,4.8),(.5,.5,9.2)); lamp_metal.box((x+.8,y,8.9),(2,.45,.4))
lamp_light.box((x+1.5,y,8.2),(1.3,1.1,.9)); lamp_metal.box((x+1.5,y,9.0),(2.2,1.8,.24))
def crate(x,y,z=0.2,sx=7,sy=6,sz=7,a=0):
orange_cover.box((x,y,z+sz/2),(sx,sy,sz),a)
cover_ink.box((x,y-sy/2-.04,z+sz*.56),(sx*.75,.1,.16),a)
def build_house(col,row,index,landmark=None,forced=None):
x,y=col*CELL,row*CELL
rr=random.Random(SEED+(col+9)*1009+(row+9)*2027)
if abs(col)>abs(row): angle=math.pi/2 if col<0 else -math.pi/2
else: angle=0 if row>0 else math.pi
plaster=forced or rr.choice(walls_palette); roofmat=rr.choice(roofs_palette)
w=rr.uniform(25,29); d=rr.uniform(24,29); h=12.0; uh=rr.choice((7.5,8.5,9.5))
uw=w*rr.uniform(.59,.75); ud=d*rr.uniform(.59,.75); passage=7.2
name="Block %02d | %s"%(index,landmark or "paper-plaster walk-up")
root=root_obj(name,x,y,angle,{"GridX":col,"GridY":row,"Stories":2,"RoofAccess":True,"Landmark":landmark or ""})
wa=Mesh(name+" plaster",plaster,BUILDINGS,root); rf=Mesh(name+" roof",roofmat,BUILDINGS,root)
ln=Mesh(name+" ink seams",seam,BUILDINGS,root); dk=Mesh(name+" dark trim",ink,BUILDINGS,root)
gl=Mesh(name+" windows",glass,BUILDINGS,root); ac=Mesh(name+" orange accents",orange_light,BUILDINGS,root); wd=Mesh(name+" cedar",wood,BUILDINGS,root)
zc=h/2+.2
# Solid side walls, but facade panels leave a broad north-south route through the house.
wa.box((-w/2+.7,0,zc),(1.4,d-2,h-.4)); wa.box((w/2-.7,0,zc),(1.4,d-2,h-.4))
for fy in (-d/2,d/2):
panel=(w-passage)/2
wa.box((-(passage/2+panel/2),fy,zc),(panel,1.35,h-.4))
wa.box(((passage/2+panel/2),fy,zc),(panel,1.35,h-.4))
wa.box((0,fy,h-.8),(passage,1.35,1.6))
# Deep cedar arcade reveals make the through-route legible at street level.
dk.box((-passage/2-.22,fy*1.025,h/2),(0.32,.22,h))
dk.box((passage/2+.22,fy*1.025,h/2),(0.32,.22,h))
# Lower roof promenade and its raised orange rim.
rf.box((0,0,h+.22),(w+5,d+5,.55)); dk.box((0,0,h+.55),(w+5.7,d+5.7,.16))
upper_z=h+.7
wa.box((0,0,upper_z+uh/2),(uw,ud,uh))
rf.box((0,0,upper_z+uh+.25),(uw+3.8,ud+3.8,.55))
rf.gable(uw+3.8,ud+3.8,upper_z+uh+.52,rr.uniform(3.2,4.8),over=.65)
ac.box((0,0,upper_z+uh+4),(0.75,ud+5,.45))
# Big paired windows and sills face the road-facing side.
for s in (-1,1):
for level in range(2):
zz=h*(.34+.37*level); wx=s*w*.22
dk.box((wx,-d/2-.12,zz),(5.3,.16,4.6))
gl.box((wx,-d/2-.22,zz),(4.35,.13,3.65))
ac.box((wx,-d/2-.29,zz-2.1),(5.8,.34,.32))
wz=upper_z+uh*.53; wx=s*uw*.23
dk.box((wx,-ud/2-.11,wz),(4.7,.15,3.8)); gl.box((wx,-ud/2-.22,wz),(3.8,.13,2.95))
# Hand-drawn panel grid: offset pencil marks on facade and side elevations.
for gx in range(-int(w/2)+8,int(w/2),8):
if abs(gx)<passage/2+1.1: continue
ln.box((gx+rr.uniform(-.1,.1),-d/2-.30,zc),(0.11,.08,h-.7))
for gz in range(8,int(h),8):
ln.box((0,-d/2-.30,gz+.2),(w-passage-1,.08,.12))
for s in (-1,1):
fx=s*(w/2+.06)
for gy in range(-int(d/2)+8,int(d/2),8): ln.box((fx,gy,zc),(.08,.12,h-.7))
for gz in range(8,int(h),8): ln.box((fx,0,gz+.2),(.08,d-1,.12))
# Wide steps reach the first roof, then a narrower stair reaches the upper deck.
n=14; rise=h/n; run=d-6
for i in range(n):
yy=d/2-3-i*run/(n-1)
rf.box((w/2+3,yy,.2+(i+.5)*rise),(5.2,2.15,rise))
dk.box((w/2+3,yy,.2+(i+1)*rise),(5.35,.10,.12))
n2=11; rise2=uh/n2
for i in range(n2):
yy=ud/2-2-i*(ud-4)/(n2-1)
rf.box((uw/2+2.6,yy,upper_z+(i+.5)*rise2),(2.5,1.9,rise2))
for i in range(rr.randint(1,3)):
cx=rr.choice((-1,1))*rr.uniform(4,8); cy=rr.choice((-1,1))*rr.uniform(4,8)
ac.box((cx,cy,h+1.4),(rr.uniform(4,7),rr.uniform(3,5),2.8))
if landmark=="Clock tower":
rf.box((0,0,upper_z+uh+5),(11,11,9)); ac.box((0,0,upper_z+uh+9.8),(13,13,.65))
for a in range(4):
q=a*math.pi/2; gl.box((math.cos(q)*5.56,math.sin(q)*5.56,upper_z+uh+5),(2.3,.2,2.3),q)
elif landmark=="Pagoda lookout":
for k in range(3):
zz=upper_z+uh+k*4.6
rf.box((0,0,zz+1.7),(16-3*k,16-3*k,3.2)); ac.box((0,0,zz+3.5),(20-3*k,20-3*k,.55))
rf.box((0,0,upper_z+uh+14),(2.4,2.4,4.2))
elif landmark=="Market arcade":
for k in (-1,0,1):
ac.box((k*7,-d/2-1,h*.7),(5.6,1,3.8)); gl.box((k*7,-d/2-1.4,h*.31),(3.4,.16,3.0))
elif landmark=="Garden pavilion":
for xx in (-7,7):
for yy in (-7,7): wd.box((xx,yy,upper_z+uh+2.2),(1.2,1.2,4.5))
ac.box((0,0,upper_z+uh+4.8),(22,22,.7))
for b in (wa,rf,ln,dk,gl,ac,wd): b.finish(.045 if b in (wa,rf,ac) else 0)
return root
slots={(-4,4):("Clock tower",cream),(4,4):("Pagoda lookout",rose),(4,-4):("Market arcade",peach),(-4,-4):("Garden pavilion",blue)}
court_slots={(-5,-5),(-5,5),(5,-5),(5,5),(-2,-2),(-2,2),(2,-2),(2,2),
(-4,-2),(-4,2),(4,-2),(4,2),(-2,-4),(2,-4),(-2,4),(2,4),
(-6,-4),(-6,4),(6,-4),(6,4),(-4,-6),(4,-6),(-4,6),(4,6)}
def build_courtyard(col,row,index):
x,y=col*CELL,row*CELL
root=root_obj("Garden court %02d | open four-way passage"%index,x,y,0,
{"GridX":col,"GridY":row,"RouteAccess":True,"LotType":"Courtyard"})
stone=Mesh(root.name+" paving",walk,LANDMARKS,root)
grass=Mesh(root.name+" planted island",green,LANDMARKS,root)
border=Mesh(root.name+" chalk edging",lav,LANDMARKS,root)
woodwork=Mesh(root.name+" benches and gates",wood,LANDMARKS,root)
trim=Mesh(root.name+" orange wayfinding",orange_light,LANDMARKS,root)
stone.box((0,0,.2),(36,36,.25))
grass.box((-7,7,.37),(11,11,.12))
# Low walls protect the garden but leave all four sides open for a readable shortcut.
for sign in (-1,1):
for side in (-1,1):
border.box((sign*17,side*11,1.8),(2,12,3.2))
border.box((side*11,sign*17,1.8),(12,2,3.2))
border.box((sign*17,0,3.5),(2,9,.45))
border.box((0,sign*17,3.5),(9,2,.45))
woodwork.box((6,-7,.9),(8,1.1,1.4)); woodwork.box((6,-9,.52),(8,1.1,.24))
trim.box((0,0,.46),(2.4,2.4,.12))
for b in (stone,grass,border,woodwork,trim): b.finish(.035 if b in (stone,border) else 0)
tree(x-7,y+7,blossom=(index%3==0),scale=.62)
house_count=0; court_count=0
for row in range(-RADIUS,RADIUS+1):
for col in range(-RADIUS,RADIUS+1):
if abs(row)<=1 and abs(col)<=1: continue
if is_route(row) or is_route(col): continue
slot=slots.get((col,row))
if (col,row) in court_slots and not slot:
court_count+=1; build_courtyard(col,row,court_count)
else:
house_count+=1
build_house(col,row,house_count,slot[0] if slot else None,slot[1] if slot else None)
# Elevated links connect adjacent roof walks across the side boulevards.
bridge=Mesh("Four raised rooftop crossovers",slate2,ROOFS)
rails=Mesh("Bridge ink railings",ink,ROOFS)
bridge_marks=Mesh("Bridge orange route markers",orange_light,ROOFS)
for x in (-120,120):
for y in (-60,60):
bridge.box((x,y,12.95),(54,8.2,.7))
for s in (-1,1): rails.box((x,y+s*4.1,14.2),(54,.38,2.2))
for dx in (-18,18): bridge_marks.box((x+dx,y,13.34),(.65,6.3,.08))
bridge.finish(.07); rails.finish(.04); bridge_marks.finish()
# Outer ramparts stop at marked cardinal gates; the south arch frames portal entry.
rampart=Mesh("Low lavender arena ramparts",lav,WALLS)
rampart_caps=Mesh("Slate rampart caps",slate,WALLS)
rampart_lines=Mesh("Rampart pencil seams",seam,WALLS)
hwall=23.0
for edge in (-SIZE/2,SIZE/2):
for c in range(-RADIUS,RADIUS+1):
if c==0: continue
x=c*CELL; rampart.box((x,edge,hwall/2),(CELL-.4,2.8,hwall)); rampart_caps.box((x,edge,hwall+.24),(CELL-.2,4.4,.55))
rampart_lines.box((x-CELL/2+2,edge-1.5,hwall/2),(.14,.08,hwall-1))
# Gate pillars at each north/south opening.
for s in (-1,1):
xx=s*32; rampart.box((xx,edge,14),(10,8,28)); rampart_caps.box((xx,edge,28.4),(13,10,.8))
rampart.box((0,edge,29),(52,8,4)); rampart_caps.box((0,edge,31.5),(56,10,.9))
for edge in (-SIZE/2,SIZE/2):
for r in range(-RADIUS,RADIUS+1):
if r==0: continue
y=r*CELL; rampart.box((edge,y,hwall/2),(2.8,CELL-.4,hwall)); rampart_caps.box((edge,y,hwall+.24),(4.4,CELL-.2,.55))
rampart_lines.box((edge-1.5,y-CELL/2+2,hwall/2),(.08,.14,hwall-1))
rampart.finish(.10); rampart_caps.finish(.07); rampart_lines.finish()
gate=Mesh("South portal arch plaster",cream,WALLS); gate_roof=Mesh("South portal arch orange canopy",orange,WALLS); gate_ink=Mesh("South gate pencil trim",ink,WALLS)
for x in (-17,17):
gate.box((x,-238,13.5),(5.5,8,27)); gate_roof.box((x,-238,27.4),(7,10,1)); gate_ink.box((x,-233.8,13.5),(.15,.12,25))
gate.box((0,-238,29),(39,8,4.5)); gate_roof.box((0,-238,31.8),(43,10,1))
gate.finish(.1); gate_roof.finish(.08); gate_ink.finish()
# Avenues carry cover islands, garden corners and regular lamps; district corners get blossom trees.
cover=Mesh("Orange combat cover",orange,PROPS); cover_marks=Mesh("Cover pencil stripes",orange_light,PROPS)
for i,(x,y) in enumerate([(-205,-205),(-165,-195),(-65,-205),(70,-205),(205,-195),(200,-65),(205,55),(195,200),(70,205),(-65,205),(-205,190),(-205,60),(-195,-65),(-70,70),(70,-70),(185,170),(-170,165)]):
sx=RNG.uniform(5,9); sy=RNG.uniform(4,7); sz=RNG.uniform(5,10); a=RNG.choice((0,0,math.pi/4))
cover.box((x,y,.2+sz/2),(sx,sy,sz),a); cover_marks.box((x,y-sy/2-.05,.2+sz*.55),(sx*.72,.12,.16),a)
cover.finish(.06); cover_marks.finish()
for row in range(-RADIUS,RADIUS+1):
for col in range(-RADIUS,RADIUS+1):
if not (is_route(row) or is_route(col)) or (abs(row)<=1 and abs(col)<=1): continue
x,y=col*CELL,row*CELL
if row%2==0 and col in (-3,3): lamp_metal.box((x+12,y-11,4.8),(.5,.5,9.2)); lamp_metal.box((x+12.8,y-11,8.9),(2,.45,.4)); lamp_light.box((x+13.5,y-11,8.2),(1.3,1.1,.9)); lamp_metal.box((x+13.5,y-11,9),(2.2,1.8,.24))
if col%2==0 and row in (-3,3): lamp_metal.box((x-11,y+12,4.8),(.5,.5,9.2)); lamp_metal.box((x-10.2,y+12,8.9),(2,.45,.4)); lamp_light.box((x-9.5,y+12,8.2),(1.3,1.1,.9)); lamp_metal.box((x-9.5,y+12,9),(2.2,1.8,.24))
for cross_col in (-3,3):
for cross_row in (-3,3):
for sx in (-1,1):
for sy in (-1,1):
tree(cross_col*CELL+sx*14.5,cross_row*CELL+sy*14.5,
blossom=((cross_col+cross_row+sx+sy)%3==0),scale=.58)
for b in (tree_trunks,tree_leaves,tree_blossoms,lamp_metal,lamp_light,planters): b.finish(.045 if b in (tree_trunks,planters) else 0)
# The central hub connects to the nearby avenue modules with straight, readable approach paths.
approach=Mesh("Four plaza to boulevard connectors",walk,LANDMARKS)
for s in (-1,1):
approach.box((0,s*80,.31),(15,40,.13)); approach.box((s*80,0,.31),(40,15,.13))
approach.finish()
# Bright afternoon replaces the old night presentation; soft shadows reveal height changes.
world=bpy.data.worlds.new("Clear blue paper sky"); scene.world=world; world.use_nodes=True
world.node_tree.nodes.clear()
background=world.node_tree.nodes.new("ShaderNodeBackground")
output=world.node_tree.nodes.new("ShaderNodeOutputWorld")
world.node_tree.links.new(background.outputs["Background"],output.inputs["Surface"])
background.inputs["Color"].default_value=(.42,.72,.93,1)
background.inputs["Strength"].default_value=.65
sun_data=bpy.data.lights.new("Late morning sun","SUN"); sun_data.energy=2.1; sun_data.angle=math.radians(20)
sun=bpy.data.objects.new("Late morning sun",sun_data); SETUP.objects.link(sun); sun.rotation_euler=(math.radians(28),math.radians(-25),math.radians(-32))
area_data=bpy.data.lights.new("Broad sky fill","AREA"); area_data.energy=110000; area_data.shape="DISK"; area_data.size=420
area=bpy.data.objects.new("Broad sky fill",area_data); SETUP.objects.link(area); area.location=(-120,-230,470); area.rotation_euler=(Vector((0,0,0))-area.location).to_track_quat("-Z","Y").to_euler()
camdata=bpy.data.cameras.new("Three-quarter city overview"); cam=bpy.data.objects.new("Three-quarter city overview",camdata); SETUP.objects.link(cam)
cam.location=(610,-720,790); cam.rotation_euler=(Vector((0,0,2))-Vector(cam.location)).to_track_quat("-Z","Y").to_euler(); camdata.type="ORTHO"; camdata.ortho_scale=810; camdata.clip_end=4000; camdata.clip_start=.1; scene.camera=cam
scene.render.engine="CYCLES"; scene.cycles.samples=20; scene.cycles.use_denoising=True
scene.render.resolution_x=1800; scene.render.resolution_y=1400; scene.render.resolution_percentage=80
scene.render.image_settings.file_format="PNG"; scene.render.image_settings.color_mode="RGBA"; scene.render.film_transparent=False
scene.view_settings.view_transform="AgX"; scene.view_settings.look="AgX - Medium High Contrast"
scene.render.filepath=RENDER_OUT; scene.render.use_file_extension=True
scene["ArenaSize"]="520 x 520 studs"; scene["Seed"]=SEED
scene["RoutePlan"]="Six connected arterial lines; central square promenade loop; through-houses; four rooftop bridges; pocket-garden detours"
scene["HouseModules"]=house_count; scene["GardenCourts"]=court_count; scene["ArtDirection"]="Bright hand-drawn pastel city, ink-grid plaster, orange slate, graphite streets"
bpy.ops.wm.save_as_mainfile(filepath=BLEND_OUT)
bpy.ops.render.render(write_still=True)
result={"blend":BLEND_OUT,"render":RENDER_OUT,"seed":SEED,"arena_size":[520,520],"building_modules":house_count,"scene_objects":len(scene.objects)}
print(result)