Update
This commit is contained in:
commit
2d6a8a867d
1093 files changed
+2424571
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import bpy,math,os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_sign_supports.blend'),copy=True)
|
||||
roots=[o for o in sc.objects if o.type=='EMPTY' and o.name.startswith('Zone_') and o.name.endswith('_Nameplate')]
|
||||
wood=bpy.data.materials.get('Fence_Warm_Cedar_Subtle');snow=bpy.data.materials.get('Snow_Full_Soft')
|
||||
coll=bpy.data.collections.new('Sign_Fence_Style_Supports');sc.collection.children.link(coll)
|
||||
template=next(o for o in sc.objects if o.name.startswith('Snow_Drape_') and not o.hide_render and o.location.z>6)
|
||||
def box(name,x,z,size,parent):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=(x,0,z));o=bpy.context.object;o.name=name;o.dimensions=size
|
||||
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.parent=parent;o.data.materials.append(wood)
|
||||
b=o.modifiers.new('Fence edge bevel','BEVEL');b.width=.09;b.segments=3
|
||||
return o
|
||||
for root in roots:
|
||||
a=root.rotation_euler.z;root.location+=Vector((math.cos(a)*3.8,math.sin(a)*3.8,0))
|
||||
for o in list(root.children):
|
||||
if o.name.startswith(('Sign_Post','Post_Snow')):o.hide_render=True;o.hide_set(True)
|
||||
else:o.location.z-=1.2
|
||||
for x in (-6.3,6.3):
|
||||
box('Sign_Fence_Post',x,4.4,(1.15,1.15,8.8),root)
|
||||
box('Sign_Post_Foot',x,.24,(1.55,1.55,.48),root)
|
||||
box('Sign_Post_Capital',x,8.65,(1.55,1.55,.44),root)
|
||||
cp=template.copy();cp.data=template.data.copy();cp.name='Sign_Smooth_SnowCap';coll.objects.link(cp);cp.parent=root
|
||||
cp.location=(x,0,9.0);cp.rotation_euler=(0,0,0)
|
||||
# Normalize copied snow to the sign's capital while retaining its curved lobes.
|
||||
coords=[v.co for v in cp.data.vertices]
|
||||
lo=Vector(tuple(min(v[k] for v in coords) for k in range(3)));hi=Vector(tuple(max(v[k] for v in coords) for k in range(3)))
|
||||
center=(lo+hi)*.5;extent=hi-lo
|
||||
for v in cp.data.vertices:
|
||||
v.co=Vector(((v.co.x-center.x)/extent.x*1.95,(v.co.y-center.y)/extent.y*1.95,(v.co.z-center.z)/extent.z*.85))
|
||||
cp.scale=(1,1,1)
|
||||
for f in cp.data.polygons:f.use_smooth=True
|
||||
# Horizontal rails connect the plaque to the wide-set fence-style posts.
|
||||
for z in (6.35,8.05):box('Sign_Mount_Rail',0,z,(12.6,.35,.36),root)
|
||||
path=os.path.join(folder,'map_signs_adjusted.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Adjusted',len(roots),'signs. Shift right 3.8, board down 1.2.',path)
|
||||
@@ -0,0 +1,48 @@
|
||||
import bpy, math, random, os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_asphalt.blend'),copy=True)
|
||||
m=bpy.data.materials.new('Asphalt_Stylized_BlueGrey');m.use_nodes=True;m.diffuse_color=(.12,.16,.205,1)
|
||||
n=m.node_tree.nodes;l=m.node_tree.links;p=next(x for x in n if x.type=='BSDF_PRINCIPLED')
|
||||
p.inputs['Roughness'].default_value=.92
|
||||
tex=n.new('ShaderNodeTexNoise');tex.inputs['Scale'].default_value=.45;tex.inputs['Detail'].default_value=0
|
||||
coord=n.new('ShaderNodeTexCoord');l.new(coord.outputs['Object'],tex.inputs['Vector'])
|
||||
r=n.new('ShaderNodeValToRGB');r.color_ramp.elements[0].color=(.105,.14,.18,1);r.color_ramp.elements[1].color=(.15,.19,.235,1)
|
||||
l.new(tex.outputs['Fac'],r.inputs[0]);l.new(r.outputs[0],p.inputs['Base Color'])
|
||||
changed=[]
|
||||
for o in sc.objects:
|
||||
if o.type!='MESH' or o.name not in ('Paths','Plaza_Inner_Tiles','Plaza_Inner_Ring'):continue
|
||||
for i,old in enumerate(o.data.materials):
|
||||
if old and ('Tile' in old.name or o.name=='Plaza_Inner_Ring'):o.data.materials[i]=m
|
||||
changed.append(o.name)
|
||||
snow=bpy.data.materials.get('Snow_Full_Soft') or bpy.data.materials.get('Snow_Soft')
|
||||
coll=bpy.data.collections.new('Asphalt_Edge_Snowdrifts');sc.collection.children.link(coll)
|
||||
rng=random.Random(71)
|
||||
def mound(x,y,z,length,width,height,angle):
|
||||
bpy.ops.mesh.primitive_uv_sphere_add(segments=16,ring_count=8,radius=1,location=(x,y,z))
|
||||
o=bpy.context.object;o.name='Asphalt_Snowbank'
|
||||
for v in o.data.vertices:
|
||||
a=math.atan2(v.co.y,v.co.x);f=1+.10*math.sin(a*3+angle)+.055*math.cos(a*5)
|
||||
v.co.x*=length*f;v.co.y*=width*f;v.co.z*=height
|
||||
o.rotation_euler.z=angle
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o)
|
||||
if snow:o.data.materials.append(snow)
|
||||
for p in o.data.polygons:p.use_smooth=True
|
||||
# Patchy snow around the central disc, keeping each radial entrance open.
|
||||
for i in range(10):
|
||||
center=i*math.tau/10
|
||||
for off in (.19,.31,.43):
|
||||
a=center+off;r0=38.2+rng.uniform(-.5,.6)
|
||||
mound(-math.sin(a)*r0,math.cos(a)*r0,.65,rng.uniform(2,3.8),rng.uniform(.9,1.8),rng.uniform(.3,.65),a)
|
||||
# Drifts accumulate at the sides of the paths rather than crossing them.
|
||||
for i in range(10):
|
||||
a=i*math.tau/10;d=Vector((-math.sin(a),math.cos(a),0));s=Vector((math.cos(a),math.sin(a),0))
|
||||
for side in (-1,1):
|
||||
for t in (44,55,66):
|
||||
if rng.random()<.22:continue
|
||||
pos=d*(t+rng.uniform(-2,2))+s*(side*rng.uniform(4.4,5.4))
|
||||
mound(pos.x,pos.y,.65,rng.uniform(2.1,4.1),rng.uniform(.8,1.4),rng.uniform(.28,.6),a+math.pi/2)
|
||||
path=os.path.join(folder,'map_compact_asphalt.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Changed:',changed,'Snowbanks:',len(coll.objects),'Saved:',path)
|
||||
@@ -0,0 +1,32 @@
|
||||
import bpy,os,math
|
||||
sc=bpy.context.scene
|
||||
folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'snow_before_cleanup.blend'),copy=True)
|
||||
def gate(o):
|
||||
x,y,z=o.matrix_world.translation
|
||||
if z>6:return False
|
||||
for i in range(10):
|
||||
t=i*math.tau/10
|
||||
u=x*math.cos(t)+y*math.sin(t);v=-x*math.sin(t)+y*math.cos(t)
|
||||
if abs(u)<4.35 and 94.8<v<101:return True
|
||||
return False
|
||||
remove=set()
|
||||
for name in ['Snow_Rounded_Caps','Snow_Posts_Repaired']:
|
||||
c=bpy.data.collections.get(name)
|
||||
if c:remove.update(c.objects)
|
||||
for o in list(sc.objects):
|
||||
if o.name.endswith('_FenceSnow'):remove.add(o)
|
||||
c=bpy.data.collections.get('Snow_Organic_Domes')
|
||||
if c:
|
||||
for o in c.objects:
|
||||
if o.location.z>5.8 or o.hide_render or gate(o):remove.add(o)
|
||||
c=bpy.data.collections.get('Snow_Draped_Reference')
|
||||
if c:
|
||||
for o in c.objects:
|
||||
if gate(o):remove.add(o)
|
||||
count=len(remove)
|
||||
for o in remove:bpy.data.objects.remove(o,do_unlink=True)
|
||||
remaining=[o.name for o in sc.objects if o.type=='MESH' and o.name.startswith('Snow_') and gate(o)]
|
||||
assert not remaining,remaining
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_terrain_snow_cleaned.blend'))
|
||||
print('Removed',count,'remaining gate snow',len(remaining))
|
||||
@@ -0,0 +1,36 @@
|
||||
import bpy, math, os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_compacting.blend'),copy=True)
|
||||
shift=23.0
|
||||
directions=[Vector((-math.sin(i*math.tau/10),math.cos(i*math.tau/10),0)) for i in range(10)]
|
||||
count=0
|
||||
for o in list(sc.objects):
|
||||
if o.name.startswith('Zone_'):
|
||||
i=int(o.name.split('_')[1])-1
|
||||
elif o.name.startswith(('Snow_Soft_','Snow_Drape_')):
|
||||
pos=o.matrix_world.translation;i=max(range(10),key=lambda k:pos.dot(directions[k]))
|
||||
else:continue
|
||||
world=o.matrix_world.copy();world.translation-=directions[i]*shift;o.matrix_world=world;count+=1
|
||||
for name in ('Plaza_Border','Plaza_Tiles'):
|
||||
o=sc.objects.get(name)
|
||||
if o:bpy.data.objects.remove(o,do_unlink=True)
|
||||
o=sc.objects.get('Paths')
|
||||
if o:
|
||||
o.data=o.data.copy();inv=o.matrix_world.inverted()
|
||||
for v in o.data.vertices:
|
||||
p=o.matrix_world@v.co;i=max(range(10),key=lambda k:p.dot(directions[k]))
|
||||
p-=directions[i]*shift;v.co=inv@p
|
||||
o=sc.objects.get('Island')
|
||||
if o:
|
||||
o.data=o.data.copy();inv=o.matrix_world.inverted()
|
||||
for v in o.data.vertices:
|
||||
p=o.matrix_world@v.co;r=math.hypot(p.x,p.y)
|
||||
if r>39:
|
||||
newr=39+(r-39)*(139/162*162-39)/(162-39)
|
||||
p.x*=newr/r;p.y*=newr/r;v.co=inv@p
|
||||
bpy.context.view_layer.update()
|
||||
assert sum(1 for o in sc.objects if o.name.startswith('Zone_') and o.name.endswith('_Fence'))==10
|
||||
path=os.path.join(folder,'map_compact.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Moved objects:',count,'inward:',shift,'10 fences retained. Saved:',path)
|
||||
@@ -0,0 +1,47 @@
|
||||
import bpy,math,os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_continuous_snow.blend'),copy=True)
|
||||
old=bpy.data.collections.get('Asphalt_Edge_Snowdrifts')
|
||||
if old:
|
||||
for o in old.objects:o.hide_render=True;o.hide_set(True)
|
||||
coll=bpy.data.collections.new('Continuous_Curb_Snow');sc.collection.children.link(coll)
|
||||
mat=bpy.data.materials.get('Snow_Full_Soft') or bpy.data.materials.get('Snow_Soft')
|
||||
radius=38.7;half=5.0;start=math.sqrt(radius**2-half**2);off=math.asin(half/radius)
|
||||
def point(angle,t,side):
|
||||
return Vector((-math.sin(angle)*t+math.cos(angle)*side,math.cos(angle)*t+math.sin(angle)*side,0))
|
||||
for sector in range(10):
|
||||
a=sector*math.tau/10;b=(sector+1)*math.tau/10
|
||||
# One connected bank follows a path edge, the plaza curb, and the next path edge.
|
||||
pts=[]
|
||||
for j in range(51):pts.append(point(a,73+(start-73)*j/50,-half))
|
||||
for j in range(1,65):
|
||||
ang=a+off+(b-off-a-off)*j/64
|
||||
pts.append(Vector((-math.sin(ang)*radius,math.cos(ang)*radius,0)))
|
||||
for j in range(1,51):pts.append(point(b,start+(73-start)*j/50,half))
|
||||
verts=[];faces=[];N=12;distance=0
|
||||
for j,p in enumerate(pts):
|
||||
if j:distance+=(p-pts[j-1]).length
|
||||
tangent=pts[min(j+1,len(pts)-1)]-pts[max(0,j-1)];tangent.normalize()
|
||||
normal=Vector((-tangent.y,tangent.x,0))
|
||||
wave=.5+.5*math.sin(distance*.67+sector*.8)
|
||||
width=.72+.3*wave+.15*math.sin(distance*1.13+1)**2
|
||||
height=.42+.23*wave+.12*math.cos(distance*.37)**2
|
||||
taper=min(1,.22+j*.27,.22+(len(pts)-1-j)*.27)
|
||||
for k in range(N):
|
||||
t=math.tau*k/N
|
||||
v=p+normal*(math.cos(t)*width*taper)
|
||||
v.z=.58+math.sin(t)*height*taper
|
||||
verts.append(tuple(v))
|
||||
for j in range(len(pts)-1):
|
||||
for k in range(N):
|
||||
q=j*N+k;r=j*N+(k+1)%N;faces.append((q,r,r+N,q+N))
|
||||
faces.append(tuple(reversed(range(N))));faces.append(tuple((len(pts)-1)*N+k for k in range(N)))
|
||||
me=bpy.data.meshes.new('ContinuousSnow');me.from_pydata(verts,[],faces);me.update()
|
||||
import bmesh
|
||||
bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces));bm.to_mesh(me);bm.free()
|
||||
ob=bpy.data.objects.new('Curb_Snow_%02d'%sector,me);coll.objects.link(ob)
|
||||
if mat:me.materials.append(mat)
|
||||
for poly in me.polygons:poly.use_smooth=True
|
||||
path=os.path.join(folder,'map_continuous_snow.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Created 10 continuous connected snowbanks, saved',path)
|
||||
@@ -0,0 +1,46 @@
|
||||
import bpy,math,os
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_festive_signs.blend'),copy=True)
|
||||
roots=[o for o in sc.objects if o.type=='EMPTY' and o.name.startswith('Zone_') and o.name.endswith('_Nameplate')]
|
||||
coll=bpy.data.collections.new('Festive_Nameplate_Details');sc.collection.children.link(coll)
|
||||
def mat(name,c,metal=0,emit=0):
|
||||
m=bpy.data.materials.new(name);m.use_nodes=True;m.diffuse_color=(*c,1)
|
||||
p=next(n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED');p.inputs['Base Color'].default_value=(*c,1);p.inputs['Roughness'].default_value=.37;p.inputs['Metallic'].default_value=metal;p.inputs['Emission Color'].default_value=(*c,1);p.inputs['Emission Strength'].default_value=emit
|
||||
return m
|
||||
green=mat('Sign_Deep_Green',(.012,.105,.075));gold=mat('Sign_Gold',(.85,.43,.035),.65);red=mat('Sign_Red',(.65,.012,.025));leaf=mat('Sign_Pine',(.035,.19,.025));light=mat('Sign_Warm_Bulbs',(1,.65,.18),0,4)
|
||||
snow=bpy.data.materials.get('Snow_Full_Soft')
|
||||
def box(name,pos,size,material,root,angle=0):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=pos);o=bpy.context.object;o.name=name;o.dimensions=size
|
||||
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True);o.rotation_euler.y=angle
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.parent=root;o.data.materials.append(material)
|
||||
b=o.modifiers.new('Soft bevel','BEVEL');b.width=.045;b.segments=2
|
||||
return o
|
||||
for root in roots:
|
||||
for o in list(root.children):
|
||||
if o.name.startswith('Player_Name_Board'):o.hide_render=True;o.hide_set(True)
|
||||
if o.type=='FONT':o.location.y=-.43;o.data.size=.63;o.data.extrude=.028
|
||||
for j in range(4):box('Green_Timber',(0,-.06,2.36+j*.49),(6.4,.48,.475),green,root)
|
||||
for z in (2.1,4.1):box('Gold_Rim',(0,-.12,z),(6.6,.6,.16),gold,root)
|
||||
for x in (-3.25,3.25):box('Gold_Rim',(x,-.12,3.1),(.16,.6,2.05),gold,root)
|
||||
for z in (2.27,3.94):
|
||||
for x in (-2.65,-1.75,-.87,0,.87,1.75,2.65):box('Fairy_Light',(x,-.43,z),(.12,.12,.14),light,root)
|
||||
for x in (-3.09,3.09):
|
||||
for z in (2.75,3.45):box('Fairy_Light',(x,-.43,z),(.12,.12,.14),light,root)
|
||||
for sign in (-1,1):
|
||||
for j in range(5):
|
||||
box('Evergreen_Sprig',(sign*(.5+j*.23),-.21,4.48+.11*math.sin(j)),(.62,.25,.20),leaf,root,sign*(.3+j*.16))
|
||||
box('Bow_Loop',(sign*.43,-.48,4.51),(.85,.32,.47),red,root,sign*-.38)
|
||||
box('Bow_Tail',(sign*.28,-.49,4.15),(.32,.23,.65),red,root,sign*.35)
|
||||
box('Bow_Gold_Knot',(0,-.66,4.48),(.33,.27,.34),gold,root)
|
||||
for x in (-2.9,2.9):
|
||||
for z in (2.42,3.75):
|
||||
for j in (-1,0,1):box('Corner_Pine',(x+j*.12,-.43,z),(.2,.18,.5),leaf,root,j*.6)
|
||||
bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=1,radius=.22,location=(x,-.65,z))
|
||||
o=bpy.context.object;o.name='Sign_Bauble'
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.parent=root;o.data.materials.append(red if z>3 else gold)
|
||||
# Snow-capped post tops keep the same snow material as fences.
|
||||
for x in (-2.7,2.7):box('Post_Snow',(x,0,3.82),(.65,.72,.23),snow,root)
|
||||
path=os.path.join(folder,'map_festive_nameplates.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Restyled nameplates:',len(roots),path)
|
||||
@@ -0,0 +1,36 @@
|
||||
import bpy, math, os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene
|
||||
old=bpy.data.collections.get('Snow_Rounded_Caps'); organic=bpy.data.collections.get('Snow_Organic_Domes')
|
||||
dest=bpy.data.collections.new('Snow_Posts_Repaired');sc.collection.children.link(dest)
|
||||
candidates=[]
|
||||
for idx,o in enumerate(list(old.objects)):
|
||||
vs=[v.co for v in o.data.vertices]; dims=[max(v[k] for v in vs)-min(v[k] for v in vs) for k in range(3)]
|
||||
if dims[2]<.8:continue
|
||||
target=organic.objects.get('Snow_Soft_%04d'%idx)
|
||||
if target:target.hide_render=True;target.hide_set(True)
|
||||
candidates.append((o,dims))
|
||||
count=0
|
||||
for o,dims in candidates:
|
||||
center=o.matrix_world.translation
|
||||
# Skip smaller snow pillows enclosed by a larger cap on the same post.
|
||||
if any(other!=o and abs(other.location.z-o.location.z)<1.5 and (other.matrix_world.translation-center).xy.length<.65 and d[0]*d[1]>dims[0]*dims[1]*1.1 for other,d in candidates):continue
|
||||
bpy.ops.mesh.primitive_uv_sphere_add(segments=24,ring_count=12,radius=1)
|
||||
cap=bpy.context.object;cap.name='Post_Snow_Soft'
|
||||
narrow=min(dims[:2])<1.2
|
||||
for v in cap.data.vertices:
|
||||
x,y,z=v.co
|
||||
angle=math.atan2(y,x)
|
||||
# Rounded continuous dome, broad soft bottom, no pinched polar tip.
|
||||
v.co.x=x*dims[0]*.50
|
||||
v.co.y=y*dims[1]*.50
|
||||
v.co.z=z*(.24 if narrow else .48)+.035*math.sin(angle*3+count)*max(0,1-z*z)
|
||||
cap.matrix_world=o.matrix_world.copy()
|
||||
for c in list(cap.users_collection):c.objects.unlink(cap)
|
||||
dest.objects.link(cap)
|
||||
for m in o.data.materials:cap.data.materials.append(m)
|
||||
for p in cap.data.polygons:p.use_smooth=True
|
||||
count+=1
|
||||
path=os.path.join(os.path.dirname(bpy.data.filepath),'map_terrain_posts_fixed.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Replaced upright caps',count,'preserved rail snow',path)
|
||||
@@ -0,0 +1,52 @@
|
||||
import bpy,math,os,random
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_holiday_decor.blend'),copy=True)
|
||||
coll=bpy.data.collections.new('Holiday_Map_Decor');sc.collection.children.link(coll)
|
||||
def mat(name,c):
|
||||
m=bpy.data.materials.new(name);m.diffuse_color=(*c,1);m.use_nodes=True
|
||||
p=next(n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED');p.inputs['Base Color'].default_value=(*c,1);p.inputs['Roughness'].default_value=.4
|
||||
return m
|
||||
red=mat('Candy_Red',(.7,.015,.025));white=mat('Candy_Cream',(.95,.97,1));green=mat('Decor_Pine',(.035,.22,.075));gold=mat('Gift_Ribbon_Gold',(.95,.54,.04));blue=mat('Gift_Ice_Blue',(.04,.35,.6));brown=mat('Decor_Trunk',(.22,.09,.035));snow=bpy.data.materials.get('Snow_Full_Soft') or white
|
||||
def attach(o,name,material):
|
||||
o.name=name
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.data.materials.append(material);return o
|
||||
def box(name,pos,size,material):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=pos);o=bpy.context.object;o.dimensions=size;bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
||||
attach(o,name,material);b=o.modifiers.new('Rounded corners','BEVEL');b.width=.09;b.segments=2
|
||||
return o
|
||||
def cane(pos,angle):
|
||||
pts=[Vector((0,0,.3+j*.4)) for j in range(13)]
|
||||
for j in range(1,17):
|
||||
t=math.pi*j/16;pts.append(Vector((.75-.75*math.cos(t),0,5.1+.75*math.sin(t))))
|
||||
verts=[];faces=[]
|
||||
for j,p in enumerate(pts):
|
||||
tangent=(pts[min(j+1,len(pts)-1)]-pts[max(j-1,0)]).normalized();side=Vector((0,1,0));n=tangent.cross(side).normalized()
|
||||
for k in range(10):
|
||||
q=p+.27*(side*math.cos(k*math.tau/10)+n*math.sin(k*math.tau/10))
|
||||
verts.append((pos.x+q.x*math.cos(angle)-q.y*math.sin(angle),pos.y+q.x*math.sin(angle)+q.y*math.cos(angle),q.z))
|
||||
for j in range(len(pts)-1):
|
||||
for k in range(10):faces.append((j*10+k,j*10+(k+1)%10,(j+1)*10+(k+1)%10,(j+1)*10+k))
|
||||
me=bpy.data.meshes.new('CandyCane');me.from_pydata(verts,[],faces);me.update();o=bpy.data.objects.new('Candy_Cane',me);coll.objects.link(o);me.materials.append(red);me.materials.append(white)
|
||||
for p in me.polygons:p.material_index=(p.index//20)%2;p.use_smooth=True
|
||||
def gift(pos,size,material):
|
||||
box('Wrapped_Gift',(pos.x,pos.y,size/2+.15),(size,size,size),material)
|
||||
box('Gift_Ribbon',(pos.x,pos.y,size/2+.15),(size+.04,.2,size+.05),gold)
|
||||
box('Gift_Ribbon',(pos.x,pos.y,size/2+.15),(.2,size+.04,size+.05),gold)
|
||||
for sign in (-1,1):
|
||||
o=box('Gift_Bow',(pos.x+sign*.22,pos.y,size+.3),(.5,.25,.2),gold);o.rotation_euler.y=sign*.4
|
||||
for i in range(10):
|
||||
a=i*math.tau/10;d=Vector((-math.sin(a),math.cos(a),0));s=Vector((math.cos(a),math.sin(a),0))
|
||||
for sign in (-1,1):cane(d*70+s*(sign*5.5),a+(math.pi if sign==1 else 0))
|
||||
# Decorations in the open wedge, not inside the playable fenced plots.
|
||||
a=(i+.5)*math.tau/10;d=Vector((-math.sin(a),math.cos(a),0));s=Vector((math.cos(a),math.sin(a),0))
|
||||
center=d*112
|
||||
bpy.ops.mesh.primitive_cone_add(vertices=8,radius1=.55,radius2=.45,depth=2,location=(center.x,center.y,1));attach(bpy.context.object,'Pine_Trunk',brown)
|
||||
for z,r,h in [(3.1,3.6,4),(5.3,2.7,3.6),(7.4,1.8,3.4)]:
|
||||
bpy.ops.mesh.primitive_cone_add(vertices=8,radius1=r,radius2=.15,depth=h,location=(center.x,center.y,z));attach(bpy.context.object,'Pine_Foliage',green)
|
||||
bpy.ops.mesh.primitive_cone_add(vertices=8,radius1=r*.83,radius2=.12,depth=h*.78,location=(center.x,center.y,z+h*.13));attach(bpy.context.object,'Pine_Snow',snow)
|
||||
base=d*47+s*2
|
||||
gift(base,1.7,red);gift(base+s*2,1.25,green);gift(base-s*1.6+d*.6,1.0,blue)
|
||||
path=os.path.join(folder,'map_holiday_decor.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Added 20 candy canes, 10 snow-covered trees, 30 gifts.',path)
|
||||
@@ -0,0 +1,2 @@
|
||||
import bpy
|
||||
print({'version': bpy.app.version_string, 'file': bpy.data.filepath, 'active_scene': bpy.context.scene.name, 'scenes': [(s.name, len(s.objects)) for s in bpy.data.scenes]})
|
||||
@@ -0,0 +1,4 @@
|
||||
import bpy
|
||||
print('FILE',bpy.data.filepath)
|
||||
for o in bpy.context.scene.objects:
|
||||
if o.type=='MESH': print(o.name, 'MATS', [m.name for m in o.data.materials if m], 'SIZE',tuple(round(v,2) for v in o.dimensions))
|
||||
@@ -0,0 +1,18 @@
|
||||
import bpy
|
||||
o=bpy.data.objects.get('Zone_01_FenceSnow')
|
||||
print('modifiers',[(m.name,m.type) for m in o.modifiers])
|
||||
me=o.data; adj=[[] for v in me.vertices]
|
||||
for e in me.edges:
|
||||
a,b=e.vertices; adj[a].append(b); adj[b].append(a)
|
||||
seen=set(); groups=[]
|
||||
for v in range(len(adj)):
|
||||
if v in seen: continue
|
||||
stack=[v];seen.add(v);ids=[]
|
||||
while stack:
|
||||
j=stack.pop();ids.append(j)
|
||||
for k in adj[j]:
|
||||
if k not in seen:seen.add(k);stack.append(k)
|
||||
pts=[o.matrix_world@me.vertices[j].co for j in ids]
|
||||
lo=[min(p[i] for p in pts) for i in range(3)];hi=[max(p[i] for p in pts) for i in range(3)]
|
||||
groups.append((len(ids),[round(x,2) for x in lo],[round(x,2) for x in hi]))
|
||||
print(groups[:90]);print('count',len(groups))
|
||||
@@ -0,0 +1,6 @@
|
||||
import bpy
|
||||
for name in ['Snow_Rounded_Caps','Snow_Organic_Domes','Snow_Draped_Reference']:
|
||||
c=bpy.data.collections.get(name)
|
||||
print(name,len(c.objects) if c else 0)
|
||||
if c:
|
||||
for o in list(c.objects)[:40]:print(o.name,tuple(round(x,2) for x in o.location),tuple(round(x,2) for x in o.dimensions))
|
||||
@@ -0,0 +1,43 @@
|
||||
import bpy, math, os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene
|
||||
old=bpy.data.collections.get('Snow_Rounded_Caps')
|
||||
new=bpy.data.collections.new('Snow_Organic_Domes');sc.collection.children.link(new)
|
||||
count=0
|
||||
for idx,o in enumerate(list(old.objects)):
|
||||
# Read original box dimensions, before its bevel modifiers.
|
||||
vs=[v.co for v in o.data.vertices]
|
||||
dims=[max(v[k] for v in vs)-min(v[k] for v in vs) for k in range(3)]
|
||||
a,b,h=dims[0]/2,dims[1]/2,dims[2]/2
|
||||
verts=[];faces=[];segments=32;rings=12
|
||||
phase=idx*1.73
|
||||
# Ellipsoidal dome with a scalloped, uneven lower edge; no planar box sides.
|
||||
verts.append((0,0,h*1.3))
|
||||
for j in range(1,rings):
|
||||
t=math.pi*j/rings
|
||||
radius=math.sin(t)
|
||||
for i in range(segments):
|
||||
ang=2*math.pi*i/segments
|
||||
wave=.065*math.sin(5*ang+phase)+.035*math.cos(3*ang-phase)
|
||||
x=a*radius*(1+wave)*math.cos(ang)
|
||||
y=b*radius*(1+wave)*math.sin(ang)
|
||||
z=h*math.cos(t)
|
||||
z+=h*.22*math.sin(3*ang+phase)*math.sin(t)**2
|
||||
z-=h*.28*(.5+.5*math.sin(5*ang+phase))*math.sin(t)**4
|
||||
verts.append((x,y,z))
|
||||
bottom=len(verts);verts.append((0,0,-h))
|
||||
for i in range(segments):faces.append((0,1+i,1+(i+1)%segments))
|
||||
for j in range(rings-2):
|
||||
for i in range(segments):
|
||||
q=1+j*segments+i;r=1+j*segments+(i+1)%segments
|
||||
faces.append((q,q+segments,r+segments,r))
|
||||
start=1+(rings-2)*segments
|
||||
for i in range(segments):faces.append((start+i,bottom,start+(i+1)%segments))
|
||||
me=bpy.data.meshes.new('OrganicSnow');me.from_pydata(verts,[],faces);me.update()
|
||||
ob=bpy.data.objects.new('Snow_Soft_%04d'%idx,me);new.objects.link(ob);ob.matrix_world=o.matrix_world.copy()
|
||||
for m in o.data.materials:me.materials.append(m)
|
||||
for p in me.polygons:p.use_smooth=True
|
||||
o.hide_render=True;o.hide_set(True);count+=1
|
||||
path=os.path.join(os.path.dirname(bpy.data.filepath),'map_terrain_organic_snow.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Organic snow caps:',count,path)
|
||||
@@ -0,0 +1,53 @@
|
||||
import bpy,math,os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_furniture.blend'),copy=True)
|
||||
coll=bpy.data.collections.new('Plaza_Benches_And_Lanterns');sc.collection.children.link(coll)
|
||||
def mat(name,c,metal=0,emit=0):
|
||||
m=bpy.data.materials.new(name);m.diffuse_color=(*c,1);m.use_nodes=True
|
||||
p=next(n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED');p.inputs['Base Color'].default_value=(*c,1);p.inputs['Metallic'].default_value=metal;p.inputs['Roughness'].default_value=.45;p.inputs['Emission Color'].default_value=(*c,1);p.inputs['Emission Strength'].default_value=emit
|
||||
return m
|
||||
wood=mat('Bench_Warm_Wood',(.32,.115,.04));iron=mat('Lantern_Dark_Bronze',(.045,.034,.027),.6)
|
||||
red=mat('Festive_Ribbon',(.65,.018,.025));glow=mat('Lantern_Warm_Glass',(1,.6,.15),0,3)
|
||||
snow=bpy.data.materials.get('Snow_Full_Soft')
|
||||
def move(o,parent,material):
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.parent=parent
|
||||
if material:o.data.materials.append(material)
|
||||
return o
|
||||
def box(name,pos,size,material,parent):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=pos);o=bpy.context.object;o.name=name;o.dimensions=size
|
||||
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
||||
bevel=o.modifiers.new('Soft edges','BEVEL');bevel.width=.06;bevel.segments=2
|
||||
return move(o,parent,material)
|
||||
def cone(name,z,r1,r2,depth,material,parent,vertices=8):
|
||||
bpy.ops.mesh.primitive_cone_add(vertices=vertices,radius1=r1,radius2=r2,depth=depth,location=(0,0,z));o=bpy.context.object;o.name=name;return move(o,parent,material)
|
||||
for i in range(10):
|
||||
a=(i+.5)*math.tau/10
|
||||
root=bpy.data.objects.new(('Bench_' if i%2==0 else 'Lamp_')+str(i),None);coll.objects.link(root)
|
||||
if i%2==0:
|
||||
for x in (-2.65,2.65):
|
||||
for y in (-.65,.65):box('Bench_Leg',(x,y,1.2),(.28,.32,1.7),iron,root)
|
||||
box('Back_Support',(x,.78,2.6),(.25,.28,3.0),iron,root)
|
||||
box('Armrest',(x,0,2.65),(.32,1.9,.22),iron,root)
|
||||
for y in (-.65,0,.65):box('Seat_Plank',(0,y,1.95),(6.4,.58,.22),wood,root)
|
||||
for z in (2.65,3.35):box('Back_Plank',(0,.87,z),(6.4,.22,.55),wood,root)
|
||||
if snow:box('Back_Snow',(0,.87,3.69),(6.45,.32,.14),snow,root)
|
||||
else:
|
||||
cone('Lamp_Base',.85,.65,.52,.7,iron,root)
|
||||
cone('Lamp_Post',3.8,.19,.14,5.4,iron,root)
|
||||
cone('Lantern_Foot',6.55,.55,.65,.25,iron,root,4)
|
||||
box('Warm_Lantern',(0,0,7.25),(.9,.9,1.2),glow,root)
|
||||
for x in (-.5,.5):
|
||||
for y in (-.5,.5):box('Lantern_Frame',(x,y,7.25),(.1,.1,1.4),iron,root)
|
||||
cone('Lantern_Roof',8.1,.95,.14,.6,iron,root,4)
|
||||
cone('Lantern_Finial',8.52,.13,0,.3,iron,root)
|
||||
for sign in (-1,1):
|
||||
o=box('Bow_Loop',(sign*.4,-.23,5.2),(.75,.24,.46),red,root);o.rotation_euler.y=sign*.3
|
||||
o=box('Ribbon_Tail',(sign*.23,-.23,4.72),(.24,.2,.7),red,root);o.rotation_euler.y=sign*-.3
|
||||
box('Bow_Knot',(0,-.38,5.2),(.3,.3,.32),red,root)
|
||||
d=bpy.data.lights.new('Warm_Pool','POINT');d.energy=100;d.color=(1,.63,.27);d.shadow_soft_size=1
|
||||
o=bpy.data.objects.new('Warm_Pool',d);coll.objects.link(o);o.parent=root;o.location=(0,0,7.2)
|
||||
root.location=(-math.sin(a)*33,math.cos(a)*33,.25);root.rotation_euler.z=a
|
||||
path=os.path.join(folder,'map_plaza_furniture.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Created 5 benches and 5 decorated lamps between plaza exits:',path)
|
||||
@@ -0,0 +1,45 @@
|
||||
import bpy, math, os, numpy as np
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene
|
||||
mat=bpy.data.materials.new('Snow_Full_Soft');mat.diffuse_color=(.88,.94,1,1);mat.use_nodes=True
|
||||
p=next(n for n in mat.node_tree.nodes if n.type=='BSDF_PRINCIPLED')
|
||||
p.inputs['Base Color'].default_value=(.88,.94,1,1);p.inputs['Roughness'].default_value=.83
|
||||
coll=bpy.data.collections.new('Snow_Rounded_Caps');sc.collection.children.link(coll)
|
||||
count=0
|
||||
for o in list(sc.objects):
|
||||
if o.name.endswith('_FenceSnow'): o.hide_render=True;o.hide_set(True)
|
||||
for o in list(sc.objects):
|
||||
if o.type!='MESH' or not o.name.endswith('_Fence'):continue
|
||||
me=o.data;adj=[[] for v in me.vertices]
|
||||
for e in me.edges:
|
||||
a,b=e.vertices;adj[a].append(b);adj[b].append(a)
|
||||
seen=set()
|
||||
for seed in range(len(adj)):
|
||||
if seed in seen:continue
|
||||
stack=[seed];seen.add(seed);ids=[]
|
||||
while stack:
|
||||
j=stack.pop();ids.append(j)
|
||||
for k in adj[j]:
|
||||
if k not in seen:seen.add(k);stack.append(k)
|
||||
pts=np.array([(o.matrix_world@me.vertices[j].co)[:] for j in ids]);lo=pts.min(0);hi=pts.max(0);dim=hi-lo
|
||||
xy=pts[:,:2];center=xy.mean(0);ev,axes=np.linalg.eigh((xy-center).T@(xy-center));axis=axes[:,-1];side=axes[:,0]
|
||||
proj=(xy-center)@np.column_stack((axis,side));length,width=np.ptp(proj,axis=0)
|
||||
upright=dim[2]>2 and dim[2]>length*1.3
|
||||
rail=length>2.5 and dim[2]<1.4 and hi[2]>2
|
||||
if not (upright or rail):continue
|
||||
# Smooth bevelled solid snow pillow; no downward icicles.
|
||||
depth=1.15 if upright else .48
|
||||
size=(length+.55,width+.55,depth) if upright else (length+.12,width+.28,depth)
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=(float(center[0]),float(center[1]),float(hi[2]+depth*.34)))
|
||||
cap=bpy.context.object;cap.name=o.name+'_SnowCap';cap.dimensions=size
|
||||
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
||||
cap.rotation_euler.z=math.atan2(axis[1],axis[0])
|
||||
for c in list(cap.users_collection):c.objects.unlink(cap)
|
||||
coll.objects.link(cap);cap.data.materials.append(mat)
|
||||
bevel=cap.modifiers.new('Rounded snow volume','BEVEL');bevel.width=min(size)*.46;bevel.segments=4
|
||||
cap.modifiers.new('Soft normals','WEIGHTED_NORMAL')
|
||||
for poly in cap.data.polygons:poly.use_smooth=True
|
||||
count+=1
|
||||
path=os.path.join(os.path.dirname(bpy.data.filepath),'map_terrain_snow_caps.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('New solid caps:',count,'Saved:',path)
|
||||
@@ -0,0 +1,47 @@
|
||||
import bpy,math,os,bmesh,random
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_reference_pines.blend'),copy=True)
|
||||
old=bpy.data.collections.get('Refined_Snowy_Pines');assert old
|
||||
positions=[o.location.copy() for o in old.objects if o.name.startswith('Pine_Visible_Trunk')]
|
||||
for o in old.objects:o.hide_render=True;o.hide_set(True)
|
||||
coll=bpy.data.collections.new('Reference_Faceted_Pines');sc.collection.children.link(coll)
|
||||
base=bpy.data.materials.get('Decor_Pine');snow=bpy.data.materials.get('Snow_Full_Soft');brown=bpy.data.materials.get('Decor_Trunk')
|
||||
mats=[]
|
||||
for i,c in enumerate([(.11,.32,.035),(.15,.40,.05),(.20,.46,.065),(.07,.24,.025)]):
|
||||
m=base.copy();m.name='Pine_Facet_'+str(i);m.diffuse_color=(*c,1)
|
||||
p=next(n for n in m.node_tree.nodes if n.type=='BSDF_PRINCIPLED');p.inputs['Base Color'].default_value=(*c,1);mats.append(m)
|
||||
for idx,pos in enumerate(positions):
|
||||
bpy.ops.mesh.primitive_cone_add(vertices=10,radius1=.9,radius2=.55,depth=3.2,location=(pos.x,pos.y,1.6))
|
||||
o=bpy.context.object;o.name='Reference_Pine_Trunk'
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.data.materials.append(brown)
|
||||
for tier,(z,r,h) in enumerate([(2.9,3.8,3.8),(5.05,3.25,3.5),(7.1,2.35,2.8),(8.9,1.6,2.5),(10.45,1.0,2.3)]):
|
||||
N=12;verts=[];faces=[]
|
||||
for ring,(rad,zz) in enumerate([(r*.77,z+.3),(r,z+.4),(r*.68,z+h*.48),(r*.28,z+h*.82)]):
|
||||
for k in range(N):
|
||||
a=k*math.tau/N+idx*.15
|
||||
rr=rad*(1.08 if k%2==0 else .88)
|
||||
dz=(-.38 if k%2==0 else .15) if ring<2 else 0
|
||||
verts.append((pos.x+rr*math.cos(a),pos.y+rr*math.sin(a),zz+dz))
|
||||
top=len(verts);verts.append((pos.x,pos.y,z+h))
|
||||
for j in range(3):
|
||||
for k in range(N):
|
||||
a=j*N+k;b=j*N+(k+1)%N
|
||||
faces.extend([(a,b,b+N),(a,b+N,a+N)])
|
||||
for k in range(N):faces.append((3*N+k,3*N+(k+1)%N,top))
|
||||
faces.append(tuple(reversed(range(N))))
|
||||
me=bpy.data.meshes.new('FacetedBranchTier');me.from_pydata(verts,[],faces);me.update()
|
||||
bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces));bm.to_mesh(me);bm.free()
|
||||
ob=bpy.data.objects.new('Pine_Faceted_Tier',me);coll.objects.link(ob)
|
||||
for m in mats:me.materials.append(m)
|
||||
for f in me.polygons:f.material_index=(f.index//3+tier)%3
|
||||
# Smooth snow rests in broad patches, leaving the jagged green skirt visible.
|
||||
for side in range(3 if tier<3 else 2):
|
||||
a=side*math.tau/3+idx*.3+tier*.6
|
||||
bpy.ops.mesh.primitive_uv_sphere_add(segments=20,ring_count=10,radius=1,location=(pos.x+math.cos(a)*r*.43,pos.y+math.sin(a)*r*.43,z+h*.46))
|
||||
ob=bpy.context.object;ob.name='Pine_Smooth_Snow_Patch';ob.scale=(r*.48,r*.29,.30 if tier<3 else .20);ob.rotation_euler.z=a+math.pi/2
|
||||
for c in list(ob.users_collection):c.objects.unlink(ob)
|
||||
coll.objects.link(ob);ob.data.materials.append(snow)
|
||||
for f in ob.data.polygons:f.use_smooth=True
|
||||
path=os.path.join(folder,'map_reference_pines.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Reference-style pines:',len(positions),path)
|
||||
@@ -0,0 +1,42 @@
|
||||
import bpy,math,os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_bench_refinement.blend'),copy=True)
|
||||
roots=[o for o in sc.objects if o.type=='EMPTY' and o.name.startswith('Bench_')]
|
||||
coll=bpy.data.collections.new('Refined_Bench_Details');sc.collection.children.link(coll)
|
||||
iron=bpy.data.materials.get('Lantern_Dark_Bronze');wood=bpy.data.materials.get('Bench_Warm_Wood');snow=bpy.data.materials.get('Snow_Full_Soft')
|
||||
def box(name,loc,size,mat,parent):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=loc);o=bpy.context.object;o.name=name;o.dimensions=size
|
||||
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.parent=parent;o.data.materials.append(mat)
|
||||
b=o.modifiers.new('Rounded timber edges','BEVEL');b.width=.075;b.segments=3
|
||||
o.modifiers.new('Normals','WEIGHTED_NORMAL')
|
||||
return o
|
||||
for root in roots:
|
||||
for o in list(root.children):o.hide_render=True;o.hide_set(True)
|
||||
for y in (-.78,-.26,.26,.78):box('Bench_Seat_Timber',(0,y,1.85),(6.6,.46,.28),wood,root)
|
||||
for z in (2.55,3.3):
|
||||
o=box('Bench_Back_Timber',(0,.95+(z-2.3)*.17,z),(6.6,.32,.65),wood,root);o.rotation_euler.x=math.radians(-10)
|
||||
for sign in (-1,1):
|
||||
x=sign*2.7
|
||||
# Side frame silhouette: splayed feet and curved armrest.
|
||||
for y in (-.73,.73):
|
||||
o=box('Bench_Splayed_Leg',(x,y,1.05),(.37,.42,1.65),iron,root);o.rotation_euler.x=.14 if y>0 else -.14
|
||||
box('Bench_Side_Beam',(x,0,1.63),(.39,2.05,.3),iron,root)
|
||||
o=box('Bench_Back_Support',(x,1.02,2.58),(.32,.33,2.05),iron,root);o.rotation_euler.x=-.17
|
||||
curve=bpy.data.curves.new('CurvedArm','CURVE');curve.dimensions='3D';curve.bevel_depth=.16;curve.bevel_resolution=2
|
||||
spline=curve.splines.new('BEZIER');spline.bezier_points.add(3)
|
||||
for p,co in zip(spline.bezier_points,[(x,-.78,1.95),(x,-.75,2.6),(x,.05,2.72),(x,.95,2.65)]):p.co=co;p.handle_left_type='AUTO';p.handle_right_type='AUTO'
|
||||
o=bpy.data.objects.new('Bench_Curved_Arm',curve);coll.objects.link(o);o.parent=root;curve.materials.append(iron)
|
||||
# A single soft, irregular snow pillow follows the upper back plank.
|
||||
bpy.ops.mesh.primitive_uv_sphere_add(segments=40,ring_count=12,radius=1)
|
||||
o=bpy.context.object;o.name='Bench_Snow_Cap'
|
||||
for v in o.data.vertices:
|
||||
x,y,z=v.co;v.co=(x*3.4,y*.36*(1+.13*math.sin(x*10)),z*.24+.045*math.sin(x*11)*(1-z*z))
|
||||
o.location=(0,1.13,3.68);o.parent=root
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.data.materials.append(snow)
|
||||
for p in o.data.polygons:p.use_smooth=True
|
||||
path=os.path.join(folder,'map_refined_benches.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Rebuilt benches:',len(roots),path)
|
||||
@@ -0,0 +1,51 @@
|
||||
import bpy,math,os,bmesh
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_tree_refinement.blend'),copy=True)
|
||||
old=bpy.data.collections.get('Holiday_Map_Decor');assert old
|
||||
trunks=[o for o in old.objects if o.name.startswith('Pine_Trunk') and not o.hide_render]
|
||||
positions=[o.location.copy() for o in trunks]
|
||||
green=bpy.data.materials.get('Decor_Pine');brown=bpy.data.materials.get('Decor_Trunk');snow=bpy.data.materials.get('Snow_Full_Soft')
|
||||
for o in old.objects:
|
||||
if o.name.startswith(('Pine_Trunk','Pine_Foliage','Pine_Snow')):o.hide_render=True;o.hide_set(True)
|
||||
coll=bpy.data.collections.new('Refined_Snowy_Pines');sc.collection.children.link(coll)
|
||||
def mesh_obj(name,verts,faces,mat):
|
||||
me=bpy.data.meshes.new(name);me.from_pydata(verts,[],faces);me.update()
|
||||
bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces));bm.to_mesh(me);bm.free()
|
||||
o=bpy.data.objects.new(name,me);coll.objects.link(o);me.materials.append(mat)
|
||||
for p in me.polygons:p.use_smooth=True
|
||||
return o
|
||||
for idx,pos in enumerate(positions):
|
||||
bpy.ops.mesh.primitive_cylinder_add(vertices=24,radius=.52,depth=3.3,location=(pos.x,pos.y,1.65))
|
||||
trunk=bpy.context.object;trunk.name='Pine_Visible_Trunk'
|
||||
for c in list(trunk.users_collection):c.objects.unlink(trunk)
|
||||
coll.objects.link(trunk);trunk.data.materials.append(brown)
|
||||
bevel=trunk.modifiers.new('Soft bark edges','BEVEL');bevel.width=.07;bevel.segments=2
|
||||
for tier,(base,radius,height) in enumerate([(2.5,3.8,4.5),(4.7,3.1,4.3),(6.8,2.4,4.0),(8.7,1.65,3.4)]):
|
||||
N=48
|
||||
# Curved branch skirts, with a visible green rim beneath snow.
|
||||
verts=[];faces=[];profile=[(0,1),(.14,.96),(.4,.75),(.7,.42),(1,.035)]
|
||||
for t,r in profile:
|
||||
for k in range(N):
|
||||
a=k*math.tau/N;wave=1+.035*math.sin(7*a+idx)
|
||||
verts.append((pos.x+radius*r*wave*math.cos(a),pos.y+radius*r*wave*math.sin(a),base+height*t))
|
||||
for j in range(len(profile)-1):
|
||||
for k in range(N):q=j*N+k;s=j*N+(k+1)%N;faces.append((q,s,s+N,q+N))
|
||||
faces.append(tuple(reversed(range(N))));faces.append(tuple((len(profile)-1)*N+k for k in range(N)))
|
||||
mesh_obj('Pine_Rounded_Branches',verts,faces,green)
|
||||
# Smooth snow mantle follows the tier, rolling down at the edge in rounded lobes.
|
||||
verts=[];faces=[]
|
||||
for j in range(13):
|
||||
t=j/12
|
||||
r=radius*.91*(1-t)**.9+.035
|
||||
for k in range(N):
|
||||
a=k*math.tau/N;lobes=.5+.5*math.sin(5*a+idx*.8+tier)
|
||||
z=base+.43+height*.91*t-.25*lobes*(1-t)**5
|
||||
rr=r*(1+.035*math.sin(5*a+idx)*(1-t))
|
||||
verts.append((pos.x+rr*math.cos(a),pos.y+rr*math.sin(a),z))
|
||||
for j in range(12):
|
||||
for k in range(N):q=j*N+k;s=j*N+(k+1)%N;faces.append((q,s,s+N,q+N))
|
||||
faces.append(tuple(reversed(range(N))));faces.append(tuple(12*N+k for k in range(N)))
|
||||
o=mesh_obj('Pine_Soft_Snow_Mantle',verts,faces,snow)
|
||||
bevel=o.modifiers.new('Round snow lips','BEVEL');bevel.width=.13;bevel.segments=3
|
||||
path=os.path.join(folder,'map_refined_trees.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Refined trees:',len(positions),'height 12.1, visible trunk 2.5, radial segments 48.',path)
|
||||
@@ -0,0 +1,27 @@
|
||||
import bpy, os
|
||||
sc=bpy.context.scene
|
||||
targets=[o for o in sc.objects if o.type=='MESH' and o.name.endswith('_Fence')]
|
||||
m=bpy.data.materials.new('Fence_Warm_Cedar_Subtle'); m.use_nodes=True
|
||||
n=m.node_tree.nodes; n.clear(); l=m.node_tree.links
|
||||
out=n.new('ShaderNodeOutputMaterial'); p=n.new('ShaderNodeBsdfPrincipled')
|
||||
p.inputs['Roughness'].default_value=.65
|
||||
p.inputs['Specular IOR Level'].default_value=.28
|
||||
l.new(p.outputs['BSDF'],out.inputs['Surface'])
|
||||
uv=n.new('ShaderNodeTexCoord'); scale=n.new('ShaderNodeVectorMath'); scale.operation='MULTIPLY'
|
||||
scale.inputs[1].default_value=(18,1.3,1); l.new(uv.outputs['UV'],scale.inputs[0])
|
||||
noise=n.new('ShaderNodeTexNoise'); noise.inputs['Scale'].default_value=2
|
||||
noise.inputs['Detail'].default_value=1.3; noise.inputs['Roughness'].default_value=.35
|
||||
l.new(scale.outputs[0],noise.inputs['Vector'])
|
||||
r=n.new('ShaderNodeValToRGB'); r.color_ramp.interpolation='EASE'
|
||||
r.color_ramp.elements[0].position=.18; r.color_ramp.elements[0].color=(.275,.105,.058,1)
|
||||
r.color_ramp.elements[1].position=.82; r.color_ramp.elements[1].color=(.32,.132,.076,1)
|
||||
l.new(noise.outputs['Fac'],r.inputs[0]); l.new(r.outputs['Color'],p.inputs['Base Color'])
|
||||
b=n.new('ShaderNodeBump'); b.inputs['Strength'].default_value=.065; b.inputs['Distance'].default_value=.008
|
||||
l.new(noise.outputs['Fac'],b.inputs['Height']); l.new(b.outputs[0],p.inputs['Normal'])
|
||||
m.diffuse_color=(.30,.12,.067,1)
|
||||
for o in targets:
|
||||
o.data.materials.clear(); o.data.materials.append(m)
|
||||
for f in o.data.polygons: f.material_index=0
|
||||
path=os.path.join(os.path.dirname(bpy.data.filepath),'map_terrain_cedar.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Updated',len(targets),'fences;',path)
|
||||
@@ -0,0 +1,84 @@
|
||||
import bpy, math, os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene
|
||||
root=next(c for c in sc.collection.children if c.name.startswith('Spirit_Winter_Model'))
|
||||
# Work on an independent scene and independent meshes.
|
||||
original=sc
|
||||
sc=bpy.data.scenes.new('Spirit_Winter_Refined')
|
||||
for obj in original.objects:
|
||||
cp=obj.copy()
|
||||
if obj.data: cp.data=obj.data.copy()
|
||||
sc.collection.objects.link(cp)
|
||||
bpy.context.window.scene=sc
|
||||
sc.world=original.world.copy()
|
||||
def find(prefix): return [o for o in sc.objects if o.name.startswith('SW_'+prefix)]
|
||||
white=find('Hood')[0].data.materials[0]
|
||||
ice=find('Hood_lower')[0].data.materials[0]
|
||||
def cube(name,loc,size,material,angle=0):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=loc)
|
||||
o=bpy.context.object; o.name=name; o.dimensions=size
|
||||
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
||||
o.rotation_euler[1]=angle; o.data.materials.append(material)
|
||||
m=o.modifiers.new('Edge highlights','BEVEL'); m.width=.035; m.segments=2
|
||||
o.modifiers.new('Normals','WEIGHTED_NORMAL')
|
||||
return o
|
||||
for o in list(sc.objects):
|
||||
if o.name.startswith(('SW_Hood','SW_Shoulder')): sc.collection.objects.unlink(o)
|
||||
for sign in (-1,1):
|
||||
for x,z in [(.72,4.1),(.87,4.36),(.94,4.64),(.88,4.92),(.72,5.17),(.46,5.35),(.16,5.44)]:
|
||||
cube('IceHood',(sign*x,-.07,z),(.45,.9,.4),white)
|
||||
for x,z,w,ang in [(1.12,3.87,1.15,-.16),(1.62,3.83,.95,-.12),(1.12,4.07,.95,-.4),(1.65,4.2,.75,-.45),(2.0,3.67,.65,0)]:
|
||||
cube('IceShoulder',(sign*x,.08,z),(w,.65,.29),white,sign*ang)
|
||||
cube('ShoulderUnderside',(sign*1.55,.2,3.53),(1.4,.67,.22),ice)
|
||||
for o in find('Face'):
|
||||
o.scale.x=.93; o.scale.z=.88
|
||||
for o in find('Eye'): o.scale*=.8
|
||||
for o in find('Robe')+find('Lapel'):
|
||||
o.location.z=3.35+(o.location.z-3.35)*.76
|
||||
o.scale.z*=.78
|
||||
o.location.x*=1.09; o.scale.x*=1.1
|
||||
for o in find('Tail'):
|
||||
for v in o.data.vertices: v.co.z=3.35+(v.co.z-3.35)*.76
|
||||
for o in find('Chest_frame'): o.scale*=.78
|
||||
for o in find('Chest_crystal'):
|
||||
for v in o.data.vertices:
|
||||
v.co.x*=.8; v.co.z=3.49+(v.co.z-3.49)*.8
|
||||
for o in find('Forehead'):
|
||||
for v in o.data.vertices:
|
||||
v.co.x*=.77; v.co.z=5.44+(v.co.z-5.44)*.8
|
||||
for o in find('Cap')+find('Neck'):
|
||||
o.location.z-=.27
|
||||
for o in find('GoldenHook'):
|
||||
for sp in o.data.splines:
|
||||
for p in sp.points:
|
||||
p.co.x*=.78; p.co.z=6.08+(p.co.z-6.35)*.78
|
||||
o.data.bevel_depth=.09
|
||||
# Copy materials so previous versions retain their original appearance.
|
||||
mapping={}
|
||||
for o in sc.objects:
|
||||
if o.type not in ('MESH','CURVE'): continue
|
||||
for slot in o.material_slots:
|
||||
m=slot.material
|
||||
if not m: continue
|
||||
if m.name not in mapping:
|
||||
cp=m.copy(); mapping[m.name]=cp
|
||||
p=next(n for n in cp.node_tree.nodes if n.type=='BSDF_PRINCIPLED')
|
||||
if 'Cyan' in m.name: p.inputs['Emission Strength'].default_value=.08
|
||||
if 'Snow' in m.name: p.inputs['Base Color'].default_value=(.56,.69,.9,1)
|
||||
p.inputs['Roughness'].default_value=.3
|
||||
slot.material=mapping[m.name]
|
||||
for o in sc.objects:
|
||||
if o.type=='LIGHT': o.data.energy*=.42
|
||||
cam=next(o for o in sc.objects if o.type=='CAMERA'); sc.camera=cam
|
||||
cam.location=(.15,-18,4.8)
|
||||
cam.rotation_euler=(Vector((0,0,3.85))-cam.location).to_track_quat('-Z','Y').to_euler()
|
||||
cam.data.ortho_scale=7.2
|
||||
sc.render.engine='CYCLES'; sc.cycles.samples=48; sc.cycles.use_denoising=True
|
||||
sc.view_settings.view_transform='AgX'
|
||||
sc.render.resolution_x=900; sc.render.resolution_y=1100; sc.render.resolution_percentage=100
|
||||
sc.render.image_settings.file_format='PNG'
|
||||
out=r'C:\roblox\Ornament Generator RNG\blender\spirit_winter_refined'
|
||||
sc.render.filepath=out+'.png'
|
||||
bpy.ops.wm.save_as_mainfile(filepath=out+'.blend')
|
||||
bpy.ops.render.render(write_still=True)
|
||||
print(sc.render.filepath)
|
||||
@@ -0,0 +1,54 @@
|
||||
import bpy, os
|
||||
from mathutils import Vector
|
||||
src=bpy.context.scene
|
||||
sc=bpy.data.scenes.new('Spirit_No_Intersections')
|
||||
for o in src.objects:
|
||||
cp=o.copy()
|
||||
if o.data: cp.data=o.data.copy()
|
||||
sc.collection.objects.link(cp)
|
||||
bpy.context.window.scene=sc
|
||||
sc.world=src.world
|
||||
sc.camera=next(o for o in sc.objects if o.type=='CAMERA')
|
||||
meshes=[]
|
||||
for o in list(sc.objects):
|
||||
if o.type!='MESH': continue
|
||||
bpy.context.view_layer.objects.active=o
|
||||
o.select_set(True)
|
||||
# Recalculate coherent face winding before exact solid operations.
|
||||
import bmesh
|
||||
bm=bmesh.new(); bm.from_mesh(o.data)
|
||||
bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces)); bm.to_mesh(o.data); bm.free()
|
||||
for m in list(o.modifiers):
|
||||
if m.type=='WEIGHTED_NORMAL': o.modifiers.remove(m)
|
||||
else:
|
||||
try: bpy.ops.object.modifier_apply(modifier=m.name)
|
||||
except RuntimeError: pass
|
||||
o.select_set(False); meshes.append(o)
|
||||
def bounds(o):
|
||||
pts=[o.matrix_world@Vector(p) for p in o.bound_box]
|
||||
return ([min(p[i] for p in pts) for i in range(3)],[max(p[i] for p in pts) for i in range(3)])
|
||||
bpy.context.view_layer.update()
|
||||
# Frontmost details retain their shapes; the covered geometry is trimmed away.
|
||||
meshes.sort(key=lambda o:bounds(o)[0][1])
|
||||
count=0
|
||||
for i,o in enumerate(meshes):
|
||||
a,b=bounds(o)
|
||||
for cutter in meshes[:i]:
|
||||
c,d=bounds(cutter)
|
||||
if not all(min(b[k],d[k])-max(a[k],c[k])>.002 for k in range(3)): continue
|
||||
mod=o.modifiers.new('Remove internal intersection','BOOLEAN')
|
||||
mod.operation='DIFFERENCE'; mod.solver='EXACT'; mod.object=cutter
|
||||
bpy.context.view_layer.objects.active=o
|
||||
try:
|
||||
bpy.ops.object.modifier_apply(modifier=mod.name); count+=1
|
||||
except RuntimeError:
|
||||
o.modifiers.remove(mod)
|
||||
sc.render.engine='CYCLES'; sc.cycles.samples=48; sc.cycles.use_denoising=True
|
||||
sc.view_settings.view_transform='AgX'
|
||||
sc.render.resolution_x=900; sc.render.resolution_y=1100; sc.render.resolution_percentage=100
|
||||
out=r'C:\roblox\Ornament Generator RNG\blender\spirit_clean'
|
||||
sc.render.image_settings.file_format='PNG'; sc.render.filepath=out+'.png'
|
||||
bpy.ops.wm.save_as_mainfile(filepath=out+'.blend')
|
||||
bpy.ops.render.render(write_still=True)
|
||||
print('Trim operations:',count)
|
||||
print(out)
|
||||
@@ -0,0 +1,22 @@
|
||||
import bpy,os
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_large_nameplates.blend'),copy=True)
|
||||
roots=[o for o in sc.objects if o.type=='EMPTY' and o.name.startswith('Zone_') and o.name.endswith('_Nameplate')]
|
||||
for root in roots:
|
||||
# Board width ~11, height ~3.2; bottom at 7, above normal six-unit fences.
|
||||
for o in root.children:
|
||||
if o.name.startswith('Sign_Post'):
|
||||
o.location.x*=2.0
|
||||
o.location.z=5.15
|
||||
o.scale.x*=1.7;o.scale.y*=1.7;o.scale.z*=10.3/3.6
|
||||
else:
|
||||
o.location.x*=1.7;o.location.y*=1.5
|
||||
o.location.z=7+(o.location.z-2.1)*1.6
|
||||
o.scale.x*=1.7;o.scale.y*=1.5;o.scale.z*=1.6
|
||||
if o.name.startswith('Post_Snow'):
|
||||
o.location.x=5.4 if o.location.x>0 else -5.4
|
||||
o.location.z=10.4
|
||||
root['board_width']=11.22;root['board_bottom_height']=7.0
|
||||
path=os.path.join(folder,'map_large_nameplates.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Enlarged',len(roots),'nameplates; board bottom 7, top 10.2; width 11.2.',path)
|
||||
@@ -0,0 +1,20 @@
|
||||
"""Send a Python file to the running Blender (Blender Lab MCP add-on on localhost:9876) and print the reply.
|
||||
|
||||
Usage: python send.py script.py
|
||||
"""
|
||||
import json
|
||||
import socket
|
||||
import sys
|
||||
|
||||
code = open(sys.argv[1], encoding="utf-8").read()
|
||||
payload = (json.dumps({"type": "execute", "code": code, "strict_json": False}) + "\0").encode("utf-8")
|
||||
with socket.create_connection(("localhost", 9876), timeout=600) as s:
|
||||
s.sendall(payload)
|
||||
buf = bytearray()
|
||||
while b"\0" not in buf:
|
||||
chunk = s.recv(65536)
|
||||
if not chunk:
|
||||
break
|
||||
buf.extend(chunk)
|
||||
end = buf.index(b"\0") if b"\0" in buf else len(buf)
|
||||
print(json.dumps(json.loads(bytes(buf[:end])), ensure_ascii=False, indent=1))
|
||||
@@ -0,0 +1,44 @@
|
||||
import bpy, math, os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene
|
||||
old=bpy.data.collections.get('Snow_Posts_Repaired')
|
||||
new=bpy.data.collections.new('Snow_Draped_Reference');sc.collection.children.link(new)
|
||||
count=0
|
||||
for idx,o in enumerate(list(old.objects)):
|
||||
if o.hide_render:continue
|
||||
points=[v.co for v in o.data.vertices]
|
||||
a=(max(v.x for v in points)-min(v.x for v in points))/2
|
||||
b=(max(v.y for v in points)-min(v.y for v in points))/2
|
||||
h=(max(v.z for v in points)-min(v.z for v in points))/2
|
||||
narrow=min(a,b)<.6
|
||||
N=64;R=24;verts=[(0,0,h*1.35)];faces=[]
|
||||
# Drops belong to the same watertight mesh as the dome.
|
||||
for j in range(1,R):
|
||||
t=math.pi*j/R; radius=math.sin(t)
|
||||
for i in range(N):
|
||||
ang=2*math.pi*i/N
|
||||
dips=0
|
||||
for az,amp,width in [(0.3,.55,.23),(1.8,.38,.27),(3.4,.85,.22),(4.9,.5,.25)]:
|
||||
diff=math.atan2(math.sin(ang-az-idx*.37),math.cos(ang-az-idx*.37))
|
||||
dips+=amp*math.exp(-.5*(diff/width)**2)
|
||||
rim=math.exp(-.5*((t-1.92)/.38)**2)
|
||||
drop=dips*(.3 if narrow else min(a,b)*.65)*rim
|
||||
verts.append((a*radius*math.cos(ang),b*radius*math.sin(ang),h*1.25*math.cos(t)-drop))
|
||||
bottom=len(verts);verts.append((0,0,-h*1.25))
|
||||
for i in range(N):faces.append((0,1+i,1+(i+1)%N))
|
||||
for j in range(R-2):
|
||||
for i in range(N):
|
||||
q=1+j*N+i;r=1+j*N+(i+1)%N
|
||||
faces.append((q,r,r+N,q+N))
|
||||
start=1+(R-2)*N
|
||||
for i in range(N):faces.append((start+i,bottom,start+(i+1)%N))
|
||||
me=bpy.data.meshes.new('SnowContinuous');me.from_pydata(verts,[],faces);me.update()
|
||||
import bmesh
|
||||
bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces));bm.to_mesh(me);bm.free()
|
||||
ob=bpy.data.objects.new('Snow_Drape_%03d'%idx,me);new.objects.link(ob);ob.matrix_world=o.matrix_world.copy()
|
||||
for m in o.data.materials:me.materials.append(m)
|
||||
for p in me.polygons:p.use_smooth=True
|
||||
o.hide_render=True;o.hide_set(True);count+=1
|
||||
path=os.path.join(os.path.dirname(bpy.data.filepath),'map_terrain_snow_draped.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Continuous draped caps:',count,path)
|
||||
@@ -0,0 +1,42 @@
|
||||
import bpy,math,random,os,bmesh
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_terrain_drifts.blend'),copy=True)
|
||||
coll=bpy.data.collections.new('Landscape_Snowdrifts');sc.collection.children.link(coll)
|
||||
mat=bpy.data.materials.get('Snow_Full_Soft') or bpy.data.materials.get('Snow')
|
||||
rng=random.Random(814)
|
||||
def hill(x,y,rx,ry,h,angle,index):
|
||||
N=32;R=10;verts=[(x,y,h-.1)];faces=[]
|
||||
for j in range(1,R+1):
|
||||
r=j/R
|
||||
for k in range(N):
|
||||
a=k*math.tau/N
|
||||
edge=1+.10*math.sin(3*a+index)+.055*math.cos(5*a-index)
|
||||
u=math.cos(a)*rx*r*edge;v=math.sin(a)*ry*r*edge
|
||||
z=h*(1-r*r)**2-.10
|
||||
z+=h*.09*math.sin(a*2+index)*r*(1-r)
|
||||
verts.append((x+u*math.cos(angle)-v*math.sin(angle),y+u*math.sin(angle)+v*math.cos(angle),z))
|
||||
for k in range(N):faces.append((0,k+1,(k+1)%N+1))
|
||||
for j in range(R-1):
|
||||
for k in range(N):
|
||||
a=1+j*N+k;b=1+j*N+(k+1)%N;faces.append((a,a+N,b+N,b))
|
||||
faces.append(tuple(reversed([1+(R-1)*N+k for k in range(N)])))
|
||||
me=bpy.data.meshes.new('SoftSnowHill');me.from_pydata(verts,[],faces);me.update()
|
||||
bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces));bm.to_mesh(me);bm.free()
|
||||
o=bpy.data.objects.new('Landscape_Drift_%02d'%index,me);coll.objects.link(o)
|
||||
if mat:me.materials.append(mat)
|
||||
for p in me.polygons:p.use_smooth=True
|
||||
idx=0
|
||||
for sector in range(10):
|
||||
# Outside the plots, raised snowy banks follow the island perimeter.
|
||||
a=sector*math.tau/10+.10
|
||||
r=123+rng.uniform(-2,2)
|
||||
hill(-math.sin(a)*r,math.cos(a)*r,rng.uniform(9,12),rng.uniform(4.5,6.5),rng.uniform(1.6,2.8),a,idx);idx+=1
|
||||
# In the open wedges between radial paths, below the plot ring.
|
||||
a=(sector+.5)*math.tau/10;r=59+rng.uniform(-3,3)
|
||||
hill(-math.sin(a)*r,math.cos(a)*r,rng.uniform(4,5.5),rng.uniform(6,8),rng.uniform(1.0,1.8),a,idx);idx+=1
|
||||
# Smaller bank outside each plot corner, avoiding its gate.
|
||||
a=(sector+.48)*math.tau/10;r=112
|
||||
hill(-math.sin(a)*r,math.cos(a)*r,4.5,6.0,rng.uniform(1.1,1.9),a,idx);idx+=1
|
||||
path=os.path.join(folder,'map_landscape_snow.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Added',len(coll.objects),'smooth landscape snowdrifts. Saved',path)
|
||||
@@ -0,0 +1,57 @@
|
||||
import bpy, numpy as np, os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene
|
||||
targets=[o for o in sc.objects if o.type=='MESH' and o.name.endswith('_Fence')]
|
||||
m=bpy.data.materials.new('Fence_Wood_Stylized_Honey'); m.use_nodes=True
|
||||
n=m.node_tree.nodes; n.clear(); l=m.node_tree.links
|
||||
out=n.new('ShaderNodeOutputMaterial'); p=n.new('ShaderNodeBsdfPrincipled'); p.inputs['Roughness'].default_value=.76
|
||||
l.new(p.outputs['BSDF'],out.inputs['Surface'])
|
||||
uv=n.new('ShaderNodeTexCoord'); scale=n.new('ShaderNodeVectorMath'); scale.operation='MULTIPLY'; scale.inputs[1].default_value=(5,.65,1); l.new(uv.outputs['UV'],scale.inputs[0])
|
||||
noise=n.new('ShaderNodeTexNoise'); noise.inputs['Scale'].default_value=2.8; noise.inputs['Detail'].default_value=1.0; noise.inputs['Roughness'].default_value=.4; l.new(scale.outputs[0],noise.inputs['Vector'])
|
||||
r=n.new('ShaderNodeValToRGB'); r.color_ramp.interpolation='CONSTANT'
|
||||
colors=[(.0,(.19,.065,.021,1)),(.32,(.32,.12,.039,1)),(.43,(.46,.20,.075,1)),(.55,(.6,.30,.12,1)),(.68,(.72,.4,.19,1))]
|
||||
r.color_ramp.elements.remove(r.color_ramp.elements[1])
|
||||
for i,(pos,col) in enumerate(colors):
|
||||
e=r.color_ramp.elements[0] if i==0 else r.color_ramp.elements.new(pos); e.position=pos; e.color=col
|
||||
l.new(noise.outputs['Fac'],r.inputs[0]); l.new(r.outputs['Color'],p.inputs['Base Color'])
|
||||
bump=n.new('ShaderNodeBump'); bump.inputs['Strength'].default_value=.12; bump.inputs['Distance'].default_value=.025
|
||||
l.new(noise.outputs['Fac'],bump.inputs['Height']); l.new(bump.outputs[0],p.inputs['Normal'])
|
||||
m.diffuse_color=(.55,.27,.095,1)
|
||||
count=0
|
||||
for o in targets:
|
||||
mesh=o.data.copy(); o.data=mesh
|
||||
adj=[[] for v in mesh.vertices]
|
||||
for e in mesh.edges:
|
||||
a,b=e.vertices; adj[a].append(b); adj[b].append(a)
|
||||
seen=set(); coords={}
|
||||
for seed in range(len(mesh.vertices)):
|
||||
if seed in seen: continue
|
||||
stack=[seed]; seen.add(seed); ids=[]
|
||||
while stack:
|
||||
v=stack.pop(); ids.append(v)
|
||||
for j in adj[v]:
|
||||
if j not in seen: seen.add(j); stack.append(j)
|
||||
points=np.array([mesh.vertices[j].co[:] for j in ids]); center=points.mean(axis=0)
|
||||
vals,axes=np.linalg.eigh((points-center).T@(points-center))
|
||||
axis=axes[:,-1]; cross=axes[:,-2]; other=axes[:,0]
|
||||
projected=(points-center)@np.column_stack((cross,other,axis))
|
||||
extent=np.ptp(projected,axis=0); extent=np.maximum(extent,.001)
|
||||
for j,q in zip(ids,projected): coords[j]=(q,extent)
|
||||
count+=1
|
||||
layer=mesh.uv_layers.new(name='Wood_Along_Beam')
|
||||
for poly in mesh.polygons:
|
||||
# Choose the transverse projection with greatest span on this face.
|
||||
qs=[coords[mesh.loops[k].vertex_index][0] for k in poly.loop_indices]
|
||||
transverse=0 if np.ptp(np.array(qs)[:,0])>=np.ptp(np.array(qs)[:,1]) else 1
|
||||
for k in poly.loop_indices:
|
||||
q,ext=coords[mesh.loops[k].vertex_index]
|
||||
layer.data[k].uv=(float(q[transverse]/ext[transverse]+.5),float(q[2]/ext[2]+.5))
|
||||
mesh.uv_layers.active=layer
|
||||
mesh.materials.clear(); mesh.materials.append(m)
|
||||
for poly in mesh.polygons: poly.material_index=0
|
||||
for screen in bpy.data.screens:
|
||||
for area in screen.areas:
|
||||
if area.type=='VIEW_3D': area.spaces.active.shading.type='MATERIAL'
|
||||
path=os.path.join(os.path.dirname(bpy.data.filepath),'map_terrain_wood.blend')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Textured fences:',len(targets),'wood components:',count,'saved:',path)
|
||||
@@ -0,0 +1,19 @@
|
||||
import bpy,bmesh,os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;o=sc.objects.get('Island');assert o and o.type=='MESH'
|
||||
folder=os.path.dirname(bpy.data.filepath)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_island_trim.blend'),copy=True)
|
||||
o.data=o.data.copy()
|
||||
world=[o.matrix_world@v.co for v in o.data.vertices]
|
||||
lo=min(p.z for p in world);hi=max(p.z for p in world)
|
||||
cut=hi-(hi-lo)*.16
|
||||
inv=o.matrix_world.inverted();point=inv@Vector((0,0,cut));normal=o.matrix_world.to_3x3().transposed()@Vector((0,0,1));normal.normalize()
|
||||
bm=bmesh.new();bm.from_mesh(o.data)
|
||||
res=bmesh.ops.bisect_plane(bm,geom=list(bm.verts)+list(bm.edges)+list(bm.faces),dist=.0001,plane_co=point,plane_no=normal,clear_inner=True,clear_outer=False)
|
||||
edges=[e for e in bm.edges if e.is_boundary and all(abs((o.matrix_world@v.co).z-cut)<.002 for v in e.verts)]
|
||||
filled=bmesh.ops.holes_fill(bm,edges=edges,sides=0)
|
||||
for f in filled['faces']:f.material_index=1 if len(o.data.materials)>1 else 0
|
||||
bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces));bm.to_mesh(o.data);bm.free();o.data.update()
|
||||
assert min((o.matrix_world@v.co).z for v in o.data.vertices)>=cut-.01
|
||||
path=os.path.join(folder,'map_trimmed_island.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Previous Z range',lo,hi,'new bottom',cut,'bottom faces',len(filled['faces']),'saved',path)
|
||||
@@ -0,0 +1,53 @@
|
||||
import bpy,math,os
|
||||
from mathutils import Vector
|
||||
sc=bpy.context.scene;folder=os.path.dirname(bpy.data.filepath)
|
||||
fences=sorted([o for o in sc.objects if o.name.startswith('Zone_') and o.name.endswith('_Fence')],key=lambda o:o.name)
|
||||
assert len(fences)==10,'Expected 10 zone fences'
|
||||
wood=fences[0].data.materials[0]
|
||||
snow=bpy.data.materials.get('Snow_Full_Soft') or bpy.data.materials.get('Snow_Soft')
|
||||
assert wood and snow
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(folder,'map_before_nameplates.blend'),copy=True)
|
||||
coll=bpy.data.collections.new('Zone_Player_Nameplates');sc.collection.children.link(coll)
|
||||
letters=bpy.data.materials.new('Nameplate_Cream_Letters');letters.diffuse_color=(1,.93,.72,1)
|
||||
letters.use_nodes=True;p=next(n for n in letters.node_tree.nodes if n.type=='BSDF_PRINCIPLED');p.inputs['Base Color'].default_value=(1,.93,.72,1);p.inputs['Roughness'].default_value=.7
|
||||
def box(name,loc,size,mat,parent):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=loc);o=bpy.context.object;o.name=name;o.dimensions=size
|
||||
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
coll.objects.link(o);o.parent=parent;o.data.materials.append(mat)
|
||||
b=o.modifiers.new('Soft wooden edges','BEVEL');b.width=.09;b.segments=3
|
||||
return o
|
||||
for i,fence in enumerate(fences):
|
||||
a=i*math.tau/10;d=Vector((-math.sin(a),math.cos(a),0));side=Vector((math.cos(a),math.sin(a),0))
|
||||
# Infer the entry distance from the fence's world vertices, rather than assuming the map scale.
|
||||
pts=[fence.matrix_world@v.co for v in fence.data.vertices]
|
||||
entry=min(v.dot(d) for v in pts)
|
||||
root=bpy.data.objects.new('Zone_%02d_Nameplate'%(i+1),None);coll.objects.link(root)
|
||||
for x in (-2.7,2.7):box('Sign_Post',(x,0,1.8),(.4,.5,3.6),wood,root)
|
||||
box('Player_Name_Board',(0,-.06,3.1),(6.4,.48,1.9),wood,root)
|
||||
# Text is editable for future replacement with player names in game.
|
||||
data=bpy.data.curves.new('Player_Name','FONT');data.body='PLAYER NAME';data.align_x='CENTER';data.align_y='CENTER';data.size=.60;data.extrude=.018;data.bevel_depth=.006
|
||||
text=bpy.data.objects.new('Zone_%02d_PlayerName'%(i+1),data);coll.objects.link(text);text.parent=root;text.location=(0,-.32,3.1);text.rotation_euler.x=math.pi/2;data.materials.append(letters)
|
||||
# Continuous smooth snow cap with rounded uneven hanging lobes.
|
||||
N=48;R=16;verts=[(0,0,.34)];faces=[]
|
||||
for j in range(1,R):
|
||||
t=math.pi*j/R
|
||||
for k in range(N):
|
||||
ang=k*math.tau/N;r=math.sin(t)
|
||||
drop=(.5+.5*math.cos(5*ang+i*.6))*.2*math.exp(-((t-1.9)/.43)**2)
|
||||
verts.append((3.38*r*math.cos(ang),.44*r*math.sin(ang),.34*math.cos(t)-drop))
|
||||
bot=len(verts);verts.append((0,0,-.34))
|
||||
for k in range(N):faces.append((0,1+k,1+(k+1)%N))
|
||||
for j in range(R-2):
|
||||
for k in range(N):
|
||||
q=1+j*N+k;r=1+j*N+(k+1)%N;faces.append((q,r,r+N,q+N))
|
||||
for k in range(N):faces.append((1+(R-2)*N+k,bot,1+(R-2)*N+(k+1)%N))
|
||||
me=bpy.data.meshes.new('Nameplate_Snow');me.from_pydata(verts,[],faces);me.update()
|
||||
import bmesh
|
||||
bm=bmesh.new();bm.from_mesh(me);bmesh.ops.recalc_face_normals(bm,faces=list(bm.faces));bm.to_mesh(me);bm.free()
|
||||
o=bpy.data.objects.new('Nameplate_SnowCap',me);coll.objects.link(o);o.parent=root;o.location=(0,-.06,4.12);me.materials.append(snow)
|
||||
for p in me.polygons:p.use_smooth=True
|
||||
root.location=d*(entry-2.0)+side*9.0;root.rotation_euler.z=a
|
||||
root['zone_id']=i+1;root['player_name_placeholder']='PLAYER NAME'
|
||||
path=os.path.join(folder,'map_zone_nameplates.blend');bpy.ops.wm.save_as_mainfile(filepath=path)
|
||||
print('Created',len(fences),'nameplates. Wood:',wood.name,'Snow:',snow.name,'Saved:',path)
|
||||
Reference in new issue
Block a user