Update
This commit is contained in:
commit
2d6a8a867d
1093 files changed
+2424571
No files matched your search
@@ -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)
|
||||
Reference in new issue
Block a user