This commit is contained in:
listik committed 2026-11-16 23:50:40 +03:00
commit 2d6a8a867d
1093 files changed
+2424571

No files matched your search

+823
View File
@@ -0,0 +1,823 @@
# Floating snow-island hub map: terrain + fenced player zones (no trees / installations yet).
# Run: blender -b --factory-startup --python build_map.py
# Units: 1 Blender unit = 1 Roblox stud (avatar ~5 studs tall).
import bpy, bmesh, math, os, random
from mathutils import Matrix, Vector, noise
OUT_DIR = r"C:\roblox\Ornament Generator RNG\map"
random.seed(11)
# ---------------------------------------------------------------- layout
ISLAND_R = 158.0 # island top radius (room for trees around the zones)
PLAZA_R = 60.0 # central plaza radius
PLAZA_INNER_R = 38.0 # inner tiled circle
ZONE_COUNT = 10
ZONE_RING_R = 112.0 # distance from centre to each zone centre (zones close to the plaza)
ZONE_A, ZONE_B, ZONE_CORNER = 21.0, 16.0, 7.0 # zone half-width (tangential), half-depth (radial), corner radius
GATE_HALF = 4.6 # half opening of the gate (between gate-post centres)
PATH_HALF = 5.0 # half width of the radial paths
POST_STEP = 6.2 # fence post spacing
POST_W, POST_H = 1.7, 6.0 # chunky square posts
RAIL_T, RAIL_H = 0.8, 1.0 # rail thickness / height
RAIL_Z = (2.0, 4.3) # rail centre heights
SNOW_RES = 0.11 # metaball polygonisation step for the fence snow (smaller = smoother)
SNOW_DECIMATE = 0.14 # keep this fraction of the snow triangles (smooth-shaded, stays soft)
def zone_frame(i):
th = math.radians(90 + i * 360.0 / ZONE_COUNT)
er = Vector((math.cos(th), math.sin(th), 0))
et = Vector((-math.sin(th), math.cos(th), 0))
return th, er, et, er * ZONE_RING_R
def zone_local(p, i):
_, er, et, c = zone_frame(i)
d = Vector((p.x, p.y, 0)) - c
return d.dot(et), d.dot(er)
def in_rounded_rect(u, v, a, b, r):
qx, qy = abs(u) - (a - r), abs(v) - (b - r)
return math.hypot(max(qx, 0), max(qy, 0)) + min(max(qx, qy), 0) - r <= 0
def flat_area(x, y, pad=4.0):
"""True where the ground must stay flat: plaza, paths and zones."""
r = math.hypot(x, y)
if r <= PLAZA_R + pad:
return True
for i in range(ZONE_COUNT):
u, v = zone_local(Vector((x, y, 0)), i)
if in_rounded_rect(u, v, ZONE_A + pad, ZONE_B + pad, ZONE_CORNER + pad):
return True
if abs(u) <= PATH_HALF + pad and -ZONE_B - pad <= v <= 0 and r <= ZONE_RING_R:
return True
th, er, et, c = zone_frame(i)
p = Vector((x, y, 0))
if abs(p.dot(et)) <= PATH_HALF + pad and 0 < p.dot(er) <= ZONE_RING_R - ZONE_B:
return True
return False
# ---------------------------------------------------------------- scene
def setup_scene():
sc = bpy.context.scene
for o in list(bpy.data.objects):
bpy.data.objects.remove(o, do_unlink=True)
for c in list(bpy.data.collections):
bpy.data.collections.remove(c)
cols = {}
for n in ("Terrain", "Fences", "Studio"):
cols[n] = bpy.data.collections.new(n)
sc.collection.children.link(cols[n])
return sc, cols
# ---------------------------------------------------------------- shaders
def new_mat(name):
m = bpy.data.materials.get(name) or bpy.data.materials.new(name)
try:
m.use_nodes = True
except Exception:
pass
m.node_tree.nodes.clear()
return m, m.node_tree.nodes, m.node_tree.links
def out(N, L, sock):
o = N.new("ShaderNodeOutputMaterial")
L.new(sock, o.inputs["Surface"])
def mat_snow():
m, N, L = new_mat("Snow")
tc = N.new("ShaderNodeTexCoord")
nz = N.new("ShaderNodeTexNoise"); nz.inputs["Scale"].default_value = 0.08; nz.inputs["Detail"].default_value = 6
L.new(tc.outputs["Object"], nz.inputs["Vector"])
ramp = N.new("ShaderNodeValToRGB")
ramp.color_ramp.elements[0].color = (0.84, 0.90, 1.0, 1) # faint cool shade in hollows
ramp.color_ramp.elements[1].color = (1.0, 1.0, 1.0, 1)
ramp.color_ramp.elements[0].position = 0.3
L.new(nz.outputs["Fac"], ramp.inputs["Fac"])
bs = N.new("ShaderNodeBsdfPrincipled")
L.new(ramp.outputs["Color"], bs.inputs["Base Color"])
bs.inputs["Roughness"].default_value = 0.55
if "Subsurface Weight" in bs.inputs:
bs.inputs["Subsurface Weight"].default_value = 0.15
bs.inputs["Subsurface Radius"].default_value = (0.4, 0.6, 1.0)
if "Coat Weight" in bs.inputs:
bs.inputs["Coat Weight"].default_value = 0.15
# fine sparkle bump
fine = N.new("ShaderNodeTexNoise"); fine.inputs["Scale"].default_value = 1.8
L.new(tc.outputs["Object"], fine.inputs["Vector"])
bump = N.new("ShaderNodeBump"); bump.inputs["Strength"].default_value = 0.25
L.new(fine.outputs["Fac"], bump.inputs["Height"])
L.new(bump.outputs["Normal"], bs.inputs["Normal"])
out(N, L, bs.outputs["BSDF"])
m.diffuse_color = (0.95, 0.97, 1, 1)
return m
def mat_snow_soft():
"""Fence snow: bright, soft subsurface look with tiny glints (like the reference snow caps)."""
m, N, L = new_mat("Snow_Soft")
tc = N.new("ShaderNodeTexCoord")
bs = N.new("ShaderNodeBsdfPrincipled")
nz = N.new("ShaderNodeTexNoise"); nz.inputs["Scale"].default_value = 1.2
L.new(tc.outputs["Object"], nz.inputs["Vector"])
ramp = N.new("ShaderNodeValToRGB")
# low-poly look: near-white flat colour, faint cool tint, no micro detail (the facets do the work)
ramp.color_ramp.elements[0].color = (0.90, 0.94, 1.0, 1)
ramp.color_ramp.elements[1].color = (1.0, 1.0, 1.0, 1)
L.new(nz.outputs["Fac"], ramp.inputs["Fac"])
L.new(ramp.outputs["Color"], bs.inputs["Base Color"])
bs.inputs["Roughness"].default_value = 0.6
if "Subsurface Weight" in bs.inputs:
bs.inputs["Subsurface Weight"].default_value = 0.08
bs.inputs["Subsurface Radius"].default_value = (0.7, 0.85, 1.0)
bs.inputs["Subsurface Scale"].default_value = 0.1
# a touch of self-light so shadowed facets stay white rather than grey-blue
bs.inputs["Emission Color"].default_value = (0.92, 0.95, 1.0, 1)
bs.inputs["Emission Strength"].default_value = 0.12
out(N, L, bs.outputs["BSDF"])
m.diffuse_color = (0.95, 0.97, 1, 1)
return m
def mat_rock():
m, N, L = new_mat("Cliff_Rock")
tc = N.new("ShaderNodeTexCoord")
wave = N.new("ShaderNodeTexWave"); wave.wave_type = "BANDS"; wave.bands_direction = "Z"
wave.inputs["Scale"].default_value = 0.035; wave.inputs["Distortion"].default_value = 6; wave.inputs["Detail"].default_value = 4
L.new(tc.outputs["Object"], wave.inputs["Vector"])
nz = N.new("ShaderNodeTexNoise"); nz.inputs["Scale"].default_value = 0.12; nz.inputs["Detail"].default_value = 8
L.new(tc.outputs["Object"], nz.inputs["Vector"])
mix = N.new("ShaderNodeMix"); mix.data_type = "FLOAT"; mix.inputs["Factor"].default_value = 0.5
L.new(wave.outputs["Fac"], mix.inputs["A"]); L.new(nz.outputs["Fac"], mix.inputs["B"])
ramp = N.new("ShaderNodeValToRGB")
ramp.color_ramp.elements[0].color = (0.10, 0.11, 0.16, 1)
ramp.color_ramp.elements[1].color = (0.42, 0.44, 0.55, 1)
L.new(mix.outputs["Result"], ramp.inputs["Fac"])
bs = N.new("ShaderNodeBsdfPrincipled")
L.new(ramp.outputs["Color"], bs.inputs["Base Color"])
bs.inputs["Roughness"].default_value = 0.85
bump = N.new("ShaderNodeBump"); bump.inputs["Strength"].default_value = 0.8
L.new(mix.outputs["Result"], bump.inputs["Height"])
L.new(bump.outputs["Normal"], bs.inputs["Normal"])
out(N, L, bs.outputs["BSDF"])
m.diffuse_color = (0.3, 0.32, 0.4, 1)
return m
def mat_tiles(name, c1, c2, mortar, scale, radial=False):
m, N, L = new_mat(name)
tc = N.new("ShaderNodeTexCoord")
vec = tc.outputs["Object"]
if radial: # polar coordinates -> rings of tiles around the plaza centre
sep = N.new("ShaderNodeSeparateXYZ"); L.new(vec, sep.inputs[0])
at = N.new("ShaderNodeMath"); at.operation = "ARCTAN2"
L.new(sep.outputs["Y"], at.inputs[0]); L.new(sep.outputs["X"], at.inputs[1])
ln = N.new("ShaderNodeVectorMath"); ln.operation = "LENGTH"; L.new(vec, ln.inputs[0])
sc_ = N.new("ShaderNodeMath"); sc_.operation = "MULTIPLY"; sc_.inputs[1].default_value = 6.0
L.new(at.outputs["Value"], sc_.inputs[0])
comb = N.new("ShaderNodeCombineXYZ")
L.new(sc_.outputs["Value"], comb.inputs["X"]); L.new(ln.outputs["Value"], comb.inputs["Y"])
vec = comb.outputs["Vector"]
br = N.new("ShaderNodeTexBrick")
br.inputs["Color1"].default_value = (*c1, 1); br.inputs["Color2"].default_value = (*c2, 1)
br.inputs["Mortar"].default_value = (*mortar, 1)
br.inputs["Scale"].default_value = scale
br.inputs["Mortar Size"].default_value = 0.025
br.inputs["Brick Width"].default_value = 0.5; br.inputs["Row Height"].default_value = 0.35
br.offset = 0.5
L.new(vec, br.inputs["Vector"])
nz = N.new("ShaderNodeTexNoise"); nz.inputs["Scale"].default_value = 0.4
L.new(tc.outputs["Object"], nz.inputs["Vector"])
snowmix = N.new("ShaderNodeMix"); snowmix.data_type = "RGBA"
pw = N.new("ShaderNodeMath"); pw.operation = "POWER"; pw.inputs[1].default_value = 6.0
L.new(nz.outputs["Fac"], pw.inputs[0])
L.new(pw.outputs["Value"], snowmix.inputs["Factor"])
L.new(br.outputs["Color"], snowmix.inputs["A"])
snowmix.inputs["B"].default_value = (0.92, 0.94, 1.0, 1) # light dusting of snow
bs = N.new("ShaderNodeBsdfPrincipled")
L.new(snowmix.outputs["Result"], bs.inputs["Base Color"])
bs.inputs["Roughness"].default_value = 0.7
bump = N.new("ShaderNodeBump"); bump.inputs["Strength"].default_value = 0.6
inv = N.new("ShaderNodeMath"); inv.operation = "SUBTRACT"; inv.inputs[0].default_value = 1.0
L.new(br.outputs["Fac"], inv.inputs[1]); L.new(inv.outputs["Value"], bump.inputs["Height"])
L.new(bump.outputs["Normal"], bs.inputs["Normal"])
out(N, L, bs.outputs["BSDF"])
m.diffuse_color = (*c1, 1)
return m
# stylised flat-colour wood (like the sample): warm tan boards with per-board tone, soft posterised
# light/dark patches along the board, sparse thin outlined grain lines, a few outlined knots.
WOOD_TOP = (0.74, 0.27, 0.09) # light orange at the top of a board
WOOD_BOTTOM = (0.36, 0.10, 0.03) # darker brown at the bottom
WOOD_LINE = (0.12, 0.025, 0.007) # thin dark grain lines / outlines
WOOD_KNOT = (0.16, 0.035, 0.01)
WOOD_HILITE = (0.90, 0.42, 0.18) # thin light edge next to grain lines
def mat_wood():
m, N, L = new_mat("Fence_Wood")
uvn = N.new("ShaderNodeUVMap"); uvn.uv_map = "UVMap"
sep = N.new("ShaderNodeSeparateXYZ"); L.new(uvn.outputs["UV"], sep.inputs[0])
def math_(op, a, b=None, val=None):
n = N.new("ShaderNodeMath"); n.operation = op
L.new(a, n.inputs[0])
if b is not None:
L.new(b, n.inputs[1])
elif val is not None:
n.inputs[1].default_value = val
return n.outputs["Value"]
def mix_col(fac, a, b):
n = N.new("ShaderNodeMix"); n.data_type = "RGBA"
L.new(fac, n.inputs["Factor"])
if isinstance(a, tuple):
n.inputs["A"].default_value = (*a, 1)
else:
L.new(a, n.inputs["A"])
if isinstance(b, tuple):
n.inputs["B"].default_value = (*b, 1)
else:
L.new(b, n.inputs["B"])
return n.outputs["Result"]
# inputs: per-face 0..1 coords, face size in studs, per-face seed
dn = N.new("ShaderNodeUVMap"); dn.uv_map = "FaceDims"
dsep = N.new("ShaderNodeSeparateXYZ"); L.new(dn.outputs["UV"], dsep.inputs[0])
sn = N.new("ShaderNodeUVMap"); sn.uv_map = "FaceSeed"
ssep = N.new("ShaderNodeSeparateXYZ"); L.new(sn.outputs["UV"], ssep.inputs[0])
U, V = sep.outputs["X"], sep.outputs["Y"]
Wd, Ln, S = dsep.outputs["X"], dsep.outputs["Y"], ssep.outputs["X"]
u_st = math_("MULTIPLY", U, Wd) # studs across the face
v_st = math_("MULTIPLY", V, Ln) # studs along the face
seed10 = math_("MULTIPLY", S, val=37.0)
# 1) one board per face: light at the top, darker toward the bottom in soft stepped bands
wob = N.new("ShaderNodeTexNoise"); wob.noise_dimensions = "2D"; wob.inputs["Scale"].default_value = 1.0
wv = N.new("ShaderNodeCombineXYZ")
L.new(math_("MULTIPLY", u_st, val=0.8), wv.inputs["X"]); L.new(math_("ADD", math_("MULTIPLY", v_st, val=0.5), seed10), wv.inputs["Y"])
L.new(wv.outputs["Vector"], wob.inputs["Vector"])
g = math_("ADD", V, math_("MULTIPLY", math_("SUBTRACT", wob.outputs["Fac"], val=0.5), val=0.18))
steps = math_("DIVIDE", math_("FLOOR", math_("MULTIPLY", g, val=7.0)), val=7.0) # posterised bands
grad = N.new("ShaderNodeValToRGB"); gcr = grad.color_ramp
gcr.elements[0].color = (*WOOD_BOTTOM, 1)
gcr.elements[1].color = (*WOOD_TOP, 1)
L.new(steps, grad.inputs["Fac"])
# slight per-face tone shift so neighbouring faces/boards differ
tone = math_("ADD", math_("MULTIPLY", S, val=0.25), val=0.88)
tn = N.new("ShaderNodeMix"); tn.data_type = "RGBA"; tn.blend_type = "MULTIPLY"; tn.inputs["Factor"].default_value = 1.0
tcomb = N.new("ShaderNodeCombineColor")
for ch in ("Red", "Green", "Blue"):
L.new(tone, tcomb.inputs[ch])
L.new(grad.outputs["Color"], tn.inputs["A"]); L.new(tcomb.outputs["Color"], tn.inputs["B"])
col = tn.outputs["Result"]
# darker strip along both long edges (bevelled-board look)
edge_d = math_("MULTIPLY", math_("MINIMUM", U, math_("SUBTRACT", math_("MULTIPLY", U, val=-1.0), val=-1.0)), Wd)
col = mix_col(math_("MULTIPLY", math_("LESS_THAN", edge_d, val=0.16), val=0.35), col, WOOD_BOTTOM)
# 2) 2-3 thin, partly-broken grain lines running along the board
gv = N.new("ShaderNodeCombineXYZ")
L.new(math_("ADD", u_st, seed10), gv.inputs["X"])
L.new(math_("MULTIPLY", v_st, val=0.07), gv.inputs["Y"])
wave = N.new("ShaderNodeTexWave"); wave.wave_type = "BANDS"; wave.bands_direction = "X"
wave.wave_profile = "SAW"
wave.inputs["Scale"].default_value = 1.4
wave.inputs["Distortion"].default_value = 1.6
wave.inputs["Detail"].default_value = 0.5
L.new(gv.outputs["Vector"], wave.inputs["Vector"])
brk = N.new("ShaderNodeTexNoise"); brk.noise_dimensions = "2D"; brk.inputs["Scale"].default_value = 1.0
bv = N.new("ShaderNodeCombineXYZ")
L.new(math_("MULTIPLY", u_st, val=2.0), bv.inputs["X"]); L.new(math_("ADD", math_("MULTIPLY", v_st, val=0.3), seed10), bv.inputs["Y"])
L.new(bv.outputs["Vector"], brk.inputs["Vector"])
keep = math_("GREATER_THAN", brk.outputs["Fac"], val=0.47)
away = math_("GREATER_THAN", edge_d, val=0.2) # no grain lines on the edge strips
line = math_("MULTIPLY", math_("MULTIPLY", math_("LESS_THAN", wave.outputs["Fac"], val=0.022), keep), away)
hi = math_("MULTIPLY", math_("MULTIPLY", math_("GREATER_THAN", wave.outputs["Fac"], val=0.022),
math_("LESS_THAN", wave.outputs["Fac"], val=0.045)), math_("MULTIPLY", keep, away))
col = mix_col(math_("MULTIPLY", hi, val=0.5), col, WOOD_HILITE)
col = mix_col(line, col, WOOD_LINE)
# 3) rare knots (outlined dark eye), only on some faces
kv = N.new("ShaderNodeCombineXYZ")
L.new(math_("MULTIPLY", u_st, val=1.2), kv.inputs["X"])
L.new(math_("ADD", math_("MULTIPLY", v_st, val=0.3), seed10), kv.inputs["Y"])
vor = N.new("ShaderNodeTexVoronoi"); vor.inputs["Scale"].default_value = 0.7
L.new(kv.outputs["Vector"], vor.inputs["Vector"])
sepc = N.new("ShaderNodeSeparateColor"); L.new(vor.outputs["Color"], sepc.inputs["Color"])
pick = math_("MULTIPLY", math_("GREATER_THAN", sepc.outputs["Red"], val=0.86), away)
d = vor.outputs["Distance"]
core = math_("MULTIPLY", math_("LESS_THAN", d, val=0.07), pick)
ring = math_("MULTIPLY", math_("MULTIPLY", math_("GREATER_THAN", d, val=0.095), math_("LESS_THAN", d, val=0.115)), pick)
col = mix_col(ring, col, WOOD_LINE)
col = mix_col(core, col, WOOD_KNOT)
# 4) thin dark outline on the long edges and the ends of every face
end_d = math_("MULTIPLY", math_("MINIMUM", V, math_("SUBTRACT", math_("MULTIPLY", V, val=-1.0), val=-1.0)), Ln)
outline = math_("MAXIMUM", math_("LESS_THAN", edge_d, val=0.045), math_("LESS_THAN", end_d, val=0.04))
col = mix_col(outline, col, WOOD_LINE)
bs = N.new("ShaderNodeBsdfPrincipled")
L.new(col, bs.inputs["Base Color"])
bs.inputs["Roughness"].default_value = 0.7
if "Specular IOR Level" in bs.inputs:
bs.inputs["Specular IOR Level"].default_value = 0.3
out(N, L, bs.outputs["BSDF"])
m.diffuse_color = (*WOOD_TOP, 1)
return m
def mat_simple(name, col, rough=0.5, emit=0.0, metal=0.0):
m, N, L = new_mat(name)
bs = N.new("ShaderNodeBsdfPrincipled")
bs.inputs["Base Color"].default_value = (*col, 1)
bs.inputs["Roughness"].default_value = rough
bs.inputs["Metallic"].default_value = metal
bs.inputs["Emission Color"].default_value = (*col, 1)
bs.inputs["Emission Strength"].default_value = emit
out(N, L, bs.outputs["BSDF"])
m.diffuse_color = (*col, 1)
return m
# ---------------------------------------------------------------- terrain
def build_island(coll, snow, rock):
SEG = 256
RINGS_TOP = 48
bm = bmesh.new()
def edge_r(a):
return ISLAND_R * (1.0 + 0.035 * noise.noise(Vector((math.cos(a) * 3, math.sin(a) * 3, 0.5)))
+ 0.015 * noise.noise(Vector((math.cos(a) * 11, math.sin(a) * 11, 2.0))))
angles = [2 * math.pi * k / SEG for k in range(SEG)]
er = [edge_r(a) for a in angles]
centre = bm.verts.new((0, 0, 0))
grid = []
for ri in range(1, RINGS_TOP + 1):
t = ri / RINGS_TOP
row = []
for k, a in enumerate(angles):
r = er[k] * t
x, y = r * math.cos(a), r * math.sin(a)
z = 0.0
if not flat_area(x, y):
z = 2.6 * max(0.0, noise.noise(Vector((x * 0.035, y * 0.035, 7.0)))) + 0.3
z *= min(1.0, (1 - t) * 6) # settle to 0 at the edge lip
if ri == RINGS_TOP:
z = 0.6 # snow lip slightly raised at the rim
row.append(bm.verts.new((x, y, z)))
grid.append(row)
for k in range(SEG):
bm.faces.new((centre, grid[0][k], grid[0][(k + 1) % SEG])).material_index = 0
for ri in range(RINGS_TOP - 1):
for k in range(SEG):
k2 = (k + 1) % SEG
bm.faces.new((grid[ri][k], grid[ri + 1][k], grid[ri + 1][k2], grid[ri][k2])).material_index = 0
# side: snow skirt with drips, then a jagged rocky cone
profile = [(1.012, -1.5, 0), (1.010, -4.0, 0), (0.995, -6.0, 1), (0.97, -14, 1), (0.93, -28, 1),
(0.86, -46, 1), (0.74, -66, 1), (0.57, -88, 1), (0.36, -110, 1), (0.16, -128, 1)]
prev = grid[-1]
for pi_, (f, z, mi) in enumerate(profile):
row = []
for k, a in enumerate(angles):
jag = 1.0
zz = z
if mi == 1:
jag += 0.06 * noise.noise(Vector((math.cos(a) * 6, math.sin(a) * 6, z * 0.05)))
jag += 0.03 * noise.noise(Vector((math.cos(a) * 25, math.sin(a) * 25, z * 0.2)))
else:
if pi_ == 1: # snow drips hanging over the cliff
zz -= 2.5 * max(0.0, noise.noise(Vector((math.cos(a) * 30, math.sin(a) * 30, 1.0))))
r = er[k] * f * jag
row.append(bm.verts.new((r * math.cos(a), r * math.sin(a), zz)))
for k in range(SEG):
k2 = (k + 1) % SEG
bm.faces.new((prev[k], row[k], row[k2], prev[k2])).material_index = mi
prev = row
tip = bm.verts.new((0, 0, -140))
for k in range(SEG):
bm.faces.new((prev[k], tip, prev[(k + 1) % SEG])).material_index = 1
bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))
me = bpy.data.meshes.new("Island")
bm.to_mesh(me); bm.free()
me.materials.append(snow); me.materials.append(rock)
for p in me.polygons:
p.use_smooth = True
ob = bpy.data.objects.new("Island", me)
coll.objects.link(ob)
return ob
def cylinder(name, coll, mat, r, z0, z1, seg=128):
bm = bmesh.new()
bmesh.ops.create_cone(bm, cap_ends=True, cap_tris=True, segments=seg, radius1=r, radius2=r, depth=z1 - z0,
matrix=Matrix.Translation((0, 0, (z0 + z1) / 2)))
me = bpy.data.meshes.new(name)
bm.to_mesh(me); bm.free()
me.materials.append(mat)
ob = bpy.data.objects.new(name, me)
bv = ob.modifiers.new("Bevel", "BEVEL"); bv.width = 0.15; bv.segments = 2; bv.limit_method = "ANGLE"
coll.objects.link(ob)
return ob
def build_plaza_and_paths(coll, tiles, tiles_inner, curb):
cylinder("Plaza_Border", coll, curb, PLAZA_R + 2.5, -0.5, 0.35)
cylinder("Plaza_Tiles", coll, tiles, PLAZA_R, -0.4, 0.45)
cylinder("Plaza_Inner_Ring", coll, curb, PLAZA_INNER_R + 1.2, -0.3, 0.5)
cylinder("Plaza_Inner_Tiles", coll, tiles_inner, PLAZA_INNER_R, -0.2, 0.55)
bm = bmesh.new()
def box(c, size, yaw, mi):
M = Matrix.Translation(c) @ Matrix.Rotation(yaw, 4, "Z") @ Matrix.Diagonal((size[0], size[1], size[2], 1))
ret = bmesh.ops.create_cube(bm, size=1.0, matrix=M)
for f in {f for v in ret["verts"] for f in v.link_faces}:
f.material_index = mi
for i in range(ZONE_COUNT):
th, er, et, c = zone_frame(i)
r0, r1 = PLAZA_R - 1.0, ZONE_RING_R - ZONE_B + 2.0
L_ = r1 - r0
mid = er * ((r0 + r1) / 2)
yaw = th
box(Vector((mid.x, mid.y, 0.15)), (L_, PATH_HALF * 2, 0.6), yaw, 0) # path tiles
for s in (-1, 1): # curbs
cp = mid + et * s * (PATH_HALF + 0.45)
box(Vector((cp.x, cp.y, 0.25)), (L_ - 3.0, 0.9, 0.8), yaw, 1)
me = bpy.data.meshes.new("Paths")
bm.to_mesh(me); bm.free()
me.materials.append(tiles); me.materials.append(curb)
ob = bpy.data.objects.new("Paths", me)
bv = ob.modifiers.new("Bevel", "BEVEL"); bv.width = 0.12; bv.segments = 2; bv.limit_method = "ANGLE"
coll.objects.link(ob)
# ---------------------------------------------------------------- fences
def zone_perimeter(a, b, r):
"""Dense CCW polyline of the rounded rectangle, from the right gate edge round to the left gate edge."""
pts = [Vector((GATE_HALF, -b))]
def arc(cx, cy, a0, a1, n=14):
for k in range(1, n + 1):
t = math.radians(a0 + (a1 - a0) * k / n)
pts.append(Vector((cx + r * math.cos(t), cy + r * math.sin(t))))
pts.append(Vector((a - r, -b)))
arc(a - r, -b + r, -90, 0)
pts.append(Vector((a, b - r)))
arc(a - r, b - r, 0, 90)
pts.append(Vector((-(a - r), b)))
arc(-(a - r), b - r, 90, 180)
pts.append(Vector((-a, -b + r)))
arc(-(a - r), -b + r, 180, 270)
pts.append(Vector((-GATE_HALF, -b)))
return pts
def resample(poly, step):
seglens = [(poly[i + 1] - poly[i]).length for i in range(len(poly) - 1)]
total = sum(seglens)
n = max(1, round(total / step))
out_, targets = [], [total * k / n for k in range(n + 1)]
acc, si = 0.0, 0
for t in targets:
while si < len(seglens) - 1 and acc + seglens[si] < t:
acc += seglens[si]; si += 1
f = 0.0 if seglens[si] == 0 else (t - acc) / seglens[si]
out_.append(poly[si].lerp(poly[si + 1], min(1.0, f)))
return out_
def uv_box(bm, uvl, center, size, yaw, mi=0, rot_y=0.0):
"""Box where EVERY FACE is its own board (like one side of a beam in the reference):
UVMap = 0..1 across (U) and along (V) the face; V runs along the box's long axis, V=1 at the top
FaceDims = (face width, face length) in studs
FaceSeed = (random seed per face, random)"""
uv, dims, seed = uvl
hs = [s / 2 for s in size]
R = Matrix.Rotation(yaw, 4, "Z") @ Matrix.Rotation(rot_y, 4, "Y")
verts = {}
for sx in (-1, 1):
for sy in (-1, 1):
for sz in (-1, 1):
verts[(sx, sy, sz)] = bm.verts.new(Vector(center) + R @ Vector((sx * hs[0], sy * hs[1], sz * hs[2])))
long_ax = max(range(3), key=lambda a: size[a])
for a in range(3):
for s in (-1, 1):
o = [k for k in range(3) if k != a]
keys = []
for cu, cv in ((-1, -1), (1, -1), (1, 1), (-1, 1)):
k = [0, 0, 0]; k[a] = s; k[o[0]] = cu; k[o[1]] = cv
keys.append(tuple(k))
f = bm.faces.new([verts[k] for k in keys])
f.material_index = mi
vax = long_ax if long_ax in o else max(o, key=lambda q: size[q])
uax = o[0] if o[1] == vax else o[1]
fs = (random.random(), random.random())
for lp, k in zip(f.loops, keys):
lp[uv].uv = ((k[uax] + 1) / 2, (k[vax] + 1) / 2)
lp[dims].uv = (size[uax], size[vax])
lp[seed].uv = fs
def finish_obj(name, bm, mats, coll, bevel, segs, angle=40):
bmesh.ops.recalc_face_normals(bm, faces=list(bm.faces))
me = bpy.data.meshes.new(name)
bm.to_mesh(me); bm.free()
for m in mats:
me.materials.append(m)
for p in me.polygons:
p.use_smooth = True
ob = bpy.data.objects.new(name, me)
bv = ob.modifiers.new("Bevel", "BEVEL")
bv.width, bv.segments, bv.limit_method = bevel, segs, "ANGLE"
bv.angle_limit = math.radians(angle)
bv.harden_normals = True
bv.use_clamp_overlap = True
coll.objects.link(ob)
return ob
def build_fence(i, coll, wood, snow, wire, bulb, bulb2):
th, er, et, c = zone_frame(i)
def W(u, v, z=0.0):
p = c + et * u + er * v
return Vector((p.x, p.y, z))
zone_name = "Zone_%02d" % (i + 1)
bw = bmesh.new() # wood
uvl = (bw.loops.layers.uv.new("UVMap"), bw.loops.layers.uv.new("FaceDims"), bw.loops.layers.uv.new("FaceSeed"))
bl = bmesh.new() # lights
# snow = metaballs: elements melt into each other -> soft, rounded caps with wavy, drooping edges
mb = bpy.data.metaballs.new(zone_name + "_SnowMB")
mb.resolution = mb.render_resolution = SNOW_RES
mb.threshold = 0.6
def melem(kind, co, radius, size=None, yaw=0.0, vertical=False, stiff=2.0):
e = mb.elements.new(type=kind)
e.co = co
e.radius = radius
e.stiffness = stiff
if size is not None:
e.size_x, e.size_y, e.size_z = size
q = Matrix.Rotation(yaw, 4, "Z").to_quaternion()
if vertical: # capsules run along local X; stand them up for drips
q = q @ Matrix.Rotation(math.radians(90), 4, "Y").to_quaternion()
e.rotation = q
return e
def drip(top_point, yaw, ln, r):
"""Hanging icicle-like drip: a vertical capsule ending in a rounder bead."""
melem("CAPSULE", top_point - Vector((0, 0, ln / 2)), r, size=(ln / 2, 1, 1), yaw=yaw, vertical=True)
melem("BALL", top_point - Vector((0, 0, ln)), r * 1.25)
def lbox(center, size, yaw, mi):
M = Matrix.Translation(center) @ Matrix.Rotation(yaw, 4, "Z") @ Matrix.Diagonal((size[0], size[1], size[2], 1))
ret = bmesh.ops.create_cube(bl, size=1.0, matrix=M)
for f in {f for v in ret["verts"] for f in v.link_faces}:
f.material_index = mi
def lbulb(center, r, mi):
M = Matrix.Translation(center) @ Matrix.Diagonal((r, r, r * 1.35, 1))
ret = bmesh.ops.create_icosphere(bl, subdivisions=2, radius=1.0, matrix=M)
for f in {f for v in ret["verts"] for f in v.link_faces}:
f.material_index = mi
def snow_cap(base, w, h, yaw):
"""Soft snow cap: rounded slab overhanging the post, a dome on top, a wavy drooping rim
made of melted beads, and a couple of drips."""
hw = w / 2
# chunky: thick overhanging slab + tall dome
melem("CUBE", base + Vector((0, 0, h + 0.45)), 0.75, size=(hw + 0.05, hw + 0.05, 0.28), yaw=yaw)
melem("ELLIPSOID", base + Vector((0, 0, h + 1.0)), 1.0, size=(hw * 0.95, hw * 0.95, 0.75), yaw=yaw)
rot = Matrix.Rotation(yaw, 4, "Z")
edge = hw + 0.45
for side in range(4):
n = rot @ Vector((math.cos(side * math.pi / 2), math.sin(side * math.pi / 2), 0))
t = Vector((-n.y, n.x, 0))
steps = 3
for s in range(steps + 1): # fat, wavy drooping rim
u = -edge + 2 * edge * s / steps
droop = random.uniform(0.0, 0.25)
melem("BALL", base + n * (edge - 0.05) + t * u + Vector((0, 0, h + 0.12 - droop)),
random.uniform(0.42, 0.55))
# flowing snow: 1-2 soft tongues sliding down the side, each ending in a long drip
for _ in range(random.choice((1, 1, 2))):
u = random.uniform(-hw * 0.8, hw * 0.8)
tl = random.uniform(0.45, 0.85) # tongue length
pt = base + n * (edge - 0.22) + t * u + Vector((0, 0, h - tl / 2 + 0.1))
melem("ELLIPSOID", pt, 1.0, size=(random.uniform(0.35, 0.5), 0.26, tl / 2 + 0.15),
yaw=yaw + side * math.pi / 2)
tip = base + n * (edge - 0.2) + t * (u + random.uniform(-0.15, 0.15)) + Vector((0, 0, h - tl + 0.15))
drip(tip, yaw, random.uniform(0.35, 1.1), random.uniform(0.17, 0.24))
for _ in range(random.choice((0, 1, 2))): # extra short drips along the rim
p = base + n * (edge - 0.1) + t * random.uniform(-hw, hw) + Vector((0, 0, h))
drip(p, yaw, random.uniform(0.3, 0.7), random.uniform(0.17, 0.23))
posts = resample(zone_perimeter(ZONE_A, ZONE_B, ZONE_CORNER), POST_STEP)
n_posts = len(posts)
GATE_W, GATE_POST_H = 2.4, 8.0
for k, p in enumerate(posts):
gate = k in (0, n_posts - 1)
prev_p, next_p = posts[max(k - 1, 0)], posts[min(k + 1, n_posts - 1)]
dl = W(next_p.x, next_p.y) - W(prev_p.x, prev_p.y)
yaw = th if gate else math.atan2(dl.y, dl.x)
base = W(p.x, p.y)
w, h = (GATE_W, GATE_POST_H) if gate else (POST_W, POST_H)
uv_box(bw, uvl, base + Vector((0, 0, h / 2)), (w, w, h), yaw)
uv_box(bw, uvl, base + Vector((0, 0, h - 0.25)), (w + 0.35, w + 0.35, 0.5), yaw) # chunky top collar
uv_box(bw, uvl, base + Vector((0, 0, 0.3)), (w + 0.3, w + 0.3, 0.6), yaw) # foot
if gate:
snow_cap(base, w + 0.35, h, yaw)
lbox(base + Vector((0, 0, h + 1.35)), (0.5, 0.5, 0.5), yaw, 0) # lantern stem
lbulb(base + Vector((0, 0, h + 2.05)), 0.62, 1) # glowing lantern
else:
snow_cap(base, w + 0.35, h, yaw)
for k in range(n_posts - 1):
a_, b_ = W(posts[k].x, posts[k].y), W(posts[k + 1].x, posts[k + 1].y)
d = b_ - a_
yaw = math.atan2(d.y, d.x)
mid = (a_ + b_) / 2
L_ = d.length - POST_W + 0.3
for z in RAIL_Z:
uv_box(bw, uvl, mid + Vector((0, 0, z)), (L_, RAIL_T, RAIL_H), yaw) # thick rails
top = RAIL_Z[1] + RAIL_H / 2
low = RAIL_Z[0] + RAIL_H / 2
tvec = d.normalized()
nvec = Vector((-tvec.y, tvec.x, 0))
# soft snow roll on the top rail: rounded slab + melted beads along both edges (wavy overhang)
# chunky roll: thick rounded slab + fat beads along both edges
melem("CUBE", mid + Vector((0, 0, top + 0.25)), 0.6, size=(L_ / 2 - 0.2, RAIL_T / 2 - 0.05, 0.16), yaw=yaw)
nb = max(3, int(L_ / 0.9))
for s_ in (-1, 1):
for bi in range(nb + 1):
u = -L_ / 2 + 0.3 + (L_ - 0.6) * bi / nb
droop = random.uniform(0.0, 0.2)
melem("BALL", mid + tvec * u + nvec * s_ * (RAIL_T / 2 + 0.12) + Vector((0, 0, top + 0.05 - droop)),
random.uniform(0.34, 0.46))
for _ in range(random.randint(2, 4)): # snow sliding over the rail edge + drips
s_ = random.choice((-1, 1))
u = random.uniform(-L_ / 2.6, L_ / 2.6)
tl = random.uniform(0.35, 0.7)
pt = mid + tvec * u + nvec * s_ * (RAIL_T / 2 + 0.1) + Vector((0, 0, top - tl / 2 + 0.1))
melem("ELLIPSOID", pt, 1.0, size=(random.uniform(0.35, 0.6), 0.22, tl / 2 + 0.12), yaw=yaw)
p = mid + tvec * (u + random.uniform(-0.2, 0.2)) + nvec * s_ * (RAIL_T / 2 + 0.12) + Vector((0, 0, top - tl + 0.1))
drip(p, yaw, random.uniform(0.3, 0.9), random.uniform(0.16, 0.22))
# lumpy snow on the lower rail
melem("CUBE", mid + Vector((0, 0, low + 0.12)), 0.42, size=(L_ / 2 - 0.5, RAIL_T / 2 - 0.12, 0.06), yaw=yaw)
for bi in range(nb):
u = -L_ / 2 + 0.6 + (L_ - 1.2) * (bi + 0.5) / nb
melem("BALL", mid + tvec * u + nvec * random.uniform(-0.15, 0.15) + Vector((0, 0, low + 0.15)),
random.uniform(0.26, 0.36))
# string lights on both faces of the fence, sagging between posts
for s_ in (-1, 1):
off = nvec * s_ * (RAIL_T / 2 + 0.55)
n = 6
prev = None
for si in range(n + 1):
t = si / n
p = a_.lerp(b_, t) + off + Vector((0, 0, POST_H - 0.75 - 0.75 * math.sin(math.pi * t)))
if prev is not None:
seg = p - prev
mid_w = (p + prev) / 2
M = (Matrix.Translation(mid_w) @ Matrix.Rotation(yaw, 4, "Z")
@ Matrix.Rotation(-math.atan2(seg.z, seg.xy.length), 4, "Y")
@ Matrix.Diagonal((seg.length, 0.09, 0.09, 1)))
bmesh.ops.create_cube(bl, size=1.0, matrix=M)
if 0 < si < n:
lbulb(p - Vector((0, 0, 0.42)), 0.24, 1 if si % 2 else 2)
prev = p
# double gate: arched plank leaves with cross rails + diagonal brace, swung open into the zone
leaf_w = GATE_HALF - GATE_W / 2 - 0.1
for side in (-1, 1):
hinge = W(side * (GATE_HALF - GATE_W / 2 - 0.05), -ZONE_B)
open_yaw = th + side * math.radians(5) # ~95 deg open
dir_ = Vector((math.cos(open_yaw), math.sin(open_yaw), 0))
n_pl = 4
pw = leaf_w / n_pl
for pk in range(n_pl):
off = pw * (pk + 0.5)
closed_u = leaf_w - off # distance from the gate centre when closed
h = 3.6 + 1.2 * math.cos(min(1.0, closed_u / GATE_HALF) * math.pi / 2)
uv_box(bw, uvl, hinge + dir_ * off + Vector((0, 0, 0.3 + h / 2)), (pw - 0.06, 0.4, h), open_yaw)
for z in (1.4, 3.3):
uv_box(bw, uvl, hinge + dir_ * (leaf_w / 2) + Vector((0, 0, z)), (leaf_w, 0.7, 0.55), open_yaw)
diag = math.atan2(1.9, leaf_w - 0.4)
uv_box(bw, uvl, hinge + dir_ * (leaf_w / 2) + Vector((0, 0, 2.35)),
(math.hypot(leaf_w - 0.4, 1.9), 0.6, 0.45), open_yaw, rot_y=diag) # Z-brace
wood_ob = finish_obj(zone_name + "_Fence", bw, [wood], coll, 0.12, 2)
# polygonise the metaball snow into a regular smooth mesh
mb_ob = bpy.data.objects.new(zone_name + "_SnowMB", mb)
coll.objects.link(mb_ob)
dg = bpy.context.evaluated_depsgraph_get()
dg.update()
sme = bpy.data.meshes.new_from_object(mb_ob.evaluated_get(dg))
bpy.data.objects.remove(mb_ob, do_unlink=True)
bpy.data.metaballs.remove(mb)
sme.name = zone_name + "_FenceSnow"
for p in sme.polygons:
p.use_smooth = True
sme.materials.clear()
sme.materials.append(snow)
snow_ob = bpy.data.objects.new(zone_name + "_FenceSnow", sme)
coll.objects.link(snow_ob)
# metaballs over-tessellate flat areas: bake a collapse-decimate into the mesh (keeps the soft shape)
dec = snow_ob.modifiers.new("Decimate", "DECIMATE")
dec.ratio = SNOW_DECIMATE
dg = bpy.context.evaluated_depsgraph_get()
dg.update()
light_me = bpy.data.meshes.new_from_object(snow_ob.evaluated_get(dg))
snow_ob.modifiers.clear()
old = snow_ob.data
snow_ob.data = light_me
light_me.name = zone_name + "_FenceSnow"
bpy.data.meshes.remove(old)
for p in light_me.polygons:
p.use_smooth = True # smooth, fluffy snow
lights_ob = finish_obj(zone_name + "_Lights", bl, [wire, bulb, bulb2], coll, 0.02, 1, angle=60)
return wood_ob, n_posts
# ---------------------------------------------------------------- studio
def setup_studio(sc, coll):
w = bpy.data.worlds.new("Sky")
try:
w.use_nodes = True
except Exception:
pass
N, L = w.node_tree.nodes, w.node_tree.links
N.clear()
tc = N.new("ShaderNodeTexCoord"); sep = N.new("ShaderNodeSeparateXYZ")
L.new(tc.outputs["Window"], sep.inputs[0])
ramp = N.new("ShaderNodeValToRGB")
ramp.color_ramp.elements[0].color = (0.32, 0.62, 1.0, 1)
ramp.color_ramp.elements[1].color = (0.10, 0.36, 0.92, 1)
L.new(sep.outputs["Y"], ramp.inputs["Fac"])
bg_cam = N.new("ShaderNodeBackground"); L.new(ramp.outputs["Color"], bg_cam.inputs["Color"])
bg_env = N.new("ShaderNodeBackground")
bg_env.inputs["Color"].default_value = (0.45, 0.62, 1.0, 1); bg_env.inputs["Strength"].default_value = 0.9
lp = N.new("ShaderNodeLightPath"); mix = N.new("ShaderNodeMixShader")
L.new(lp.outputs["Is Camera Ray"], mix.inputs["Fac"])
L.new(bg_env.outputs["Background"], mix.inputs[1]); L.new(bg_cam.outputs["Background"], mix.inputs[2])
L.new(mix.outputs["Shader"], N.new("ShaderNodeOutputWorld").inputs["Surface"])
sc.world = w
sun = bpy.data.objects.new("Sun", bpy.data.lights.new("Sun", "SUN"))
sun.data.energy = 3.2
sun.data.color = (1.0, 0.93, 0.82)
sun.data.angle = math.radians(4)
sun.rotation_euler = (math.radians(58), 0, math.radians(-40))
coll.objects.link(sun)
cam = bpy.data.objects.new("Map_Camera", bpy.data.cameras.new("Map_Camera"))
cam.data.lens = 35
cam.data.clip_end = 5000
target = Vector((0, 0, -32))
dist, el = 500.0, math.radians(36)
cam.location = target + Vector((0, -dist * math.cos(el), dist * math.sin(el)))
cam.rotation_euler = (target - cam.location).to_track_quat("-Z", "Y").to_euler()
coll.objects.link(cam)
sc.camera = cam
sc.render.engine = "BLENDER_EEVEE"
try:
sc.eevee.use_raytracing = True
except Exception:
pass
sc.render.resolution_x, sc.render.resolution_y = 1920, 1080
try:
sc.view_settings.view_transform = "AgX"
sc.view_settings.look = "AgX - Medium High Contrast"
except Exception:
pass
try:
tree = bpy.data.node_groups.new("Map_Compositor", "CompositorNodeTree")
sc.compositing_node_group = tree
rl, gl, go = tree.nodes.new("CompositorNodeRLayers"), tree.nodes.new("CompositorNodeGlare"), tree.nodes.new("NodeGroupOutput")
tree.interface.new_socket("Image", in_out="OUTPUT", socket_type="NodeSocketColor")
try:
gl.glare_type = "BLOOM"
except Exception:
if "Type" in gl.inputs:
gl.inputs["Type"].default_value = "Bloom"
for k, v in (("Threshold", 1.0), ("Strength", 0.4), ("Size", 0.4)):
if k in gl.inputs:
gl.inputs[k].default_value = v
tree.links.new(rl.outputs["Image"], gl.inputs["Image"])
tree.links.new(gl.outputs["Image"], go.inputs[0])
except Exception as ex:
print("bloom unavailable:", ex)
# ---------------------------------------------------------------- main
def main():
os.makedirs(OUT_DIR, exist_ok=True)
sc, cols = setup_scene()
snow, rock = mat_snow(), mat_rock()
snow_soft = mat_snow_soft()
tiles = mat_tiles("Path_Tiles", (0.30, 0.20, 0.13), (0.24, 0.155, 0.10), (0.11, 0.09, 0.08), 0.13)
tiles_inner = mat_tiles("Plaza_Tiles_Radial", (0.36, 0.25, 0.17), (0.29, 0.19, 0.13), (0.12, 0.10, 0.09), 0.16, radial=True)
curb = mat_simple("Stone_Curb", (0.15, 0.14, 0.16), 0.75)
wood = mat_wood()
wire = mat_simple("Light_Wire", (0.03, 0.04, 0.03), 0.6)
bulb = mat_simple("Light_Bulb", (1.0, 0.72, 0.30), 0.2, emit=14.0)
bulb2 = mat_simple("Light_Bulb_Gold", (1.0, 0.50, 0.12), 0.2, emit=12.0)
build_island(cols["Terrain"], snow, rock)
build_plaza_and_paths(cols["Terrain"], tiles, tiles_inner, curb)
posts = 0
for i in range(ZONE_COUNT):
_, n = build_fence(i, cols["Fences"], wood, snow_soft, wire, bulb, bulb2)
posts += n
setup_studio(sc, cols["Studio"])
sc.render.filepath = os.path.join(OUT_DIR, "map_preview.png")
bpy.ops.render.render(write_still=True)
# close-up of the bottom zone's gate to show fence detail and string lights
cam = sc.camera
_, er, et, c = zone_frame(7) # zone at 270 deg (front, nearest the camera)
gate = c - er * ZONE_B
tgt = Vector((gate.x, gate.y, 4.0)) + er * 6
cam.location = Vector((gate.x, gate.y, 0)) - er * 30 + et * 16 + Vector((0, 0, 13))
cam.rotation_euler = (tgt - cam.location).to_track_quat("-Z", "Y").to_euler()
sc.render.filepath = os.path.join(OUT_DIR, "map_closeup.png")
bpy.ops.render.render(write_still=True)
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT_DIR, "map_terrain.blend"))
tris = sum(sum(len(p.vertices) - 2 for p in o.data.polygons) for o in bpy.data.objects if o.type == "MESH")
return {"posts": posts, "tris_base": tris}
if __name__ == "__main__":
print("RESULT", main())
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+411
View File
@@ -0,0 +1,411 @@
# Map -> Roblox GLBs with all textures embedded (same idea as the ornament machine export).
# Run on the saved copy: blender -b map/roblox/export_source.blend --python map/roblox/export_map_glb.py
#
# * flat-colour materials -> one palette atlas (32 px cells); every face points at its material's cell
# * procedural materials (fence wood, island snow, cliff, asphalt) -> baked into their own textures (Cycles)
# - the 10 zone fences share one bake: zone 1 is baked, the other fences get the same UVs (identical meshes)
# * snow meshes are decimated (they are the bulk of the 1.3M triangles)
# * everything is merged per texture into chunks of <= MAX_TRIS triangles (Roblox limit per MeshPart)
# * export: map_glb/Map_<Group>.glb (Zones / Plaza_Decor / Ground), each < 20 MB, + manifest.json
# * the zone name signs are left out (removed from the game earlier)
import bpy, bmesh, json, math, os
from collections import Counter, defaultdict
from mathutils import Vector, Matrix
SRC_DIR = os.path.dirname(bpy.data.filepath)
OUT = os.path.join(SRC_DIR, "map_glb")
os.makedirs(OUT, exist_ok=True)
MAX_TRIS = 18000
SNOW_RATIO = 0.35 # decimation of snow meshes (plaza, pines)
ZONE_SNOW_RATIO = 0.15 # snow draped on the 10 zone fences
BULB_RATIO = 0.22 # garland bulbs (smooth spheres)
WIRE_RATIO = 0.35 # garland wire
CELL, GRID = 32, 8 # palette atlas: 8x8 cells of 32 px
EXCLUDE = {"Studio"}
GROUND = {"Terrain", "Landscape_Snowdrifts", "Asphalt_Edge_Snowdrifts", "Continuous_Curb_Snow"}
ZONES = {"Fences", "Snow_Draped_Reference", "Snow_Organic_Domes",
"Festive_Nameplate_Details", "Sign_Fence_Style_Supports", "Zone_Player_Nameplates"}
# v2: no per-object bakes any more (their UVs came out wrong in Roblox): procedural materials are baked once,
# averaged to one colour and go into the palette like the flat ones; detail comes from the Roblox material.
BAKE_SIZE = {"Island__Snow": 2048}
DEFAULT_BAKE = 1024
FENCE_MAT = "Fence_Warm_Cedar_Subtle"
def to_srgb(c):
c = max(0.0, min(1.0, c))
return 12.92 * c if c <= 0.0031308 else 1.055 * (c ** (1 / 2.4)) - 0.055
def bsdf(m):
return next((n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED"), None) if m and m.node_tree else None
def is_procedural(m):
if not m or not m.node_tree:
return False
return any(n.type.startswith("TEX_") for n in m.node_tree.nodes)
def glow_of(m):
b = bsdf(m)
name = m.name.lower() if m else ""
return ("bulb" in name or "glass" in name) or (b is not None and b.inputs["Emission Strength"].default_value >= 0.5)
def coll_of(o):
return o.users_collection[0].name if o.users_collection else ""
# ------------------------------------------------------------------ scene objects to export
visible = [o for o in bpy.data.objects if o.type in ("MESH", "CURVE") and o.visible_get() and coll_of(o) not in EXCLUDE]
def group_of(o):
c = coll_of(o)
if c in GROUND:
return "Ground"
if c in ZONES:
# two files (upload limit 20 MB): zones on the +Y half of the island and on the -Y half
cs = [o.matrix_world @ Vector(v) for v in o.bound_box]
return "Zones_North" if sum(v.y for v in cs) >= 0 else "Zones_South"
return "Plaza_Decor"
print("OBJECTS", len(visible), dict(Counter(group_of(o) for o in visible)))
work = bpy.data.collections.new("RobloxExport") # merged export meshes live here (in the same scene)
bpy.context.scene.collection.children.link(work)
dg = bpy.context.evaluated_depsgraph_get()
def world_mesh(o):
me = bpy.data.meshes.new_from_object(o.evaluated_get(dg))
me.transform(o.matrix_world)
if o.matrix_world.determinant() < 0:
me.flip_normals()
return me
# ------------------------------------------------------------------ palette for flat materials
palette, cells = {}, []
proc_color = {} # procedural material name -> averaged linear colour
def cell_uv(m):
key = m.name if m else "__none__"
if key not in palette:
b = bsdf(m)
col = list(b.inputs["Base Color"].default_value[:3]) if b else [0.8, 0.8, 0.8]
if m and m.name in proc_color:
col = proc_color[m.name]
if m and glow_of(m) and b:
ec = b.inputs["Emission Color"].default_value
if max(ec[:3]) > 0.05:
col = list(ec[:3])
palette[key] = len(cells)
cells.append(col)
if len(cells) > GRID * GRID:
raise RuntimeError("palette overflow")
i = palette[key]
return ((i % GRID) + 0.5) / GRID, ((i // GRID) + 0.5) / GRID
# ------------------------------------------------------------------ bake helpers
sc = bpy.context.scene
sc.render.engine = "CYCLES"
sc.cycles.samples = 4
sc.cycles.device = "CPU"
sc.render.bake.use_pass_direct = False
sc.render.bake.use_pass_indirect = False
sc.render.bake.use_pass_color = True
sc.render.bake.margin = 6
def bake_object_texture(name, me, mat, size):
"""me = world-space mesh using only `mat`; adds BakeUV, bakes the diffuse colour, returns the image."""
ob = bpy.data.objects.new("_bake_" + name, me)
sc.collection.objects.link(ob)
uv = me.uv_layers.new(name="BakeUV")
for l in me.uv_layers:
l.active_render = (l.name != "BakeUV") if len(me.uv_layers) > 1 else True
me.uv_layers.active = uv
bpy.ops.object.select_all(action="DESELECT")
ob.select_set(True)
bpy.context.view_layer.objects.active = ob
bpy.ops.object.mode_set(mode="EDIT")
bpy.ops.mesh.select_all(action="SELECT")
bpy.ops.uv.smart_project(angle_limit=math.radians(66), island_margin=0.003, scale_to_bounds=True)
bpy.ops.object.mode_set(mode="OBJECT")
img = bpy.data.images.new("Tex_" + name, size, size, alpha=False)
bm_ = mat.copy()
t = bm_.node_tree.nodes.new("ShaderNodeTexImage")
t.image = img
bm_.node_tree.nodes.active = t
me.materials.clear()
me.materials.append(bm_)
bpy.ops.object.bake(type="DIFFUSE", pass_filter={"COLOR"}, use_clear=True)
img.filepath_raw = os.path.join(OUT, img.name + ".png")
img.file_format = "PNG"
img.save()
sc.collection.objects.unlink(ob)
bpy.data.objects.remove(ob)
return img
# ------------------------------------------------------------------ build per-object pieces
# piece = (group, texture key, roblox material, bmesh in world space with a "UV" layer)
pieces = []
fence_bake = None # (image, uv list) from zone 1
fences = sorted([o for o in visible if any(s.material and s.material.name == FENCE_MAT for s in o.material_slots)
and coll_of(o) in ZONES], key=lambda o: o.name)
def split_faces(o, me):
"""-> {material: bmesh with only that material's faces}"""
names = [s.material for s in o.material_slots] or [None]
out = {}
used = {min(p.material_index, len(names) - 1) for p in me.polygons}
for idx in used:
m = names[idx]
bm = bmesh.new()
bm.from_mesh(me)
bmesh.ops.delete(bm, geom=[f for f in bm.faces if min(f.material_index, len(names) - 1) != idx], context="FACES")
if bm.faces:
key = m.name if m else "__none__"
if key in out:
tmp = bpy.data.meshes.new("_tmp"); bm.to_mesh(tmp); out[key][1].from_mesh(tmp); bpy.data.meshes.remove(tmp); bm.free()
else:
out[key] = (m, bm)
else:
bm.free()
return out
def decimate_bm(bm, ratio):
me = bpy.data.meshes.new("_dec")
bm.to_mesh(me)
bm.free()
ob = bpy.data.objects.new("_dec", me)
sc.collection.objects.link(ob)
mod = ob.modifiers.new("D", "DECIMATE")
mod.ratio = ratio
d2 = bpy.context.evaluated_depsgraph_get(); d2.update()
nm = bpy.data.meshes.new_from_object(ob.evaluated_get(d2))
out = bmesh.new()
out.from_mesh(nm)
sc.collection.objects.unlink(ob)
bpy.data.objects.remove(ob)
bpy.data.meshes.remove(me)
bpy.data.meshes.remove(nm)
return out
def set_uv_cell(bm, uv_xy):
for l in list(bm.loops.layers.uv):
bm.loops.layers.uv.remove(l)
uv = bm.loops.layers.uv.new("UV")
for f in bm.faces:
for lp in f.loops:
lp[uv].uv = uv_xy
def bm_from_mesh(me, keep_uv_name=None):
bm = bmesh.new()
bm.from_mesh(me)
if keep_uv_name:
keep = bm.loops.layers.uv.get(keep_uv_name)
for l in list(bm.loops.layers.uv):
if l != keep:
bm.loops.layers.uv.remove(l)
# rename to "UV"
uv = bm.loops.layers.uv.new("UV")
for f in bm.faces:
for lp in f.loops:
lp[uv].uv = lp[keep].uv
bm.loops.layers.uv.remove(keep)
return bm
def to_linear(c):
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
def mean_color(o, m):
me = world_mesh(o)
parts = split_faces(o, me)
bpy.data.meshes.remove(me)
if m.name not in parts:
return None
bm = parts.pop(m.name)[1]
for _, b2 in parts.values():
b2.free()
tmp = bpy.data.meshes.new("_mc"); bm.to_mesh(tmp); bm.free()
img = bake_object_texture("_mean_" + m.name, tmp, m, 128)
bpy.data.meshes.remove(tmp)
px = list(img.pixels)
acc, n = [0.0, 0.0, 0.0], 0
for k in range(0, len(px), 4):
if px[k] + px[k + 1] + px[k + 2] > 0.03: # skip the black background around UV islands
acc[0] += px[k]; acc[1] += px[k + 1]; acc[2] += px[k + 2]; n += 1
os.remove(img.filepath_raw)
bpy.data.images.remove(img)
return [to_linear(a / max(1, n)) for a in acc]
for o in visible:
for s in o.material_slots:
m = s.material
if m and is_procedural(m) and m.name not in proc_color:
c = mean_color(o, m)
if c:
proc_color[m.name] = c
print("MEAN", m.name, [round(to_srgb(v) * 255) for v in c])
fences = [] # fences now go through the palette path like everything else
if False:
z1 = fences[0]
me = world_mesh(z1)
img = bake_object_texture("Fence_Wood", me, bpy.data.materials[FENCE_MAT], DEFAULT_BAKE)
uvs = [d.uv.copy() for d in me.uv_layers["BakeUV"].data]
fence_bake = (img, uvs)
pieces.append((group_of(z1), img.name, "Wood", bm_from_mesh(me, "BakeUV")))
bpy.data.meshes.remove(me)
for o in fences[1:]:
me2 = world_mesh(o)
if len(me2.loops) == len(uvs):
lay = me2.uv_layers.new(name="BakeUV")
for k, d in enumerate(lay.data):
d.uv = uvs[k]
pieces.append((group_of(o), img.name, "Wood", bm_from_mesh(me2, "BakeUV")))
else:
print("WARNING fence topology differs, baking separately:", o.name)
im2 = bake_object_texture("Fence_" + o.name, me2, bpy.data.materials[FENCE_MAT], DEFAULT_BAKE)
pieces.append((group_of(o), im2.name, "Wood", bm_from_mesh(me2, "BakeUV")))
bpy.data.meshes.remove(me2)
fence_set = set(fences)
baked = Counter()
for o in visible:
if o in fence_set:
continue
grp = group_of(o)
me = world_mesh(o)
for key, (m, bm) in split_faces(o, me).items():
if False:
# bake this object's faces of the procedural material
tmp = bpy.data.meshes.new("_proc"); bm.to_mesh(tmp); bm.free()
img = bake_object_texture("%s_%s" % (o.name, m.name), tmp, m, BAKE_SIZE.get(o.name, DEFAULT_BAKE))
baked[m.name] += 1
pieces.append((grp, img.name, "Snow" if "snow" in m.name.lower() else ("Slate" if "rock" in m.name.lower() else "SmoothPlastic"),
bm_from_mesh(tmp, "BakeUV")))
bpy.data.meshes.remove(tmp)
else:
low_name = m.name.lower() if m else ""
ratio = None
if grp.startswith("Zones"): # 10 copies of everything: keep it light
if "snow" in low_name:
ratio = ZONE_SNOW_RATIO
elif "bulb" in low_name:
ratio = BULB_RATIO
elif "wire" in low_name:
ratio = WIRE_RATIO
elif "snow" in low_name and grp != "Ground":
ratio = SNOW_RATIO
if ratio:
bm = decimate_bm(bm, ratio)
set_uv_cell(bm, cell_uv(m))
low = (m.name.lower() if m else "")
rb = "Neon" if (m and glow_of(m)) else ("Snow" if "snow" in low else ("Wood" if "wood" in low or "trunk" in low
or "cedar" in low or "fence" in low or "timber" in low
else ("Slate" if "rock" in low or "cliff" in low else ("Asphalt" if "asphalt" in low
else ("Metal" if "bronze" in low or "gold" in low else "SmoothPlastic")))))
# one colour per mesh part: Roblox gets Part.Color from the cell, no texture sampling at all
pieces.append((grp, "C%02d" % palette[m.name if m else "__none__"], rb, bm))
bpy.data.meshes.remove(me)
print("BAKED", dict(baked), "PALETTE", len(cells))
# ------------------------------------------------------------------ palette image
TEX = CELL * GRID
pal = bpy.data.images.new("Tex_Palette", TEX, TEX, alpha=False)
px = [0.0] * (TEX * TEX * 4)
for i, c in enumerate(cells):
r, g, b = to_srgb(c[0]), to_srgb(c[1]), to_srgb(c[2])
cx, cy = (i % GRID) * CELL, (i // GRID) * CELL
for y in range(cy, cy + CELL):
for x in range(cx, cx + CELL):
k = (y * TEX + x) * 4
px[k:k + 4] = (r, g, b, 1.0)
pal.pixels = px
pal.filepath_raw = os.path.join(OUT, "Tex_Palette.png")
pal.file_format = "PNG"
pal.save()
# ------------------------------------------------------------------ export materials (one per texture)
mats = {}
def export_mat(tex_name, glow):
key = tex_name + ("_glow" if glow else "")
if key in mats:
return mats[key]
m = bpy.data.materials.new("M_" + key)
try:
m.use_nodes = True
except Exception:
pass
nt = m.node_tree
nt.nodes.clear()
out = nt.nodes.new("ShaderNodeOutputMaterial")
b = nt.nodes.new("ShaderNodeBsdfPrincipled")
b.inputs["Roughness"].default_value = 0.6
t = nt.nodes.new("ShaderNodeTexImage")
t.image = bpy.data.images["Tex_Palette" if tex_name.startswith("C") else tex_name]
t.interpolation = "Closest"
nt.links.new(t.outputs["Color"], b.inputs["Base Color"])
if glow:
nt.links.new(t.outputs["Color"], b.inputs["Emission Color"])
b.inputs["Emission Strength"].default_value = 1.0
nt.links.new(b.outputs["BSDF"], out.inputs["Surface"])
mats[key] = m
return m
# ------------------------------------------------------------------ merge into chunks and export
def tris(bm):
return sum(len(f.verts) - 2 for f in bm.faces)
buckets = defaultdict(list) # (group, texture, roblox material) -> [bm]
for grp, tex, rb, bm in pieces:
buckets[(grp, tex, rb)].append(bm)
manifest = []
group_objs = defaultdict(list)
for (grp, tex, rb), bms in sorted(buckets.items()):
# sort pieces around the island so chunks are spatially compact
def ang(bm):
c = sum((v.co for v in bm.verts), Vector()) / max(1, len(bm.verts))
return math.atan2(c.y, c.x)
bms.sort(key=ang)
chunk, n, k = bmesh.new(), 0, 0
def flush():
nonlocal_holder = None
out_chunks = []
for bm in bms:
t = tris(bm)
if n and n + t > MAX_TRIS:
out_chunks.append(chunk); chunk, n = bmesh.new(), 0
me = bpy.data.meshes.new("_m"); bm.to_mesh(me); chunk.from_mesh(me); bpy.data.meshes.remove(me); bm.free()
n += t
if n:
out_chunks.append(chunk)
for k, ch in enumerate(out_chunks):
bmesh.ops.triangulate(ch, faces=ch.faces[:])
if tris(ch) > MAX_TRIS: # a single huge piece: decimate the chunk
ch = decimate_bm(ch, MAX_TRIS / tris(ch) * 0.97)
name = "%s_%s_%s_%d" % (grp, rb, tex.replace("Tex_", ""), k)
name = name[:60]
me = bpy.data.meshes.new(name)
ch.to_mesh(me)
ch.free()
glow = rb == "Neon"
me.materials.append(export_mat(tex, glow))
for p in me.polygons:
p.use_smooth = rb == "Snow"
cs = [v.co for v in me.vertices]
lo = Vector((min(c.x for c in cs), min(c.y for c in cs), min(c.z for c in cs)))
hi = Vector((max(c.x for c in cs), max(c.y for c in cs), max(c.z for c in cs)))
ob = bpy.data.objects.new(name, me)
work.objects.link(ob)
group_objs[grp].append(ob)
manifest.append({"name": name, "group": grp, "material": rb, "texture": tex, "tris": len(me.polygons),
"center": [round(v, 3) for v in (lo + hi) / 2]})
# export one GLB per group (selection in the work scene)
for grp, objs in group_objs.items():
for o in bpy.context.view_layer.objects:
o.select_set(False)
for o in objs:
o.select_set(True)
path = os.path.join(OUT, "Map_%s.glb" % grp)
bpy.ops.export_scene.gltf(filepath=path, export_format="GLB", use_selection=True, export_yup=True,
export_apply=True, export_materials="EXPORT", export_image_format="AUTO")
print("GLB", grp, len(objs), "objects", round(os.path.getsize(path) / 1e6, 2), "MB",
sum(m["tris"] for m in manifest if m["group"] == grp), "tris")
json.dump({"parts": manifest, "palette": [[round(v, 4) for v in c] for c in cells]},
open(os.path.join(OUT, "manifest.json"), "w"), indent=1)
print("TOTAL", len(manifest), "meshes", sum(m["tris"] for m in manifest), "tris")
+329
View File
@@ -0,0 +1,329 @@
# Export map_reference_pines_split (saved copy: map/roblox/export_source.blend) for Roblox.
# Run: blender -b export_source.blend --python export_map_v2.py
#
# Output: map/roblox/map_v2/
# *.glb + manifest.json meshes, one material each (Roblox MeshPart = one material), <= MAX_TRIS triangles
# clone = "zones" content of player zone 1 (fence, lights, fence snow); Studio clones it for all 10 zones
# (manifest.zone_angles = Blender angle of every zone, zone 1 = 90 deg)
# Zone_Fence_Wood.png the procedural cedar wood baked into a texture (Cycles diffuse colour)
# terrain_columns.json ground (island snow, cliff, paths, plaza, drifts, curb snow) sampled for Roblox Terrain
# Left out on purpose: zone name signs (collections below), hidden objects.
import bpy, bmesh, json, math, os
from collections import Counter
from mathutils import Vector, Matrix
from mathutils.bvhtree import BVHTree
HERE = os.path.dirname(bpy.data.filepath)
OUT = os.path.join(HERE, "map_v2")
os.makedirs(OUT, exist_ok=True)
MAX_TRIS = 18000
ZONE1_ANGLE, ZONE_HALF = 90.0, 17.0
EXCLUDE = {"Festive_Nameplate_Details", "Sign_Fence_Style_Supports", "Zone_Player_Nameplates", "Studio"}
GROUND = {"Terrain", "Landscape_Snowdrifts", "Asphalt_Edge_Snowdrifts", "Continuous_Curb_Snow"}
ZONE_COLLS = {"Fences", "Snow_Draped_Reference", "Snow_Organic_Domes"}
CELL = 4.0
BAKE_SIZE = 1024
export_coll = bpy.data.collections.new("RobloxExport")
bpy.context.scene.collection.children.link(export_coll)
manifest = []
def obj_center(o):
cs = [o.matrix_world @ Vector(c) for c in o.bound_box]
return sum(cs, Vector()) / 8
def angle_of(o):
c = obj_center(o)
return math.degrees(math.atan2(c.y, c.x))
def in_zone1(o):
return abs(((angle_of(o) - ZONE1_ANGLE + 180) % 360) - 180) <= ZONE_HALF
def coll_of(o):
return o.users_collection[0].name if o.users_collection else ""
def lin_to_srgb255(c):
f = lambda v: 12.92 * v if v <= 0.0031308 else 1.055 * v ** (1 / 2.4) - 0.055
return [max(0, min(255, round(f(max(0.0, v)) * 255))) for v in c]
def bsdf(mat):
return next((n for n in mat.node_tree.nodes if n.type == "BSDF_PRINCIPLED"), None) if mat and mat.node_tree else None
def mat_props(mname):
m = bpy.data.materials.get(mname)
b = bsdf(m)
col = [0.8, 0.8, 0.8]
glow = False
metal = 0.0
if b:
col = list(b.inputs["Base Color"].default_value[:3])
metal = b.inputs["Metallic"].default_value
es = b.inputs["Emission Strength"].default_value
if es >= 0.5:
glow = True
ec = b.inputs["Emission Color"].default_value
col = list(ec[:3]) if max(ec[:3]) > 0.05 else col
low = mname.lower()
if "bulb" in low or "glass" in low:
glow = True
if "snow" in low:
rb = "Snow"
elif glow:
rb = "Neon"
elif "wood" in low or "cedar" in low or "trunk" in low:
rb = "Wood"
elif metal > 0.5 or "bronze" in low or "gold" in low:
rb = "Metal"
else:
rb = "SmoothPlastic"
return {"material": rb, "color": lin_to_srgb255(col), "glow": glow}
def evaluated_mesh(o):
dg = bpy.context.evaluated_depsgraph_get()
me = bpy.data.meshes.new_from_object(o.evaluated_get(dg))
me.transform(o.matrix_world)
return me
def faces_by_material(o, me):
names = [s.material.name if s.material else "" for s in o.material_slots] or [""]
out = Counter()
for p in me.polygons:
out[names[min(p.material_index, len(names) - 1)]] += len(p.vertices) - 2
return out, names
def finish(name, bm, info, smooth=True):
bmesh.ops.triangulate(bm, faces=bm.faces[:])
me = bpy.data.meshes.new(name)
bm.to_mesh(me)
bm.free()
ob = bpy.data.objects.new(name, me)
export_coll.objects.link(ob)
tris = len(me.polygons)
if tris > MAX_TRIS:
dec = ob.modifiers.new("Dec", "DECIMATE")
dec.ratio = MAX_TRIS / tris * 0.97
dg = bpy.context.evaluated_depsgraph_get()
dg.update()
nm = bpy.data.meshes.new_from_object(ob.evaluated_get(dg))
ob.modifiers.clear()
ob.data = nm
bpy.data.meshes.remove(me)
me = nm
cs = [v.co for v in me.vertices]
lo = Vector((min(c.x for c in cs), min(c.y for c in cs), min(c.z for c in cs)))
hi = Vector((max(c.x for c in cs), max(c.y for c in cs), max(c.z for c in cs)))
ctr = (lo + hi) / 2
me.transform(Matrix.Translation(-ctr))
for p in me.polygons:
p.use_smooth = smooth
info.update({"name": name, "center": [round(v, 4) for v in ctr], "size": [round(v, 3) for v in hi - lo],
"tris": len(me.polygons), "file": name + ".glb"})
manifest.append(info)
return ob
def export_group(prefix, objs, clone, raw_chunk=MAX_TRIS):
"""Merge objs per material (world space) into chunks of <= raw_chunk source triangles; chunks above
MAX_TRIS are decimated down to it in finish()."""
per_mat = {}
for o in objs:
me = evaluated_mesh(o)
counts, names = faces_by_material(o, me)
bpy.data.meshes.remove(me)
for mname, n in counts.items():
per_mat.setdefault(mname, []).append((o, n))
for mname, items in sorted(per_mat.items()):
if not mname:
continue
items.sort(key=lambda t: angle_of(t[0])) # spatially coherent chunks
chunks, cur, cur_n = [], [], 0
for o, n in items:
if cur and cur_n + n > raw_chunk:
chunks.append(cur); cur, cur_n = [], 0
cur.append(o); cur_n += n
if cur:
chunks.append(cur)
props = mat_props(mname)
for k, chunk in enumerate(chunks):
bm = bmesh.new()
for o in chunk:
me = evaluated_mesh(o)
tmp = bmesh.new()
tmp.from_mesh(me)
names = [s.material.name if s.material else "" for s in o.material_slots] or [""]
bmesh.ops.delete(tmp, geom=[f for f in tmp.faces if names[min(f.material_index, len(names) - 1)] != mname], context="FACES")
tmp.to_mesh(me)
tmp.free()
bm.from_mesh(me)
bpy.data.meshes.remove(me)
if not bm.faces:
bm.free(); continue
name = "%s_%s_%d" % (prefix, mname, k)
info = dict(props)
info["clone"] = clone
info["source_material"] = mname
finish(name, bm, info, smooth=(props["material"] in ("Snow",)) or "Snow" in mname)
# ------------------------------------------------------------------ classify visible objects
visible = [o for o in bpy.data.objects if o.type in ("MESH", "CURVE") and o.visible_get()]
zone_objs, global_objs, skipped = [], [], Counter()
for o in visible:
c = coll_of(o)
if c in EXCLUDE:
skipped[c] += 1
elif c in GROUND:
continue
elif c in ZONE_COLLS:
if in_zone1(o):
zone_objs.append(o)
else:
skipped["other zones"] += 1
else:
global_objs.append(o)
print("CLASSIFY zone1:", len(zone_objs), "global:", len(global_objs), "skipped:", dict(skipped))
# ------------------------------------------------------------------ zone 1: fence with baked wood
fence = next(o for o in zone_objs if o.name.startswith("Zone_01_Fence"))
wood_mat = fence.material_slots[0].material
me = evaluated_mesh(fence)
fob = bpy.data.objects.new("Zone_Fence", me)
export_coll.objects.link(fob)
bake_uv = me.uv_layers.new(name="BakeUV")
for l in me.uv_layers:
l.active_render = (l.name == "UVMap")
me.uv_layers.active = bake_uv
bpy.ops.object.select_all(action="DESELECT")
fob.select_set(True)
bpy.context.view_layer.objects.active = fob
bpy.ops.object.mode_set(mode="EDIT")
bpy.ops.mesh.select_all(action="SELECT")
bpy.ops.uv.smart_project(angle_limit=math.radians(66), island_margin=0.004, scale_to_bounds=True)
bpy.ops.object.mode_set(mode="OBJECT")
img = bpy.data.images.new("Zone_Fence_Wood", BAKE_SIZE, BAKE_SIZE, alpha=False)
bake_mat = wood_mat.copy()
tex = bake_mat.node_tree.nodes.new("ShaderNodeTexImage")
tex.image = img
bake_mat.node_tree.nodes.active = tex
me.materials.clear()
me.materials.append(bake_mat)
sc = bpy.context.scene
sc.render.engine = "CYCLES"
sc.cycles.samples = 4
sc.cycles.device = "CPU"
sc.render.bake.use_pass_direct = False
sc.render.bake.use_pass_indirect = False
sc.render.bake.use_pass_color = True
sc.render.bake.margin = 6
bpy.ops.object.bake(type="DIFFUSE", pass_filter={"COLOR"}, use_clear=True)
img.filepath_raw = os.path.join(OUT, "Zone_Fence_Wood.png")
img.file_format = "PNG"
img.save()
for l in [l for l in me.uv_layers if l.name != "BakeUV"]:
me.uv_layers.remove(l)
exp_mat = bpy.data.materials.new("Zone_Fence_Wood_Mat")
try:
exp_mat.use_nodes = True
except Exception:
pass
nt = exp_mat.node_tree
b = next(n for n in nt.nodes if n.type == "BSDF_PRINCIPLED")
t2 = nt.nodes.new("ShaderNodeTexImage")
t2.image = img
nt.links.new(t2.outputs["Color"], b.inputs["Base Color"])
me.materials.clear()
me.materials.append(exp_mat)
cs = [v.co for v in me.vertices]
lo = Vector((min(c.x for c in cs), min(c.y for c in cs), min(c.z for c in cs)))
hi = Vector((max(c.x for c in cs), max(c.y for c in cs), max(c.z for c in cs)))
ctr = (lo + hi) / 2
me.transform(Matrix.Translation(-ctr))
manifest.append({"name": "Zone_Fence", "clone": "zones", "material": "Wood", "texture": "Zone_Fence_Wood.png",
"color": [255, 255, 255], "glow": False, "center": [round(v, 4) for v in ctr],
"size": [round(v, 3) for v in hi - lo], "tris": sum(len(p.vertices) - 2 for p in me.polygons),
"file": "Zone_Fence.glb"})
if manifest[-1]["tris"] > MAX_TRIS:
print("WARNING fence tris", manifest[-1]["tris"])
sc.render.engine = "BLENDER_EEVEE"
# ------------------------------------------------------------------ zone 1: lights + snow; global parts
export_group("Zone", [o for o in zone_objs if o is not fence], "zones", raw_chunk=45000)
export_group("Map", global_objs, None)
# ------------------------------------------------------------------ export every part as its own GLB
for info in manifest:
o = bpy.data.objects[info["name"]]
bpy.ops.object.select_all(action="DESELECT")
o.select_set(True)
bpy.context.view_layer.objects.active = o
bpy.ops.export_scene.gltf(filepath=os.path.join(OUT, info["file"]), export_format="GLB",
use_selection=True, export_yup=True, export_apply=True)
zone_angles = []
for k in range(1, 11):
z = bpy.data.objects.get("Zone_%02d_Fence" % k)
if z:
zone_angles.append(round(angle_of(z), 3))
lamps = [[round(v, 3) for v in obj_center(o)] for o in visible if o.name.startswith("Warm_Lantern") or
(coll_of(o) == "Plaza_Benches_And_Lanterns" and "Glass" in o.name)]
# ------------------------------------------------------------------ terrain columns
dg = bpy.context.evaluated_depsgraph_get()
trees = []
tlo = Vector((1e9, 1e9, 1e9)); thi = -tlo
for o in visible:
if coll_of(o) not in GROUND or o.type != "MESH":
continue
ev = o.evaluated_get(dg)
tm = ev.to_mesh()
tm.transform(o.matrix_world)
verts = [v.co.copy() for v in tm.vertices]
polys = [tuple(p.vertices) for p in tm.polygons]
mats = [(o.material_slots[p.material_index].material.name
if o.material_slots and o.material_slots[p.material_index].material else "") for p in tm.polygons]
ev.to_mesh_clear()
trees.append((BVHTree.FromPolygons(verts, polys), mats, o.name))
for v in verts:
tlo = Vector(map(min, tlo, v)); thi = Vector(map(max, thi, v))
def code_for(obj, mat):
m, n = mat.lower(), obj.lower()
if "rock" in m or "cliff" in m:
return "R"
if "curb" in m and "snow" not in m:
return "C"
if "asphalt" in m:
return "P" if "plaza" in n else "A"
return "S"
x0 = (int(tlo.x // CELL) - 1) * CELL
y0 = (int(tlo.y // CELL) - 1) * CELL
nx = int((thi.x - x0) // CELL) + 2
ny = int((thi.y - y0) // CELL) + 2
top, bot, mat = [], [], []
for j in range(ny):
for i in range(nx):
x = x0 + (i + 0.5) * CELL
y = y0 + (j + 0.5) * CELL
best_t, best_c, best_b = None, ".", None
for bvh, mats, name in trees:
hit = bvh.ray_cast(Vector((x, y, thi.z + 10)), Vector((0, 0, -1)))
if hit[0] is not None and (best_t is None or hit[0].z > best_t):
best_t = hit[0].z
best_c = code_for(name, mats[hit[2]])
hb = bvh.ray_cast(Vector((x, y, tlo.z - 10)), Vector((0, 0, 1)))
if hb[0] is not None and (best_b is None or hb[0].z < best_b):
best_b = hb[0].z
top.append(round(best_t, 2) if best_t is not None else None)
bot.append(round(best_b, 2) if best_b is not None else None)
mat.append(best_c)
json.dump({"cell": CELL, "x0": x0, "y0": y0, "nx": nx, "ny": ny, "top": top, "bot": bot, "mat": "".join(mat),
"zmin": tlo.z, "zmax": thi.z}, open(os.path.join(OUT, "terrain_columns.json"), "w"))
json.dump({"zone_angles": zone_angles, "zone1_angle": ZONE1_ANGLE, "parts": manifest, "lantern_lights": lamps},
open(os.path.join(OUT, "manifest.json"), "w"), indent=1)
total = 0
for m in manifest:
mult = len(zone_angles) if m["clone"] == "zones" else 1
total += m["tris"] * mult
print("PART", m["name"], m["tris"], m["material"], m["color"], m["clone"])
print("TERRAIN", nx, ny, dict(Counter(mat)))
print("TOTAL_PARTS", len(manifest), "IN_GAME_TRIS", total, "ZONES", zone_angles, "LAMPS", len(lamps))
+202
View File
@@ -0,0 +1,202 @@
# Export the non-terrain parts of map_refined_benches.blend as Roblox-ready GLBs + a manifest.
# Run: blender -b map_refined_benches.blend --python export_meshes.py
#
# * Zone 1 (fence, lights, fence snow) is exported once; Studio clones it 10x rotated about the island centre.
# * Plaza benches / lanterns are merged per material in world space.
# * The procedural fence wood is baked (Cycles, diffuse colour) into a 1024px PNG on a fresh UV map.
# * Every mesh is re-centred on its bounding-box centre; the manifest stores that centre (Blender coords).
import bpy, bmesh, json, math, os
from mathutils import Vector, Matrix
HERE = os.path.dirname(bpy.data.filepath)
OUT = os.path.join(HERE, "roblox", "meshes")
os.makedirs(OUT, exist_ok=True)
MAX_TRIS = 18000
ZONE_ANGLE, ZONE_HALF = 90.0, 18.0 # zone 1 sector (degrees)
BAKE_SIZE = 1024
dg = bpy.context.evaluated_depsgraph_get()
export_coll = bpy.data.collections.new("RobloxExport")
bpy.context.scene.collection.children.link(export_coll)
manifest = []
def obj_center(o):
cs = [o.matrix_world @ Vector(c) for c in o.bound_box]
return sum(cs, Vector()) / 8
def in_zone1(o):
c = obj_center(o)
a = math.degrees(math.atan2(c.y, c.x))
return abs(((a - ZONE_ANGLE + 180) % 360) - 180) <= ZONE_HALF
def collect_bm(objs, keep_uv=False, mat_filter=None, drop_modifiers=()):
"""Evaluated, world-space geometry of objs joined into one bmesh (optionally only faces of one material)."""
bm = bmesh.new()
for o in objs:
saved = []
for m in o.modifiers:
if m.type in drop_modifiers and m.show_render:
m.show_viewport = False; saved.append(m)
dg2 = bpy.context.evaluated_depsgraph_get(); dg2.update()
ev = o.evaluated_get(dg2)
me = bpy.data.meshes.new_from_object(ev)
for m in saved:
m.show_viewport = True
me.transform(o.matrix_world)
if mat_filter is not None:
tmp = bmesh.new(); tmp.from_mesh(me)
names = [s.material.name if s.material else "" for s in o.material_slots] or [""]
bmesh.ops.delete(tmp, geom=[f for f in tmp.faces if names[min(f.material_index, len(names) - 1)] != mat_filter],
context="FACES")
tmp.to_mesh(me); tmp.free()
bm.from_mesh(me)
bpy.data.meshes.remove(me)
return bm
def finish(name, bm, info):
"""bmesh -> object, decimate to MAX_TRIS, re-centre, register in the manifest (export later)."""
bmesh.ops.triangulate(bm, faces=bm.faces[:])
me = bpy.data.meshes.new(name)
bm.to_mesh(me); bm.free()
ob = bpy.data.objects.new(name, me)
export_coll.objects.link(ob)
tris = len(me.polygons)
if tris > MAX_TRIS:
dec = ob.modifiers.new("Dec", "DECIMATE"); dec.ratio = MAX_TRIS / tris * 0.97
d2 = bpy.context.evaluated_depsgraph_get(); d2.update()
nm = bpy.data.meshes.new_from_object(ob.evaluated_get(d2))
ob.modifiers.clear(); ob.data = nm; bpy.data.meshes.remove(me); me = nm
cs = [v.co for v in me.vertices]
lo = Vector((min(c.x for c in cs), min(c.y for c in cs), min(c.z for c in cs)))
hi = Vector((max(c.x for c in cs), max(c.y for c in cs), max(c.z for c in cs)))
ctr = (lo + hi) / 2
me.transform(Matrix.Translation(-ctr))
for p in me.polygons:
p.use_smooth = info.pop("smooth", True)
info.update({"name": name, "center": [round(v, 4) for v in ctr], "size": [round(v, 3) for v in hi - lo],
"tris": len(me.polygons), "file": name + ".glb"})
manifest.append(info)
return ob
def base_color(mat):
if mat and mat.node_tree:
b = next((n for n in mat.node_tree.nodes if n.type == "BSDF_PRINCIPLED"), None)
if b:
c = b.inputs["Base Color"].default_value
return [round(c[0], 4), round(c[1], 4), round(c[2], 4)]
return [0.8, 0.8, 0.8]
def lin_to_srgb255(c):
f = lambda v: 12.92 * v if v <= 0.0031308 else 1.055 * v ** (1 / 2.4) - 0.055
return [max(0, min(255, round(f(v) * 255))) for v in c]
# ------------------------------------------------------------------ zone 1: fence (baked wood)
fence_src = bpy.data.objects["Zone_01_Fence"]
wood_mat = fence_src.material_slots[0].material
ob = finish("Zone_Fence", collect_bm([fence_src]), {"clone": "zones", "material": "Wood", "texture": "Zone_Fence_Wood.png",
"color": [255, 255, 255], "smooth": True})
# bake: give the mesh the original wood shader (needs its UVMap/FaceDims/FaceSeed layers) -> rebuild with UVs kept
bpy.data.objects.remove(ob, do_unlink=True); manifest.pop()
d2 = bpy.context.evaluated_depsgraph_get()
me = bpy.data.meshes.new_from_object(fence_src.evaluated_get(d2))
me.transform(fence_src.matrix_world)
fob = bpy.data.objects.new("Zone_Fence", me)
export_coll.objects.link(fob)
bake_uv = me.uv_layers.new(name="BakeUV")
for l in me.uv_layers:
l.active_render = (l.name == "UVMap")
me.uv_layers.active = bake_uv
bpy.ops.object.select_all(action="DESELECT")
fob.select_set(True); bpy.context.view_layer.objects.active = fob
bpy.ops.object.mode_set(mode="EDIT")
bpy.ops.mesh.select_all(action="SELECT")
bpy.ops.uv.smart_project(angle_limit=math.radians(66), island_margin=0.004, scale_to_bounds=True)
bpy.ops.object.mode_set(mode="OBJECT")
img = bpy.data.images.new("Zone_Fence_Wood", BAKE_SIZE, BAKE_SIZE, alpha=False)
bake_mat = wood_mat.copy()
tex = bake_mat.node_tree.nodes.new("ShaderNodeTexImage"); tex.image = img
bake_mat.node_tree.nodes.active = tex
me.materials.clear(); me.materials.append(bake_mat)
sc = bpy.context.scene
sc.render.engine = "CYCLES"
sc.cycles.samples = 4
sc.cycles.device = "CPU"
sc.render.bake.use_pass_direct = False
sc.render.bake.use_pass_indirect = False
sc.render.bake.use_pass_color = True
sc.render.bake.margin = 6
bpy.ops.object.bake(type="DIFFUSE", pass_filter={"COLOR"}, use_clear=True)
img.filepath_raw = os.path.join(OUT, "Zone_Fence_Wood.png"); img.file_format = "PNG"; img.save()
# keep only the bake UV + a plain textured material for export
for l in [l for l in me.uv_layers if l.name != "BakeUV"]:
me.uv_layers.remove(l)
exp_mat = bpy.data.materials.new("Zone_Fence_Wood_Mat")
try:
exp_mat.use_nodes = True
except Exception:
pass
nt = exp_mat.node_tree
bsdf = next(n for n in nt.nodes if n.type == "BSDF_PRINCIPLED")
t2 = nt.nodes.new("ShaderNodeTexImage"); t2.image = img
nt.links.new(t2.outputs["Color"], bsdf.inputs["Base Color"])
me.materials.clear(); me.materials.append(exp_mat)
cs = [v.co for v in me.vertices]
lo = Vector((min(c.x for c in cs), min(c.y for c in cs), min(c.z for c in cs)))
hi = Vector((max(c.x for c in cs), max(c.y for c in cs), max(c.z for c in cs)))
ctr = (lo + hi) / 2
me.transform(Matrix.Translation(-ctr))
manifest.append({"name": "Zone_Fence", "clone": "zones", "material": "Wood", "texture": "Zone_Fence_Wood.png",
"color": [255, 255, 255], "center": [round(v, 4) for v in ctr], "size": [round(v, 3) for v in hi - lo],
"tris": sum(len(p.vertices) - 2 for p in me.polygons), "file": "Zone_Fence.glb"})
# ------------------------------------------------------------------ zone 1: lights (wire + glowing bulbs), snow
lights_src = bpy.data.objects["Zone_01_Lights"]
lmats = [s.material.name for s in lights_src.material_slots if s.material]
for mname in lmats:
glow = "bulb" in mname.lower()
finish("Zone_" + mname, collect_bm([lights_src], mat_filter=mname, drop_modifiers=("BEVEL",)),
{"clone": "zones", "material": "Neon" if glow else "SmoothPlastic",
"color": lin_to_srgb255(base_color(bpy.data.materials[mname])), "glow": glow})
snow_objs = [o for o in bpy.data.objects if o.type == "MESH" and o.users_collection
and o.users_collection[0].name in ("Snow_Draped_Reference", "Snow_Organic_Domes") and in_zone1(o)]
finish("Zone_FenceSnow", collect_bm(snow_objs), {"clone": "zones", "material": "Snow", "color": [248, 251, 255],
"count_src": len(snow_objs)})
# ------------------------------------------------------------------ plaza benches + lanterns, merged per material
plaza = [o for o in bpy.data.objects if o.type in ("MESH", "CURVE") and o.users_collection
and o.users_collection[0].name in ("Plaza_Benches_And_Lanterns", "Refined_Bench_Details")]
by_mat = {}
for o in plaza:
for s in o.material_slots:
if s.material:
by_mat.setdefault(s.material.name, set()).add(o)
RB = {"Bench_Warm_Wood": "Wood", "Lantern_Dark_Bronze": "Metal", "Lantern_Warm_Glass": "Neon",
"Festive_Ribbon": "SmoothPlastic", "Snow_Full_Soft": "Snow", "Snow_Soft": "Snow"}
for mname, objs in by_mat.items():
objs = sorted(objs, key=lambda o: o.name)
halves = [objs]
probe = collect_bm(objs, mat_filter=mname); n = len(probe.faces) * 2; probe.free()
if n > MAX_TRIS:
k = math.ceil(n / MAX_TRIS)
halves = [objs[i::k] for i in range(k)]
for hi_, part in enumerate(halves):
finish("Plaza_%s_%d" % (mname, hi_), collect_bm(part, mat_filter=mname),
{"clone": None, "material": RB.get(mname, "SmoothPlastic"),
"color": lin_to_srgb255(base_color(bpy.data.materials[mname])),
"glow": RB.get(mname) == "Neon"})
# lantern light positions (for PointLights in Studio)
lamps = [[round(v, 3) for v in obj_center(o)] for o in bpy.data.objects if o.name.startswith("Warm_Lantern")]
# ------------------------------------------------------------------ export each mesh as its own GLB
for info in manifest:
o = bpy.data.objects[info["name"]]
bpy.ops.object.select_all(action="DESELECT")
o.select_set(True); bpy.context.view_layer.objects.active = o
bpy.ops.export_scene.gltf(filepath=os.path.join(OUT, info["file"]), export_format="GLB",
use_selection=True, export_yup=True, export_apply=True)
json.dump({"zone_angle_deg": ZONE_ANGLE, "zone_count": 10, "parts": manifest, "lantern_lights": lamps},
open(os.path.join(OUT, "manifest.json"), "w"), indent=1)
for m in manifest:
print("PART", m["name"], m["tris"], m["material"], m["color"], m.get("clone"))
print("LAMPS", len(lamps))
+58
View File
@@ -0,0 +1,58 @@
# Assets so the zone name signs match the fence: one baked board face of Fence_Warm_Cedar_Subtle
# (vertical + horizontal grain) and two of the fence's snow pieces (post cap, rail snow).
# Run: blender -b map_refined_benches.blend --python export_sign_assets.py
import bpy, bmesh, os
from mathutils import Vector, Matrix
OUT = os.path.join(os.path.dirname(bpy.data.filepath), "roblox", "sign")
os.makedirs(OUT, exist_ok=True)
sc = bpy.context.scene
sc.render.engine = "CYCLES"; sc.cycles.samples = 4; sc.cycles.device = "CPU"
sc.render.bake.use_pass_direct = False; sc.render.bake.use_pass_indirect = False
sc.render.bake.use_pass_color = True; sc.render.bake.margin = 4
wood = bpy.data.materials["Fence_Warm_Cedar_Subtle"]
def bake_face(name, w, h, rotate):
"""Plane whose UVMap is 0..1 (like each fence face). rotate=True turns the grain 90 degrees."""
bm = bmesh.new()
vs = [bm.verts.new(v) for v in ((0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0))]
f = bm.faces.new(vs)
uvl = bm.loops.layers.uv.new("UVMap")
bake = bm.loops.layers.uv.new("BakeUV")
for lp, (x, y) in zip(f.loops, ((0, 0), (1, 0), (1, 1), (0, 1))):
lp[uvl].uv = (y, x) if rotate else (x, y)
lp[bake].uv = (x, y)
me = bpy.data.meshes.new(name); bm.to_mesh(me); bm.free()
me.uv_layers["UVMap"].active_render = True
me.uv_layers.active = me.uv_layers["BakeUV"]
ob = bpy.data.objects.new(name, me); sc.collection.objects.link(ob)
img = bpy.data.images.new(name, w, h, alpha=False)
mat = wood.copy(); me.materials.append(mat)
tex = mat.node_tree.nodes.new("ShaderNodeTexImage"); tex.image = img; mat.node_tree.nodes.active = tex
bpy.ops.object.select_all(action="DESELECT"); ob.select_set(True); bpy.context.view_layer.objects.active = ob
bpy.ops.object.bake(type="DIFFUSE", pass_filter={"COLOR"}, use_clear=True)
img.filepath_raw = os.path.join(OUT, name + ".png"); img.file_format = "PNG"; img.save()
bake_face("SignWood_Vertical", 256, 1024, rotate=False) # grain runs along image height (posts)
bake_face("SignWood_Horizontal", 1024, 256, rotate=True) # grain runs along image width (rails)
def export_piece(src_name, out_name):
src = bpy.data.objects[src_name]
dg = bpy.context.evaluated_depsgraph_get()
me = bpy.data.meshes.new_from_object(src.evaluated_get(dg))
me.transform(src.matrix_world)
cs = [v.co for v in me.vertices]
lo = Vector((min(c.x for c in cs), min(c.y for c in cs), min(c.z for c in cs)))
hi = Vector((max(c.x for c in cs), max(c.y for c in cs), max(c.z for c in cs)))
me.transform(Matrix.Translation(-(lo + hi) / 2))
for p in me.polygons:
p.use_smooth = True
ob = bpy.data.objects.new(out_name, me); sc.collection.objects.link(ob)
bpy.ops.object.select_all(action="DESELECT"); ob.select_set(True); bpy.context.view_layer.objects.active = ob
bpy.ops.export_scene.gltf(filepath=os.path.join(OUT, out_name + ".glb"), export_format="GLB",
use_selection=True, export_yup=True)
print("PIECE", out_name, [round(v, 3) for v in (hi - lo)], len(me.polygons))
export_piece("Snow_Drape_000", "SignSnow_PostCap")
export_piece("Snow_Soft_0036", "SignSnow_Rail")
print("DONE")
Binary file not shown.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
{"lamps": [[4.6, 10.05, 73.0], [-4.6, 10.05, 73.0], [46.63, 10.05, 56.35], [39.19, 10.05, 61.76], [70.85, 10.05, 18.18], [68.01, 10.05, 26.93], [68.01, 10.05, -26.93], [70.85, 10.05, -18.18], [39.19, 10.05, -61.76], [46.63, 10.05, -56.35], [-4.6, 10.05, -73.0], [4.6, 10.05, -73.0], [-46.63, 10.05, -56.35], [-39.19, 10.05, -61.76], [-70.85, 10.05, -18.18], [-68.01, 10.05, -26.93], [-68.01, 10.05, 26.93], [-70.85, 10.05, 18.18], [-39.19, 10.05, 61.76], [-46.63, 10.05, 56.35]], "garland": [[5.66, 4.45, 73.95], [13.93, 4.08, 74.32], [21.0, 4.45, 77.25], [20.05, 4.45, 86.02], [20.05, 4.08, 94.47], [18.12, 4.45, 101.96], [9.51, 4.08, 104.05], [1.06, 4.45, 104.05], [-7.39, 4.45, 104.05], [-15.37, 4.08, 103.22], [-21.47, 4.45, 98.95], [-20.05, 4.45, 90.24], [-19.98, 4.08, 81.82], [-17.02, 4.45, 75.15], [-9.88, 4.45, 73.95], [48.04, 4.45, 56.5], [54.96, 4.08, 51.94], [62.39, 4.45, 50.15], [66.78, 4.45, 57.81], [71.75, 4.08, 64.64], [74.59, 4.45, 71.84], [68.85, 4.08, 78.59], [62.01, 4.45, 83.56], [55.18, 4.45, 88.52], [48.24, 4.08, 92.54], [40.79, 4.45, 92.67], [36.82, 4.45, 84.79], [31.93, 4.08, 77.94], [30.4, 4.45, 70.8], [35.47, 4.45, 65.64], [72.08, 4.45, 17.47], [74.99, 4.08, 9.72], [79.95, 4.45, 3.9], [88.0, 4.45, 7.51], [96.04, 4.08, 10.12], [102.57, 4.45, 14.27], [101.9, 4.08, 23.11], [99.28, 4.45, 31.15], [96.67, 4.45, 39.19], [93.42, 4.08, 46.51], [87.47, 4.45, 51.0], [79.63, 4.45, 46.96], [71.64, 4.08, 44.28], [66.21, 4.45, 39.4], [67.28, 4.45, 32.25], [68.58, 4.45, -28.23], [66.38, 4.08, -36.22], [66.98, 4.45, -43.84], [75.61, 4.45, -45.65], [83.65, 4.08, -48.26], [91.37, 4.45, -48.74], [96.02, 4.08, -41.19], [98.63, 4.45, -33.16], [101.24, 4.45, -25.12], [102.92, 4.08, -17.28], [100.74, 4.45, -10.16], [92.02, 4.45, -8.82], [83.99, 4.08, -6.28], [76.73, 4.45, -7.04], [73.38, 4.45, -13.45], [38.89, 4.45, -63.15], [32.41, 4.08, -68.32], [28.42, 4.45, -74.84], [34.34, 4.45, -81.38], [39.31, 4.08, -88.21], [45.27, 4.45, -93.14], [53.47, 4.08, -89.77], [60.3, 4.45, -84.8], [67.14, 4.45, -79.83], [73.11, 4.08, -74.48], [75.53, 4.45, -67.43], [69.26, 4.45, -61.22], [64.26, 4.08, -54.45], [57.94, 4.45, -50.79], [51.46, 4.45, -54.02], [-5.66, 4.45, -73.95], [-13.93, 4.08, -74.32], [-21.0, 4.45, -77.25], [-20.05, 4.45, -86.02], [-20.05, 4.08, -94.47], [-18.12, 4.45, -101.96], [-9.51, 4.08, -104.05], [-1.06, 4.45, -104.05], [7.39, 4.45, -104.05], [15.37, 4.08, -103.22], [21.47, 4.45, -98.95], [20.05, 4.45, -90.24], [19.98, 4.08, -81.82], [17.02, 4.45, -75.15], [9.88, 4.45, -73.95], [-48.04, 4.45, -56.5], [-54.96, 4.08, -51.94], [-62.39, 4.45, -50.15], [-66.78, 4.45, -57.81], [-71.75, 4.08, -64.64], [-74.59, 4.45, -71.84], [-68.85, 4.08, -78.59], [-62.01, 4.45, -83.56], [-55.18, 4.45, -88.52], [-48.24, 4.08, -92.54], [-40.79, 4.45, -92.67], [-36.82, 4.45, -84.79], [-31.93, 4.08, -77.94], [-30.4, 4.45, -70.8], [-35.47, 4.45, -65.64], [-72.08, 4.45, -17.47], [-74.99, 4.08, -9.72], [-79.95, 4.45, -3.9], [-88.0, 4.45, -7.51], [-96.04, 4.08, -10.12], [-102.57, 4.45, -14.27], [-101.9, 4.08, -23.11], [-99.28, 4.45, -31.15], [-96.67, 4.45, -39.19], [-93.42, 4.08, -46.51], [-87.47, 4.45, -51.0], [-79.63, 4.45, -46.96], [-71.64, 4.08, -44.28], [-66.21, 4.45, -39.4], [-67.28, 4.45, -32.25], [-68.58, 4.45, 28.23], [-66.38, 4.08, 36.22], [-66.98, 4.45, 43.84], [-75.61, 4.45, 45.65], [-83.65, 4.08, 48.26], [-91.37, 4.45, 48.74], [-96.02, 4.08, 41.19], [-98.63, 4.45, 33.16], [-101.24, 4.45, 25.12], [-102.92, 4.08, 17.28], [-100.74, 4.45, 10.16], [-92.02, 4.45, 8.82], [-83.99, 4.08, 6.28], [-76.73, 4.45, 7.04], [-73.38, 4.45, 13.45], [-38.89, 4.45, 63.15], [-32.41, 4.08, 68.32], [-28.42, 4.45, 74.84], [-34.34, 4.45, 81.38], [-39.31, 4.08, 88.21], [-45.27, 4.45, 93.14], [-53.47, 4.08, 89.77], [-60.3, 4.45, 84.8], [-67.14, 4.45, 79.83], [-73.11, 4.08, 74.48], [-75.53, 4.45, 67.43], [-69.26, 4.45, 61.22], [-64.26, 4.08, 54.45], [-57.94, 4.45, 50.79], [-51.46, 4.45, 54.02]], "signs": [[-12.8, 7.41, 68.98], [30.19, 7.41, 63.33], [61.65, 7.41, 33.49], [69.56, 7.41, -9.14], [50.9, 7.41, -48.28], [12.8, 7.41, -68.98], [-30.19, 7.41, -63.33], [-61.65, 7.41, -33.49], [-69.56, 7.41, 9.14], [-50.9, 7.41, 48.28]], "lanterns": [[26.7, 7.5, 19.4], [26.7, 7.5, -19.4], [-10.2, 7.5, -31.38], [-33.0, 7.5, -0.0], [-10.2, 7.5, 31.38]]}
+39
View File
@@ -0,0 +1,39 @@
# Turn material_table.json into per-object Roblox styles: {object name: [RobloxMaterial, r, g, b, glow]}
import json, os
HERE = os.path.dirname(os.path.abspath(__file__))
t = json.load(open(os.path.join(HERE, "material_table.json"), encoding="utf-8"))
def roblox_material(name, info):
n = name.lower()
if info.get("emit", 0) > 0.5:
return "Neon"
if "snow" in n:
return "SmoothPlastic"
if "asphalt" in n:
return "Asphalt"
if "rock" in n or "cliff" in n:
return "Rock"
if "curb" in n or "stone" in n:
return "Slate"
if "wood" in n or "cedar" in n or "trunk" in n or "timber" in n:
return "Wood"
if "bronze" in n or "gold" in n and info.get("metal", 0) > 0.3:
return "Metal"
return "SmoothPlastic"
styles = {}
multi = 0
for obj, mats in t["objects"].items():
mats = [m for m in mats if m]
if not mats:
continue
if len(mats) > 1:
multi += 1
# one Roblox part = one material: pick the one that reads best for multi-material objects
PREF = ("Pine_Facet_1", "Candy_Red", "Snow", "Asphalt_Stylized_BlueGrey", "Light_Bulb")
m = next((p for p in PREF if p in mats), mats[0])
info = t["materials"][m]
col = info.get("emit_color", info["color"]) if info.get("emit", 0) > 0.5 else info["color"]
styles[obj] = [roblox_material(m, info), col[0], col[1], col[2], 1 if info.get("emit", 0) > 0.5 else 0, m]
json.dump(styles, open(os.path.join(HERE, "part_styles.json"), "w", encoding="utf-8"), ensure_ascii=False)
print("styles", len(styles), "multi-material objects", multi)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

+861
View File
@@ -0,0 +1,861 @@
{
"parts": [
{
"name": "Ground_Snow_C02_0",
"group": "Ground",
"material": "Snow",
"texture": "C02",
"tris": 17610,
"center": [
-40.695,
-72.158,
1.032
]
},
{
"name": "Ground_Snow_C02_1",
"group": "Ground",
"material": "Snow",
"texture": "C02",
"tris": 17610,
"center": [
76.93,
-14.825,
0.811
]
},
{
"name": "Ground_Snow_C02_2",
"group": "Ground",
"material": "Snow",
"texture": "C02",
"tris": 17610,
"center": [
-11.376,
71.742,
1.182
]
},
{
"name": "Ground_Snow_C02_3",
"group": "Ground",
"material": "Snow",
"texture": "C02",
"tris": 5870,
"center": [
-82.489,
9.441,
0.922
]
},
{
"name": "Ground_Slate_C12_0",
"group": "Ground",
"material": "Slate",
"texture": "C12",
"tris": 1790,
"center": [
0.02,
-1.1,
-12.145
]
},
{
"name": "Ground_Snow_C13_0",
"group": "Ground",
"material": "Snow",
"texture": "C13",
"tris": 17460,
"center": [
-0.941,
-1.003,
-1.674
]
},
{
"name": "Ground_Asphalt_C14_0",
"group": "Ground",
"material": "Asphalt",
"texture": "C14",
"tris": 4152,
"center": [
0.0,
0.0,
0.125
]
},
{
"name": "Ground_SmoothPlastic_C15_0",
"group": "Ground",
"material": "SmoothPlastic",
"texture": "C15",
"tris": 2160,
"center": [
-0.0,
0.0,
0.25
]
},
{
"name": "Plaza_Decor_Metal_C00_0",
"group": "Plaza_Decor",
"material": "Metal",
"texture": "C00",
"tris": 15910,
"center": [
-0.197,
0.0,
4.692
]
},
{
"name": "Plaza_Decor_Wood_C01_0",
"group": "Plaza_Decor",
"material": "Wood",
"texture": "C01",
"tris": 5640,
"center": [
-2.323,
-0.0,
2.922
]
},
{
"name": "Plaza_Decor_Snow_C02_0",
"group": "Plaza_Decor",
"material": "Snow",
"texture": "C02",
"tris": 17920,
"center": [
-0.002,
0.005,
7.699
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C04_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C04",
"tris": 2700,
"center": [
2.915,
0.0,
5.19
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C06_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C06",
"tris": 5600,
"center": [
0.0,
0.0,
3.603
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C07_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C07",
"tris": 6680,
"center": [
0.0,
0.0,
3.128
]
},
{
"name": "Plaza_Decor_Metal_C10_0",
"group": "Plaza_Decor",
"material": "Metal",
"texture": "C10",
"tris": 12960,
"center": [
0.0,
0.0,
1.14
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C16_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C16",
"tris": 1510,
"center": [
0.092,
-0.044,
7.785
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C17_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C17",
"tris": 1610,
"center": [
0.092,
-0.044,
7.785
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C18_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C18",
"tris": 1580,
"center": [
0.092,
-0.044,
7.785
]
},
{
"name": "Plaza_Decor_Wood_C19_0",
"group": "Plaza_Decor",
"material": "Wood",
"texture": "C19",
"tris": 360,
"center": [
0.0,
0.0,
1.6
]
},
{
"name": "Plaza_Decor_Neon_C21_0",
"group": "Plaza_Decor",
"material": "Neon",
"texture": "C21",
"tris": 540,
"center": [
3.074,
0.0,
7.5
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C22_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C22",
"tris": 1080,
"center": [
0.0,
0.0,
0.775
]
},
{
"name": "Plaza_Decor_SmoothPlastic_C23_0",
"group": "Plaza_Decor",
"material": "SmoothPlastic",
"texture": "C23",
"tris": 1080,
"center": [
0.0,
0.0,
0.65
]
},
{
"name": "Zones_North_Snow_C02_0",
"group": "Zones_North",
"material": "Snow",
"texture": "C02",
"tris": 17968,
"center": [
80.324,
35.211,
5.996
]
},
{
"name": "Zones_North_Snow_C02_1",
"group": "Zones_North",
"material": "Snow",
"texture": "C02",
"tris": 17952,
"center": [
40.061,
75.841,
5.997
]
},
{
"name": "Zones_North_Snow_C02_2",
"group": "Zones_North",
"material": "Snow",
"texture": "C02",
"tris": 17632,
"center": [
-34.008,
79.574,
5.996
]
},
{
"name": "Zones_North_Snow_C02_3",
"group": "Zones_North",
"material": "Snow",
"texture": "C02",
"tris": 17632,
"center": [
-77.772,
41.112,
5.997
]
},
{
"name": "Zones_North_Snow_C02_4",
"group": "Zones_North",
"material": "Snow",
"texture": "C02",
"tris": 1296,
"center": [
-82.19,
5.342,
4.727
]
},
{
"name": "Zones_North_Metal_C03_0",
"group": "Zones_North",
"material": "Metal",
"texture": "C03",
"tris": 2900,
"center": [
3.955,
36.84,
7.776
]
},
{
"name": "Zones_North_SmoothPlastic_C05_0",
"group": "Zones_North",
"material": "SmoothPlastic",
"texture": "C05",
"tris": 2360,
"center": [
3.955,
36.589,
9.167
]
},
{
"name": "Zones_North_SmoothPlastic_C08_0",
"group": "Zones_North",
"material": "SmoothPlastic",
"texture": "C08",
"tris": 11880,
"center": [
3.955,
36.709,
8.043
]
},
{
"name": "Zones_North_Neon_C09_0",
"group": "Zones_North",
"material": "Neon",
"texture": "C09",
"tris": 1980,
"center": [
3.955,
36.559,
7.408
]
},
{
"name": "Zones_North_SmoothPlastic_C11_0",
"group": "Zones_North",
"material": "SmoothPlastic",
"texture": "C11",
"tris": 2160,
"center": [
3.955,
36.972,
7.392
]
},
{
"name": "Zones_North_Wood_C20_0",
"group": "Zones_North",
"material": "Wood",
"texture": "C20",
"tris": 15644,
"center": [
75.2,
27.976,
4.435
]
},
{
"name": "Zones_North_Wood_C20_1",
"group": "Zones_North",
"material": "Wood",
"texture": "C20",
"tris": 14140,
"center": [
41.331,
72.025,
4.435
]
},
{
"name": "Zones_North_Wood_C20_2",
"group": "Zones_North",
"material": "Wood",
"texture": "C20",
"tris": 14140,
"center": [
-7.264,
82.622,
4.435
]
},
{
"name": "Zones_North_Wood_C20_3",
"group": "Zones_North",
"material": "Wood",
"texture": "C20",
"tris": 14140,
"center": [
-52.519,
61.164,
4.435
]
},
{
"name": "Zones_North_Wood_C20_4",
"group": "Zones_North",
"material": "Wood",
"texture": "C20",
"tris": 12636,
"center": [
-84.462,
27.345,
4.0
]
},
{
"name": "Zones_North_Neon_C24_0",
"group": "Zones_North",
"material": "Neon",
"texture": "C24",
"tris": 10730,
"center": [
-0.011,
54.901,
7.305
]
},
{
"name": "Zones_North_Neon_C25_0",
"group": "Zones_North",
"material": "Neon",
"texture": "C25",
"tris": 7040,
"center": [
-0.001,
55.051,
4.18
]
},
{
"name": "Zones_North_SmoothPlastic_C26_0",
"group": "Zones_North",
"material": "SmoothPlastic",
"texture": "C26",
"tris": 14904,
"center": [
14.121,
54.756,
7.029
]
},
{
"name": "Zones_North_SmoothPlastic_C26_1",
"group": "Zones_North",
"material": "SmoothPlastic",
"texture": "C26",
"tris": 3726,
"center": [
-84.413,
27.323,
7.024
]
},
{
"name": "Zones_South_Snow_C02_0",
"group": "Zones_South",
"material": "Snow",
"texture": "C02",
"tris": 17968,
"center": [
-80.326,
-35.21,
5.997
]
},
{
"name": "Zones_South_Snow_C02_1",
"group": "Zones_South",
"material": "Snow",
"texture": "C02",
"tris": 17952,
"center": [
-40.055,
-75.762,
5.996
]
},
{
"name": "Zones_South_Snow_C02_2",
"group": "Zones_South",
"material": "Snow",
"texture": "C02",
"tris": 17632,
"center": [
33.998,
-79.576,
5.996
]
},
{
"name": "Zones_South_Snow_C02_3",
"group": "Zones_South",
"material": "Snow",
"texture": "C02",
"tris": 17632,
"center": [
77.778,
-41.111,
5.996
]
},
{
"name": "Zones_South_Snow_C02_4",
"group": "Zones_South",
"material": "Snow",
"texture": "C02",
"tris": 1296,
"center": [
82.249,
-5.343,
4.73
]
},
{
"name": "Zones_South_Metal_C03_0",
"group": "Zones_South",
"material": "Metal",
"texture": "C03",
"tris": 2900,
"center": [
-3.955,
-36.84,
7.776
]
},
{
"name": "Zones_South_SmoothPlastic_C05_0",
"group": "Zones_South",
"material": "SmoothPlastic",
"texture": "C05",
"tris": 2360,
"center": [
-3.955,
-36.589,
9.167
]
},
{
"name": "Zones_South_SmoothPlastic_C08_0",
"group": "Zones_South",
"material": "SmoothPlastic",
"texture": "C08",
"tris": 11880,
"center": [
-3.955,
-36.709,
8.043
]
},
{
"name": "Zones_South_Neon_C09_0",
"group": "Zones_South",
"material": "Neon",
"texture": "C09",
"tris": 1980,
"center": [
-3.955,
-36.559,
7.408
]
},
{
"name": "Zones_South_SmoothPlastic_C11_0",
"group": "Zones_South",
"material": "SmoothPlastic",
"texture": "C11",
"tris": 2160,
"center": [
-3.955,
-36.972,
7.392
]
},
{
"name": "Zones_South_Wood_C20_0",
"group": "Zones_South",
"material": "Wood",
"texture": "C20",
"tris": 15644,
"center": [
-75.2,
-27.976,
4.435
]
},
{
"name": "Zones_South_Wood_C20_1",
"group": "Zones_South",
"material": "Wood",
"texture": "C20",
"tris": 14140,
"center": [
-41.331,
-72.025,
4.435
]
},
{
"name": "Zones_South_Wood_C20_2",
"group": "Zones_South",
"material": "Wood",
"texture": "C20",
"tris": 14140,
"center": [
7.264,
-82.622,
4.435
]
},
{
"name": "Zones_South_Wood_C20_3",
"group": "Zones_South",
"material": "Wood",
"texture": "C20",
"tris": 14140,
"center": [
52.519,
-61.164,
4.435
]
},
{
"name": "Zones_South_Wood_C20_4",
"group": "Zones_South",
"material": "Wood",
"texture": "C20",
"tris": 12636,
"center": [
84.462,
-27.345,
4.0
]
},
{
"name": "Zones_South_Neon_C24_0",
"group": "Zones_South",
"material": "Neon",
"texture": "C24",
"tris": 10730,
"center": [
0.022,
-54.9,
7.305
]
},
{
"name": "Zones_South_Neon_C25_0",
"group": "Zones_South",
"material": "Neon",
"texture": "C25",
"tris": 7040,
"center": [
0.021,
-55.053,
4.18
]
},
{
"name": "Zones_South_SmoothPlastic_C26_0",
"group": "Zones_South",
"material": "SmoothPlastic",
"texture": "C26",
"tris": 14904,
"center": [
-14.121,
-54.756,
7.029
]
},
{
"name": "Zones_South_SmoothPlastic_C26_1",
"group": "Zones_South",
"material": "SmoothPlastic",
"texture": "C26",
"tris": 3726,
"center": [
84.413,
-27.323,
7.024
]
}
],
"palette": [
[
0.045,
0.034,
0.027
],
[
0.32,
0.115,
0.04
],
[
0.88,
0.94,
1.0
],
[
0.85,
0.43,
0.035
],
[
0.65,
0.018,
0.025
],
[
0.65,
0.012,
0.025
],
[
0.95,
0.97,
1.0
],
[
0.7,
0.015,
0.025
],
[
0.035,
0.19,
0.025
],
[
1.0,
0.65,
0.18
],
[
0.95,
0.54,
0.04
],
[
0.012,
0.105,
0.075
],
[
0.2535,
0.2681,
0.3462
],
[
0.8337,
0.8739,
0.9387
],
[
0.1239,
0.1603,
0.2016
],
[
0.15,
0.14,
0.16
],
[
0.11,
0.32,
0.035
],
[
0.15,
0.4,
0.05
],
[
0.2,
0.46,
0.065
],
[
0.22,
0.09,
0.035
],
[
0.2909,
0.1156,
0.0653
],
[
1.0,
0.6,
0.15
],
[
0.035,
0.22,
0.075
],
[
0.04,
0.35,
0.6
],
[
1.0,
0.72,
0.3
],
[
1.0,
0.5,
0.12
],
[
0.03,
0.04,
0.03
]
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 881 KiB

File diff suppressed because it is too large. Load diff
+66
View File
@@ -0,0 +1,66 @@
# Dump object -> materials and a representative colour per material from the open .blend.
# Run: blender -b map_reference_pines.blend --python material_table.py
import bpy, json, os, re
def srgb(c):
f = lambda v: 12.92 * v if v <= 0.0031308 else 1.055 * max(v, 0) ** (1 / 2.4) - 0.055
return [max(0, min(255, round(f(v) * 255))) for v in c[:3]]
def mat_info(m):
info = {"color": srgb(m.diffuse_color), "emit": 0.0, "metal": 0.0, "rough": 0.5, "alpha": 1.0, "src": "viewport"}
if not m.node_tree:
return info
b = next((n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED"), None)
em = next((n for n in m.node_tree.nodes if n.type == "EMISSION"), None)
if b:
bc = b.inputs["Base Color"]
if bc.is_linked:
src = bc.links[0].from_node
# walk back to a colour ramp / RGB / mix and average its colours
stack, seen = [src], set()
cols = []
while stack:
n = stack.pop()
if n.name in seen:
continue
seen.add(n.name)
if n.type == "VALTORGB":
cols += [list(e.color[:3]) for e in n.color_ramp.elements]
elif n.type == "RGB":
cols.append(list(n.outputs[0].default_value[:3]))
elif n.type in ("MIX", "MIX_RGB"):
for i in n.inputs:
if i.type == "RGBA" and not i.is_linked:
cols.append(list(i.default_value[:3]))
for i in n.inputs:
if i.is_linked:
stack.append(i.links[0].from_node)
if cols:
avg = [sum(c[k] for c in cols) / len(cols) for k in range(3)]
info["color"] = srgb(avg); info["src"] = "ramp"
else:
info["color"] = srgb(bc.default_value); info["src"] = "bsdf"
info["metal"] = round(b.inputs["Metallic"].default_value, 2)
info["rough"] = round(b.inputs["Roughness"].default_value, 2) if not b.inputs["Roughness"].is_linked else 0.5
info["alpha"] = round(b.inputs["Alpha"].default_value, 2)
es = b.inputs.get("Emission Strength")
if es is not None and (es.default_value > 0.5 or es.is_linked):
info["emit"] = round(es.default_value, 2)
ec = b.inputs["Emission Color"]
if not ec.is_linked and info["emit"] > 0.5:
info["emit_color"] = srgb(ec.default_value)
if em and em.outputs[0].is_linked:
info["emit"] = max(info["emit"], round(em.inputs["Strength"].default_value, 2))
info["emit_color"] = srgb(em.inputs["Color"].default_value)
return info
objs = {}
for o in bpy.data.objects:
if o.type in ("MESH", "CURVE", "FONT"):
objs[o.name] = [s.material.name if s.material else "" for s in o.material_slots]
mats = {m.name: mat_info(m) for m in bpy.data.materials if m.users}
out = os.path.join(os.path.dirname(bpy.data.filepath), "roblox", "material_table.json")
json.dump({"objects": objs, "materials": mats}, open(out, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
print("TABLE", len(objs), "objects", len(mats), "materials")
for k, v in sorted(mats.items()):
print("MAT", k, v)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 881 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.
+286
View File
@@ -0,0 +1,286 @@
{
"zone_angle_deg": 90.0,
"zone_count": 10,
"parts": [
{
"name": "Zone_Fence",
"clone": "zones",
"material": "Wood",
"texture": "Zone_Fence_Wood.png",
"color": [
255,
255,
255
],
"center": [
0.0,
88.8832,
4.0
],
"size": [
44.367,
34.516,
8.0
],
"tris": 12636,
"file": "Zone_Fence.glb"
},
{
"clone": "zones",
"material": "SmoothPlastic",
"color": [
48,
56,
48
],
"glow": false,
"name": "Zone_Light_Wire",
"center": [
0.0,
89.0,
7.0276
],
"size": [
43.99,
33.99,
5.145
],
"tris": 2904,
"file": "Zone_Light_Wire.glb"
},
{
"clone": "zones",
"material": "Neon",
"color": [
255,
221,
149
],
"glow": true,
"name": "Zone_Light_Bulb",
"center": [
0.0,
89.0,
7.3215
],
"size": [
44.357,
34.38,
7.131
],
"tris": 9760,
"file": "Zone_Light_Bulb.glb"
},
{
"clone": "zones",
"material": "Neon",
"color": [
255,
188,
97
],
"glow": true,
"name": "Zone_Light_Bulb_Gold",
"center": [
0.0,
89.0,
4.1805
],
"size": [
44.357,
34.38,
0.648
],
"tris": 6400,
"file": "Zone_Light_Bulb_Gold.glb"
},
{
"clone": "zones",
"material": "Snow",
"color": [
248,
251,
255
],
"count_src": 61,
"name": "Zone_FenceSnow",
"center": [
-0.0068,
88.9149,
5.7295
],
"size": [
44.945,
34.874,
6.619
],
"tris": 17460,
"file": "Zone_FenceSnow.glb"
},
{
"clone": null,
"material": "Metal",
"color": [
60,
52,
46
],
"glow": false,
"name": "Plaza_Lantern_Dark_Bronze_0",
"center": [
-0.3467,
-0.6184,
4.6921
],
"size": [
67.993,
65.814,
8.456
],
"tris": 10122,
"file": "Plaza_Lantern_Dark_Bronze_0.glb"
},
{
"clone": null,
"material": "Metal",
"color": [
60,
52,
46
],
"glow": false,
"name": "Plaza_Lantern_Dark_Bronze_1",
"center": [
-0.1967,
0.1392,
4.6921
],
"size": [
68.293,
66.772,
8.456
],
"tris": 10108,
"file": "Plaza_Lantern_Dark_Bronze_1.glb"
},
{
"clone": null,
"material": "Wood",
"color": [
153,
95,
56
],
"glow": false,
"name": "Plaza_Bench_Warm_Wood_0",
"center": [
-2.3225,
-0.0,
2.9224
],
"size": [
63.997,
67.28,
1.925
],
"tris": 8340,
"file": "Plaza_Bench_Warm_Wood_0.glb"
},
{
"clone": null,
"material": "Snow",
"color": [
241,
248,
255
],
"glow": false,
"name": "Plaza_Snow_Full_Soft_0",
"center": [
-2.449,
-0.0012,
3.93
],
"size": [
64.166,
67.129,
0.48
],
"tris": 4940,
"file": "Plaza_Snow_Full_Soft_0.glb"
},
{
"clone": null,
"material": "SmoothPlastic",
"color": [
211,
36,
44
],
"glow": false,
"name": "Plaza_Festive_Ribbon_0",
"center": [
2.9151,
0.0,
5.1904
],
"size": [
59.95,
63.025,
1.145
],
"tris": 2700,
"file": "Plaza_Festive_Ribbon_0.glb"
},
{
"clone": null,
"material": "Neon",
"color": [
255,
203,
108
],
"glow": true,
"name": "Plaza_Lantern_Warm_Glass_0",
"center": [
3.0742,
0.0,
7.5
],
"size": [
60.752,
63.867,
1.2
],
"tris": 540,
"file": "Plaza_Lantern_Warm_Glass_0.glb"
}
],
"lantern_lights": [
[
-26.698,
19.397,
7.5
],
[
-26.698,
-19.397,
7.5
],
[
10.198,
-31.385,
7.5
],
[
33.0,
-0.0,
7.5
],
[
10.198,
31.385,
7.5
]
]
}
+1
View File
@@ -0,0 +1 @@
{"Armrest": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.001": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.002": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.003": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.004": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.005": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.006": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.007": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.008": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Armrest.009": ["Metal", 60, 52, 46, 0, "Lantern_Dark_Bronze"], "Asphalt_Snowbank": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.001": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.002": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.003": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.004": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.005": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.006": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.007": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.008": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.009": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.010": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.011": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.012": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.013": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.014": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.015": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.016": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.017": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.018": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.019": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.020": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.021": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.022": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.023": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.024": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.025": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.026": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.027": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.028": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.029": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.030": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.031": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.032": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.033": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.034": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.035": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.036": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.037": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.038": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.039": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.040": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.041": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.042": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.043": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.044": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.045": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.046": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.047": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.048": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.049": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.050": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.051": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.052": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.053": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.054": ["SmoothPlastic", 241, 248, 255, 0, "Snow_Full_Soft"], "Asphalt_Snowbank.055Line truncated
+68
View File
@@ -0,0 +1,68 @@
# Sample the island ground of map_refined_benches.blend into a column grid for Roblox Terrain.
# Run: blender -b map_refined_benches.blend --python sample_terrain.py
# Output: terrain_columns.json (Blender units == studs; Blender Z-up -> Roblox Y-up handled in Luau)
import bpy, json, os
from mathutils import Vector
from mathutils.bvhtree import BVHTree
OUT = os.path.join(os.path.dirname(bpy.data.filepath), "roblox", "terrain_columns.json")
CELL = 4.0
GROUND_COLLS = {"Terrain", "Landscape_Snowdrifts", "Asphalt_Edge_Snowdrifts", "Continuous_Curb_Snow"}
dg = bpy.context.evaluated_depsgraph_get()
trees = [] # (bvh, per-face material name list, object name)
lo = Vector((1e9, 1e9, 1e9)); hi = -lo
for o in bpy.data.objects:
if o.type != "MESH" or not ({c.name for c in o.users_collection} & GROUND_COLLS):
continue
ev = o.evaluated_get(dg)
me = ev.to_mesh()
me.transform(o.matrix_world)
verts = [v.co.copy() for v in me.vertices]
polys = [tuple(p.vertices) for p in me.polygons]
mats = [(o.material_slots[p.material_index].material.name
if o.material_slots and o.material_slots[p.material_index].material else "") for p in me.polygons]
ev.to_mesh_clear()
trees.append((BVHTree.FromPolygons(verts, polys), mats, o.name))
for v in verts:
lo = Vector(map(min, lo, v)); hi = Vector(map(max, hi, v))
def code_for(obj, mat):
m = mat.lower(); n = obj.lower()
if "rock" in m or "cliff" in m:
return "R"
if "curb" in m or "curb" in n and "snow" not in m:
return "C"
if "asphalt" in m:
return "A"
if "tile" in m or "path" in m or "plaza" in n:
return "P"
return "S" # snow (ground, drifts)
x0 = (int(lo.x // CELL) - 1) * CELL
y0 = (int(lo.y // CELL) - 1) * CELL
nx = int((hi.x - x0) // CELL) + 2
ny = int((hi.y - y0) // CELL) + 2
top, bot, mat = [], [], []
for j in range(ny):
for i in range(nx):
x = x0 + (i + 0.5) * CELL
y = y0 + (j + 0.5) * CELL
best_t, best_c = None, "."
best_b = None
for bvh, mats, name in trees:
hit = bvh.ray_cast(Vector((x, y, hi.z + 10)), Vector((0, 0, -1)))
if hit[0] is not None and (best_t is None or hit[0].z > best_t):
best_t = hit[0].z
best_c = code_for(name, mats[hit[2]])
hb = bvh.ray_cast(Vector((x, y, lo.z - 10)), Vector((0, 0, 1)))
if hb[0] is not None and (best_b is None or hb[0].z < best_b):
best_b = hb[0].z
top.append(round(best_t, 2) if best_t is not None else None)
bot.append(round(best_b, 2) if best_b is not None else None)
mat.append(best_c)
os.makedirs(os.path.dirname(OUT), exist_ok=True)
json.dump({"cell": CELL, "x0": x0, "y0": y0, "nx": nx, "ny": ny, "top": top, "bot": bot, "mat": "".join(mat),
"zmin": lo.z, "zmax": hi.z}, open(OUT, "w"))
from collections import Counter
print("SAMPLED", nx, ny, dict(Counter(mat)), round(lo.z, 1), round(hi.z, 1))
Binary file not shown.
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

+51
View File
@@ -0,0 +1,51 @@
# Split every object that uses several materials into one object per material, so Roblox (one
# material per MeshPart) keeps candy stripes, pine facet shades, wire vs bulbs, snow vs cliff.
# Saves a NEW file next to the source and exports FBX + GLB for Roblox.
# Run: blender -b map_reference_pines.blend --python split_by_material.py
import bpy, os
src = bpy.data.filepath
base = os.path.splitext(src)[0] + "_split"
def material_names(o):
return [s.material.name for s in o.material_slots if s.material]
targets = [o for o in bpy.data.objects if o.type == "MESH" and len(set(material_names(o))) > 1]
made = 0
for o in targets:
orig_name = o.name
before = set(bpy.data.objects)
bpy.ops.object.mode_set(mode="OBJECT") if bpy.context.object and bpy.context.object.mode != "OBJECT" else None
bpy.ops.object.select_all(action="DESELECT")
o.select_set(True)
bpy.context.view_layer.objects.active = o
bpy.ops.object.mode_set(mode="EDIT")
bpy.ops.mesh.select_all(action="SELECT")
bpy.ops.mesh.separate(type="MATERIAL")
bpy.ops.object.mode_set(mode="OBJECT")
pieces = [o] + [x for x in set(bpy.data.objects) - before]
for p in pieces:
# each piece now only has faces of one material; drop unused slots and name it after that material
used = {f.material_index for f in p.data.polygons}
mats = [p.material_slots[i].material for i in sorted(used) if i < len(p.material_slots)]
mname = mats[0].name if mats else "None"
p.data.materials.clear()
for f in p.data.polygons:
f.material_index = 0
if mats:
p.data.materials.append(mats[0])
p.name = "%s__%s" % (orig_name, mname)
made += 1
bpy.ops.wm.save_as_mainfile(filepath=base + ".blend", copy=True)
bpy.ops.object.select_all(action="DESELECT")
export_objs = [o for o in bpy.data.objects if o.type in ("MESH", "CURVE", "FONT") and o.visible_get()]
for o in export_objs:
o.select_set(True)
bpy.ops.export_scene.fbx(filepath=base + ".fbx", use_selection=True, object_types={"MESH", "OTHER"},
apply_unit_scale=True, apply_scale_options="FBX_SCALE_ALL", use_mesh_modifiers=True,
mesh_smooth_type="FACE", path_mode="AUTO")
bpy.ops.export_scene.gltf(filepath=base + ".glb", export_format="GLB", use_selection=True,
export_yup=True, export_apply=True)
print("SPLIT objects:", len(targets), "-> pieces:", made, "| exported", len(export_objs), "objects")
print("FILES", base + ".blend", base + ".fbx", base + ".glb")
+1
View File
@@ -0,0 +1 @@
{"cell": 4.0, "x0": -144.0, "y0": -144.0, "nx": 72, "ny": 72, "top": [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, -1.49, -1.42, -1.0, -0.05, 0.28, 0.11, 0.51, 0.6, -0.28, -1.42, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.56, 0.56, 0.56, 0.5, 0.28, 0.09, 0.08, 0.04, 0.05, 0.05, 0.05, 0.05, 0.05, 0.04, 0.11, 0.22, 0.47, -1.25, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.24, 0.27, 0.17, 0.17, 0.11, 0.07, 0.08, 0.09, 0.09, 0.09, 0.1, 0.11, 0.11, 0.11, 0.11, 0.1, 0.09, 0.08, 0.06, 0.16, 0.39, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.59, 0.29, 0.12, 0.22, 0.27, 0.23, 0.13, 0.12, 0.13, 0.14, 0.15, 0.15, 0.16, 0.22, 0.67, 1.0, 0.16, 0.15, 0.14, 0.13, 0.11, 0.08, 0.05, 0.13, 0.3, 0.53, -0.99, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.17, 0.24, 0.05, 0.09, 0.16, 0.24, 0.25, 0.22, 0.18, 0.17, 0.18, 0.2, 0.2, 0.33, 0.4, 0.41, 1.05, 1.43, 0.69, 0.32, 0.32, 0.22, 0.16, 0.13, 0.1, 0.09, 0.11, 0.21, 0.25, 0.5, -0.4, -5.41, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, -1.48, 0.41, 0.38, 0.16, 0.07, 0.08, 0.1, 0.17, 0.25, 0.29, 0.27, 0.23, 0.23, 0.23, 0.24, 0.32, 0.61, 0.93, 1.11, 1.1, 0.98, 0.86, 0.74, 0.72, 0.76, 0.54, 0.21, 0.17, 0.15, 0.14, 0.13, 0.31, 0.41, 0.37, 0.21, 0.5, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, -0.88, 0.49, 0.25, 0.24, 0.28, 0.24, 0.18, 0.17, 0.25, 0.39, 0.49, 0.5, 0.41, 0.29, 0.29, 0.1, 0.05, 0.17, 0.7, 0.83, 0.49, 0.4, 0.36, 0.17, 0.76, 0.96, 1.02, 0.74, 0.31, 0.22, 0.21, 0.2, 0.18, 0.33, 0.52, 0.55, 0.4, 0.19, 0.35, -1.29, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.54, 0.22, 0.32, 0.48, 0.55, 0.52, 0.82, 0.33, 0.34, 0.51, 0.73, 0.84, 0.82, 0.65, 0.39, 0.26, 0.0, 0.0, -0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.82, 0.83, 0.68, 0.62, 0.28, 0.26, 0.25, 0.23, 0.29, 0.5, 0.56, 0.45, 0.28, 0.14, 0.3, -0.58, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.38, 0.11, 0.24, 0.44, 0.65, 1.1, 2.19, 1.37, 0.4, 0.46, 0.76, 1.07, 1.21, 1.04, 0.76, 0.5, 0.13, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.14, 0.51, 0.46, 1.07, 0.3, 0.3, 0.3, 0.28, 0.29, 0.42, 0.43, 0.36, 0.25, 0.16, 0.13, 0.14, 0.27, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, 0.54, 0.05, 0.09, 0.16, 0.35, 0.58, 0.67, 1.15, 0.4, 0.26, 0.42, 0.84, 1.12, 1.16, 1.01, 0.71, 0.45, 0.25, 0.0, 0.0, 0.0, -0.0, 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, 0.2, 0.32, 0.32, 0.3, 0.3, 0.3, 0.22, 0.13, 0.26, 0.38, 0.32, 0.25, 0.2, 0.15, 0.21, 0.24, 0.21, -0.64, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, -0.13, 0.06, 0.08, 0.13, 0.17, 0.25, 0.43, 0.48, 0.36, -0.0, 0.0, 0.0, 0.08, 0.77, 0.87, 0.74, 0.47, 0.31, 0.12, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,Line truncated
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB