12
This commit is contained in:
1 parent
ff796c9c6f
commit
1161e51690
29 files changed
+985
-1
No files matched your search
@@ -0,0 +1,111 @@
|
||||
import bpy, math, os, json
|
||||
from mathutils import Vector
|
||||
OUT=os.path.dirname(os.path.abspath(__file__))
|
||||
bpy.ops.object.select_all(action='SELECT');bpy.ops.object.delete(use_global=False)
|
||||
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=.4;p.inputs['Metallic'].default_value=metal;p.inputs['Emission Color'].default_value=(*c,1);p.inputs['Emission Strength'].default_value=emit
|
||||
return m
|
||||
wood=mat('Warm stylized wood',(.30,.12,.055));green=mat('Deep emerald board',(.012,.105,.075));gold=mat('Golden frame',(.85,.43,.035),.65);red=mat('Christmas red',(.65,.012,.025));pine=mat('Pine greenery',(.035,.19,.025));snow=mat('Smooth snow',(.9,.95,1));light=mat('Warm bulbs',(1,.65,.18),0,3)
|
||||
root=bpy.data.objects.new('Leaderboard_ROOT',None);bpy.context.collection.objects.link(root)
|
||||
def setup(o,n,m):
|
||||
o.name=n;o.parent=root;o.data.materials.append(m);return o
|
||||
def box(n,p,s,m,b=.05):
|
||||
bpy.ops.mesh.primitive_cube_add(size=1,location=p);o=bpy.context.object;o.dimensions=s;bpy.ops.object.transform_apply(location=False,rotation=False,scale=True);setup(o,n,m)
|
||||
if b:
|
||||
mod=o.modifiers.new('Soft edges','BEVEL');mod.width=b;mod.segments=3;o.modifiers.new('Weighted normals','WEIGHTED_NORMAL')
|
||||
return o
|
||||
def ball(n,p,s,m):
|
||||
bpy.ops.mesh.primitive_uv_sphere_add(segments=24,ring_count=12,location=p);o=bpy.context.object;o.scale=s;setup(o,n,m)
|
||||
for f in o.data.polygons:f.use_smooth=True
|
||||
return o
|
||||
def curve(n,pts,r,m):
|
||||
c=bpy.data.curves.new(n,'CURVE');c.dimensions='3D';c.bevel_depth=r;c.bevel_resolution=3;s=c.splines.new('POLY');s.points.add(len(pts)-1)
|
||||
for p,v in zip(s.points,pts):p.co=(*v,1)
|
||||
o=bpy.data.objects.new(n,c);bpy.context.collection.objects.link(o);return setup(o,n,m)
|
||||
def snowcap(n,cx,cy,z,rx,ry,h):
|
||||
# Smooth single continuous cap, asymmetrical gently draped perimeter.
|
||||
vs=[(cx,cy,z+h)];fs=[];N=64;R=10
|
||||
for k in range(1,R+1):
|
||||
t=k/R
|
||||
for j in range(N):
|
||||
a=j*math.tau/N;wave=.04*math.sin(5*a)+.025*math.cos(9*a)
|
||||
zz=z+h*math.sqrt(max(0,1-t*t))-(.06+.08*(.5+.5*math.sin(5*a+.4)))*t**6
|
||||
vs.append((cx+rx*t*(1+wave)*math.cos(a),cy+ry*t*(1+wave)*math.sin(a),zz))
|
||||
for j in range(N):fs.append((0,1+j,1+(j+1)%N))
|
||||
for k in range(R-1):
|
||||
for j in range(N):
|
||||
a=1+k*N+j;b=1+k*N+(j+1)%N;fs.append((a,a+N,b+N,b))
|
||||
me=bpy.data.meshes.new(n);me.from_pydata(vs,[],fs);me.update();o=bpy.data.objects.new(n,me);bpy.context.collection.objects.link(o);setup(o,n,snow)
|
||||
mod=o.modifiers.new('Snow thickness','SOLIDIFY');mod.thickness=.09
|
||||
for f in me.polygons:f.use_smooth=True
|
||||
return o
|
||||
# Overall size about 9.8 wide, 9.3 high. Board starts 0.45 above ground.
|
||||
for x in (-4.45,4.45):
|
||||
box('Wood post',(x,0,4.25),(.64,.72,8.5),wood)
|
||||
box('Post foot',(x,0,.17),(.86,.92,.34),wood)
|
||||
box('Post capital',(x,0,8.32),(.86,.94,.22),wood)
|
||||
snowcap('Smooth post snow',x,0,8.49,.55,.59,.26)
|
||||
for z in (1.2,7.7):box('Rear crossbeam',(0,.18,z),(9.05,.30,.32),wood)
|
||||
box('Board backing',(0,0,4.4),(8.1,.34,7.9),green)
|
||||
# Dedicated flat uninterrupted front mesh for Roblox SurfaceGui.
|
||||
box('Leaderboard_Display',(0,-.195,4.4),(7.55,.045,7.35),green,.0)
|
||||
for x in (-4.04,4.04):box('Gold vertical frame',(x,-.18,4.4),(.19,.36,7.95),gold)
|
||||
for z in (.45,8.35):box('Gold horizontal frame',(0,-.18,z),(8.25,.36,.20),gold)
|
||||
for x in (-3.92,3.92):
|
||||
for i in range(11):
|
||||
z=.82+i*.71
|
||||
box('Bulb socket',(x,-.40,z),(.095,.10,.12),gold,.02)
|
||||
ball('Warm fairy light',(x,-.475,z),(.062,.06,.075),light)
|
||||
for z in (.60,8.19):
|
||||
for i in range(10):
|
||||
x=-3.5+i*7/9
|
||||
ball('Warm fairy light',(x,-.45,z),(.065,.06,.065),light)
|
||||
# Snow stays on top of rim rather than obscuring display.
|
||||
snowcap('Long smooth snow cap',0,0,8.47,4.16,.40,.25)
|
||||
for sign in (-1,1):
|
||||
for i in range(5):
|
||||
o=box('Pine sprig',(sign*(.48+i*.30),-.18,8.75+.08*math.sin(i)),(.85,.20,.22),pine,.05);o.rotation_euler.y=sign*(.2+i*.15)
|
||||
# Ribbon loops formed as continuous curved ribbons, with actual openings.
|
||||
vs=[];fs=[];N=40
|
||||
for i in range(N+1):
|
||||
a=i*math.tau/N
|
||||
x=sign*(.13+.95*(1-math.cos(a))/2);y=-.43-.24*math.sin(a);z=8.82+.36*(1-math.cos(a))/2
|
||||
for d in (-1,1):vs.append((x,y,z+d*(.11+.15*(1-math.cos(a))/2)))
|
||||
for i in range(N):fs.append((2*i,2*i+1,2*i+3,2*i+2))
|
||||
me=bpy.data.meshes.new('Ribbon loop');me.from_pydata(vs,[],fs);me.update();o=bpy.data.objects.new('Red bow loop',me);bpy.context.collection.objects.link(o);setup(o,o.name,red)
|
||||
mod=o.modifiers.new('Ribbon thickness','SOLIDIFY');mod.thickness=.045
|
||||
for p in me.polygons:p.use_smooth=True
|
||||
o=box('Red bow tail',(sign*.3,-.42,8.48),(.30,.10,.65),red,.04);o.rotation_euler.y=sign*-.30
|
||||
box('Gold bow knot',(0,-.52,8.83),(.31,.28,.34),gold)
|
||||
for x in (-3.70,3.70):
|
||||
for z in (.94,7.84):
|
||||
for j in (-1,0,1):
|
||||
o=box('Corner evergreen',(x+j*.10,-.40,z),(.14,.14,.40),pine,.025);o.rotation_euler.y=j*.6
|
||||
bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=1,radius=.18,location=(x,-.59,z));setup(bpy.context.object,'Corner ornament',red if z>4 else gold)
|
||||
root['display_width']=7.55;root['display_height']=7.35;root['display_front']='Local -Y: Roblox SurfaceGui Front after standard glTF import; verify orientation in Studio.'
|
||||
root['purpose']='Blank top-10 leaderboard. Header and ten rows are dynamic UI, not baked geometry.'
|
||||
# Export asset alone; standard PBR materials packed in GLB.
|
||||
bpy.ops.object.select_all(action='DESELECT')
|
||||
for o in root.children:o.select_set(True)
|
||||
bpy.context.view_layer.objects.active=next(o for o in root.children if o.type=='MESH')
|
||||
bpy.ops.object.convert(target='MESH')
|
||||
root.select_set(True)
|
||||
glb=os.path.join(OUT,'christmas_leaderboard.glb')
|
||||
bpy.ops.export_scene.gltf(filepath=glb,export_format='GLB',use_selection=True,export_animations=False,export_apply=True)
|
||||
# Separate presentation collection, excluded from exported GLB.
|
||||
studio=bpy.data.collections.new('Presentation only');bpy.context.scene.collection.children.link(studio)
|
||||
def stage(o):
|
||||
for c in list(o.users_collection):c.objects.unlink(o)
|
||||
studio.objects.link(o);return o
|
||||
bpy.ops.mesh.primitive_plane_add(size=200);o=stage(bpy.context.object);o.name='Studio floor';o.data.materials.append(mat('Studio teal',(.055,.13,.18)))
|
||||
def aim(o,p):o.rotation_euler=(Vector(p)-o.location).to_track_quat('-Z','Y').to_euler()
|
||||
for loc,energy,size in [((2,-8,14),2600,8),((-8,-3,8),2000,7),((4,5,11),2200,6)]:
|
||||
bpy.ops.object.light_add(type='AREA',location=loc);o=stage(bpy.context.object);o.data.energy=energy;o.data.shape='DISK';o.data.size=size;aim(o,(0,0,4))
|
||||
bpy.ops.object.camera_add(location=(10,-24,12));cam=stage(bpy.context.object);aim(cam,(0,0,4.5));cam.data.type='ORTHO';cam.data.ortho_scale=12.1
|
||||
sc=bpy.context.scene;sc.camera=cam;sc.render.engine='CYCLES';sc.cycles.samples=32;sc.render.resolution_x=1300;sc.render.resolution_y=1300;sc.render.resolution_percentage=100
|
||||
sc.world.use_nodes=True;bg=next(n for n in sc.world.node_tree.nodes if n.type=='BACKGROUND');bg.inputs[0].default_value=(.16,.22,.3,1);bg.inputs[1].default_value=.5
|
||||
sc.render.filepath=os.path.join(OUT,'christmas_leaderboard_preview.png')
|
||||
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'christmas_leaderboard.blend'))
|
||||
bpy.ops.render.render(write_still=True)
|
||||
print('LEADERBOARD_READY',glb)
|
||||
Reference in new issue
Block a user